@salutejs/plasma-new-hope 0.193.1-canary.1562.11858039838.0 → 0.194.0-canary.1552.11858023676.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Combobox/ComboboxNew/Combobox.css +2 -0
- package/cjs/components/Combobox/ComboboxNew/Combobox.js +42 -24
- package/cjs/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
- package/cjs/components/Combobox/ComboboxNew/ui/Inner/Inner.css +2 -0
- package/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.css +2 -0
- package/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js.map +1 -1
- package/cjs/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.css +1 -0
- package/cjs/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.js +39 -0
- package/cjs/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.js.map +1 -0
- package/cjs/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles.js +15 -0
- package/cjs/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles.js.map +1 -0
- package/cjs/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles_18yw2bf.css +1 -0
- package/cjs/components/Combobox/ComboboxOld/Combobox.css +4 -5
- package/cjs/components/Combobox/ComboboxOld/ui/ComboboxDivider/ComboboxDivider.css +4 -5
- package/cjs/components/Combobox/ComboboxOld/ui/ComboboxFooter/ComboboxFooter.css +4 -5
- package/cjs/components/Combobox/ComboboxOld/ui/ComboboxGroup/ComboboxGroup.css +4 -5
- package/cjs/components/Combobox/ComboboxOld/ui/ComboboxHeader/ComboboxHeader.css +4 -5
- package/cjs/components/Dropdown/Dropdown.css +4 -5
- package/cjs/components/Dropdown/Dropdown.js +2 -4
- package/cjs/components/Dropdown/Dropdown.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.css +4 -5
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +2 -3
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +1 -7
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownItem/{DropdownItem.styles_14yih1y.css → DropdownItem.styles_1b439rx.css} +0 -1
- package/cjs/components/Select/Select.js +1 -0
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/cjs/components/Select/ui/Inner/ui/Item/Item.js.map +1 -1
- package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -18
- package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js.map +1 -1
- package/cjs/index.css +6 -5
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +1 -1
- package/cjs/utils/createEvent.js +54 -0
- package/cjs/utils/createEvent.js.map +1 -0
- package/cjs/utils/index.js.map +1 -1
- package/emotion/cjs/components/Combobox/ComboboxNew/Combobox.js +43 -29
- package/emotion/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/emotion/cjs/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.js +40 -0
- package/emotion/cjs/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles.js +13 -0
- package/emotion/cjs/components/Dropdown/Dropdown.js +2 -4
- package/emotion/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +2 -3
- package/emotion/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +11 -15
- package/emotion/cjs/components/Select/Select.js +1 -0
- package/emotion/cjs/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/emotion/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
- package/emotion/cjs/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +1 -1
- package/emotion/cjs/utils/createEvent.js +53 -0
- package/emotion/cjs/utils/index.js +10 -1
- package/emotion/es/components/Combobox/ComboboxNew/Combobox.js +44 -29
- package/emotion/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/emotion/es/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.js +31 -0
- package/emotion/es/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles.js +6 -0
- package/emotion/es/components/Dropdown/Dropdown.js +2 -4
- package/emotion/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +3 -4
- package/emotion/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +11 -15
- package/emotion/es/components/Select/Select.js +1 -0
- package/emotion/es/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/emotion/es/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
- package/emotion/es/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +1 -1
- package/emotion/es/utils/createEvent.js +47 -0
- package/emotion/es/utils/index.js +1 -0
- package/es/components/Combobox/ComboboxNew/Combobox.css +2 -0
- package/es/components/Combobox/ComboboxNew/Combobox.js +44 -26
- package/es/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
- package/es/components/Combobox/ComboboxNew/ui/Inner/Inner.css +2 -0
- package/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.css +2 -0
- package/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js.map +1 -1
- package/es/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.css +1 -0
- package/es/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.js +35 -0
- package/es/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.js.map +1 -0
- package/es/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles.js +11 -0
- package/es/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles.js.map +1 -0
- package/es/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles_18yw2bf.css +1 -0
- package/es/components/Combobox/ComboboxOld/Combobox.css +4 -5
- package/es/components/Combobox/ComboboxOld/ui/ComboboxDivider/ComboboxDivider.css +4 -5
- package/es/components/Combobox/ComboboxOld/ui/ComboboxFooter/ComboboxFooter.css +4 -5
- package/es/components/Combobox/ComboboxOld/ui/ComboboxGroup/ComboboxGroup.css +4 -5
- package/es/components/Combobox/ComboboxOld/ui/ComboboxHeader/ComboboxHeader.css +4 -5
- package/es/components/Dropdown/Dropdown.css +4 -5
- package/es/components/Dropdown/Dropdown.js +2 -4
- package/es/components/Dropdown/Dropdown.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.css +4 -5
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +3 -4
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +2 -7
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownItem/{DropdownItem.styles_14yih1y.css → DropdownItem.styles_1b439rx.css} +0 -1
- package/es/components/Select/Select.js +1 -0
- package/es/components/Select/Select.js.map +1 -1
- package/es/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/es/components/Select/ui/Inner/ui/Item/Item.js.map +1 -1
- package/es/components/Select/ui/Target/ui/Textfield/Textfield.js +4 -19
- package/es/components/Select/ui/Target/ui/Textfield/Textfield.js.map +1 -1
- package/es/index.css +6 -5
- package/es/index.js +1 -0
- package/es/index.js.map +1 -1
- package/es/utils/createEvent.js +50 -0
- package/es/utils/createEvent.js.map +1 -0
- package/es/utils/index.js.map +1 -1
- package/package.json +2 -3
- package/styled-components/cjs/components/Combobox/ComboboxNew/Combobox.js +43 -29
- package/styled-components/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/styled-components/cjs/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.js +40 -0
- package/styled-components/cjs/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles.js +12 -0
- package/styled-components/cjs/components/Dropdown/Dropdown.js +2 -4
- package/styled-components/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +2 -3
- package/styled-components/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +2 -5
- package/styled-components/cjs/components/Select/Select.js +1 -0
- package/styled-components/cjs/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/styled-components/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
- package/styled-components/cjs/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +1 -1
- package/styled-components/cjs/utils/createEvent.js +53 -0
- package/styled-components/cjs/utils/index.js +10 -1
- package/styled-components/es/components/Combobox/ComboboxNew/Combobox.js +44 -29
- package/styled-components/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/styled-components/es/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.js +31 -0
- package/styled-components/es/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles.js +5 -0
- package/styled-components/es/components/Dropdown/Dropdown.js +2 -4
- package/styled-components/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +3 -4
- package/styled-components/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +2 -5
- package/styled-components/es/components/Select/Select.js +1 -0
- package/styled-components/es/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/styled-components/es/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
- package/styled-components/es/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +1 -1
- package/styled-components/es/utils/createEvent.js +47 -0
- package/styled-components/es/utils/index.js +1 -0
- package/types/components/Combobox/ComboboxNew/Combobox.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts +26 -3
- package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.d.ts +6 -0
- package/types/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.d.ts.map +1 -0
- package/types/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles.d.ts +3 -0
- package/types/components/Combobox/ComboboxNew/ui/SelectNative/SelectNative.styles.d.ts.map +1 -0
- package/types/components/Dropdown/Dropdown.d.ts +2 -50
- package/types/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/types/components/Dropdown/Dropdown.types.d.ts +6 -11
- package/types/components/Dropdown/Dropdown.types.d.ts.map +1 -1
- package/types/components/Dropdown/index.d.ts +0 -1
- package/types/components/Dropdown/index.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownItem/DropdownItem.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownItem/DropdownItem.styles.d.ts +0 -1
- package/types/components/Dropdown/ui/DropdownItem/DropdownItem.styles.d.ts.map +1 -1
- package/types/components/Select/Select.d.ts.map +1 -1
- package/types/components/Select/Select.types.d.ts +2 -1
- package/types/components/Select/Select.types.d.ts.map +1 -1
- package/types/components/Select/ui/Inner/ui/Item/Item.d.ts.map +1 -1
- package/types/components/Select/ui/Target/ui/Textfield/Textfield.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts +1076 -116
- package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Dropdown/Dropdown.d.ts +1 -25
- package/types/examples/plasma_b2c/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Combobox/Combobox.d.ts +1076 -116
- package/types/examples/plasma_web/components/Combobox/Combobox.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Dropdown/Dropdown.d.ts +1 -25
- package/types/examples/plasma_web/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/types/utils/createEvent.d.ts +3 -0
- package/types/utils/createEvent.d.ts.map +1 -0
- package/types/utils/index.d.ts +1 -0
- package/types/utils/index.d.ts.map +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import React, { forwardRef, useState, useReducer, useMemo, createContext, useLayoutEffect, useRef } from 'react';\nimport { safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines';\nimport { isEmpty } from '../../utils';\nimport { useOutsideClick } from '../../hooks';\n\nimport { useKeyNavigation, getItemByFocused } from './hooks/useKeyboardNavigation';\nimport {\n initialItemsTransform,\n updateAncestors,\n updateDescendants,\n updateSingleAncestors,\n getView,\n getInitialValue,\n} from './utils';\nimport { Inner, Target } from './ui';\nimport { pathReducer, focusedPathReducer } from './reducers';\nimport { usePathMaps } from './hooks/usePathMaps';\nimport { Ul, base } from './Select.styles';\nimport type { ItemContext, MergedSelectProps } from './Select.types';\nimport type { MergedDropdownNodeTransformed } from './ui/Inner/ui/Item/Item.types';\nimport { FloatingPopover } from './FloatingPopover';\n\nexport const Context = createContext<ItemContext>({} as ItemContext);\n\n/**\n * Выпадающий список. Поддерживает выбор одного или нескольких значений.\n */\nexport const selectRoot = (Root: RootProps<HTMLButtonElement, Omit<MergedSelectProps, 'items'>>) =>\n forwardRef<HTMLButtonElement, MergedSelectProps>((props, ref) => {\n const {\n value: outerValue,\n onChange: outerOnChange,\n target = 'textfield-like',\n items,\n placement = 'bottom',\n label,\n labelPlacement,\n placeholder,\n helperText,\n disabled = false,\n view: outerView,\n size,\n listOverflow,\n listHeight,\n listWidth,\n contentLeft,\n onScrollBottom,\n chipView,\n variant = 'normal',\n portal,\n renderValue,\n renderItem,\n status,\n onItemSelect,\n separator,\n closeAfterSelect: outerCloseAfterSelect,\n isTargetAmount,\n ...rest\n } = props;\n const transformedItems = useMemo(() => initialItemsTransform(items || []), [items]);\n\n // Создаем структуры для быстрой работы с деревом\n const [pathMap, focusedToValueMap, valueToCheckedMap, valueToItemMap, labelToItemMap] = usePathMaps(\n transformedItems,\n );\n\n const [internalValue, setInternalValue] = useState<string | number | Array<string | number>>(\n props.multiselect ? [] : '',\n );\n\n const value =\n outerValue !== null && outerValue !== undefined\n ? getInitialValue(outerValue, valueToItemMap)\n : internalValue;\n\n const floatingPopoverRef = useRef<HTMLDivElement>(null);\n\n // Состояния дерева элементов\n const [path, dispatchPath] = useReducer(pathReducer, []);\n const [focusedPath, dispatchFocusedPath] = useReducer(focusedPathReducer, []);\n const [checked, setChecked] = useState(valueToCheckedMap);\n\n const isCurrentListOpen = Boolean(path[0]);\n const activeDescendantItemValue = getItemByFocused(focusedPath, focusedToValueMap)?.value.toString() || '';\n const closeAfterSelect = outerCloseAfterSelect ?? !props.multiselect;\n const treeId = safeUseId();\n const view = target === 'textfield-like' && disabled ? 'default' : getView(status, outerView);\n\n const targetRef = useOutsideClick<HTMLUListElement>(() => {\n if (!isCurrentListOpen) {\n return;\n }\n\n dispatchPath({ type: 'reset' });\n dispatchFocusedPath({ type: 'reset' });\n }, floatingPopoverRef);\n\n const onChange = (newValue: string | number | Array<string | number>) => {\n if (outerOnChange) {\n outerOnChange(newValue as any);\n }\n\n setInternalValue(newValue);\n };\n\n const handleClickArrow = () => {\n if (disabled) {\n return;\n }\n\n if (isCurrentListOpen) {\n dispatchPath({ type: 'reset' });\n } else {\n dispatchPath({ type: 'opened_first_level' });\n }\n\n dispatchFocusedPath({ type: 'reset' });\n };\n\n const handleListToggle = (opened: boolean) => {\n if (disabled) {\n return;\n }\n\n if (opened) {\n dispatchPath({ type: 'opened_first_level' });\n } else {\n dispatchFocusedPath({ type: 'reset' });\n dispatchPath({ type: 'reset' });\n }\n };\n\n const handleCheckboxChange = (item: MergedDropdownNodeTransformed) => {\n if (!props.multiselect) {\n return;\n }\n\n const checkedCopy = new Map(checked);\n\n if (!checkedCopy.get(item.value)) {\n checkedCopy.set(item.value, true);\n updateDescendants(item, checkedCopy, true);\n } else {\n checkedCopy.set(item.value, false);\n updateDescendants(item, checkedCopy, false);\n }\n\n updateAncestors(item, checkedCopy);\n\n const newValues: Array<string | number> = [];\n\n valueToItemMap.forEach((item, key) => {\n if (checkedCopy.get(key)) {\n newValues.push(item.value);\n }\n });\n\n if (closeAfterSelect) {\n dispatchPath({ type: 'reset' });\n dispatchFocusedPath({ type: 'reset' });\n }\n\n if (onChange) {\n onChange(newValues);\n }\n };\n\n const handleItemClick = (item: MergedDropdownNodeTransformed, e?: React.MouseEvent<HTMLElement>) => {\n if (!isEmpty(item?.items)) {\n return;\n }\n\n if (props.multiselect) {\n handleCheckboxChange(item);\n return;\n }\n\n if (e) {\n e.stopPropagation();\n }\n\n const isCurrentChecked = checked.get(item.value);\n\n if (closeAfterSelect) {\n dispatchPath({ type: 'reset' });\n dispatchFocusedPath({ type: 'reset' });\n }\n\n if (onChange) {\n onChange(isCurrentChecked ? '' : item.value);\n }\n\n if (onItemSelect) {\n onItemSelect(item, e!);\n }\n };\n\n const handlePressDown = (item: MergedDropdownNodeTransformed, e?: React.MouseEvent<HTMLElement>) => {\n if (isEmpty(item.items)) {\n handleItemClick(item, e);\n } else if (props.multiselect) {\n handleCheckboxChange(item);\n }\n };\n\n const handleScroll = (e: React.UIEvent<HTMLUListElement>) => {\n if (!onScrollBottom) return;\n\n const { target } = e;\n\n if (\n (target as HTMLElement).scrollHeight - (target as HTMLElement).scrollTop ===\n (target as HTMLElement).clientHeight\n ) {\n onScrollBottom(e);\n }\n };\n\n const { onKeyDown } = useKeyNavigation({\n focusedPath,\n dispatchFocusedPath,\n path,\n dispatchPath,\n pathMap,\n focusedToValueMap,\n handleListToggle,\n handlePressDown,\n });\n\n // В данном эффекте мы следим за изменениями value снаружи и вносим коррективы в дерево чекбоксов.\n // Пример: когда юзер очистил value извне, тогда нужно пройтись по элементам и выключить все чекбоксы.\n useLayoutEffect(() => {\n const checkedCopy = new Map(checked);\n\n checkedCopy.forEach((_, key) => {\n checkedCopy.set(key, false);\n });\n\n if (!isEmpty(value) || typeof value === 'number') {\n if (Array.isArray(value)) {\n value.forEach((val) => {\n checkedCopy.set(val, true);\n updateDescendants(valueToItemMap.get(val)!, checkedCopy, true);\n updateAncestors(valueToItemMap.get(val)!, checkedCopy);\n });\n } else {\n checkedCopy.set(value, 'done');\n updateSingleAncestors(valueToItemMap.get(value)!, checkedCopy, 'dot');\n }\n }\n\n setChecked(checkedCopy);\n\n // В deps мы кладем именно outerValue и internalValue, а не просто value.\n // Т.к. вначале нужно отфильтровать и провалидировать outerValue и результат положить в переменную.\n // А переменную, содержащую сложные типы данных, нельзя помещать в deps.\n }, [outerValue, internalValue, items]);\n\n return (\n <Root\n view={view}\n size={size}\n labelPlacement={labelPlacement}\n chipView={chipView}\n disabled={disabled}\n {...(rest as any)}\n >\n <Context.Provider\n value={{\n focusedPath,\n checked,\n multiselect: props.multiselect,\n size,\n handleCheckboxChange,\n handleItemClick,\n variant,\n renderItem,\n treeId,\n }}\n >\n <FloatingPopover\n ref={floatingPopoverRef}\n opened={isCurrentListOpen}\n onToggle={(opened: boolean) => opened && handleListToggle(true)}\n placement={placement}\n portal={portal}\n listWidth={listWidth}\n target={(referenceRef) => (\n <Target\n ref={ref}\n target={target}\n value={value}\n opened={isCurrentListOpen}\n valueToItemMap={valueToItemMap}\n label={label}\n placeholder={placeholder}\n onKeyDown={onKeyDown}\n labelPlacement={labelPlacement}\n size={size}\n contentLeft={contentLeft}\n disabled={disabled}\n renderValue={renderValue}\n selectProps={props}\n inputWrapperRef={referenceRef as React.MutableRefObject<HTMLDivElement>}\n multiselect={props.multiselect}\n view={view}\n handleClickArrow={handleClickArrow}\n helperText={helperText}\n treeId={treeId}\n activeDescendantItemValue={activeDescendantItemValue}\n isTargetAmount={isTargetAmount}\n onChange={onChange}\n labelToItemMap={labelToItemMap}\n chipView={chipView}\n separator={separator}\n />\n )}\n >\n <Root\n view={view}\n size={size}\n labelPlacement={labelPlacement}\n chipView={chipView}\n disabled={disabled}\n {...(rest as any)}\n >\n <Ul\n role=\"tree\"\n id={`${treeId}_tree_level_1`}\n aria-multiselectable={Boolean(props.multiselect)}\n listHeight={listHeight}\n listOverflow={listOverflow}\n onScroll={handleScroll}\n listWidth={listWidth}\n ref={targetRef}\n >\n {transformedItems.map((item, index) => (\n <Inner\n key={`${index}/0`}\n item={item}\n currentLevel={0}\n path={path}\n dispatchPath={dispatchPath}\n index={index}\n listWidth={listWidth}\n />\n ))}\n </Ul>\n </Root>\n </FloatingPopover>\n </Context.Provider>\n </Root>\n );\n });\n\nexport const selectConfig = {\n name: 'Select',\n tag: 'div',\n layout: selectRoot,\n base,\n variations: {},\n defaults: {\n view: 'default',\n size: 'm',\n labelPlacement: 'outer',\n chipView: 'default',\n },\n};\n"],"names":["Context","createContext","selectRoot","Root","forwardRef","props","ref","_getItemByFocused","outerValue","value","outerOnChange","onChange","_props$target","target","items","_props$placement","placement","label","labelPlacement","placeholder","helperText","_props$disabled","disabled","outerView","view","size","listOverflow","listHeight","listWidth","contentLeft","onScrollBottom","chipView","_props$variant","variant","portal","renderValue","renderItem","status","onItemSelect","separator","outerCloseAfterSelect","closeAfterSelect","isTargetAmount","rest","_objectWithoutProperties","_excluded","transformedItems","useMemo","initialItemsTransform","_usePathMaps","usePathMaps","_usePathMaps2","_slicedToArray","pathMap","focusedToValueMap","valueToCheckedMap","valueToItemMap","labelToItemMap","_useState","useState","multiselect","_useState2","internalValue","setInternalValue","undefined","getInitialValue","floatingPopoverRef","useRef","_useReducer","useReducer","pathReducer","_useReducer2","path","dispatchPath","_useReducer3","focusedPathReducer","_useReducer4","focusedPath","dispatchFocusedPath","_useState3","_useState4","checked","setChecked","isCurrentListOpen","Boolean","activeDescendantItemValue","getItemByFocused","toString","treeId","safeUseId","getView","targetRef","useOutsideClick","type","newValue","handleClickArrow","handleListToggle","opened","handleCheckboxChange","item","checkedCopy","Map","get","set","updateDescendants","updateAncestors","newValues","forEach","key","push","handleItemClick","e","isEmpty","stopPropagation","isCurrentChecked","handlePressDown","handleScroll","scrollHeight","scrollTop","clientHeight","_useKeyNavigation","useKeyNavigation","onKeyDown","useLayoutEffect","_","Array","isArray","val","updateSingleAncestors","React","createElement","_extends","Provider","FloatingPopover","onToggle","referenceRef","Target","selectProps","inputWrapperRef","Ul","role","id","concat","onScroll","map","index","Inner","currentLevel","selectConfig","name","tag","layout","base","variations","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;IAwBaA,OAAO,gBAAGC,mBAAa,CAAc,EAAiB,EAAC;;AAEpE;AACA;AACA;IACaC,UAAU,GAAG,SAAbA,UAAUA,CAAIC,IAAoE,EAAA;AAAA,EAAA,oBAC3FC,gBAAU,CAAuC,UAACC,KAAK,EAAEC,GAAG,EAAK;AAAA,IAAA,IAAAC,iBAAA,CAAA;AAC7D,IAAA,IACWC,UAAU,GA4BjBH,KAAK,CA5BLI,KAAK;MACKC,aAAa,GA2BvBL,KAAK,CA3BLM,QAAQ;MAAAC,aAAA,GA2BRP,KAAK,CA1BLQ,MAAM;AAANA,MAAAA,OAAM,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,gBAAgB,GAAAA,aAAA;MACzBE,KAAK,GAyBLT,KAAK,CAzBLS,KAAK;MAAAC,gBAAA,GAyBLV,KAAK,CAxBLW,SAAS;AAATA,MAAAA,SAAS,GAAAD,gBAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,gBAAA;MACpBE,KAAK,GAuBLZ,KAAK,CAvBLY,KAAK;MACLC,cAAc,GAsBdb,KAAK,CAtBLa,cAAc;MACdC,WAAW,GAqBXd,KAAK,CArBLc,WAAW;MACXC,UAAU,GAoBVf,KAAK,CApBLe,UAAU;MAAAC,eAAA,GAoBVhB,KAAK,CAnBLiB,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,eAAA;MACVE,SAAS,GAkBflB,KAAK,CAlBLmB,IAAI;MACJC,IAAI,GAiBJpB,KAAK,CAjBLoB,IAAI;MACJC,YAAY,GAgBZrB,KAAK,CAhBLqB,YAAY;MACZC,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,CAChB,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAMwH,YAAY,GAAG;AACxBC,EAAAA,IAAI,EAAE,QAAQ;AACdC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAErJ,UAAU;AAClBsJ,EAAAA,IAAI,EAAJA,kBAAI;EACJC,UAAU,EAAE,EAAE;AACdC,EAAAA,QAAQ,EAAE;AACNlI,IAAAA,IAAI,EAAE,SAAS;AACfC,IAAAA,IAAI,EAAE,GAAG;AACTP,IAAAA,cAAc,EAAE,OAAO;AACvBa,IAAAA,QAAQ,EAAE,SAAA;AACd,GAAA;AACJ;;;;;;"}
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import React, { forwardRef, useState, useReducer, useMemo, createContext, useLayoutEffect, useRef } from 'react';\nimport { safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines';\nimport { isEmpty } from '../../utils';\nimport { useOutsideClick } from '../../hooks';\n\nimport { useKeyNavigation, getItemByFocused } from './hooks/useKeyboardNavigation';\nimport {\n initialItemsTransform,\n updateAncestors,\n updateDescendants,\n updateSingleAncestors,\n getView,\n getInitialValue,\n} from './utils';\nimport { Inner, Target } from './ui';\nimport { pathReducer, focusedPathReducer } from './reducers';\nimport { usePathMaps } from './hooks/usePathMaps';\nimport { Ul, base } from './Select.styles';\nimport type { ItemContext, MergedSelectProps } from './Select.types';\nimport type { MergedDropdownNodeTransformed } from './ui/Inner/ui/Item/Item.types';\nimport { FloatingPopover } from './FloatingPopover';\n\nexport const Context = createContext<ItemContext>({} as ItemContext);\n\n/**\n * Выпадающий список. Поддерживает выбор одного или нескольких значений.\n */\nexport const selectRoot = (Root: RootProps<HTMLButtonElement, Omit<MergedSelectProps, 'items'>>) =>\n forwardRef<HTMLButtonElement, MergedSelectProps>((props, ref) => {\n const {\n value: outerValue,\n onChange: outerOnChange,\n target = 'textfield-like',\n items,\n placement = 'bottom',\n label,\n labelPlacement,\n placeholder,\n helperText,\n disabled = false,\n view: outerView,\n size,\n listOverflow,\n listHeight,\n listWidth,\n contentLeft,\n onScrollBottom,\n chipView,\n variant = 'normal',\n portal,\n renderValue,\n renderItem,\n status,\n onItemSelect,\n separator,\n closeAfterSelect: outerCloseAfterSelect,\n isTargetAmount,\n ...rest\n } = props;\n const transformedItems = useMemo(() => initialItemsTransform(items || []), [items]);\n\n // Создаем структуры для быстрой работы с деревом\n const [pathMap, focusedToValueMap, valueToCheckedMap, valueToItemMap, labelToItemMap] = usePathMaps(\n transformedItems,\n );\n\n const [internalValue, setInternalValue] = useState<string | number | Array<string | number>>(\n props.multiselect ? [] : '',\n );\n\n const value =\n outerValue !== null && outerValue !== undefined\n ? getInitialValue(outerValue, valueToItemMap)\n : internalValue;\n\n const floatingPopoverRef = useRef<HTMLDivElement>(null);\n\n // Состояния дерева элементов\n const [path, dispatchPath] = useReducer(pathReducer, []);\n const [focusedPath, dispatchFocusedPath] = useReducer(focusedPathReducer, []);\n const [checked, setChecked] = useState(valueToCheckedMap);\n\n const isCurrentListOpen = Boolean(path[0]);\n const activeDescendantItemValue = getItemByFocused(focusedPath, focusedToValueMap)?.value.toString() || '';\n const closeAfterSelect = outerCloseAfterSelect ?? !props.multiselect;\n const treeId = safeUseId();\n const view = target === 'textfield-like' && disabled ? 'default' : getView(status, outerView);\n\n const targetRef = useOutsideClick<HTMLUListElement>(() => {\n if (!isCurrentListOpen) {\n return;\n }\n\n dispatchPath({ type: 'reset' });\n dispatchFocusedPath({ type: 'reset' });\n }, floatingPopoverRef);\n\n const onChange = (newValue: string | number | Array<string | number>) => {\n if (outerOnChange) {\n outerOnChange(newValue as any);\n }\n\n setInternalValue(newValue);\n };\n\n const handleClickArrow = () => {\n if (disabled) {\n return;\n }\n\n if (isCurrentListOpen) {\n dispatchPath({ type: 'reset' });\n } else {\n dispatchPath({ type: 'opened_first_level' });\n }\n\n dispatchFocusedPath({ type: 'reset' });\n };\n\n const handleListToggle = (opened: boolean) => {\n if (disabled) {\n return;\n }\n\n if (opened) {\n dispatchPath({ type: 'opened_first_level' });\n } else {\n dispatchFocusedPath({ type: 'reset' });\n dispatchPath({ type: 'reset' });\n }\n };\n\n const handleCheckboxChange = (item: MergedDropdownNodeTransformed) => {\n if (!props.multiselect) {\n return;\n }\n\n const checkedCopy = new Map(checked);\n\n if (!checkedCopy.get(item.value)) {\n checkedCopy.set(item.value, true);\n updateDescendants(item, checkedCopy, true);\n } else {\n checkedCopy.set(item.value, false);\n updateDescendants(item, checkedCopy, false);\n }\n\n updateAncestors(item, checkedCopy);\n\n const newValues: Array<string | number> = [];\n\n valueToItemMap.forEach((item, key) => {\n if (checkedCopy.get(key)) {\n newValues.push(item.value);\n }\n });\n\n if (closeAfterSelect) {\n dispatchPath({ type: 'reset' });\n dispatchFocusedPath({ type: 'reset' });\n }\n\n if (onChange) {\n onChange(newValues);\n }\n };\n\n const handleItemClick = (item: MergedDropdownNodeTransformed, e?: React.MouseEvent<HTMLElement>) => {\n if (!isEmpty(item?.items)) {\n return;\n }\n\n if (props.multiselect) {\n handleCheckboxChange(item);\n return;\n }\n\n if (e) {\n e.stopPropagation();\n }\n\n const isCurrentChecked = checked.get(item.value);\n\n if (closeAfterSelect) {\n dispatchPath({ type: 'reset' });\n dispatchFocusedPath({ type: 'reset' });\n }\n\n if (onChange) {\n onChange(isCurrentChecked ? '' : item.value);\n }\n\n if (onItemSelect) {\n onItemSelect(item, e!);\n }\n };\n\n const handlePressDown = (item: MergedDropdownNodeTransformed, e?: React.MouseEvent<HTMLElement>) => {\n if (isEmpty(item.items)) {\n handleItemClick(item, e);\n } else if (props.multiselect) {\n handleCheckboxChange(item);\n }\n };\n\n const handleScroll = (e: React.UIEvent<HTMLUListElement>) => {\n if (!onScrollBottom) return;\n\n const { target } = e;\n\n if (\n (target as HTMLElement).scrollHeight - (target as HTMLElement).scrollTop ===\n (target as HTMLElement).clientHeight\n ) {\n onScrollBottom(e);\n }\n };\n\n const { onKeyDown } = useKeyNavigation({\n focusedPath,\n dispatchFocusedPath,\n path,\n dispatchPath,\n pathMap,\n focusedToValueMap,\n handleListToggle,\n handlePressDown,\n });\n\n // В данном эффекте мы следим за изменениями value снаружи и вносим коррективы в дерево чекбоксов.\n // Пример: когда юзер очистил value извне, тогда нужно пройтись по элементам и выключить все чекбоксы.\n useLayoutEffect(() => {\n const checkedCopy = new Map(checked);\n\n checkedCopy.forEach((_, key) => {\n checkedCopy.set(key, false);\n });\n\n if (!isEmpty(value) || typeof value === 'number') {\n if (Array.isArray(value)) {\n value.forEach((val) => {\n checkedCopy.set(val, true);\n updateDescendants(valueToItemMap.get(val)!, checkedCopy, true);\n updateAncestors(valueToItemMap.get(val)!, checkedCopy);\n });\n } else {\n checkedCopy.set(value, 'done');\n updateSingleAncestors(valueToItemMap.get(value)!, checkedCopy, 'dot');\n }\n }\n\n setChecked(checkedCopy);\n\n // В deps мы кладем именно outerValue и internalValue, а не просто value.\n // Т.к. вначале нужно отфильтровать и провалидировать outerValue и результат положить в переменную.\n // А переменную, содержащую сложные типы данных, нельзя помещать в deps.\n }, [outerValue, internalValue, items]);\n\n return (\n <Root\n view={view}\n size={size}\n labelPlacement={labelPlacement}\n chipView={chipView}\n disabled={disabled}\n {...(rest as any)}\n >\n <Context.Provider\n value={{\n focusedPath,\n checked,\n multiselect: props.multiselect,\n size,\n handleCheckboxChange,\n handleItemClick,\n variant,\n renderItem,\n valueToItemMap,\n treeId,\n }}\n >\n <FloatingPopover\n ref={floatingPopoverRef}\n opened={isCurrentListOpen}\n onToggle={(opened: boolean) => opened && handleListToggle(true)}\n placement={placement}\n portal={portal}\n listWidth={listWidth}\n target={(referenceRef) => (\n <Target\n ref={ref}\n target={target}\n value={value}\n opened={isCurrentListOpen}\n valueToItemMap={valueToItemMap}\n label={label}\n placeholder={placeholder}\n onKeyDown={onKeyDown}\n labelPlacement={labelPlacement}\n size={size}\n contentLeft={contentLeft}\n disabled={disabled}\n renderValue={renderValue}\n selectProps={props}\n inputWrapperRef={referenceRef as React.MutableRefObject<HTMLDivElement>}\n multiselect={props.multiselect}\n view={view}\n handleClickArrow={handleClickArrow}\n helperText={helperText}\n treeId={treeId}\n activeDescendantItemValue={activeDescendantItemValue}\n isTargetAmount={isTargetAmount}\n onChange={onChange}\n labelToItemMap={labelToItemMap}\n chipView={chipView}\n separator={separator}\n />\n )}\n >\n <Root\n view={view}\n size={size}\n labelPlacement={labelPlacement}\n chipView={chipView}\n disabled={disabled}\n {...(rest as any)}\n >\n <Ul\n role=\"tree\"\n id={`${treeId}_tree_level_1`}\n aria-multiselectable={Boolean(props.multiselect)}\n listHeight={listHeight}\n listOverflow={listOverflow}\n onScroll={handleScroll}\n listWidth={listWidth}\n ref={targetRef}\n >\n {transformedItems.map((item, index) => (\n <Inner\n key={`${index}/0`}\n item={item}\n currentLevel={0}\n path={path}\n dispatchPath={dispatchPath}\n index={index}\n listWidth={listWidth}\n />\n ))}\n </Ul>\n </Root>\n </FloatingPopover>\n </Context.Provider>\n </Root>\n );\n });\n\nexport const selectConfig = {\n name: 'Select',\n tag: 'div',\n layout: selectRoot,\n base,\n variations: {},\n defaults: {\n view: 'default',\n size: 'm',\n labelPlacement: 'outer',\n chipView: 'default',\n },\n};\n"],"names":["Context","createContext","selectRoot","Root","forwardRef","props","ref","_getItemByFocused","outerValue","value","outerOnChange","onChange","_props$target","target","items","_props$placement","placement","label","labelPlacement","placeholder","helperText","_props$disabled","disabled","outerView","view","size","listOverflow","listHeight","listWidth","contentLeft","onScrollBottom","chipView","_props$variant","variant","portal","renderValue","renderItem","status","onItemSelect","separator","outerCloseAfterSelect","closeAfterSelect","isTargetAmount","rest","_objectWithoutProperties","_excluded","transformedItems","useMemo","initialItemsTransform","_usePathMaps","usePathMaps","_usePathMaps2","_slicedToArray","pathMap","focusedToValueMap","valueToCheckedMap","valueToItemMap","labelToItemMap","_useState","useState","multiselect","_useState2","internalValue","setInternalValue","undefined","getInitialValue","floatingPopoverRef","useRef","_useReducer","useReducer","pathReducer","_useReducer2","path","dispatchPath","_useReducer3","focusedPathReducer","_useReducer4","focusedPath","dispatchFocusedPath","_useState3","_useState4","checked","setChecked","isCurrentListOpen","Boolean","activeDescendantItemValue","getItemByFocused","toString","treeId","safeUseId","getView","targetRef","useOutsideClick","type","newValue","handleClickArrow","handleListToggle","opened","handleCheckboxChange","item","checkedCopy","Map","get","set","updateDescendants","updateAncestors","newValues","forEach","key","push","handleItemClick","e","isEmpty","stopPropagation","isCurrentChecked","handlePressDown","handleScroll","scrollHeight","scrollTop","clientHeight","_useKeyNavigation","useKeyNavigation","onKeyDown","useLayoutEffect","_","Array","isArray","val","updateSingleAncestors","React","createElement","_extends","Provider","FloatingPopover","onToggle","referenceRef","Target","selectProps","inputWrapperRef","Ul","role","id","concat","onScroll","map","index","Inner","currentLevel","selectConfig","name","tag","layout","base","variations","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;IAwBaA,OAAO,gBAAGC,mBAAa,CAAc,EAAiB,EAAC;;AAEpE;AACA;AACA;IACaC,UAAU,GAAG,SAAbA,UAAUA,CAAIC,IAAoE,EAAA;AAAA,EAAA,oBAC3FC,gBAAU,CAAuC,UAACC,KAAK,EAAEC,GAAG,EAAK;AAAA,IAAA,IAAAC,iBAAA,CAAA;AAC7D,IAAA,IACWC,UAAU,GA4BjBH,KAAK,CA5BLI,KAAK;MACKC,aAAa,GA2BvBL,KAAK,CA3BLM,QAAQ;MAAAC,aAAA,GA2BRP,KAAK,CA1BLQ,MAAM;AAANA,MAAAA,OAAM,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,gBAAgB,GAAAA,aAAA;MACzBE,KAAK,GAyBLT,KAAK,CAzBLS,KAAK;MAAAC,gBAAA,GAyBLV,KAAK,CAxBLW,SAAS;AAATA,MAAAA,SAAS,GAAAD,gBAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,gBAAA;MACpBE,KAAK,GAuBLZ,KAAK,CAvBLY,KAAK;MACL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,EAAA;AAAA,MAAA,oBAC9BhB,KAAA,CAAAC,aAAA,CAACgB,WAAK,EAAA;AACFtC,QAAAA,GAAG,EAAAkC,EAAAA,CAAAA,MAAA,CAAKG,KAAK,EAAK,IAAA,CAAA;AAClB9C,QAAAA,IAAI,EAAEA,IAAK;AACXgD,QAAAA,YAAY,EAAE,CAAE;AAChB3E,QAAAA,IAAI,EAAEA,IAAK;AACXC,QAAAA,YAAY,EAAEA,YAAa;AAC3BwE,QAAAA,KAAK,EAAEA,KAAM;AACbrH,QAAAA,SAAS,EAAEA,SAAAA;AAAU,OACxB,CAAC,CAAA;AAAA,KACL,CACD,CACF,CACO,CACH,CAChB,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAMwH,YAAY,GAAG;AACxBC,EAAAA,IAAI,EAAE,QAAQ;AACdC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAErJ,UAAU;AAClBsJ,EAAAA,IAAI,EAAJA,kBAAI;EACJC,UAAU,EAAE,EAAE;AACdC,EAAAA,QAAQ,EAAE;AACNlI,IAAAA,IAAI,EAAE,SAAS;AACfC,IAAAA,IAAI,EAAE,GAAG;AACTP,IAAAA,cAAc,EAAE,OAAO;AACvBa,IAAAA,QAAQ,EAAE,SAAA;AACd,GAAA;AACJ;;;;;;"}
|
@@ -40,6 +40,7 @@ var Item = function Item(_ref) {
|
|
40
40
|
handleItemClick = _useContext.handleItemClick,
|
41
41
|
variant = _useContext.variant,
|
42
42
|
renderItem = _useContext.renderItem,
|
43
|
+
valueToItemMap = _useContext.valueToItemMap,
|
43
44
|
treeId = _useContext.treeId;
|
44
45
|
var itemDisabled = Boolean(disabled || isDisabled);
|
45
46
|
var disabledClassName = itemDisabled ? Select_tokens.classes.dropdownItemIsDisabled : undefined;
|
@@ -94,7 +95,7 @@ var Item = function Item(_ref) {
|
|
94
95
|
}))), !multiselect && checked.get(item.value) === 'done' && /*#__PURE__*/React.createElement(IconDone.IconDone, {
|
95
96
|
size: sizeToIconSize.sizeToIconSize(size, variant),
|
96
97
|
color: "inherit"
|
97
|
-
})), renderItem ? /*#__PURE__*/React.createElement(Item_styles.StyledText, null, renderItem(
|
98
|
+
})), renderItem ? /*#__PURE__*/React.createElement(Item_styles.StyledText, null, renderItem(valueToItemMap.get(value))) : /*#__PURE__*/React.createElement(Item_styles.StyledWrapper, null, /*#__PURE__*/React.createElement(Item_styles.StyledCell, {
|
98
99
|
contentLeft: contentLeft,
|
99
100
|
contentRight: contentRight
|
100
101
|
// TODO: #1548
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Item.js","sources":["../../../../../../../src/components/Select/ui/Inner/ui/Item/Item.tsx"],"sourcesContent":["import React, { useRef, FC, useContext } from 'react';\n\nimport { sizeToIconSize, getItemId } from '../../../../utils';\nimport { classes } from '../../../../Select.tokens';\nimport { cx, isEmpty } from '../../../../../../utils';\nimport { IconDisclosureRightCentered, IconDone } from '../../../../../_Icon';\nimport { Context } from '../../../../Select';\nimport { useDidMountEffect } from '../../../../../../hooks';\n\nimport { ItemProps } from './Item.types';\nimport {\n StyledWrapper,\n StyledCell,\n StyledCheckbox,\n StyledIndicator,\n DisclosureIconWrapper,\n IconWrapper,\n StyledText,\n Wrapper,\n StyledCheckboxWrapper,\n} from './Item.styles';\n\nexport const Item: FC<ItemProps> = ({\n item,\n path,\n currentLevel,\n index,\n ariaControls,\n ariaExpanded,\n ariaLevel,\n ariaLabel,\n}) => {\n const { value, label, disabled, isDisabled, contentLeft, contentRight } = item;\n\n const ref = useRef<HTMLLIElement | null>(null);\n\n const {\n focusedPath,\n checked,\n multiselect,\n size,\n handleCheckboxChange,\n handleItemClick,\n variant,\n renderItem,\n treeId,\n } = useContext(Context);\n\n const itemDisabled = Boolean(disabled || isDisabled);\n\n const disabledClassName = itemDisabled ? classes.dropdownItemIsDisabled : undefined;\n const focusedClass =\n currentLevel === focusedPath.length - 1 && index === focusedPath?.[currentLevel]\n ? classes.dropdownItemIsFocused\n : undefined;\n const activeClass = value === path?.[currentLevel + 1] ? classes.dropdownItemIsActive : undefined;\n\n useDidMountEffect(() => {\n if (focusedClass && ref?.current) {\n ref.current.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'center',\n });\n }\n }, [focusedClass]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (itemDisabled) return;\n\n e.stopPropagation();\n\n handleCheckboxChange(item);\n };\n\n const handleClick = (e: React.MouseEvent<HTMLElement>) => {\n if (itemDisabled) {\n e.stopPropagation();\n return;\n }\n\n handleItemClick(item, e);\n };\n\n return (\n <Wrapper\n className={cx(disabledClassName, focusedClass, activeClass)}\n id={getItemId(treeId, value.toString())}\n ref={ref}\n onClick={handleClick}\n variant={variant}\n role=\"treeitem\"\n aria-controls={ariaControls}\n aria-expanded={ariaExpanded}\n aria-level={ariaLevel}\n aria-label={ariaLabel}\n aria-selected={Boolean(checked.get(item.value))}\n >\n <IconWrapper variant={variant}>\n {multiselect && (\n <StyledCheckboxWrapper onClick={(e) => e.stopPropagation()}>\n <StyledCheckbox\n checked={Boolean(checked.get(item.value))}\n indeterminate={checked.get(item.value) === 'indeterminate'}\n onChange={handleChange}\n />\n </StyledCheckboxWrapper>\n )}\n\n {!multiselect && checked.get(item.value) === 'dot' && <StyledIndicator size=\"s\" view=\"default\" />}\n\n {!multiselect && checked.get(item.value) === 'done' && (\n <IconDone size={sizeToIconSize(size, variant)} color=\"inherit\" />\n )}\n </IconWrapper>\n\n {renderItem ? (\n <StyledText>{renderItem(item)}</StyledText>\n ) : (\n <StyledWrapper>\n <StyledCell\n contentLeft={contentLeft}\n contentRight={contentRight}\n // TODO: #1548\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n title={<span>{label}</span>}\n />\n </StyledWrapper>\n )}\n\n {!isEmpty(item.items) && (\n <DisclosureIconWrapper>\n <IconDisclosureRightCentered size={sizeToIconSize(size, variant)} color=\"inherit\" />\n </DisclosureIconWrapper>\n )}\n </Wrapper>\n );\n};\n"],"names":["Item","_ref","item","path","currentLevel","index","ariaControls","ariaExpanded","ariaLevel","ariaLabel","value","label","disabled","isDisabled","contentLeft","contentRight","ref","useRef","_useContext","useContext","Context","focusedPath","checked","multiselect","size","handleCheckboxChange","handleItemClick","variant","renderItem","treeId","itemDisabled","Boolean","disabledClassName","classes","dropdownItemIsDisabled","undefined","focusedClass","length","dropdownItemIsFocused","activeClass","dropdownItemIsActive","useDidMountEffect","current","scrollIntoView","behavior","block","inline","handleChange","e","stopPropagation","handleClick","React","createElement","Wrapper","className","cx","id","getItemId","toString","onClick","role","get","IconWrapper","StyledCheckboxWrapper","StyledCheckbox","indeterminate","onChange","_StyledIndicator","StyledIndicator","view","IconDone","sizeToIconSize","color","StyledText","StyledWrapper","StyledCell","title","isEmpty","items","DisclosureIconWrapper","IconDisclosureRightCentered"],"mappings":";;;;;;;;;;;;;;;;;IAsBaA,IAAmB,GAAG,SAAtBA,IAAmBA,CAAAC,IAAA,EAS1B;AAAA,EAAA,IARFC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,YAAY,GAAAH,IAAA,CAAZG,YAAY;IACZC,OAAK,GAAAJ,IAAA,CAALI,KAAK;IACLC,YAAY,GAAAL,IAAA,CAAZK,YAAY;IACZC,YAAY,GAAAN,IAAA,CAAZM,YAAY;IACZC,SAAS,GAAAP,IAAA,CAATO,SAAS;IACTC,SAAS,GAAAR,IAAA,CAATQ,SAAS,CAAA;AAET,EAAA,IAAQC,KAAK,GAA6DR,IAAI,CAAtEQ,KAAK;IAAEC,KAAK,GAAsDT,IAAI,CAA/DS,KAAK;IAAEC,QAAQ,GAA4CV,IAAI,CAAxDU,QAAQ;IAAEC,UAAU,GAAgCX,IAAI,CAA9CW,UAAU;IAAEC,WAAW,GAAmBZ,IAAI,CAAlCY,WAAW;IAAEC,YAAY,GAAKb,IAAI,CAArBa,YAAY,CAAA;AAErE,E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7C,UAAU,CAAC1B,IAAI,CAAc,CAAC,gBAE3CiD,KAAA,CAAAC,aAAA,CAACsB,yBAAa,EAAA,IAAA,eACVvB,KAAA,CAAAC,aAAA,CAACuB,sBAAU,EAAA;AACP7D,IAAAA,WAAW,EAAEA,WAAY;AACzBC,IAAAA,YAAY,EAAEA,YAAAA;AACd;AACA;AACA;AAAA;AACA6D,IAAAA,KAAK,eAAEzB,KAAA,CAAAC,aAAA,eAAOzC,KAAY,CAAA;GAC7B,CACU,CAClB,EAEA,CAACkE,eAAO,CAAC3E,IAAI,CAAC4E,KAAK,CAAC,iBACjB3B,KAAA,CAAAC,aAAA,CAAC2B,iCAAqB,qBAClB5B,KAAA,CAAAC,aAAA,CAAC4B,uDAA2B,EAAA;AAACxD,IAAAA,IAAI,EAAE+C,6BAAc,CAAC/C,IAAI,EAAEG,OAAO,CAAE;AAAC6C,IAAAA,KAAK,EAAC,SAAA;GAAW,CAChE,CAEtB,CAAC,CAAA;AAElB;;;;"}
|
1
|
+
{"version":3,"file":"Item.js","sources":["../../../../../../../src/components/Select/ui/Inner/ui/Item/Item.tsx"],"sourcesContent":["import React, { useRef, FC, useContext } from 'react';\n\nimport { sizeToIconSize, getItemId } from '../../../../utils';\nimport { classes } from '../../../../Select.tokens';\nimport { cx, isEmpty } from '../../../../../../utils';\nimport { IconDisclosureRightCentered, IconDone } from '../../../../../_Icon';\nimport { Context } from '../../../../Select';\nimport { useDidMountEffect } from '../../../../../../hooks';\n\nimport { ItemProps } from './Item.types';\nimport {\n StyledWrapper,\n StyledCell,\n StyledCheckbox,\n StyledIndicator,\n DisclosureIconWrapper,\n IconWrapper,\n StyledText,\n Wrapper,\n StyledCheckboxWrapper,\n} from './Item.styles';\n\nexport const Item: FC<ItemProps> = ({\n item,\n path,\n currentLevel,\n index,\n ariaControls,\n ariaExpanded,\n ariaLevel,\n ariaLabel,\n}) => {\n const { value, label, disabled, isDisabled, contentLeft, contentRight } = item;\n\n const ref = useRef<HTMLLIElement | null>(null);\n\n const {\n focusedPath,\n checked,\n multiselect,\n size,\n handleCheckboxChange,\n handleItemClick,\n variant,\n renderItem,\n valueToItemMap,\n treeId,\n } = useContext(Context);\n\n const itemDisabled = Boolean(disabled || isDisabled);\n\n const disabledClassName = itemDisabled ? classes.dropdownItemIsDisabled : undefined;\n const focusedClass =\n currentLevel === focusedPath.length - 1 && index === focusedPath?.[currentLevel]\n ? classes.dropdownItemIsFocused\n : undefined;\n const activeClass = value === path?.[currentLevel + 1] ? classes.dropdownItemIsActive : undefined;\n\n useDidMountEffect(() => {\n if (focusedClass && ref?.current) {\n ref.current.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'center',\n });\n }\n }, [focusedClass]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (itemDisabled) return;\n\n e.stopPropagation();\n\n handleCheckboxChange(item);\n };\n\n const handleClick = (e: React.MouseEvent<HTMLElement>) => {\n if (itemDisabled) {\n e.stopPropagation();\n return;\n }\n\n handleItemClick(item, e);\n };\n\n return (\n <Wrapper\n className={cx(disabledClassName, focusedClass, activeClass)}\n id={getItemId(treeId, value.toString())}\n ref={ref}\n onClick={handleClick}\n variant={variant}\n role=\"treeitem\"\n aria-controls={ariaControls}\n aria-expanded={ariaExpanded}\n aria-level={ariaLevel}\n aria-label={ariaLabel}\n aria-selected={Boolean(checked.get(item.value))}\n >\n <IconWrapper variant={variant}>\n {multiselect && (\n <StyledCheckboxWrapper onClick={(e) => e.stopPropagation()}>\n <StyledCheckbox\n checked={Boolean(checked.get(item.value))}\n indeterminate={checked.get(item.value) === 'indeterminate'}\n onChange={handleChange}\n />\n </StyledCheckboxWrapper>\n )}\n\n {!multiselect && checked.get(item.value) === 'dot' && <StyledIndicator size=\"s\" view=\"default\" />}\n\n {!multiselect && checked.get(item.value) === 'done' && (\n <IconDone size={sizeToIconSize(size, variant)} color=\"inherit\" />\n )}\n </IconWrapper>\n\n {renderItem ? (\n <StyledText>{renderItem(valueToItemMap.get(value)!)}</StyledText>\n ) : (\n <StyledWrapper>\n <StyledCell\n contentLeft={contentLeft}\n contentRight={contentRight}\n // TODO: #1548\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n title={<span>{label}</span>}\n />\n </StyledWrapper>\n )}\n\n {!isEmpty(item.items) && (\n <DisclosureIconWrapper>\n <IconDisclosureRightCentered size={sizeToIconSize(size, variant)} color=\"inherit\" />\n </DisclosureIconWrapper>\n )}\n </Wrapper>\n );\n};\n"],"names":["Item","_ref","item","path","currentLevel","index","ariaControls","ariaExpanded","ariaLevel","ariaLabel","value","label","disabled","isDisabled","contentLeft","contentRight","ref","useRef","_useContext","useContext","Context","focusedPath","checked","multiselect","size","handleCheckboxChange","handleItemClick","variant","renderItem","valueToItemMap","treeId","itemDisabled","Boolean","disabledClassName","classes","dropdownItemIsDisabled","undefined","focusedClass","length","dropdownItemIsFocused","activeClass","dropdownItemIsActive","useDidMountEffect","current","scrollIntoView","behavior","block","inline","handleChange","e","stopPropagation","handleClick","React","createElement","Wrapper","className","cx","id","getItemId","toString","onClick","role","get","IconWrapper","StyledCheckboxWrapper","StyledCheckbox","indeterminate","onChange","_StyledIndicator","StyledIndicator","view","IconDone","sizeToIconSize","color","StyledText","StyledWrapper","StyledCell","title","isEmpty","items","DisclosureIconWrapper","IconDisclosureRightCentered"],"mappings":";;;;;;;;;;;;;;;;;IAsBaA,IAAmB,GAAG,SAAtBA,IAAmBA,CAAAC,IAAA,EAS1B;AAAA,EAAA,IARFC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,YAAY,GAAAH,IAAA,CAAZG,YAAY;IACZC,OAAK,GAAAJ,IAAA,CAALI,KAAK;IACLC,YAAY,GAAAL,IAAA,CAAZK,YAAY;IACZC,YAAY,GAAAN,IAAA,CAAZM,YAAY;IACZC,SAAS,GAAAP,IAAA,CAATO,SAAS;IACTC,SAAS,GAAAR,IAAA,CAATQ,SAA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C/C,WAAW,IAAID,OAAO,CAACwC,GAAG,CAAC5D,IAAI,CAACQ,KAAK,CAAC,KAAK,MAAM,iBAC/C0C,KAAA,CAAAC,aAAA,CAACkB,iBAAQ,EAAA;AAAC/C,IAAAA,IAAI,EAAEgD,6BAAc,CAAChD,IAAI,EAAEG,OAAO,CAAE;AAAC8C,IAAAA,KAAK,EAAC,SAAA;AAAS,GAAE,CAE3D,CAAC,EAEb7C,UAAU,gBACPwB,KAAA,CAAAC,aAAA,CAACqB,sBAAU,EAAA,IAAA,EAAE9C,UAAU,CAACC,cAAc,CAACiC,GAAG,CAACpD,KAAK,CAAE,CAAc,CAAC,gBAEjE0C,KAAA,CAAAC,aAAA,CAACsB,yBAAa,EACVvB,IAAAA,eAAAA,KAAA,CAAAC,aAAA,CAACuB,sBAAU,EAAA;AACP9D,IAAAA,WAAW,EAAEA,WAAY;AACzBC,IAAAA,YAAY,EAAEA,YAAAA;AACd;AACA;AACA;AAAA;AACA8D,IAAAA,KAAK,eAAEzB,KAAA,CAAAC,aAAA,eAAO1C,KAAY,CAAA;GAC7B,CACU,CAClB,EAEA,CAACmE,eAAO,CAAC5E,IAAI,CAAC6E,KAAK,CAAC,iBACjB3B,KAAA,CAAAC,aAAA,CAAC2B,iCAAqB,qBAClB5B,KAAA,CAAAC,aAAA,CAAC4B,uDAA2B,EAAA;AAACzD,IAAAA,IAAI,EAAEgD,6BAAc,CAAChD,IAAI,EAAEG,OAAO,CAAE;AAAC8C,IAAAA,KAAK,EAAC,SAAA;GAAW,CAChE,CAEtB,CAAC,CAAA;AAElB;;;;"}
|
@@ -53,24 +53,9 @@ var Textfield = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
53
53
|
|
54
54
|
// Обработчик чипов
|
55
55
|
var handleChipsChange = function handleChipsChange(chipLabels) {
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
// Из лейблов чипов получаем value у item и далее прокидываем его в onChange.
|
60
|
-
if (renderValue && !isTargetAmount) {
|
61
|
-
var resultValues = _rollupPluginBabelHelpers.toConsumableArray(value);
|
62
|
-
value.forEach(function (_, index) {
|
63
|
-
var labelAfterRenderValue = renderValue(labelToItemMap.get(valueToItemMap.get(value[index]).label));
|
64
|
-
if (!chipLabels.includes(labelAfterRenderValue)) {
|
65
|
-
resultValues.splice(index, 1);
|
66
|
-
}
|
67
|
-
});
|
68
|
-
onChange(resultValues);
|
69
|
-
} else {
|
70
|
-
onChange(chipLabels.map(function (chipLabel) {
|
71
|
-
return labelToItemMap.get(chipLabel).value;
|
72
|
-
}));
|
73
|
-
}
|
56
|
+
onChange(chipLabels.map(function (chipLabel) {
|
57
|
+
return labelToItemMap.get(chipLabel).value;
|
58
|
+
}));
|
74
59
|
};
|
75
60
|
return /*#__PURE__*/React.createElement(Textfield_styles.StyledTextField, _rollupPluginBabelHelpers.extends({
|
76
61
|
ref: ref,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Textfield.js","sources":["../../../../../../../src/components/Select/ui/Target/ui/Textfield/Textfield.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { sizeToIconSize, getItemId } from '../../../../utils';\nimport { classes } from '../../../../Select.tokens';\n\nimport { IconArrowWrapper, StyledArrow, StyledTextField } from './Textfield.styles';\nimport { TextfieldProps } from './Textfield.types';\n\nexport const Textfield = forwardRef<HTMLInputElement, TextfieldProps>(\n (\n {\n inputWrapperRef,\n opened,\n multiselect,\n value,\n label,\n placeholder,\n onKeyDown,\n labelPlacement,\n size,\n view,\n handleClickArrow,\n contentLeft,\n helperText,\n treeId,\n activeDescendantItemValue,\n disabled,\n isTargetAmount,\n valueToItemMap,\n renderValue,\n onChange,\n labelToItemMap,\n chipView,\n },\n ref,\n ) => {\n const withArrowInverse = opened ? classes.arrowInverse : undefined;\n\n const getChips = (): string[] => {\n if (multiselect && Array.isArray(value)) {\n if (value.length === 0) return [];\n\n if (isTargetAmount) {\n return [`Выбрано ${value.length}`];\n }\n\n const renderValueMapper =\n renderValue && ((stringValue: string | number) => renderValue(valueToItemMap.get(stringValue)!));\n const valueToItemMapper = (stringValue: string | number) => valueToItemMap.get(stringValue)!.label;\n\n return value.map(renderValueMapper || valueToItemMapper);\n }\n\n return [];\n };\n\n // Обработчик чипов\n const handleChipsChange = (chipLabels: any[]) => {\n
|
1
|
+
{"version":3,"file":"Textfield.js","sources":["../../../../../../../src/components/Select/ui/Target/ui/Textfield/Textfield.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { sizeToIconSize, getItemId } from '../../../../utils';\nimport { classes } from '../../../../Select.tokens';\n\nimport { IconArrowWrapper, StyledArrow, StyledTextField } from './Textfield.styles';\nimport { TextfieldProps } from './Textfield.types';\n\nexport const Textfield = forwardRef<HTMLInputElement, TextfieldProps>(\n (\n {\n inputWrapperRef,\n opened,\n multiselect,\n value,\n label,\n placeholder,\n onKeyDown,\n labelPlacement,\n size,\n view,\n handleClickArrow,\n contentLeft,\n helperText,\n treeId,\n activeDescendantItemValue,\n disabled,\n isTargetAmount,\n valueToItemMap,\n renderValue,\n onChange,\n labelToItemMap,\n chipView,\n },\n ref,\n ) => {\n const withArrowInverse = opened ? classes.arrowInverse : undefined;\n\n const getChips = (): string[] => {\n if (multiselect && Array.isArray(value)) {\n if (value.length === 0) return [];\n\n if (isTargetAmount) {\n return [`Выбрано ${value.length}`];\n }\n\n const renderValueMapper =\n renderValue && ((stringValue: string | number) => renderValue(valueToItemMap.get(stringValue)!));\n const valueToItemMapper = (stringValue: string | number) => valueToItemMap.get(stringValue)!.label;\n\n return value.map(renderValueMapper || valueToItemMapper);\n }\n\n return [];\n };\n\n // Обработчик чипов\n const handleChipsChange = (chipLabels: any[]) => {\n onChange(chipLabels.map((chipLabel) => labelToItemMap.get(chipLabel)!.value));\n };\n\n return (\n <StyledTextField\n ref={ref}\n inputWrapperRef={inputWrapperRef}\n readOnly\n value={multiselect ? undefined : valueToItemMap.get(value.toString())?.label || ''}\n size={size}\n view={view}\n chipView={chipView}\n labelPlacement={labelPlacement}\n disabled={disabled}\n label={label}\n placeholder={value instanceof Array && value.length ? '' : placeholder}\n contentLeft={contentLeft as React.ReactElement}\n contentRight={\n <IconArrowWrapper disabled={Boolean(disabled)} onClick={handleClickArrow}>\n <StyledArrow color=\"inherit\" size={sizeToIconSize(size)} className={withArrowInverse} />\n </IconArrowWrapper>\n }\n onKeyDown={onKeyDown}\n leftHelper={helperText}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-controls={`${treeId}_tree_level_1`}\n aria-expanded={opened}\n aria-activedescendant={activeDescendantItemValue ? getItemId(treeId, activeDescendantItemValue) : ''}\n {...(multiselect\n ? {\n enumerationType: 'chip',\n chips: getChips(),\n onChangeChips: handleChipsChange,\n }\n : { enumerationType: 'plain' })}\n onEnterDisabled // Пропс для отключения обработчика Enter внутри Textfield\n opened={opened}\n // TODO: #1547\n _forceChipManipulationWithReadonly\n />\n );\n },\n);\n"],"names":["Textfield","forwardRef","_ref","ref","_valueToItemMap$get","inputWrapperRef","opened","multiselect","value","label","placeholder","onKeyDown","labelPlacement","size","view","handleClickArrow","contentLeft","helperText","treeId","activeDescendantItemValue","disabled","isTargetAmount","valueToItemMap","renderValue","onChange","labelToItemMap","chipView","withArrowInverse","classes","arrowInverse","undefined","getChips","Array","isArray","length","concat","renderValueMapper","stringValue","get","valueToItemMapper","map","handleChipsChange","chipLabels","chipLabel","React","createElement","StyledTextField","_extends","readOnly","toString","contentRight","IconArrowWrapper","Boolean","onClick","StyledArrow","color","sizeToIconSize","className","leftHelper","role","getItemId","enumerationType","chips","onChangeChips","onEnterDisabled","_forceChipManipulationWithReadonly"],"mappings":";;;;;;;;;;;AAQO,IAAMA,SAAS,gBAAGC,gBAAU,CAC/B,UAAAC,IAAA,EAyBIC,GAAG,EACF;AAAA,EAAA,IAAAC,mBAAA,CAAA;AAAA,EAAA,IAxBGC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,WAAW,G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AAA,GAAA,CACrC,CAAC,CAAA;AAEV,CACJ;;;;"}
|
package/cjs/index.css
CHANGED
@@ -392,12 +392,11 @@
|
|
392
392
|
|
393
393
|
.DropdownHeader_styles_196gwgm_s133b1g2__3510806e{background:var(--plasma-dropdown-header-background);font-family:var(--plasma-dropdown-header-font-family);font-size:var(--plasma-dropdown-header-font-size);font-style:var(--plasma-dropdown-header-font-style);font-weight:var(--plasma-dropdown-header-letter-spacing);-webkit-letter-spacing:var(--plasma-dropdown-header-line-height);-moz-letter-spacing:var(--plasma-dropdown-header-line-height);-ms-letter-spacing:var(--plasma-dropdown-header-line-height);letter-spacing:var(--plasma-dropdown-header-line-height);line-height:var(--plasma-dropdown-header-font-weight);width:var(--plasma-dropdown-header-width);height:var(--plasma-dropdown-header-height);padding:var(--plasma-dropdown-header-padding-top) var(--plasma-dropdown-header-padding-right) var(--plasma-dropdown-header-padding-bottom) var(--plasma-dropdown-header-padding-left);margin:var(--plasma-dropdown-header-margin-top) var(--plasma-dropdown-header-margin-right) var(--plasma-dropdown-header-margin-bottom) var(--plasma-dropdown-header-margin-left);}
|
394
394
|
|
395
|
-
.
|
395
|
+
.DropdownItem_styles_1b439rx_c1gkzlls__ed711128{--plasma-cell-title-color:var(--text-primary);--plasma-cell-background-color:var(--plasma-colors-transparent);--plasma-cell-padding:var(--plasma-dropdown-cell-padding);--plasma-cell-padding-left-content:var(--plasma-dropdown-cell-padding-left-content);--plasma-cell-padding-content:var(--plasma-dropdown-cell-padding-content);--plasma-cell-padding-right-content:var(--plasma-dropdown-cell-padding-right-content);--plasma-cell-textbox-gap:var(--plasma-dropdown-cell-textbox-gap);--plasma-cell-gap:var(--plasma-dropdown-cell-gap);--plasma-cell-title-font-family:var(--plasma-dropdown-cell-title-font-family);--plasma-cell-title-font-size:var(--plasma-dropdown-cell-title-font-size);--plasma-cell-title-font-style:var(--plasma-dropdown-cell-title-font-style);--plasma-cell-title-font-weight:var(--plasma-dropdown-cell-title-font-weight);--plasma-cell-title-letter-spacing:var(--plasma-dropdown-cell-title-letter-spacing);--plasma-cell-title-line-height:var(--plasma-dropdown-cell-title-line-height);width:100%;}
|
396
396
|
|
397
|
-
.
|
398
|
-
.
|
399
|
-
.
|
400
|
-
.DropdownItem_styles_14yih1y_r1jav4ek__bf539568{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-flex:1;-ms-flex:1;flex:1;}
|
397
|
+
.DropdownItem_styles_1b439rx_d1m97l2m__ed711128{line-height:0;color:var(--text-secondary);}
|
398
|
+
.DropdownItem_styles_1b439rx_doib72h__ed711128{height:1px;margin-top:var(--doib72h-0);margin-right:var(--plasma-dropdown-divider-margin-right);margin-bottom:var(--doib72h-1);margin-left:var(--plasma-dropdown-divider-margin-left);background:var(--plasma-dropdown-divider-color);}
|
399
|
+
.DropdownItem_styles_1b439rx_w6l2f0g__ed711128{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;min-height:var(--plasma-dropdown-item-height);margin:0;box-sizing:content-box;padding:var(--w6l2f0g-0);font-family:var(--plasma-dropdown-item-font-family);font-size:var(--plasma-dropdown-item-font-size);font-style:var(--plasma-dropdown-item-font-style);font-weight:var(--plasma-dropdown-item-letter-spacing);-webkit-letter-spacing:var(--plasma-dropdown-item-line-height);-moz-letter-spacing:var(--plasma-dropdown-item-line-height);-ms-letter-spacing:var(--plasma-dropdown-item-line-height);letter-spacing:var(--plasma-dropdown-item-line-height);line-height:var(--plasma-dropdown-item-font-weight);background-color:var(--plasma-colors-transparent);border-radius:var(--plasma-dropdown-border-radius);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border-right:0.125rem solid transparent;border-left:0.125rem solid transparent;background-clip:padding-box;position:relative;}.DropdownItem_styles_1b439rx_w6l2f0g__ed711128:hover:not(.DropdownItem_styles_1b439rx_dropdownItemIsDisabled__ed711128){cursor:pointer;background-color:var(--plasma-dropdown-item-background-hover);}.DropdownItem_styles_1b439rx_w6l2f0g__ed711128.DropdownItem_styles_1b439rx_dropdownItemIsActive__ed711128{background-color:var(--plasma-dropdown-item-background-hover);}.DropdownItem_styles_1b439rx_w6l2f0g__ed711128.DropdownItem_styles_1b439rx_dropdownItemIsDisabled__ed711128{opacity:0.4;cursor:not-allowed;}.DropdownItem_styles_1b439rx_w6l2f0g__ed711128:focus{outline:none;}.DropdownItem_styles_1b439rx_w6l2f0g__ed711128::before{content:'';position:absolute;top:0;left:0;right:0;bottom:0;z-index:1;display:block;box-sizing:content-box;border:0.0625rem solid transparent;border-radius:var(--plasma-dropdown-item-border-radius);-webkit-transition:none;transition:none;pointer-events:none;}.DropdownItem_styles_1b439rx_w6l2f0g__ed711128.DropdownItem_styles_1b439rx_dropdownItemIsFocused__ed711128:before{outline:none;box-shadow:0 0 0 0.0625rem var(--surface-accent);}
|
401
400
|
|
402
401
|
.DropdownItem_styles_1lyg81y_s1iqs5in__b17ea060{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;min-width:var(--plasma-dropdown-item-content-left-width);color:var(--plasma-dropdown-item-content-left-color);}
|
403
402
|
.DropdownItem_styles_1lyg81y_sfg3dyd__b17ea060{margin-left:auto;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;min-width:var(--plasma-dropdown-item-content-right-width);color:var(--plasma-dropdown-item-content-right-color);}
|
@@ -585,6 +584,8 @@
|
|
585
584
|
|
586
585
|
.Combobox_styles_18a8p75_s11cn92k__ba048029{--plasma-emptystate-border-radius:var(--plasma-combobox-new-textfield-border-radius);--plasma-emptystate-padding:var(--plasma-combobox-new-empty-state-padding);--plasma-emptystate-font-family:var(--plasma-combobox-new-textfield-font-family);--plasma-emptystate-font-size:var(--plasma-combobox-new-textfield-font-size);--plasma-emptystate-font-style:var(--plasma-combobox-new-textfield-font-style);--plasma-emptystate-font-weight:var(--plasma-combobox-new-textfield-font-weight);--plasma-emptystate-font-letter-spacing:var(--plasma-combobox-new-textfield-letter-spacing);--plasma-emptystate-font-line-height:var(--plasma-combobox-new-textfield-line-height);}
|
587
586
|
|
587
|
+
.SelectNative_styles_18yw2bf_st8j5fy__14a96fe5{visibility:hidden;width:0;height:0;opacity:0;margin:0;padding:0;border:none;}
|
588
|
+
|
588
589
|
.Indicator_styles_v8giip_b5hgwnm__ffd4472f{border-radius:100%;}
|
589
590
|
|
590
591
|
.base_1rjb5ly_bu942ai__5ed616c0{background-color:var(--plasma-indicator-color);}
|
package/cjs/index.js
CHANGED
@@ -32,6 +32,7 @@ var react = require('./utils/react.js');
|
|
32
32
|
var isNumber = require('./utils/isNumber.js');
|
33
33
|
var setRefList = require('./utils/setRefList.js');
|
34
34
|
var isEmpty = require('./utils/isEmpty.js');
|
35
|
+
var createEvent = require('./utils/createEvent.js');
|
35
36
|
var noop = require('./utils/noop.js');
|
36
37
|
var fixedForwardRef = require('./utils/fixedForwardRef.js');
|
37
38
|
var getPopoverPlacement = require('./utils/getPopoverPlacement.js');
|
@@ -309,6 +310,7 @@ exports.isNumber = isNumber.isNumber;
|
|
309
310
|
exports.mergeRefs = setRefList.mergeRefs;
|
310
311
|
exports.setRefList = setRefList.setRefList;
|
311
312
|
exports.isEmpty = isEmpty.isEmpty;
|
313
|
+
exports.createEvent = createEvent.createEvent;
|
312
314
|
exports.noop = noop.noop;
|
313
315
|
exports.fixedForwardRef = fixedForwardRef.fixedForwardRef;
|
314
316
|
exports.getPlacement = getPopoverPlacement.getPlacement;
|
package/cjs/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
var createEvent = function createEvent(ref) {
|
6
|
+
if (ref.current) {
|
7
|
+
var event = new Event('change', {
|
8
|
+
bubbles: true
|
9
|
+
});
|
10
|
+
Object.defineProperty(event, 'target', {
|
11
|
+
writable: false,
|
12
|
+
value: ref.current
|
13
|
+
});
|
14
|
+
var syntheticEvent = createSyntheticEvent(event);
|
15
|
+
return syntheticEvent;
|
16
|
+
}
|
17
|
+
return null;
|
18
|
+
};
|
19
|
+
var createSyntheticEvent = function createSyntheticEvent(event) {
|
20
|
+
var _isDefaultPrevented = false;
|
21
|
+
var _isPropagationStopped = false;
|
22
|
+
var preventDefault = function preventDefault() {
|
23
|
+
_isDefaultPrevented = true;
|
24
|
+
event.preventDefault();
|
25
|
+
};
|
26
|
+
var stopPropagation = function stopPropagation() {
|
27
|
+
_isPropagationStopped = true;
|
28
|
+
event.stopPropagation();
|
29
|
+
};
|
30
|
+
return {
|
31
|
+
nativeEvent: event,
|
32
|
+
currentTarget: event.currentTarget,
|
33
|
+
target: event.target,
|
34
|
+
bubbles: event.bubbles,
|
35
|
+
cancelable: event.cancelable,
|
36
|
+
defaultPrevented: event.defaultPrevented,
|
37
|
+
eventPhase: event.eventPhase,
|
38
|
+
isTrusted: event.isTrusted,
|
39
|
+
preventDefault: preventDefault,
|
40
|
+
isDefaultPrevented: function isDefaultPrevented() {
|
41
|
+
return _isDefaultPrevented;
|
42
|
+
},
|
43
|
+
stopPropagation: stopPropagation,
|
44
|
+
isPropagationStopped: function isPropagationStopped() {
|
45
|
+
return _isPropagationStopped;
|
46
|
+
},
|
47
|
+
persist: function persist() {},
|
48
|
+
timeStamp: event.timeStamp,
|
49
|
+
type: event.type
|
50
|
+
};
|
51
|
+
};
|
52
|
+
|
53
|
+
exports.createEvent = createEvent;
|
54
|
+
//# sourceMappingURL=createEvent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createEvent.js","sources":["../../src/utils/createEvent.ts"],"sourcesContent":["import { RefObject } from 'react';\n\nexport const createEvent = <T extends HTMLSelectElement | HTMLInputElement | HTMLTextAreaElement>(\n ref: RefObject<T>,\n) => {\n if (ref.current) {\n const event = new Event('change', { bubbles: true });\n Object.defineProperty(event, 'target', { writable: false, value: ref.current });\n const syntheticEvent = createSyntheticEvent(event) as React.ChangeEvent<typeof ref.current>;\n return syntheticEvent;\n }\n\n return null;\n};\n\nconst createSyntheticEvent = <T extends Element, E extends Event>(event: E): React.SyntheticEvent<T, E> => {\n let isDefaultPrevented = false;\n let isPropagationStopped = false;\n const preventDefault = () => {\n isDefaultPrevented = true;\n event.preventDefault();\n };\n const stopPropagation = () => {\n isPropagationStopped = true;\n event.stopPropagation();\n };\n return {\n nativeEvent: event,\n currentTarget: event.currentTarget as EventTarget & T,\n target: event.target as EventTarget & T,\n bubbles: event.bubbles,\n cancelable: event.cancelable,\n defaultPrevented: event.defaultPrevented,\n eventPhase: event.eventPhase,\n isTrusted: event.isTrusted,\n preventDefault,\n isDefaultPrevented: () => isDefaultPrevented,\n stopPropagation,\n isPropagationStopped: () => isPropagationStopped,\n persist: () => {},\n timeStamp: event.timeStamp,\n type: event.type,\n };\n};\n"],"names":["createEvent","ref","current","event","Event","bubbles","Object","defineProperty","writable","value","syntheticEvent","createSyntheticEvent","isDefaultPrevented","isPropagationStopped","preventDefault","stopPropagation","nativeEvent","currentTarget","target","cancelable","defaultPrevented","eventPhase","isTrusted","persist","timeStamp","type"],"mappings":";;;;IAEaA,WAAW,GAAG,SAAdA,WAAWA,CACpBC,GAAiB,EAChB;EACD,IAAIA,GAAG,CAACC,OAAO,EAAE;AACb,IAAA,IAAMC,KAAK,GAAG,IAAIC,KAAK,CAAC,QAAQ,EAAE;AAAEC,MAAAA,OAAO,EAAE,IAAA;AAAK,KAAC,CAAC,CAAA;AACpDC,IAAAA,MAAM,CAACC,cAAc,CAACJ,KAAK,EAAE,QAAQ,EAAE;AAAEK,MAAAA,QAAQ,EAAE,KAAK;MAAEC,KAAK,EAAER,GAAG,CAACC,OAAAA;AAAQ,KAAC,CAAC,CAAA;AAC/E,IAAA,IAAMQ,cAAc,GAAGC,oBAAoB,CAACR,KAAK,CAA0C,CAAA;AAC3F,IAAA,OAAOO,cAAc,CAAA;AACzB,GAAA;AAEA,EAAA,OAAO,IAAI,CAAA;AACf,EAAC;AAED,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAwCR,KAAQ,EAAiC;EACvG,IAAIS,mBAAkB,GAAG,KAAK,CAAA;EAC9B,IAAIC,qBAAoB,GAAG,KAAK,CAAA;AAChC,EAAA,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,GAAS;AACzBF,IAAAA,mBAAkB,GAAG,IAAI,CAAA;IACzBT,KAAK,CAACW,cAAc,EAAE,CAAA;GACzB,CAAA;AACD,EAAA,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,GAAS;AAC1BF,IAAAA,qBAAoB,GAAG,IAAI,CAAA;IAC3BV,KAAK,CAACY,eAAe,EAAE,CAAA;GAC1B,CAAA;EACD,OAAO;AACHC,IAAAA,WAAW,EAAEb,KAAK;IAClBc,aAAa,EAAEd,KAAK,CAACc,aAAgC;IACrDC,MAAM,EAAEf,KAAK,CAACe,MAAyB;IACvCb,OAAO,EAAEF,KAAK,CAACE,OAAO;IACtBc,UAAU,EAAEhB,KAAK,CAACgB,UAAU;IAC5BC,gBAAgB,EAAEjB,KAAK,CAACiB,gBAAgB;IACxCC,UAAU,EAAElB,KAAK,CAACkB,UAAU;IAC5BC,SAAS,EAAEnB,KAAK,CAACmB,SAAS;AAC1BR,IAAAA,cAAc,EAAdA,cAAc;IACdF,kBAAkB,EAAE,SAAAA,kBAAA,GAAA;AAAA,MAAA,OAAMA,mBAAkB,CAAA;AAAA,KAAA;AAC5CG,IAAAA,eAAe,EAAfA,eAAe;IACfF,oBAAoB,EAAE,SAAAA,oBAAA,GAAA;AAAA,MAAA,OAAMA,qBAAoB,CAAA;AAAA,KAAA;AAChDU,IAAAA,OAAO,EAAE,SAAAA,OAAA,GAAM,EAAE;IACjBC,SAAS,EAAErB,KAAK,CAACqB,SAAS;IAC1BC,IAAI,EAAEtB,KAAK,CAACsB,IAAAA;GACf,CAAA;AACL,CAAC;;;;"}
|
package/cjs/utils/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":["import { CSSProperties } from '@linaria/core';\n\nexport { canUseDOM } from './canUseDOM';\nexport { extractTextFrom } from './extractTextFrom';\nexport { getSizeValueFromProp } from './getSizeValueFromProp';\nexport { IS_REACT_18, safeUseId } from './react';\nexport { isNumber } from './isNumber';\nexport { mergeRefs, setRefList } from './setRefList';\nexport { isEmpty } from './isEmpty';\nexport * as constants from './constants';\nexport * from './getPopoverPlacement';\nexport { noop } from './noop';\n\nexport const cx = (...classes: (string | boolean | undefined)[]) => classes.filter((classItem) => classItem).join(' ');\n\nexport const composableStyle = (s: TemplateStringsArray, ...expr: Array<string | number | CSSProperties>): string => {\n let res = '';\n for (let i = 0; i < Math.max(s.length, expr.length); ++i) {\n res += s[i] ?? '';\n res += expr[i] ?? '';\n }\n\n return res;\n};\n\nexport { fixedForwardRef } from './fixedForwardRef';\n"],"names":["cx","_len","arguments","length","classes","Array","_key","filter","classItem","join","composableStyle","s","res","i","Math","max","_s$i","_ref","undefined"],"mappings":";;;;
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":["import { CSSProperties } from '@linaria/core';\n\nexport { canUseDOM } from './canUseDOM';\nexport { extractTextFrom } from './extractTextFrom';\nexport { getSizeValueFromProp } from './getSizeValueFromProp';\nexport { IS_REACT_18, safeUseId } from './react';\nexport { isNumber } from './isNumber';\nexport { mergeRefs, setRefList } from './setRefList';\nexport { isEmpty } from './isEmpty';\nexport { createEvent } from './createEvent';\nexport * as constants from './constants';\nexport * from './getPopoverPlacement';\nexport { noop } from './noop';\n\nexport const cx = (...classes: (string | boolean | undefined)[]) => classes.filter((classItem) => classItem).join(' ');\n\nexport const composableStyle = (s: TemplateStringsArray, ...expr: Array<string | number | CSSProperties>): string => {\n let res = '';\n for (let i = 0; i < Math.max(s.length, expr.length); ++i) {\n res += s[i] ?? '';\n res += expr[i] ?? '';\n }\n\n return res;\n};\n\nexport { fixedForwardRef } from './fixedForwardRef';\n"],"names":["cx","_len","arguments","length","classes","Array","_key","filter","classItem","join","composableStyle","s","res","i","Math","max","_s$i","_ref","undefined"],"mappings":";;;;AAcaA,IAAAA,EAAE,GAAG,SAALA,EAAEA,GAAA;AAAA,EAAA,KAAA,IAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAOC,OAAO,GAAAC,IAAAA,KAAA,CAAAJ,IAAA,GAAAK,IAAA,GAAA,CAAA,EAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA,EAAA,EAAA;AAAPF,IAAAA,OAAO,CAAAE,IAAA,CAAAJ,GAAAA,SAAA,CAAAI,IAAA,CAAA,CAAA;AAAA,GAAA;AAAA,EAAA,OAAuCF,OAAO,CAACG,MAAM,CAAC,UAACC,SAAS,EAAA;AAAA,IAAA,OAAKA,SAAS,CAAA;AAAA,GAAA,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAA;AAAA,EAAA;IAEzGC,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,CAAuB,EAA8D;EACjH,IAAIC,GAAG,GAAG,EAAE,CAAA;EACZ,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGC,IAAI,CAACC,GAAG,CAACJ,CAAC,CAACR,MAAM,EAAAD,SAAA,CAAAC,MAAA,IAAA,CAAA,GAAA,CAAA,GAAAD,SAAA,CAAAC,MAAA,GAAA,CAAa,CAAC,EAAE,EAAEU,CAAC,EAAE;IAAA,IAAAG,IAAA,EAAAC,IAAA,CAAA;AACtDL,IAAAA,GAAG,IAAAI,CAAAA,IAAA,GAAIL,CAAC,CAACE,CAAC,CAAC,MAAA,IAAA,IAAAG,IAAA,KAAA,KAAA,CAAA,GAAAA,IAAA,GAAI,EAAE,CAAA;IACjBJ,GAAG,IAAA,CAAAK,IAAA,GAASJ,CAAC,YAAAX,SAAA,CAAAC,MAAA,IAADU,CAAC,OAAAK,SAAA,GAAAhB,SAAA,CAADW,CAAC,mBAAAI,IAAA,KAAA,KAAA,CAAA,GAAAA,IAAA,GAAK,EAAE,CAAA;AACxB,GAAA;AAEA,EAAA,OAAOL,GAAG,CAAA;AACd;;;;;"}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
@@ -20,14 +19,12 @@ var _getPathMaps = /*#__PURE__*/require("./hooks/getPathMaps");
|
|
20
19
|
var _Combobox2 = /*#__PURE__*/require("./Combobox.styles");
|
21
20
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
22
21
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
23
|
-
var
|
22
|
+
var _SelectNative = /*#__PURE__*/require("./ui/SelectNative/SelectNative");
|
23
|
+
var _excluded = ["name", "multiple", "value", "onChange", "defaultValue", "isTargetAmount", "targetAmount", "items", "placement", "label", "placeholder", "helperText", "contentLeft", "textBefore", "textAfter", "variant", "listOverflow", "listHeight", "listWidth", "portal", "renderItem", "view", "size", "labelPlacement", "readOnly", "disabled", "alwaysOpened", "filter", "closeAfterSelect", "renderValue"];
|
24
24
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
25
25
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
26
26
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
27
|
-
function
|
28
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
29
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
30
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
27
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
31
28
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
32
29
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
33
30
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
@@ -41,12 +38,15 @@ var Context = exports.Context = /*#__PURE__*/(0, _react.createContext)({});
|
|
41
38
|
/**
|
42
39
|
* Поле ввода с выпадающим списком и возможностью фильтрации и выбора элементов.
|
43
40
|
*/
|
41
|
+
|
44
42
|
var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
45
43
|
return /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
46
44
|
var _valueToItemMap$get, _valueToItemMap$get2, _getItemByFocused;
|
47
|
-
var
|
45
|
+
var name = props.name,
|
46
|
+
multiple = props.multiple,
|
48
47
|
outerValue = props.value,
|
49
48
|
outerOnChange = props.onChange,
|
49
|
+
defaultValue = props.defaultValue,
|
50
50
|
isTargetAmount = props.isTargetAmount,
|
51
51
|
targetAmount = props.targetAmount,
|
52
52
|
items = props.items,
|
@@ -78,6 +78,7 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
78
78
|
outerCloseAfterSelect = props.closeAfterSelect,
|
79
79
|
renderValue = props.renderValue,
|
80
80
|
rest = _objectWithoutProperties(props, _excluded);
|
81
|
+
console.log('render');
|
81
82
|
var transformedItems = (0, _react.useMemo)(function () {
|
82
83
|
return (0, _utils3.initialItemsTransform)(items || []);
|
83
84
|
}, [items]);
|
@@ -153,11 +154,27 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
153
154
|
}
|
154
155
|
}
|
155
156
|
}, floatingPopoverRef);
|
157
|
+
|
158
|
+
// Эта функция срабатывает при изменении Combobox и
|
159
|
+
// при изменении нативного Select для формы (срабатывает только после изменения internalValue и рендера).
|
156
160
|
var onChange = function onChange(newValue) {
|
161
|
+
// Условие для отправки изменений наружу
|
157
162
|
if (outerOnChange) {
|
158
|
-
|
163
|
+
// Условие для отправки если комбобокс используется без формы.
|
164
|
+
if (!name && (typeof newValue === 'string' || Array.isArray(newValue))) {
|
165
|
+
outerOnChange(newValue);
|
166
|
+
}
|
167
|
+
|
168
|
+
// Условие для отправки если комбобокс используется с формой.
|
169
|
+
if (name && _typeof(newValue) === 'object' && !Array.isArray(newValue)) {
|
170
|
+
outerOnChange(newValue);
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
// Условие для изменения внутреннего значения (только если newValue строка или массив строк).
|
175
|
+
if (typeof newValue === 'string' || Array.isArray(newValue)) {
|
176
|
+
setInternalValue(newValue);
|
159
177
|
}
|
160
|
-
setInternalValue(newValue);
|
161
178
|
};
|
162
179
|
var handleClickArrow = function handleClickArrow() {
|
163
180
|
if (disabled || readOnly) {
|
@@ -190,24 +207,9 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
190
207
|
|
191
208
|
// Обработчик чипов
|
192
209
|
var handleChipsChange = function handleChipsChange(chipLabels) {
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
// Из лейблов чипов получаем value у item и далее прокидываем его в onChange.
|
197
|
-
if (renderValue && !isTargetAmount) {
|
198
|
-
var resultValues = _toConsumableArray(value);
|
199
|
-
value.forEach(function (_, index) {
|
200
|
-
var labelAfterRenderValue = renderValue(labelToItemMap.get(valueToItemMap.get(value[index]).label));
|
201
|
-
if (!chipLabels.includes(labelAfterRenderValue)) {
|
202
|
-
resultValues.splice(index, 1);
|
203
|
-
}
|
204
|
-
});
|
205
|
-
onChange(resultValues);
|
206
|
-
} else {
|
207
|
-
onChange(chipLabels.map(function (chipLabel) {
|
208
|
-
return labelToItemMap.get(chipLabel).value;
|
209
|
-
}));
|
210
|
-
}
|
210
|
+
onChange(chipLabels.map(function (chipLabel) {
|
211
|
+
return labelToItemMap.get(chipLabel).value;
|
212
|
+
}));
|
211
213
|
};
|
212
214
|
|
213
215
|
// Обработчик открытия/закрытия выпадающего списка
|
@@ -360,13 +362,24 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
360
362
|
// Т.к. вначале нужно отфильтровать и провалидировать outerValue и результат положить в переменную.
|
361
363
|
// А переменную, содержащую сложные типы данных, нельзя помещать в deps.
|
362
364
|
}, [outerValue, internalValue, items]);
|
365
|
+
(0, _react.useEffect)(function () {
|
366
|
+
if (defaultValue) {
|
367
|
+
setInternalValue(defaultValue);
|
368
|
+
}
|
369
|
+
}, [defaultValue]);
|
363
370
|
return /*#__PURE__*/_react["default"].createElement(Root, {
|
364
371
|
size: size,
|
365
372
|
view: view,
|
366
373
|
labelPlacement: labelPlacement,
|
367
374
|
disabled: disabled,
|
368
375
|
readOnly: readOnly
|
369
|
-
},
|
376
|
+
}, name && /*#__PURE__*/_react["default"].createElement(_SelectNative.SelectNative, {
|
377
|
+
name: name,
|
378
|
+
value: internalValue,
|
379
|
+
multiple: multiple,
|
380
|
+
onChange: onChange,
|
381
|
+
ref: ref
|
382
|
+
}), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(Context.Provider, {
|
370
383
|
value: {
|
371
384
|
focusedPath: focusedPath,
|
372
385
|
checked: checked,
|
@@ -376,6 +389,7 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
376
389
|
handleItemClick: handleItemClick,
|
377
390
|
variant: variant,
|
378
391
|
renderItem: renderItem,
|
392
|
+
valueToItemMap: valueToItemMap,
|
379
393
|
treeId: treeId
|
380
394
|
}
|
381
395
|
}, /*#__PURE__*/_react["default"].createElement(_FloatingPopover.FloatingPopover, {
|
@@ -389,7 +403,7 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
389
403
|
listWidth: listWidth,
|
390
404
|
target: function target(referenceRef) {
|
391
405
|
return /*#__PURE__*/_react["default"].createElement(_ui.StyledTextField, _extends({
|
392
|
-
ref: inputForkRef,
|
406
|
+
ref: name ? inputRef : inputForkRef,
|
393
407
|
inputWrapperRef: referenceRef,
|
394
408
|
value: textValue,
|
395
409
|
onChange: handleTextValueChange,
|