From 4ccacafa4ed5860d822e7edab9bc945fc5a91c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toprak=20Ko=C3=A7?= Date: Mon, 22 Jan 2024 15:50:20 +0300 Subject: [PATCH 1/5] Added empty message into tree --- components/lib/tree/Tree.js | 66 +++++++++++++++++++++++---------- components/lib/tree/TreeBase.js | 2 + 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/components/lib/tree/Tree.js b/components/lib/tree/Tree.js index a827e1fe68..610eabd594 100644 --- a/components/lib/tree/Tree.js +++ b/components/lib/tree/Tree.js @@ -1,5 +1,5 @@ import * as React from 'react'; -import { PrimeReactContext } from '../api/Api'; +import { localeOption, PrimeReactContext } from '../api/Api'; import { useHandleStyle } from '../componentbase/ComponentBase'; import { useMergeProps } from '../hooks/Hooks'; import { useUpdateEffect } from '../hooks/useUpdateEffect'; @@ -408,33 +408,59 @@ export const Tree = React.memo( ); }; - const createRootChildren = () => { - if (props.filter) { - filterChanged.current = true; - _filter(); - } + const createEmptyMessageNode = () => { + const emptyMessageProps = mergeProps( + { + className: classNames(props.contentClassName, cx('emptyMessage')) + }, + ptm('emptyMessage') + ); + + return ( +
  • + {localeOption('emptyMessage')} +
  • + ); + }; - const value = getRootNode(); + const createRootChildrenContainer = (children) => { + const containerProps = mergeProps( + { + className: classNames(props.contentClassName, cx('container')), + role: 'tree', + 'aria-label': props.ariaLabel, + 'aria-labelledby': props.ariaLabelledBy, + style: props.contentStyle, + ...ariaProps + }, + ptm('container') + ); + return ; + }; + + const createRootChildren = (value) => { return value.map((node, index) => createRootChild(node, index, index === value.length - 1)); }; const createModel = () => { if (props.value) { - const rootNodes = createRootChildren(); - const containerProps = mergeProps( - { - className: classNames(props.contentClassName, cx('container')), - role: 'tree', - 'aria-label': props.ariaLabel, - 'aria-labelledby': props.ariaLabelledBy, - style: props.contentStyle, - ...ariaProps - }, - ptm('container') - ); + if (props.filter) { + filterChanged.current = true; + _filter(); + } - return ; + const value = getRootNode(); + + if (value.length > 0) { + const rootNodes = createRootChildren(value); + + return createRootChildrenContainer(rootNodes); + } else { + const emptyMessageNode = createEmptyMessageNode(); + + return createRootChildrenContainer(emptyMessageNode); + } } return null; diff --git a/components/lib/tree/TreeBase.js b/components/lib/tree/TreeBase.js index 5c96d169c9..3b7335bc57 100644 --- a/components/lib/tree/TreeBase.js +++ b/components/lib/tree/TreeBase.js @@ -6,6 +6,7 @@ const classes = { loadingIcon: 'p-tree-loading-icon', loadingOverlay: 'p-tree-loading-overlay p-component-overlay', searchIcon: 'p-tree-filter-icon', + emptyMessage: 'p-treenode p-tree-empty-message', filterContainer: 'p-tree-filter-container', input: 'p-tree-filter p-inputtext p-component', header: 'p-tree-header', @@ -117,6 +118,7 @@ export const TreeBase = ComponentBase.extend({ value: null, checkboxIcon: null, disabled: false, + emptyMessage: null, selectionMode: null, selectionKeys: null, onSelectionChange: null, From 653a95985d4ee9027b151ffa4a468b402cf0649d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toprak=20Ko=C3=A7?= Date: Wed, 24 Jan 2024 05:17:56 +0300 Subject: [PATCH 2/5] Fix: Added TS Support to Doc Highlights --- components/doc/common/codeeditor/templates.js | 96 +++++++++++++++---- 1 file changed, 79 insertions(+), 17 deletions(-) diff --git a/components/doc/common/codeeditor/templates.js b/components/doc/common/codeeditor/templates.js index 37f9ed7cbb..46c35743b0 100644 --- a/components/doc/common/codeeditor/templates.js +++ b/components/doc/common/codeeditor/templates.js @@ -9,7 +9,59 @@ const PrimeReact = { const app_dependencies = pkg ? pkg.dependencies : {}; -const getConfiguredDependencies = (isUnstyled) => { +const typeScriptDependencies = { + '@types/react-dom': '^18.0.0', + '@vitejs/plugin-react': '^1.3.0', + typescript: '^4.6.3' +}; + +const typeScriptFiles = { + 'tsconfig.json': { + content: `{ + "compilerOptions": { + "target": "ESNext", + "lib": ["DOM", "DOM.Iterable", "ESNext"], + "module": "ESNext", + "skipLibCheck": true, + "allowJs": true, + + /* Bundler mode */ + "moduleResolution": "node", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} + ` + }, + 'tsconfig.node.json': { + content: `{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true + }, + "include": ["vite.config.ts"] +}` + } +}; + +const getConfiguredDependencies = (isUnstyled, isTypeScript) => { const defaultDependencies = { '@types/react': '^18.2.38', // For stackblitz react: app_dependencies['react'] || 'latest', @@ -18,7 +70,8 @@ const getConfiguredDependencies = (isUnstyled) => { primereact: PrimeReact.version || 'latest', // latest primeicons: app_dependencies['primeicons'] || 'latest', vite: 'latest', - '@vitejs/plugin-react': 'latest' + '@vitejs/plugin-react': 'latest', + ...(isTypeScript ? typeScriptDependencies : '') }; if (isUnstyled) { @@ -36,7 +89,9 @@ const getConfiguredDependencies = (isUnstyled) => { } }; -const getUnstyledFiles = (path) => { +const getUnstyledFiles = (path, isTypeScript) => { + const fileExtension = isTypeScript ? 'tsx' : 'jsx'; + const tailwindConfig = { content: `/** @type {import('tailwindcss').Config} */ export default { @@ -134,7 +189,7 @@ import './index.css'; import './flags.css'; import App from './App'; -const root = ReactDOM.createRoot(document.getElementById('root')); +const root = ReactDOM.createRoot(document.getElementById('root')${isTypeScript ? ' as HTMLElement' : ''}); root.render( @@ -145,10 +200,12 @@ root.render( );` }; - return { 'tailwind.config.js': tailwindConfig, 'postcss.config.js': postcssConfig, [`${path}main.jsx`]: mainJsx, [`${path}index.css`]: tailwindCss, [`${path}components/themeSwitcher.jsx`]: themeSwitcher }; + return { 'tailwind.config.js': tailwindConfig, 'postcss.config.js': postcssConfig, [`${path}main.${fileExtension}`]: mainJsx, [`${path}index.css`]: tailwindCss, [`${path}components/themeSwitcher.${fileExtension}`]: themeSwitcher }; }; -const getStyledFiles = (path) => { +const getStyledFiles = (path, isTypeScript) => { + const fileExtension = isTypeScript ? 'tsx' : 'jsx'; + const globalCss = { content: `html { font-size: 14px; @@ -185,7 +242,7 @@ import './index.css'; import './flags.css'; import App from './App'; -const root = ReactDOM.createRoot(document.getElementById('root')); +const root = ReactDOM.createRoot(document.getElementById('root')${isTypeScript ? ' as HTMLElement' : ''}); root.render( @@ -195,16 +252,18 @@ root.render( );` }; - return { [`${path}main.jsx`]: mainJsx, [`${path}index.css`]: globalCss }; + return { [`${path}main.${fileExtension}`]: mainJsx, [`${path}index.css`]: globalCss }; }; const getVite = (props = {}, template = 'javascript') => { const path = 'src/'; const isUnstyled = props.embedded; + const isTypeScript = template === 'typescript'; + const fileExtension = isTypeScript ? 'tsx' : 'jsx'; const { code: sources, title = 'primereact_demo', description = '', dependencies: pDependencies = {} } = props; - const configuredDependencies = getConfiguredDependencies(isUnstyled); + const configuredDependencies = getConfiguredDependencies(isUnstyled, isTypeScript); const dependencies = { ...configuredDependencies, ...pDependencies, 'react-scripts': '5.0.1' }; const extFiles = {}; @@ -216,6 +275,8 @@ const getVite = (props = {}, template = 'javascript') => { }; }); + const buildType = isTypeScript ? 'tsc && vite build' : 'vite build'; + const packageJson = { content: { name: title.toLowerCase().replaceAll(' ', '_'), @@ -223,10 +284,10 @@ const getVite = (props = {}, template = 'javascript') => { type: 'module', scripts: { dev: 'vite', - build: 'vite build', + build: buildType, preview: 'vite preview' }, - main: `${path}main.jsx`, + main: `${path}main.${fileExtension}`, keywords: ['primereact', 'react', 'vite', 'starter'], dependencies } @@ -261,33 +322,34 @@ export default defineConfig({
    - + ` }; - const configuredFiles = isUnstyled ? getUnstyledFiles(path) : getStyledFiles(path); + const configuredFiles = isUnstyled ? getUnstyledFiles(path, isTypeScript) : getStyledFiles(path, isTypeScript); let files = { 'package.json': packageJson, 'vite.config.js': viteConfig, 'index.html': indexHtml, [`${path}flags.css`]: flagsCss, - [`${path}App.jsx`]: { + [`${path}App.${fileExtension}`]: { content: sources[template].replace(/^\n/, '') }, - ...configuredFiles + ...configuredFiles, + ...(isTypeScript ? typeScriptFiles : '') }; if (props.service) { props.service.forEach((name) => { - files[`${path}service/${name}.jsx`] = { + files[`${path}service/${name}.${fileExtension}`] = { content: services[name] }; }); } - return { files, dependencies, sourceFileName: `${path}App.jsx` }; + return { files, dependencies, sourceFileName: `${path}App.${fileExtension}` }; }; const flagsCss = { From 0346efa37ac039da2988484c3dbd038839e4277f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toprak=20Ko=C3=A7?= Date: Wed, 24 Jan 2024 05:18:29 +0300 Subject: [PATCH 3/5] Revert "Fix: Added TS Support to Doc Highlights" This reverts commit 653a95985d4ee9027b151ffa4a468b402cf0649d. --- components/doc/common/codeeditor/templates.js | 96 ++++--------------- 1 file changed, 17 insertions(+), 79 deletions(-) diff --git a/components/doc/common/codeeditor/templates.js b/components/doc/common/codeeditor/templates.js index 46c35743b0..37f9ed7cbb 100644 --- a/components/doc/common/codeeditor/templates.js +++ b/components/doc/common/codeeditor/templates.js @@ -9,59 +9,7 @@ const PrimeReact = { const app_dependencies = pkg ? pkg.dependencies : {}; -const typeScriptDependencies = { - '@types/react-dom': '^18.0.0', - '@vitejs/plugin-react': '^1.3.0', - typescript: '^4.6.3' -}; - -const typeScriptFiles = { - 'tsconfig.json': { - content: `{ - "compilerOptions": { - "target": "ESNext", - "lib": ["DOM", "DOM.Iterable", "ESNext"], - "module": "ESNext", - "skipLibCheck": true, - "allowJs": true, - - /* Bundler mode */ - "moduleResolution": "node", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx", - - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["src"], - "references": [{ "path": "./tsconfig.node.json" }] -} - ` - }, - 'tsconfig.node.json': { - content: `{ - "compilerOptions": { - "composite": true, - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true, - "esModuleInterop": true - }, - "include": ["vite.config.ts"] -}` - } -}; - -const getConfiguredDependencies = (isUnstyled, isTypeScript) => { +const getConfiguredDependencies = (isUnstyled) => { const defaultDependencies = { '@types/react': '^18.2.38', // For stackblitz react: app_dependencies['react'] || 'latest', @@ -70,8 +18,7 @@ const getConfiguredDependencies = (isUnstyled, isTypeScript) => { primereact: PrimeReact.version || 'latest', // latest primeicons: app_dependencies['primeicons'] || 'latest', vite: 'latest', - '@vitejs/plugin-react': 'latest', - ...(isTypeScript ? typeScriptDependencies : '') + '@vitejs/plugin-react': 'latest' }; if (isUnstyled) { @@ -89,9 +36,7 @@ const getConfiguredDependencies = (isUnstyled, isTypeScript) => { } }; -const getUnstyledFiles = (path, isTypeScript) => { - const fileExtension = isTypeScript ? 'tsx' : 'jsx'; - +const getUnstyledFiles = (path) => { const tailwindConfig = { content: `/** @type {import('tailwindcss').Config} */ export default { @@ -189,7 +134,7 @@ import './index.css'; import './flags.css'; import App from './App'; -const root = ReactDOM.createRoot(document.getElementById('root')${isTypeScript ? ' as HTMLElement' : ''}); +const root = ReactDOM.createRoot(document.getElementById('root')); root.render( @@ -200,12 +145,10 @@ root.render( );` }; - return { 'tailwind.config.js': tailwindConfig, 'postcss.config.js': postcssConfig, [`${path}main.${fileExtension}`]: mainJsx, [`${path}index.css`]: tailwindCss, [`${path}components/themeSwitcher.${fileExtension}`]: themeSwitcher }; + return { 'tailwind.config.js': tailwindConfig, 'postcss.config.js': postcssConfig, [`${path}main.jsx`]: mainJsx, [`${path}index.css`]: tailwindCss, [`${path}components/themeSwitcher.jsx`]: themeSwitcher }; }; -const getStyledFiles = (path, isTypeScript) => { - const fileExtension = isTypeScript ? 'tsx' : 'jsx'; - +const getStyledFiles = (path) => { const globalCss = { content: `html { font-size: 14px; @@ -242,7 +185,7 @@ import './index.css'; import './flags.css'; import App from './App'; -const root = ReactDOM.createRoot(document.getElementById('root')${isTypeScript ? ' as HTMLElement' : ''}); +const root = ReactDOM.createRoot(document.getElementById('root')); root.render( @@ -252,18 +195,16 @@ root.render( );` }; - return { [`${path}main.${fileExtension}`]: mainJsx, [`${path}index.css`]: globalCss }; + return { [`${path}main.jsx`]: mainJsx, [`${path}index.css`]: globalCss }; }; const getVite = (props = {}, template = 'javascript') => { const path = 'src/'; const isUnstyled = props.embedded; - const isTypeScript = template === 'typescript'; - const fileExtension = isTypeScript ? 'tsx' : 'jsx'; const { code: sources, title = 'primereact_demo', description = '', dependencies: pDependencies = {} } = props; - const configuredDependencies = getConfiguredDependencies(isUnstyled, isTypeScript); + const configuredDependencies = getConfiguredDependencies(isUnstyled); const dependencies = { ...configuredDependencies, ...pDependencies, 'react-scripts': '5.0.1' }; const extFiles = {}; @@ -275,8 +216,6 @@ const getVite = (props = {}, template = 'javascript') => { }; }); - const buildType = isTypeScript ? 'tsc && vite build' : 'vite build'; - const packageJson = { content: { name: title.toLowerCase().replaceAll(' ', '_'), @@ -284,10 +223,10 @@ const getVite = (props = {}, template = 'javascript') => { type: 'module', scripts: { dev: 'vite', - build: buildType, + build: 'vite build', preview: 'vite preview' }, - main: `${path}main.${fileExtension}`, + main: `${path}main.jsx`, keywords: ['primereact', 'react', 'vite', 'starter'], dependencies } @@ -322,34 +261,33 @@ export default defineConfig({
    - + ` }; - const configuredFiles = isUnstyled ? getUnstyledFiles(path, isTypeScript) : getStyledFiles(path, isTypeScript); + const configuredFiles = isUnstyled ? getUnstyledFiles(path) : getStyledFiles(path); let files = { 'package.json': packageJson, 'vite.config.js': viteConfig, 'index.html': indexHtml, [`${path}flags.css`]: flagsCss, - [`${path}App.${fileExtension}`]: { + [`${path}App.jsx`]: { content: sources[template].replace(/^\n/, '') }, - ...configuredFiles, - ...(isTypeScript ? typeScriptFiles : '') + ...configuredFiles }; if (props.service) { props.service.forEach((name) => { - files[`${path}service/${name}.${fileExtension}`] = { + files[`${path}service/${name}.jsx`] = { content: services[name] }; }); } - return { files, dependencies, sourceFileName: `${path}App.${fileExtension}` }; + return { files, dependencies, sourceFileName: `${path}App.jsx` }; }; const flagsCss = { From cd282ffc26e4c4f3de730ef0150b632a80f2f570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toprak=20Ko=C3=A7?= Date: Wed, 24 Jan 2024 05:17:56 +0300 Subject: [PATCH 4/5] Fix: Added TS Support to Doc Highlights --- components/doc/common/codeeditor/templates.js | 96 +++++++++++++++---- 1 file changed, 79 insertions(+), 17 deletions(-) diff --git a/components/doc/common/codeeditor/templates.js b/components/doc/common/codeeditor/templates.js index 37f9ed7cbb..46c35743b0 100644 --- a/components/doc/common/codeeditor/templates.js +++ b/components/doc/common/codeeditor/templates.js @@ -9,7 +9,59 @@ const PrimeReact = { const app_dependencies = pkg ? pkg.dependencies : {}; -const getConfiguredDependencies = (isUnstyled) => { +const typeScriptDependencies = { + '@types/react-dom': '^18.0.0', + '@vitejs/plugin-react': '^1.3.0', + typescript: '^4.6.3' +}; + +const typeScriptFiles = { + 'tsconfig.json': { + content: `{ + "compilerOptions": { + "target": "ESNext", + "lib": ["DOM", "DOM.Iterable", "ESNext"], + "module": "ESNext", + "skipLibCheck": true, + "allowJs": true, + + /* Bundler mode */ + "moduleResolution": "node", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} + ` + }, + 'tsconfig.node.json': { + content: `{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true + }, + "include": ["vite.config.ts"] +}` + } +}; + +const getConfiguredDependencies = (isUnstyled, isTypeScript) => { const defaultDependencies = { '@types/react': '^18.2.38', // For stackblitz react: app_dependencies['react'] || 'latest', @@ -18,7 +70,8 @@ const getConfiguredDependencies = (isUnstyled) => { primereact: PrimeReact.version || 'latest', // latest primeicons: app_dependencies['primeicons'] || 'latest', vite: 'latest', - '@vitejs/plugin-react': 'latest' + '@vitejs/plugin-react': 'latest', + ...(isTypeScript ? typeScriptDependencies : '') }; if (isUnstyled) { @@ -36,7 +89,9 @@ const getConfiguredDependencies = (isUnstyled) => { } }; -const getUnstyledFiles = (path) => { +const getUnstyledFiles = (path, isTypeScript) => { + const fileExtension = isTypeScript ? 'tsx' : 'jsx'; + const tailwindConfig = { content: `/** @type {import('tailwindcss').Config} */ export default { @@ -134,7 +189,7 @@ import './index.css'; import './flags.css'; import App from './App'; -const root = ReactDOM.createRoot(document.getElementById('root')); +const root = ReactDOM.createRoot(document.getElementById('root')${isTypeScript ? ' as HTMLElement' : ''}); root.render( @@ -145,10 +200,12 @@ root.render( );` }; - return { 'tailwind.config.js': tailwindConfig, 'postcss.config.js': postcssConfig, [`${path}main.jsx`]: mainJsx, [`${path}index.css`]: tailwindCss, [`${path}components/themeSwitcher.jsx`]: themeSwitcher }; + return { 'tailwind.config.js': tailwindConfig, 'postcss.config.js': postcssConfig, [`${path}main.${fileExtension}`]: mainJsx, [`${path}index.css`]: tailwindCss, [`${path}components/themeSwitcher.${fileExtension}`]: themeSwitcher }; }; -const getStyledFiles = (path) => { +const getStyledFiles = (path, isTypeScript) => { + const fileExtension = isTypeScript ? 'tsx' : 'jsx'; + const globalCss = { content: `html { font-size: 14px; @@ -185,7 +242,7 @@ import './index.css'; import './flags.css'; import App from './App'; -const root = ReactDOM.createRoot(document.getElementById('root')); +const root = ReactDOM.createRoot(document.getElementById('root')${isTypeScript ? ' as HTMLElement' : ''}); root.render( @@ -195,16 +252,18 @@ root.render( );` }; - return { [`${path}main.jsx`]: mainJsx, [`${path}index.css`]: globalCss }; + return { [`${path}main.${fileExtension}`]: mainJsx, [`${path}index.css`]: globalCss }; }; const getVite = (props = {}, template = 'javascript') => { const path = 'src/'; const isUnstyled = props.embedded; + const isTypeScript = template === 'typescript'; + const fileExtension = isTypeScript ? 'tsx' : 'jsx'; const { code: sources, title = 'primereact_demo', description = '', dependencies: pDependencies = {} } = props; - const configuredDependencies = getConfiguredDependencies(isUnstyled); + const configuredDependencies = getConfiguredDependencies(isUnstyled, isTypeScript); const dependencies = { ...configuredDependencies, ...pDependencies, 'react-scripts': '5.0.1' }; const extFiles = {}; @@ -216,6 +275,8 @@ const getVite = (props = {}, template = 'javascript') => { }; }); + const buildType = isTypeScript ? 'tsc && vite build' : 'vite build'; + const packageJson = { content: { name: title.toLowerCase().replaceAll(' ', '_'), @@ -223,10 +284,10 @@ const getVite = (props = {}, template = 'javascript') => { type: 'module', scripts: { dev: 'vite', - build: 'vite build', + build: buildType, preview: 'vite preview' }, - main: `${path}main.jsx`, + main: `${path}main.${fileExtension}`, keywords: ['primereact', 'react', 'vite', 'starter'], dependencies } @@ -261,33 +322,34 @@ export default defineConfig({
    - + ` }; - const configuredFiles = isUnstyled ? getUnstyledFiles(path) : getStyledFiles(path); + const configuredFiles = isUnstyled ? getUnstyledFiles(path, isTypeScript) : getStyledFiles(path, isTypeScript); let files = { 'package.json': packageJson, 'vite.config.js': viteConfig, 'index.html': indexHtml, [`${path}flags.css`]: flagsCss, - [`${path}App.jsx`]: { + [`${path}App.${fileExtension}`]: { content: sources[template].replace(/^\n/, '') }, - ...configuredFiles + ...configuredFiles, + ...(isTypeScript ? typeScriptFiles : '') }; if (props.service) { props.service.forEach((name) => { - files[`${path}service/${name}.jsx`] = { + files[`${path}service/${name}.${fileExtension}`] = { content: services[name] }; }); } - return { files, dependencies, sourceFileName: `${path}App.jsx` }; + return { files, dependencies, sourceFileName: `${path}App.${fileExtension}` }; }; const flagsCss = { From 711936e723c94f0bf3a7cfe334d85663e66cc6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toprak=20Ko=C3=A7?= Date: Wed, 24 Jan 2024 05:22:02 +0300 Subject: [PATCH 5/5] Revert "Added empty message into tree" This reverts commit 4ccacafa4ed5860d822e7edab9bc945fc5a91c12. --- components/lib/tree/Tree.js | 66 ++++++++++----------------------- components/lib/tree/TreeBase.js | 2 - 2 files changed, 20 insertions(+), 48 deletions(-) diff --git a/components/lib/tree/Tree.js b/components/lib/tree/Tree.js index 610eabd594..a827e1fe68 100644 --- a/components/lib/tree/Tree.js +++ b/components/lib/tree/Tree.js @@ -1,5 +1,5 @@ import * as React from 'react'; -import { localeOption, PrimeReactContext } from '../api/Api'; +import { PrimeReactContext } from '../api/Api'; import { useHandleStyle } from '../componentbase/ComponentBase'; import { useMergeProps } from '../hooks/Hooks'; import { useUpdateEffect } from '../hooks/useUpdateEffect'; @@ -408,59 +408,33 @@ export const Tree = React.memo( ); }; - const createEmptyMessageNode = () => { - const emptyMessageProps = mergeProps( - { - className: classNames(props.contentClassName, cx('emptyMessage')) - }, - ptm('emptyMessage') - ); - - return ( -
  • - {localeOption('emptyMessage')} -
  • - ); - }; - - const createRootChildrenContainer = (children) => { - const containerProps = mergeProps( - { - className: classNames(props.contentClassName, cx('container')), - role: 'tree', - 'aria-label': props.ariaLabel, - 'aria-labelledby': props.ariaLabelledBy, - style: props.contentStyle, - ...ariaProps - }, - ptm('container') - ); + const createRootChildren = () => { + if (props.filter) { + filterChanged.current = true; + _filter(); + } - return
      {children}
    ; - }; + const value = getRootNode(); - const createRootChildren = (value) => { return value.map((node, index) => createRootChild(node, index, index === value.length - 1)); }; const createModel = () => { if (props.value) { - if (props.filter) { - filterChanged.current = true; - _filter(); - } - - const value = getRootNode(); - - if (value.length > 0) { - const rootNodes = createRootChildren(value); - - return createRootChildrenContainer(rootNodes); - } else { - const emptyMessageNode = createEmptyMessageNode(); + const rootNodes = createRootChildren(); + const containerProps = mergeProps( + { + className: classNames(props.contentClassName, cx('container')), + role: 'tree', + 'aria-label': props.ariaLabel, + 'aria-labelledby': props.ariaLabelledBy, + style: props.contentStyle, + ...ariaProps + }, + ptm('container') + ); - return createRootChildrenContainer(emptyMessageNode); - } + return
      {rootNodes}
    ; } return null; diff --git a/components/lib/tree/TreeBase.js b/components/lib/tree/TreeBase.js index 3b7335bc57..5c96d169c9 100644 --- a/components/lib/tree/TreeBase.js +++ b/components/lib/tree/TreeBase.js @@ -6,7 +6,6 @@ const classes = { loadingIcon: 'p-tree-loading-icon', loadingOverlay: 'p-tree-loading-overlay p-component-overlay', searchIcon: 'p-tree-filter-icon', - emptyMessage: 'p-treenode p-tree-empty-message', filterContainer: 'p-tree-filter-container', input: 'p-tree-filter p-inputtext p-component', header: 'p-tree-header', @@ -118,7 +117,6 @@ export const TreeBase = ComponentBase.extend({ value: null, checkboxIcon: null, disabled: false, - emptyMessage: null, selectionMode: null, selectionKeys: null, onSelectionChange: null,