From e74fe08056011d0cb1588a4a8f5b0adc8080e80e Mon Sep 17 00:00:00 2001 From: Ihor Korenets Date: Mon, 25 Mar 2024 18:25:45 +0200 Subject: [PATCH] [PickerTogglerTag]: removed tooltipContext and made a doc example --- .../PickerTogglerTagDemo.example.tsx | 63 +++++++++++++ app/src/docs/pickerInput/PickerInput.doc.tsx | 1 + app/src/sandbox/SandboxPage.tsx | 2 - .../pickerTogglerTag/PickerTogglerTagDemo.tsx | 92 ------------------- ...ples-pickerInput-PickerTogglerTagDemo.json | 17 ++++ public/docs/docsGenOutput/docsGenOutput.json | 28 ++---- uui/components/pickers/PickerInput.tsx | 4 + uui/components/pickers/PickerTogglerTag.tsx | 15 +-- 8 files changed, 98 insertions(+), 124 deletions(-) create mode 100644 app/src/docs/_examples/pickerInput/PickerTogglerTagDemo.example.tsx delete mode 100644 app/src/sandbox/pickerTogglerTag/PickerTogglerTagDemo.tsx create mode 100644 public/docs/content/examples-pickerInput-PickerTogglerTagDemo.json diff --git a/app/src/docs/_examples/pickerInput/PickerTogglerTagDemo.example.tsx b/app/src/docs/_examples/pickerInput/PickerTogglerTagDemo.example.tsx new file mode 100644 index 0000000000..4621222e4a --- /dev/null +++ b/app/src/docs/_examples/pickerInput/PickerTogglerTagDemo.example.tsx @@ -0,0 +1,63 @@ +import React, { useState } from 'react'; +import { DataQueryFilter, useLazyDataSource, useUuiContext } from '@epam/uui-core'; +import { FlexCell, PickerInput, PickerTogglerTag, Tooltip } from '@epam/uui'; +import { Location } from '@epam/uui-docs'; + +const cascadeSelectionModes: Array<{ id: 'explicit' | 'implicit'; caption: string }> = [ + { + id: 'explicit', + caption: 'Explicit cascade selection', + }, { + id: 'implicit', + caption: 'Implicit cascade selection', + }, +]; + +export default function PickerTogglerTagDemoExample() { + const svc = useUuiContext(); + const [value, onValueChange] = useState(); + const [cascadeSelection] = useState(cascadeSelectionModes[0].id); + + const dataSource = useLazyDataSource>( + { + api: (request, ctx) => { + const { search } = request; + // and since parentId is meaningful value, it is required to exclude it from the filter. + const filter = search ? {} : { parentId: ctx?.parentId }; + return svc.api.demo.locations({ ...request, search, filter }); + }, + getId: (i) => i.id, + getParentId: (i) => i.parentId, + getChildCount: (l) => l.childCount, + }, + [], + ); + + return ( + + { + if (props.isCollapsed) { + return ( + + ); + } else { + return ( + i.value.name).join('/')}/${props.caption}` }> + + + ); + } + } } + /> + + ); +} diff --git a/app/src/docs/pickerInput/PickerInput.doc.tsx b/app/src/docs/pickerInput/PickerInput.doc.tsx index 822b709d43..31e7bff4cf 100644 --- a/app/src/docs/pickerInput/PickerInput.doc.tsx +++ b/app/src/docs/pickerInput/PickerInput.doc.tsx @@ -80,6 +80,7 @@ export class PickerInputDoc extends BaseDocsBlock { + ); } diff --git a/app/src/sandbox/SandboxPage.tsx b/app/src/sandbox/SandboxPage.tsx index b9f530f2cb..458dd8877d 100644 --- a/app/src/sandbox/SandboxPage.tsx +++ b/app/src/sandbox/SandboxPage.tsx @@ -23,7 +23,6 @@ import { ProjectTasksDemo } from './tasks/ProjectTasksDemo'; import { RichTextEditorDemo } from './RTE/rteDemo'; import { TableColumnConfigModalTest } from './tableColConfigModal/TableColumnConfigModalTest'; import { PalettePage } from './tokens/palette/palettePage'; -import { PickerTogglerTagDemo } from './pickerTogglerTag/PickerTogglerTagDemo'; export function SandboxPage() { const items = useMemo( @@ -47,7 +46,6 @@ export function SandboxPage() { { id: 'tagInput', name: 'Tag Input', component: TagInputDemo }, { id: 'tokens', name: 'Tokens' }, { parentId: 'tokens', id: 'tokensPalette', name: 'Palette', component: PalettePage }, - { id: 'pickerTogglerTag', name: 'PickerTogglerTag', component: PickerTogglerTagDemo }, ], [], ); diff --git a/app/src/sandbox/pickerTogglerTag/PickerTogglerTagDemo.tsx b/app/src/sandbox/pickerTogglerTag/PickerTogglerTagDemo.tsx deleted file mode 100644 index 3278754710..0000000000 --- a/app/src/sandbox/pickerTogglerTag/PickerTogglerTagDemo.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import React, { useState } from 'react'; -import { DataQueryFilter, useLazyDataSource, useUuiContext } from '@epam/uui-core'; -import { FlexCell, FlexRow, LabeledInput, NumericInput, PickerInput, PickerTogglerTag } from '@epam/uui'; -import { Location } from '@epam/uui-docs'; -import { ReactComponent as myIcon } from '@epam/assets/icons/action-account-fill.svg'; - -const cascadeSelectionModes: Array<{ id: 'explicit' | 'implicit'; caption: string }> = [ - { - id: 'explicit', - caption: 'Explicit cascade selection', - }, { - id: 'implicit', - caption: 'Implicit cascade selection', - }, -]; - -export function PickerTogglerTagDemo() { - const svc = useUuiContext(); - const [maxItems, setMaxItems] = useState(null); - const [value, onValueChange] = useState(); - const [cascadeSelection] = useState(cascadeSelectionModes[0].id); - - const dataSource = useLazyDataSource>( - { - api: (request, ctx) => { - const { search } = request; - // and since parentId is meaningful value, it is required to exclude it from the filter. - const filter = search ? {} : { parentId: ctx?.parentId }; - return svc.api.demo.locations({ ...request, search, filter }); - }, - getId: (i) => i.id, - getParentId: (i) => i.parentId, - getChildCount: (l) => l.childCount, - }, - [], - ); - - return ( - - - - - - - - { - return ( - i.value.name).join('/')}/${props.caption}` } - icon={ !props.isCollapsed && myIcon } - /> - ); - - // if (props.isCollapsed) { - // return ( - //