@elliemae/ds-controlled-form 2.3.0-alpha.2 → 2.3.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/cjs/controlled-checkbox/propTypes.js +1 -1
  2. package/cjs/controlled-checkbox/propTypes.js.map +2 -2
  3. package/cjs/controlled-combobox/ComboBoxCTX.js +4 -0
  4. package/cjs/controlled-combobox/ComboBoxCTX.js.map +2 -2
  5. package/cjs/controlled-combobox/config/useComboBox.js +6 -0
  6. package/cjs/controlled-combobox/config/useComboBox.js.map +2 -2
  7. package/cjs/controlled-combobox/index.d.js.map +1 -1
  8. package/cjs/controlled-combobox/parts/container/Container.js +3 -3
  9. package/cjs/controlled-combobox/parts/container/Container.js.map +2 -2
  10. package/cjs/controlled-combobox/parts/header-list/HeaderList.js +7 -3
  11. package/cjs/controlled-combobox/parts/header-list/HeaderList.js.map +2 -2
  12. package/cjs/controlled-combobox/propTypes.js +3 -1
  13. package/cjs/controlled-combobox/propTypes.js.map +2 -2
  14. package/cjs/controlled-combobox/utils/hooks/useKeyboardNavigation.js +26 -3
  15. package/cjs/controlled-combobox/utils/hooks/useKeyboardNavigation.js.map +2 -2
  16. package/esm/controlled-checkbox/propTypes.js +1 -1
  17. package/esm/controlled-checkbox/propTypes.js.map +2 -2
  18. package/esm/controlled-combobox/ComboBoxCTX.js +4 -0
  19. package/esm/controlled-combobox/ComboBoxCTX.js.map +2 -2
  20. package/esm/controlled-combobox/config/useComboBox.js +6 -0
  21. package/esm/controlled-combobox/config/useComboBox.js.map +2 -2
  22. package/esm/controlled-combobox/parts/container/Container.js +3 -3
  23. package/esm/controlled-combobox/parts/container/Container.js.map +2 -2
  24. package/esm/controlled-combobox/parts/header-list/HeaderList.js +7 -3
  25. package/esm/controlled-combobox/parts/header-list/HeaderList.js.map +2 -2
  26. package/esm/controlled-combobox/propTypes.js +3 -1
  27. package/esm/controlled-combobox/propTypes.js.map +2 -2
  28. package/esm/controlled-combobox/utils/hooks/useKeyboardNavigation.js +26 -3
  29. package/esm/controlled-combobox/utils/hooks/useKeyboardNavigation.js.map +2 -2
  30. package/package.json +10 -10
  31. package/types/controlled-combobox/ComboBox.d.ts +6 -0
  32. package/types/controlled-combobox/propTypes.d.ts +6 -0
@@ -42,7 +42,7 @@ const propTypes = {
42
42
  disabled: import_react_desc.PropTypes.bool.description("Whether the checkbox is disabled or not."),
43
43
  ariaControls: import_react_desc.PropTypes.string.description("This string is required when you use a mixed checkbox. It contains all the ids that this checkbox is controlling."),
44
44
  ariaLabel: import_react_desc.PropTypes.string.description("Checkbox aria-label property. This property is going to be required if there is no label property added."),
45
- innerRef: import_react_desc.PropTypes.func.description("Checkbox input ref."),
45
+ innerRef: import_react_desc.PropTypes.oneOfType([import_react_desc.PropTypes.func, import_react_desc.PropTypes.object]).description("Checkbox input ref."),
46
46
  autoFocus: import_react_desc.PropTypes.bool.description("Whether you want the checkbox to be autofocused on render")
47
47
  };
48
48
  module.exports = __toCommonJS(propTypes_exports);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/controlled-checkbox/propTypes.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { PropTypes } from 'react-desc';\n\nexport const propTypes = {\n checked: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['mixed'])]).isRequired.description(\n 'Whether the checkbox is invalid or not.',\n ),\n value: PropTypes.string.description('Checkbox value property.'),\n name: PropTypes.string.isRequired.description('Checkbox name property.'),\n label: PropTypes.string.description(\n 'Checkbox Label property. This label is also going to be used as an aria-label for screen readers.',\n ),\n id: PropTypes.string.isRequired.description(\n 'Checkbox unique id property, this property is required for accesibility purposes.',\n ),\n readOnly: PropTypes.bool.description('Checkbox readOnly property.'),\n hasError: PropTypes.bool.description('Whether the checkbox has error or not.'),\n disabled: PropTypes.bool.description('Whether the checkbox is disabled or not.'),\n ariaControls: PropTypes.string.description(\n 'This string is required when you use a mixed checkbox. It contains all the ids that this checkbox is controlling.',\n ),\n ariaLabel: PropTypes.string.description(\n 'Checkbox aria-label property. This property is going to be required if there is no label property added.',\n ),\n innerRef: PropTypes.func.description('Checkbox input ref.'),\n autoFocus: PropTypes.bool.description('Whether you want the checkbox to be autofocused on render'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAEnB,MAAM,YAAY;AAAA,EACvB,SAAS,4BAAU,UAAU,CAAC,4BAAU,MAAM,4BAAU,MAAM,CAAC,YAAY,WAAW,YACpF;AAAA,EAEF,OAAO,4BAAU,OAAO,YAAY;AAAA,EACpC,MAAM,4BAAU,OAAO,WAAW,YAAY;AAAA,EAC9C,OAAO,4BAAU,OAAO,YACtB;AAAA,EAEF,IAAI,4BAAU,OAAO,WAAW,YAC9B;AAAA,EAEF,UAAU,4BAAU,KAAK,YAAY;AAAA,EACrC,UAAU,4BAAU,KAAK,YAAY;AAAA,EACrC,UAAU,4BAAU,KAAK,YAAY;AAAA,EACrC,cAAc,4BAAU,OAAO,YAC7B;AAAA,EAEF,WAAW,4BAAU,OAAO,YAC1B;AAAA,EAEF,UAAU,4BAAU,KAAK,YAAY;AAAA,EACrC,WAAW,4BAAU,KAAK,YAAY;AAAA;",
4
+ "sourcesContent": ["import { PropTypes } from 'react-desc';\n\nexport const propTypes = {\n checked: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['mixed'])]).isRequired.description(\n 'Whether the checkbox is invalid or not.',\n ),\n value: PropTypes.string.description('Checkbox value property.'),\n name: PropTypes.string.isRequired.description('Checkbox name property.'),\n label: PropTypes.string.description(\n 'Checkbox Label property. This label is also going to be used as an aria-label for screen readers.',\n ),\n id: PropTypes.string.isRequired.description(\n 'Checkbox unique id property, this property is required for accesibility purposes.',\n ),\n readOnly: PropTypes.bool.description('Checkbox readOnly property.'),\n hasError: PropTypes.bool.description('Whether the checkbox has error or not.'),\n disabled: PropTypes.bool.description('Whether the checkbox is disabled or not.'),\n ariaControls: PropTypes.string.description(\n 'This string is required when you use a mixed checkbox. It contains all the ids that this checkbox is controlling.',\n ),\n ariaLabel: PropTypes.string.description(\n 'Checkbox aria-label property. This property is going to be required if there is no label property added.',\n ),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Checkbox input ref.'),\n autoFocus: PropTypes.bool.description('Whether you want the checkbox to be autofocused on render'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAEnB,MAAM,YAAY;AAAA,EACvB,SAAS,4BAAU,UAAU,CAAC,4BAAU,MAAM,4BAAU,MAAM,CAAC,YAAY,WAAW,YACpF;AAAA,EAEF,OAAO,4BAAU,OAAO,YAAY;AAAA,EACpC,MAAM,4BAAU,OAAO,WAAW,YAAY;AAAA,EAC9C,OAAO,4BAAU,OAAO,YACtB;AAAA,EAEF,IAAI,4BAAU,OAAO,WAAW,YAC9B;AAAA,EAEF,UAAU,4BAAU,KAAK,YAAY;AAAA,EACrC,UAAU,4BAAU,KAAK,YAAY;AAAA,EACrC,UAAU,4BAAU,KAAK,YAAY;AAAA,EACrC,cAAc,4BAAU,OAAO,YAC7B;AAAA,EAEF,WAAW,4BAAU,OAAO,YAC1B;AAAA,EAEF,UAAU,4BAAU,UAAU,CAAC,4BAAU,MAAM,4BAAU,SAAS,YAAY;AAAA,EAC9E,WAAW,4BAAU,KAAK,YAAY;AAAA;",
6
6
  "names": []
7
7
  }
@@ -47,6 +47,8 @@ const defaultProps = {
47
47
  onSelectAll: import_lodash.noop,
48
48
  onCreate: import_lodash.noop,
49
49
  withToggle: false,
50
+ withoutPortal: true,
51
+ zIndex: 10,
50
52
  onChange: import_lodash.noop,
51
53
  onKeyDown: import_lodash.noop,
52
54
  onFilter: import_lodash.noop,
@@ -67,6 +69,8 @@ const defaultContext = {
67
69
  wrapperListRef: (0, import_react.createRef)(),
68
70
  controlsWrapperRef: (0, import_react.createRef)(),
69
71
  selectedOptionsRef: (0, import_react.createRef)(),
72
+ selectAllCheckboxRef: (0, import_react.createRef)(),
73
+ toggleSelectionButtonRef: (0, import_react.createRef)(),
70
74
  showSelectedValue: false,
71
75
  setShowSelectedValue: import_lodash.noop,
72
76
  focusOptionIdx: "",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/controlled-combobox/ComboBoxCTX.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { createContext, createRef } from 'react';\nimport { noop } from 'lodash';\nimport { ComboBoxPropsT, ComboBoxContextT } from './index.d';\n// eslint-disable-next-line @typescript-eslint/no-empty-function\n\nexport const defaultProps: ComboBoxPropsT = {\n placeholder: '',\n options: [],\n selectedValues: null,\n hasError: false,\n inline: false,\n autoFocus: false,\n startPlacementPreference: 'bottom-start',\n placementOrderPreference: ['bottom-start', 'bottom-end'],\n onClearAll: noop,\n onSelectAll: noop,\n onCreate: noop,\n withToggle: false,\n onChange: noop,\n onKeyDown: noop,\n onFilter: noop,\n onMenuOpen: noop,\n};\nconst defaultContext = {\n props: defaultProps,\n showPopover: false,\n setShowPopover: noop,\n scrollOptionIntoView: noop,\n referenceElement: null,\n hasFocus: false,\n setHasFocus: noop,\n pillGroupRef: createRef<HTMLDivElement>(),\n setReferenceElement: noop,\n inputRef: createRef<HTMLInputElement>(),\n listRef: createRef<HTMLDivElement>(),\n wrapperListRef: createRef<HTMLDivElement>(),\n controlsWrapperRef: createRef<HTMLInputElement>(),\n selectedOptionsRef: createRef<HTMLInputElement>(),\n showSelectedValue: false,\n setShowSelectedValue: noop,\n focusOptionIdx: '',\n setCurrentOption: noop,\n showSelectedOptions: false,\n setShowSelectedOptions: noop,\n};\n/** Context for cross component communication */\nexport const ComboBoxContext = createContext<ComboBoxContextT>(defaultContext);\n\nexport default ComboBoxContext;\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AACzC,oBAAqB;AAId,MAAM,eAA+B;AAAA,EAC1C,aAAa;AAAA,EACb,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,gBAAgB;AAAA,EAC3C,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA;AAEd,MAAM,iBAAiB;AAAA,EACrB,OAAO;AAAA,EACP,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,aAAa;AAAA,EACb,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,UAAU;AAAA,EACV,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,wBAAwB;AAAA;AAGnB,MAAM,kBAAkB,gCAAgC;AAE/D,IAAO,sBAAQ;",
4
+ "sourcesContent": ["import { createContext, createRef } from 'react';\nimport { noop } from 'lodash';\nimport { ComboBoxPropsT, ComboBoxContextT } from './index.d';\n// eslint-disable-next-line @typescript-eslint/no-empty-function\n\nexport const defaultProps: ComboBoxPropsT = {\n placeholder: '',\n options: [],\n selectedValues: null,\n hasError: false,\n inline: false,\n autoFocus: false,\n startPlacementPreference: 'bottom-start',\n placementOrderPreference: ['bottom-start', 'bottom-end'],\n onClearAll: noop,\n onSelectAll: noop,\n onCreate: noop,\n withToggle: false,\n withoutPortal: true,\n zIndex: 10,\n onChange: noop,\n onKeyDown: noop,\n onFilter: noop,\n onMenuOpen: noop,\n};\nconst defaultContext = {\n props: defaultProps,\n showPopover: false,\n setShowPopover: noop,\n scrollOptionIntoView: noop,\n referenceElement: null,\n hasFocus: false,\n setHasFocus: noop,\n pillGroupRef: createRef<HTMLDivElement>(),\n setReferenceElement: noop,\n inputRef: createRef<HTMLInputElement>(),\n listRef: createRef<HTMLDivElement>(),\n wrapperListRef: createRef<HTMLDivElement>(),\n controlsWrapperRef: createRef<HTMLInputElement>(),\n selectedOptionsRef: createRef<HTMLInputElement>(),\n selectAllCheckboxRef: createRef<HTMLInputElement>(),\n toggleSelectionButtonRef: createRef<HTMLButtonElement>(),\n showSelectedValue: false,\n setShowSelectedValue: noop,\n focusOptionIdx: '',\n setCurrentOption: noop,\n showSelectedOptions: false,\n setShowSelectedOptions: noop,\n};\n/** Context for cross component communication */\nexport const ComboBoxContext = createContext<ComboBoxContextT>(defaultContext);\n\nexport default ComboBoxContext;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AACzC,oBAAqB;AAId,MAAM,eAA+B;AAAA,EAC1C,aAAa;AAAA,EACb,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,gBAAgB;AAAA,EAC3C,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA;AAEd,MAAM,iBAAiB;AAAA,EACrB,OAAO;AAAA,EACP,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,aAAa;AAAA,EACb,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,UAAU;AAAA,EACV,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,0BAA0B;AAAA,EAC1B,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,wBAAwB;AAAA;AAGnB,MAAM,kBAAkB,gCAAgC;AAE/D,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
@@ -47,6 +47,8 @@ const useComboBox = (props) => {
47
47
  const wrapperListRef = (0, import_react.useRef)(null);
48
48
  const selectedOptionsRef = (0, import_react.useRef)(null);
49
49
  const controlsWrapperRef = (0, import_react.useRef)(null);
50
+ const selectAllCheckboxRef = (0, import_react.useRef)(null);
51
+ const toggleSelectionButtonRef = (0, import_react.useRef)(null);
50
52
  const pillGroupRef = (0, import_react.useRef)(null);
51
53
  const propsWithDefaults = (0, import_useGetPropsWithDefault.useGetComboBoxWithDefaultsProps)(props);
52
54
  const { options, selectedValues, onCreate } = propsWithDefaults;
@@ -106,6 +108,8 @@ const useComboBox = (props) => {
106
108
  focusOptionIdx,
107
109
  selectedOptionsRef,
108
110
  controlsWrapperRef,
111
+ selectAllCheckboxRef,
112
+ toggleSelectionButtonRef,
109
113
  hasFocus,
110
114
  pillGroupRef,
111
115
  showSelectedOptions,
@@ -132,6 +136,8 @@ const useComboBox = (props) => {
132
136
  inputRef,
133
137
  selectedOptionsRef,
134
138
  controlsWrapperRef,
139
+ selectAllCheckboxRef,
140
+ toggleSelectionButtonRef,
135
141
  hasFocus,
136
142
  listRef
137
143
  ]);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/controlled-combobox/config/useComboBox.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useMemo, useState, useRef, useCallback } from 'react';\nimport { noop } from 'lodash';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { useVirtual } from 'react-virtual';\nimport { useGetComboBoxWithDefaultsProps } from './useGetPropsWithDefault';\nimport type { ComboBoxPropsT, ComboBoxContextT, CBOptionT, CBItemCreatableOption } from '../index.d';\n\nexport const useComboBox = (props: Partial<ComboBoxPropsT>): ComboBoxContextT => {\n const [showPopover, setShowPopover] = useState<boolean>(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n const [showSelectedValue, setShowSelectedValue] = useState<boolean>(false);\n const [showSelectedOptions, setShowSelectedOptions] = useState<boolean>(false);\n\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n const [focusOptionIdx, setCurrentOption] = useState<string>('');\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const wrapperListRef = useRef<HTMLDivElement>(null);\n\n const selectedOptionsRef = useRef<HTMLDivElement>(null);\n const controlsWrapperRef = useRef<HTMLDivElement>(null);\n const pillGroupRef = useRef<HTMLDivElement>(null);\n\n const propsWithDefaults = useGetComboBoxWithDefaultsProps(props);\n const { options, selectedValues, onCreate } = propsWithDefaults;\n\n // ---------------------------------------------------------------------------\n // Menu Options with/out selected filter\n // ---------------------------------------------------------------------------\n\n const selectedValuesWithSections = useCallback(() => {\n const multiSelectedValue = selectedValues as CBOptionT[];\n const items = [] as CBOptionT[];\n\n options.forEach((option) => {\n const isSelectedValue = multiSelectedValue.find((item) => item.dsId === option.dsId);\n if (isSelectedValue) {\n items.push(option);\n }\n\n if (option.type === 'section') {\n if (items[items.length - 1]?.type === 'section') {\n items[items.length - 1] = option;\n } else {\n items.push(option);\n }\n }\n });\n if (items[items.length - 1]?.type === 'section') {\n items.pop();\n }\n\n return items;\n }, [options, selectedValues]);\n\n const correctOptions = useMemo(() => {\n if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {\n return selectedValuesWithSections();\n }\n if (onCreate !== noop && inputRef.current && inputRef.current.value !== '') {\n const creatableUuid = uuidv4() as string;\n const creatableItem: CBItemCreatableOption = {\n dsId: `creatable-${creatableUuid}`,\n label: inputRef.current?.value,\n type: 'creatable',\n };\n return [creatableItem, ...options];\n }\n return options;\n }, [options, onCreate, selectedValuesWithSections, selectedValues, showSelectedOptions]);\n\n // ===========================================================================\n // Virtualization setup\n // ===========================================================================\n\n const virtualListHelpers: ReturnType<typeof useVirtual> = useVirtual({\n size: correctOptions.length,\n parentRef: listRef,\n overscan: 15,\n paddingStart: 0,\n });\n\n // ===========================================================================\n // Scroll into view function\n // ===========================================================================\n const scrollOptionIntoView = useCallback(\n (dsId: string, opts = { align: 'center' }) => {\n virtualListHelpers.scrollToIndex(\n correctOptions.findIndex((opt) => opt.dsId === dsId),\n opts,\n );\n },\n [correctOptions, virtualListHelpers],\n );\n\n const ctx = useMemo(\n () => ({\n props: { ...propsWithDefaults, options: correctOptions },\n virtualListHelpers,\n showPopover,\n referenceElement,\n inputRef,\n showSelectedValue,\n listRef,\n focusOptionIdx,\n selectedOptionsRef,\n controlsWrapperRef,\n hasFocus,\n pillGroupRef,\n showSelectedOptions,\n wrapperListRef,\n setShowSelectedOptions,\n setHasFocus,\n setCurrentOption,\n scrollOptionIntoView,\n setShowSelectedValue,\n setReferenceElement,\n setShowPopover,\n }),\n [\n scrollOptionIntoView,\n correctOptions,\n propsWithDefaults,\n virtualListHelpers,\n focusOptionIdx,\n showSelectedValue,\n wrapperListRef,\n showSelectedOptions,\n showPopover,\n pillGroupRef,\n referenceElement,\n inputRef,\n selectedOptionsRef,\n controlsWrapperRef,\n hasFocus,\n listR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M,iBAAiB,0BAAQ,MAAM;AACnC,QAAI,uBAAuB,MAAM,QAAQ,mBAAmB,eAAe,SAAS,GAAG;AACrF,aAAO;AAAA;AAET,QAAI,aAAa,sBAAQ,SAAS,WAAW,SAAS,QAAQ,UAAU,IAAI;AAC1E,YAAM,gBAAgB;AACtB,YAAM,gBAAuC;AAAA,QAC3C,MAAM,aAAa;AAAA,QACnB,OAAO,SAAS,SAAS;AAAA,QACzB,MAAM;AAAA;AAER,aAAO,CAAC,eAAe,GAAG;AAAA;AAE5B,WAAO;AAAA,KACN,CAAC,SAAS,UAAU,4BAA4B,gBAAgB;AAMnE,QAAM,qBAAoD,qCAAW;AAAA,IACnE,MAAM,eAAe;AAAA,IACrB,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA;AAMhB,QAAM,uBAAuB,8BAC3B,CAAC,MAAc,OAAO,EAAE,OAAO,eAAe;AAC5C,uBAAmB,cACjB,eAAe,UAAU,CAAC,QAAQ,IAAI,SAAS,OAC/C;AAAA,KAGJ,CAAC,gBAAgB;AAGnB,QAAM,MAAM,0BACV,MAAO;AAAA,IACL,OAAO,KAAK,mBAAmB,SAAS;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAEF;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAIJ,SAAO;AAAA;",
4
+ "sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useMemo, useState, useRef, useCallback } from 'react';\nimport { noop } from 'lodash';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { useVirtual } from 'react-virtual';\nimport { useGetComboBoxWithDefaultsProps } from './useGetPropsWithDefault';\nimport type { ComboBoxPropsT, ComboBoxContextT, CBOptionT, CBItemCreatableOption } from '../index.d';\n\nexport const useComboBox = (props: Partial<ComboBoxPropsT>): ComboBoxContextT => {\n const [showPopover, setShowPopover] = useState<boolean>(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n const [showSelectedValue, setShowSelectedValue] = useState<boolean>(false);\n const [showSelectedOptions, setShowSelectedOptions] = useState<boolean>(false);\n\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n const [focusOptionIdx, setCurrentOption] = useState<string>('');\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const wrapperListRef = useRef<HTMLDivElement>(null);\n\n const selectedOptionsRef = useRef<HTMLDivElement>(null);\n const controlsWrapperRef = useRef<HTMLDivElement>(null);\n const selectAllCheckboxRef = useRef<HTMLInputElement>(null);\n const toggleSelectionButtonRef = useRef<HTMLButtonElement>(null);\n const pillGroupRef = useRef<HTMLDivElement>(null);\n\n const propsWithDefaults = useGetComboBoxWithDefaultsProps(props);\n const { options, selectedValues, onCreate } = propsWithDefaults;\n\n // ---------------------------------------------------------------------------\n // Menu Options with/out selected filter\n // ---------------------------------------------------------------------------\n\n const selectedValuesWithSections = useCallback(() => {\n const multiSelectedValue = selectedValues as CBOptionT[];\n const items = [] as CBOptionT[];\n\n options.forEach((option) => {\n const isSelectedValue = multiSelectedValue.find((item) => item.dsId === option.dsId);\n if (isSelectedValue) {\n items.push(option);\n }\n\n if (option.type === 'section') {\n if (items[items.length - 1]?.type === 'section') {\n items[items.length - 1] = option;\n } else {\n items.push(option);\n }\n }\n });\n if (items[items.length - 1]?.type === 'section') {\n items.pop();\n }\n\n return items;\n }, [options, selectedValues]);\n\n const correctOptions = useMemo(() => {\n if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {\n return selectedValuesWithSections();\n }\n if (onCreate !== noop && inputRef.current && inputRef.current.value !== '') {\n const creatableUuid = uuidv4();\n const creatableItem: CBItemCreatableOption = {\n dsId: `creatable-${creatableUuid}`,\n label: inputRef.current?.value,\n type: 'creatable',\n };\n return [creatableItem, ...options];\n }\n return options;\n }, [options, onCreate, selectedValuesWithSections, selectedValues, showSelectedOptions]);\n\n // ===========================================================================\n // Virtualization setup\n // ===========================================================================\n\n const virtualListHelpers: ReturnType<typeof useVirtual> = useVirtual({\n size: correctOptions.length,\n parentRef: listRef,\n overscan: 15,\n paddingStart: 0,\n });\n\n // ===========================================================================\n // Scroll into view function\n // ===========================================================================\n const scrollOptionIntoView = useCallback(\n (dsId: string, opts = { align: 'center' }) => {\n virtualListHelpers.scrollToIndex(\n correctOptions.findIndex((opt) => opt.dsId === dsId),\n opts,\n );\n },\n [correctOptions, virtualListHelpers],\n );\n\n const ctx = useMemo(\n () => ({\n props: { ...propsWithDefaults, options: correctOptions },\n virtualListHelpers,\n showPopover,\n referenceElement,\n inputRef,\n showSelectedValue,\n listRef,\n focusOptionIdx,\n selectedOptionsRef,\n controlsWrapperRef,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n hasFocus,\n pillGroupRef,\n showSelectedOptions,\n wrapperListRef,\n setShowSelectedOptions,\n setHasFocus,\n setCurrentOption,\n scrollOptionIntoView,\n setShowSelectedValue,\n setReferenceElement,\n setShowPopover,\n }),\n [\n scrollOptionIntoView,\n correctOptions,\n propsWithDefaults,\n virtualListHelpers,\n focusOptionIdx,\n showSelectedValue,\n wrapperListRef,\n showSelectedOptions,\n showPopover,\n pillGroupRef,\n referenceElement,\n inputRef,\n selectedOptionsRef,\n controlsWrapperRef,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n hasFocus,\n listRef,\n ],\n );\n\n return ctx;\n};\n", "import * as React from 'react';\nexport { React };\n"],
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,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/controlled-combobox/index.d.ts", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { LayoutProps } from 'styled-system';\n\ninterface CommonCBItemOptions {\n dsId: string;\n render?: React.ComponentType<unknown>;\n}\nexport interface CBItemSeparatorOptions extends CommonCBItemOptions {\n type: 'separator';\n}\n\nexport interface CBItemSectionOptions extends CommonCBItemOptions {\n type: 'section';\n label: string;\n}\n\nexport interface CBItemOption extends CommonCBItemOptions {\n value: unknown;\n label: string;\n type: 'option';\n disabled?: boolean;\n}\n\nexport interface CBItemCreatableOption {\n dsId: string;\n label: string;\n type: 'creatable';\n}\n\nexport type CBOptionT = CBItemOption | CBItemSectionOptions | CBItemSeparatorOptions | CBItemCreatableOption;\n\nexport type CBSelectedOptionsT = CBItemOption[] | CBItemOption | null;\n\nexport interface ComboBoxPropsT {\n placeholder?: string;\n options: CBOptionT[];\n selectedValues: CBSelectedOptionsT;\n hasError?: boolean;\n inline?: boolean;\n autoFocus?: boolean;\n startPlacementPreference: string;\n placementOrderPreference: string[];\n inputMinWidth?: number;\n menuMinWidth?: number;\n menuMaxHeight?: number;\n onKeyDown: (e: KeyboardEvent<Element>, value: CBOptionT | undefined) => void;\n onChange: (value: CBItemValue) => void;\n onSelectAll: () => void;\n onClearAll: () => void;\n onFilter: (value: string) => void;\n onCreate: (label: string) => void;\n onMenuOpen?: () => void;\n onCancel?: () => void;\n}\n\nexport interface ComboBoxContextT {\n props: ComboBoxPropsT;\n virtualListHelpers?: ReturnType<typeof useVirtual>;\n showPopover: boolean;\n setShowPopover: React.Dispatch<React.SetStateAction<boolean>>;\n referenceElement: HTMLElement | null;\n setReferenceElement: React.Dispatch<React.SetStateAction<HTMLElement | null>>;\n hasFocus: boolean;\n pillGroupRef: React.RefObject<HTMLDivElement>;\n scrollOptionIntoView: (dsId: string, opts?: any) => void;\n setHasFocus: React.Dispatch<React.SetStateAction<boolean>>;\n inputRef: React.RefObject<HTMLInputElement>;\n listRef: React.RefObject<HTMLDivElement>;\n wrapperListRef: React.RefObject<HTMLDivElement>;\n selectedOptionsRef: React.RefObject<HTMLDivElement>;\n controlsWrapperRef: React.RefObject<HTMLDivElement>;\n showSelectedValue: boolean;\n setShowSelectedValue: React.Dispatch<React.SetStateAction<boolean>>;\n focusOptionIdx: string;\n setCurrentOption: React.Dispatch<React.SetStateAction<string>>;\n showSelectedOptions: boolean;\n setShowSelectedOptions: React.Dispatch<React.SetStateAction<boolean>>;\n}\n", "import * as React from 'react';\nexport { React };\n"],
4
+ "sourcesContent": ["import React from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { LayoutProps } from 'styled-system';\n\ninterface CommonCBItemOptions {\n dsId: string;\n render?: React.ComponentType<unknown>;\n}\nexport interface CBItemSeparatorOptions extends CommonCBItemOptions {\n type: 'separator';\n}\n\nexport interface CBItemSectionOptions extends CommonCBItemOptions {\n type: 'section';\n label: string;\n}\n\nexport interface CBItemOption extends CommonCBItemOptions {\n value: unknown;\n label: string;\n type: 'option';\n disabled?: boolean;\n}\n\nexport interface CBItemCreatableOption {\n dsId: string;\n label: string;\n type: 'creatable';\n}\n\nexport type CBOptionT = CBItemOption | CBItemSectionOptions | CBItemSeparatorOptions | CBItemCreatableOption;\n\nexport type CBSelectedOptionsT = CBItemOption[] | CBItemOption | null;\n\nexport interface ComboBoxPropsT {\n placeholder?: string;\n options: CBOptionT[];\n selectedValues: CBSelectedOptionsT;\n hasError?: boolean;\n inline?: boolean;\n autoFocus?: boolean;\n startPlacementPreference: string;\n placementOrderPreference: string[];\n withToggle?: boolean;\n withoutPortal?: boolean;\n zIndex?: number;\n inputMinWidth?: number;\n menuMinWidth?: number;\n menuMaxHeight?: number;\n onKeyDown: (e: KeyboardEvent<Element>, value: CBOptionT | undefined) => void;\n onChange: (value: CBItemValue) => void;\n onSelectAll: () => void;\n onClearAll: () => void;\n onFilter: (value: string) => void;\n onCreate: (label: string) => void;\n onMenuOpen?: () => void;\n onCancel?: () => void;\n}\n\nexport interface ComboBoxContextT {\n props: ComboBoxPropsT;\n virtualListHelpers?: ReturnType<typeof useVirtual>;\n showPopover: boolean;\n setShowPopover: React.Dispatch<React.SetStateAction<boolean>>;\n referenceElement: HTMLElement | null;\n setReferenceElement: React.Dispatch<React.SetStateAction<HTMLElement | null>>;\n hasFocus: boolean;\n pillGroupRef: React.RefObject<HTMLDivElement>;\n scrollOptionIntoView: (dsId: string, opts?: any) => void;\n setHasFocus: React.Dispatch<React.SetStateAction<boolean>>;\n inputRef: React.RefObject<HTMLInputElement>;\n listRef: React.RefObject<HTMLDivElement>;\n wrapperListRef: React.RefObject<HTMLDivElement>;\n selectedOptionsRef: React.RefObject<HTMLDivElement>;\n controlsWrapperRef: React.RefObject<HTMLDivElement>;\n selectAllCheckboxRef: React.RefObject<HTMLInputElement>;\n toggleSelectionButtonRef: React.RefObject<HTMLButtonElement>;\n showSelectedValue: boolean;\n setShowSelectedValue: React.Dispatch<React.SetStateAction<boolean>>;\n focusOptionIdx: string;\n setCurrentOption: React.Dispatch<React.SetStateAction<string>>;\n showSelectedOptions: boolean;\n setShowSelectedOptions: React.Dispatch<React.SetStateAction<boolean>>;\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;",
6
6
  "names": []
7
7
  }
@@ -38,7 +38,7 @@ var import_controls = require("../controls");
38
38
  var import_menu_list = require("../menu-list");
39
39
  const Container = () => {
40
40
  const {
41
- props: { inline, startPlacementPreference, placementOrderPreference },
41
+ props: { inline, startPlacementPreference, placementOrderPreference, withoutPortal, zIndex },
42
42
  showPopover,
43
43
  inputRef,
44
44
  setReferenceElement,
@@ -67,10 +67,10 @@ const Container = () => {
67
67
  showPopover,
68
68
  startPlacementPreference,
69
69
  placementOrderPreference,
70
- withoutPortal: true,
70
+ withoutPortal,
71
71
  withoutArrow: true,
72
72
  withoutAnimation: true,
73
- zIndex: 10
73
+ zIndex
74
74
  }, /* @__PURE__ */ import_react.default.createElement(import_styled.StyledPopperWrapper, {
75
75
  tabIndex: -1,
76
76
  onMouseDown: handleMouseDown
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/controlled-combobox/parts/container/Container.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable complexity */\nimport React, { useCallback, useContext } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport { StyledContainerWithPopper, StyledContainerInline, StyledPopperWrapper } from './styled';\nimport { Controls } from '../controls';\nimport { MenuList } from '../menu-list';\nconst Container = (): JSX.Element => {\n const {\n props: { inline, startPlacementPreference, placementOrderPreference },\n showPopover,\n inputRef,\n setReferenceElement,\n setShowPopover,\n referenceElement,\n } = useContext(ComboBoxContext);\n\n const handleCloseMenu = useCallback(() => {\n setShowPopover(false);\n if (inputRef.current) inputRef.current.blur();\n }, [inputRef, setShowPopover]);\n\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n }, []);\n\n const handleOnClickContainer = useCallback(() => {\n setShowPopover(!showPopover);\n }, [setShowPopover, showPopover]);\n\n const StyledContainer = inline ? StyledContainerInline : StyledContainerWithPopper;\n return (\n <>\n <StyledContainer ref={setReferenceElement} onClick={handleOnClickContainer}>\n <Controls />\n {inline ? <MenuList /> : null}\n </StyledContainer>\n {!inline ? (\n <DSPopperJS\n customOffset={[0, 5]}\n closeContextMenu={handleCloseMenu}\n referenceElement={referenceElement}\n showPopover={showPopover}\n startPlacementPreference={startPlacementPreference}\n placementOrderPreference={placementOrderPreference}\n withoutPortal\n withoutArrow\n withoutAnimation\n zIndex={10}\n >\n <StyledPopperWrapper tabIndex={-1} onMouseDown={handleMouseDown}>\n <MenuList />\n </StyledPopperWrapper>\n </DSPopperJS>\n ) : null}\n </>\n );\n};\n\nexport { Container };\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAA+C;AAC/C,yBAA2B;AAC3B,yBAAgC;AAChC,oBAAsF;AACtF,sBAAyB;AACzB,uBAAyB;AACzB,MAAM,YAAY,MAAmB;AACnC,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ,0BAA0B;AAAA,IAC3C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,6BAAW;AAEf,QAAM,kBAAkB,8BAAY,MAAM;AACxC,mBAAe;AACf,QAAI,SAAS;AAAS,eAAS,QAAQ;AAAA,KACtC,CAAC,UAAU;AAEd,QAAM,kBAAkB,8BAAY,CAAC,MAAwB;AAC3D,MAAE;AAAA,KACD;AAEH,QAAM,yBAAyB,8BAAY,MAAM;AAC/C,mBAAe,CAAC;AAAA,KACf,CAAC,gBAAgB;AAEpB,QAAM,kBAAkB,SAAS,sCAAwB;AACzD,SACE,wFACE,mDAAC,iBAAD;AAAA,IAAiB,KAAK;AAAA,IAAqB,SAAS;AAAA,KAClD,mDAAC,0BAAD,OACC,SAAS,mDAAC,2BAAD,QAAe,OAE1B,CAAC,SACA,mDAAC,+BAAD;AAAA,IACE,cAAc,CAAC,GAAG;AAAA,IAClB,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAa;AAAA,IACb,cAAY;AAAA,IACZ,kBAAgB;AAAA,IAChB,QAAQ;AAAA,KAER,mDAAC,mCAAD;AAAA,IAAqB,UAAU;AAAA,IAAI,aAAa;AAAA,KAC9C,mDAAC,2BAAD,UAGF;AAAA;",
4
+ "sourcesContent": ["/* eslint-disable complexity */\nimport React, { useCallback, useContext } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport { StyledContainerWithPopper, StyledContainerInline, StyledPopperWrapper } from './styled';\nimport { Controls } from '../controls';\nimport { MenuList } from '../menu-list';\nconst Container = (): JSX.Element => {\n const {\n props: { inline, startPlacementPreference, placementOrderPreference, withoutPortal, zIndex },\n showPopover,\n inputRef,\n setReferenceElement,\n setShowPopover,\n referenceElement,\n } = useContext(ComboBoxContext);\n\n const handleCloseMenu = useCallback(() => {\n setShowPopover(false);\n if (inputRef.current) inputRef.current.blur();\n }, [inputRef, setShowPopover]);\n\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n }, []);\n\n const handleOnClickContainer = useCallback(() => {\n setShowPopover(!showPopover);\n }, [setShowPopover, showPopover]);\n\n const StyledContainer = inline ? StyledContainerInline : StyledContainerWithPopper;\n return (\n <>\n <StyledContainer ref={setReferenceElement} onClick={handleOnClickContainer}>\n <Controls />\n {inline ? <MenuList /> : null}\n </StyledContainer>\n {!inline ? (\n <DSPopperJS\n customOffset={[0, 5]}\n closeContextMenu={handleCloseMenu}\n referenceElement={referenceElement}\n showPopover={showPopover}\n startPlacementPreference={startPlacementPreference}\n placementOrderPreference={placementOrderPreference}\n withoutPortal={withoutPortal}\n withoutArrow\n withoutAnimation\n zIndex={zIndex}\n >\n <StyledPopperWrapper tabIndex={-1} onMouseDown={handleMouseDown}>\n <MenuList />\n </StyledPopperWrapper>\n </DSPopperJS>\n ) : null}\n </>\n );\n};\n\nexport { Container };\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAA+C;AAC/C,yBAA2B;AAC3B,yBAAgC;AAChC,oBAAsF;AACtF,sBAAyB;AACzB,uBAAyB;AACzB,MAAM,YAAY,MAAmB;AACnC,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ,0BAA0B,0BAA0B,eAAe;AAAA,IACpF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,6BAAW;AAEf,QAAM,kBAAkB,8BAAY,MAAM;AACxC,mBAAe;AACf,QAAI,SAAS;AAAS,eAAS,QAAQ;AAAA,KACtC,CAAC,UAAU;AAEd,QAAM,kBAAkB,8BAAY,CAAC,MAAwB;AAC3D,MAAE;AAAA,KACD;AAEH,QAAM,yBAAyB,8BAAY,MAAM;AAC/C,mBAAe,CAAC;AAAA,KACf,CAAC,gBAAgB;AAEpB,QAAM,kBAAkB,SAAS,sCAAwB;AACzD,SACE,wFACE,mDAAC,iBAAD;AAAA,IAAiB,KAAK;AAAA,IAAqB,SAAS;AAAA,KAClD,mDAAC,0BAAD,OACC,SAAS,mDAAC,2BAAD,QAAe,OAE1B,CAAC,SACA,mDAAC,+BAAD;AAAA,IACE,cAAc,CAAC,GAAG;AAAA,IAClB,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAY;AAAA,IACZ,kBAAgB;AAAA,IAChB;AAAA,KAEA,mDAAC,mCAAD;AAAA,IAAqB,UAAU;AAAA,IAAI,aAAa;AAAA,KAC9C,mDAAC,2BAAD,UAGF;AAAA;",
6
6
  "names": []
7
7
  }
@@ -41,7 +41,9 @@ const HeaderList = () => {
41
41
  const {
42
42
  props: { onSelectAll, onClearAll, selectedValues },
43
43
  showSelectedOptions,
44
- inputRef
44
+ inputRef,
45
+ selectAllCheckboxRef,
46
+ toggleSelectionButtonRef
45
47
  } = (0, import_react.useContext)(import_ComboBoxCTX.ComboBoxContext);
46
48
  const isSelectAllSupplied = onSelectAll !== import_lodash.noop;
47
49
  const isClearAllSupplied = onClearAll !== import_lodash.noop;
@@ -62,7 +64,8 @@ const HeaderList = () => {
62
64
  if (multiSelectedValues.length === 0) {
63
65
  setTimeout(() => inputRef.current?.focus());
64
66
  }
65
- }
67
+ },
68
+ innerRef: selectAllCheckboxRef
66
69
  })), /* @__PURE__ */ import_react.default.createElement(import_styled.StyledSelectedItems, null, multiSelectedValues.length > 0 ? /* @__PURE__ */ import_react.default.createElement(import_styled.StyledButtonSelection, {
67
70
  onBlur: () => {
68
71
  setTimeout(() => inputRef.current?.focus());
@@ -71,7 +74,8 @@ const HeaderList = () => {
71
74
  onClick: handleToggle,
72
75
  labelText: !showSelectedOptions ? `SHOW SELECTED [${multiSelectedValues.length}]` : "SHOW ALL",
73
76
  size: "s",
74
- "data-testid": import_ComboboxDataTestids.ComboboxDataTestid.SHOW_SELECTED_OPTIONS_TOGGLE
77
+ "data-testid": import_ComboboxDataTestids.ComboboxDataTestid.SHOW_SELECTED_OPTIONS_TOGGLE,
78
+ innerRef: toggleSelectionButtonRef
75
79
  }) : /* @__PURE__ */ import_react.default.createElement(import_styled.StyledNoOptionsSelected, null, "0 SELECTED")));
76
80
  };
77
81
  module.exports = __toCommonJS(HeaderList_exports);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/controlled-combobox/parts/header-list/HeaderList.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport React, { useContext } from 'react';\nimport { noop } from 'lodash';\nimport { DSControlledCheckbox } from '@elliemae/ds-controlled-form';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport {\n StyledHeaderListWrapper,\n StyledButtonSelection,\n StyledSelectedItems,\n StyledSelectAllCheckbox,\n StyledNoOptionsSelected,\n} from './styled';\nimport { CBItemOption } from '../../index.d';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport { useHeaderListHandlers } from './useHeaderListHandlers';\nconst HeaderList = (): JSX.Element => {\n const {\n props: { onSelectAll, onClearAll, selectedValues },\n showSelectedOptions,\n inputRef,\n } = useContext(ComboBoxContext);\n\n const isSelectAllSupplied = onSelectAll !== noop;\n const isClearAllSupplied = onClearAll !== noop;\n\n const multiSelectedValues = selectedValues as CBItemOption[];\n const { handleKeyDown, handleOnMouseDown, handleToggle, checkboxStatus, handleSelectAllCheckboxChange } =\n useHeaderListHandlers();\n\n return (\n <StyledHeaderListWrapper onKeyDown={handleKeyDown} onMouseDown={handleOnMouseDown}>\n <StyledSelectAllCheckbox>\n {isSelectAllSupplied && isClearAllSupplied && (\n <DSControlledCheckbox\n checked={checkboxStatus}\n ariaControls={checkboxStatus === 'mixed' ? multiSelectedValues.map((item) => item.dsId).join(' ') : ''}\n name=\"select-all-checkbox\"\n ariaLabel=\"Select/Unselect All Items\"\n id=\"select-all-checkbox\"\n onChange={handleSelectAllCheckboxChange}\n data-testid={ComboboxDataTestid.SELECT_ALL_CHECKBOX}\n onBlur={() => {\n if (multiSelectedValues.length === 0) {\n setTimeout(() => inputRef.current?.focus());\n }\n }}\n />\n )}\n </StyledSelectAllCheckbox>\n <StyledSelectedItems>\n {multiSelectedValues.length > 0 ? (\n <StyledButtonSelection\n onBlur={() => {\n setTimeout(() => inputRef.current?.focus());\n }}\n buttonType=\"text\"\n onClick={handleToggle}\n labelText={!showSelectedOptions ? `SHOW SELECTED [${multiSelectedValues.length}]` : 'SHOW ALL'}\n size=\"s\"\n data-testid={ComboboxDataTestid.SHOW_SELECTED_OPTIONS_TOGGLE}\n />\n ) : (\n <StyledNoOptionsSelected>0 SELECTED</StyledNoOptionsSelected>\n )}\n </StyledSelectedItems>\n </StyledHeaderListWrapper>\n );\n};\n\nexport { HeaderList };\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAAkC;AAClC,oBAAqB;AACrB,gCAAqC;AACrC,yBAAgC;AAChC,oBAMO;AAEP,iCAAmC;AACnC,mCAAsC;AACtC,MAAM,aAAa,MAAmB;AACpC,QAAM;AAAA,IACJ,OAAO,EAAE,aAAa,YAAY;AAAA,IAClC;AAAA,IACA;AAAA,MACE,6BAAW;AAEf,QAAM,sBAAsB,gBAAgB;AAC5C,QAAM,qBAAqB,eAAe;AAE1C,QAAM,sBAAsB;AAC5B,QAAM,EAAE,eAAe,mBAAmB,cAAc,gBAAgB,kCACtE;AAEF,SACE,mDAAC,uCAAD;AAAA,IAAyB,WAAW;AAAA,IAAe,aAAa;AAAA,KAC9D,mDAAC,uCAAD,MACG,uBAAuB,sBACtB,mDAAC,gDAAD;AAAA,IACE,SAAS;AAAA,IACT,cAAc,mBAAmB,UAAU,oBAAoB,IAAI,CAAC,SAAS,KAAK,MAAM,KAAK,OAAO;AAAA,IACpG,MAAK;AAAA,IACL,WAAU;AAAA,IACV,IAAG;AAAA,IACH,UAAU;AAAA,IACV,eAAa,8CAAmB;AAAA,IAChC,QAAQ,MAAM;AACZ,UAAI,oBAAoB,WAAW,GAAG;AACpC,mBAAW,MAAM,SAAS,SAAS;AAAA;AAAA;AAAA,OAM7C,mDAAC,mCAAD,MACG,oBAAoB,SAAS,IAC5B,mDAAC,qCAAD;AAAA,IACE,QAAQ,MAAM;AACZ,iBAAW,MAAM,SAAS,SAAS;AAAA;AAAA,IAErC,YAAW;AAAA,IACX,SAAS;AAAA,IACT,WAAW,CAAC,sBAAsB,kBAAkB,oBAAoB,YAAY;AAAA,IACpF,MAAK;AAAA,IACL,eAAa,8CAAmB;AAAA,OAGlC,mDAAC,uCAAD,MAAyB;AAAA;",
4
+ "sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport React, { useContext } from 'react';\nimport { noop } from 'lodash';\nimport { DSControlledCheckbox } from '@elliemae/ds-controlled-form';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport {\n StyledHeaderListWrapper,\n StyledButtonSelection,\n StyledSelectedItems,\n StyledSelectAllCheckbox,\n StyledNoOptionsSelected,\n} from './styled';\nimport { CBItemOption } from '../../index.d';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport { useHeaderListHandlers } from './useHeaderListHandlers';\nconst HeaderList = (): JSX.Element => {\n const {\n props: { onSelectAll, onClearAll, selectedValues },\n showSelectedOptions,\n inputRef,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n } = useContext(ComboBoxContext);\n\n const isSelectAllSupplied = onSelectAll !== noop;\n const isClearAllSupplied = onClearAll !== noop;\n\n const multiSelectedValues = selectedValues as CBItemOption[];\n const { handleKeyDown, handleOnMouseDown, handleToggle, checkboxStatus, handleSelectAllCheckboxChange } =\n useHeaderListHandlers();\n\n return (\n <StyledHeaderListWrapper onKeyDown={handleKeyDown} onMouseDown={handleOnMouseDown}>\n <StyledSelectAllCheckbox>\n {isSelectAllSupplied && isClearAllSupplied && (\n <DSControlledCheckbox\n checked={checkboxStatus}\n ariaControls={checkboxStatus === 'mixed' ? multiSelectedValues.map((item) => item.dsId).join(' ') : ''}\n name=\"select-all-checkbox\"\n ariaLabel=\"Select/Unselect All Items\"\n id=\"select-all-checkbox\"\n onChange={handleSelectAllCheckboxChange}\n data-testid={ComboboxDataTestid.SELECT_ALL_CHECKBOX}\n onBlur={() => {\n if (multiSelectedValues.length === 0) {\n setTimeout(() => inputRef.current?.focus());\n }\n }}\n innerRef={selectAllCheckboxRef}\n />\n )}\n </StyledSelectAllCheckbox>\n <StyledSelectedItems>\n {multiSelectedValues.length > 0 ? (\n <StyledButtonSelection\n onBlur={() => {\n setTimeout(() => inputRef.current?.focus());\n }}\n buttonType=\"text\"\n onClick={handleToggle}\n labelText={!showSelectedOptions ? `SHOW SELECTED [${multiSelectedValues.length}]` : 'SHOW ALL'}\n size=\"s\"\n data-testid={ComboboxDataTestid.SHOW_SELECTED_OPTIONS_TOGGLE}\n innerRef={toggleSelectionButtonRef}\n />\n ) : (\n <StyledNoOptionsSelected>0 SELECTED</StyledNoOptionsSelected>\n )}\n </StyledSelectedItems>\n </StyledHeaderListWrapper>\n );\n};\n\nexport { HeaderList };\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;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putMinWidth: import_react_desc.PropTypes.any.description("Minimum width for the combo box input controller").defaultValue(void 0),
48
48
  menuMinWidth: import_react_desc.PropTypes.any.description("Minimum width for the dropdown menu").defaultValue(void 0),
49
49
  menuMaxHeight: import_react_desc.PropTypes.any.description("Maximum height for the dropdown menu").defaultValue(void 0),
50
- withToggle: import_react_desc.PropTypes.bool.description("POC purpose this prop will not remain").defaultValue("false")
50
+ withToggle: import_react_desc.PropTypes.bool.description("POC purpose this prop will not remain").defaultValue("false"),
51
+ withoutPortal: import_react_desc.PropTypes.bool.description("Whether the combobox menu is rendered in a portal or not").defaultValue(false),
52
+ zIndex: import_react_desc.PropTypes.number.description("The z-index of the combobox menu").defaultValue(10)
51
53
  };
52
54
  module.exports = __toCommonJS(propTypes_exports);
53
55
  //# sourceMappingURL=propTypes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/controlled-combobox/propTypes.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { PropTypes } from 'react-desc';\n\nexport const propTypes = {\n placeholder: PropTypes.string.description('input s placeholder value').defaultValue(''),\n options: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).description('List of options').defaultValue([]),\n selectedValues: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]).description(\n 'Array of option or single option selected',\n ),\n autoFocus: PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),\n hasError: PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),\n onChange: PropTypes.func\n .description('function triggered when an option is selected it will send the options selected')\n .defaultValue(''),\n onSelectAll: PropTypes.func\n .description('function triggered when ALL button is selected from the header menu list')\n .defaultValue(''),\n onFilter: PropTypes.func.description('function triggered when user type in the combobox input').defaultValue(''),\n onCreate: PropTypes.func\n .description(\n 'function triggered when user select \"create\" a new item whenever is not a match in the all option list',\n )\n .defaultValue(''),\n onClearAll: PropTypes.func\n .description('function triggered when user select CLEAR button from the header menu list')\n .defaultValue(''),\n onCancel: PropTypes.func.description('function triggered when user press ESC key').defaultValue(''),\n onMenuOpen: PropTypes.func.description('function triggered when user open the menu list').defaultValue(''),\n inputMinWidth: PropTypes.any.description('Minimum width for the combo box input controller').defaultValue(undefined),\n menuMinWidth: PropTypes.any.description('Minimum width for the dropdown menu').defaultValue(undefined),\n menuMaxHeight: PropTypes.any.description('Maximum height for the dropdown menu').defaultValue(undefined),\n withToggle: PropTypes.bool.description('POC purpose this prop will not remain').defaultValue('false'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAEnB,MAAM,YAAY;AAAA,EACvB,aAAa,4BAAU,OAAO,YAAY,6BAA6B,aAAa;AAAA,EACpF,SAAS,4BAAU,UAAU,CAAC,4BAAU,OAAO,4BAAU,SAAS,YAAY,mBAAmB,aAAa;AAAA,EAC9G,gBAAgB,4BAAU,UAAU,CAAC,4BAAU,QAAQ,4BAAU,SAAS,4BAAU,SAAS,YAC3F;AAAA,EAEF,WAAW,4BAAU,KAAK,YAAY,gDAAgD,aAAa;AAAA,EACnG,UAAU,4BAAU,KAAK,YAAY,0CAA0C,aAAa;AAAA,EAC5F,UAAU,4BAAU,KACjB,YAAY,mFACZ,aAAa;AAAA,EAChB,aAAa,4BAAU,KACpB,YAAY,4EACZ,aAAa;AAAA,EAChB,UAAU,4BAAU,KAAK,YAAY,2DAA2D,aAAa;AAAA,EAC7G,UAAU,4BAAU,KACjB,YACC,0GAED,aAAa;AAAA,EAChB,YAAY,4BAAU,KACnB,YAAY,8EACZ,aAAa;AAAA,EAChB,UAAU,4BAAU,KAAK,YAAY,8CAA8C,aAAa;AAAA,EAChG,YAAY,4BAAU,KAAK,YAAY,mDAAmD,aAAa;AAAA,EACvG,eAAe,4BAAU,IAAI,YAAY,oDAAoD,aAAa;AAAA,EAC1G,cAAc,4BAAU,IAAI,YAAY,uCAAuC,aAAa;AAAA,EAC5F,eAAe,4BAAU,IAAI,YAAY,wCAAwC,aAAa;AAAA,EAC9F,YAAY,4BAAU,KAAK,YAAY,yCAAyC,aAAa;AAAA;",
4
+ "sourcesContent": ["import { PropTypes } from 'react-desc';\n\nexport const propTypes = {\n placeholder: PropTypes.string.description('input s placeholder value').defaultValue(''),\n options: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).description('List of options').defaultValue([]),\n selectedValues: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]).description(\n 'Array of option or single option selected',\n ),\n autoFocus: PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),\n hasError: PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),\n onChange: PropTypes.func\n .description('function triggered when an option is selected it will send the options selected')\n .defaultValue(''),\n onSelectAll: PropTypes.func\n .description('function triggered when ALL button is selected from the header menu list')\n .defaultValue(''),\n onFilter: PropTypes.func.description('function triggered when user type in the combobox input').defaultValue(''),\n onCreate: PropTypes.func\n .description(\n 'function triggered when user select \"create\" a new item whenever is not a match in the all option list',\n )\n .defaultValue(''),\n onClearAll: PropTypes.func\n .description('function triggered when user select CLEAR button from the header menu list')\n .defaultValue(''),\n onCancel: PropTypes.func.description('function triggered when user press ESC key').defaultValue(''),\n onMenuOpen: PropTypes.func.description('function triggered when user open the menu list').defaultValue(''),\n inputMinWidth: PropTypes.any.description('Minimum width for the combo box input controller').defaultValue(undefined),\n menuMinWidth: PropTypes.any.description('Minimum width for the dropdown menu').defaultValue(undefined),\n menuMaxHeight: PropTypes.any.description('Maximum height for the dropdown menu').defaultValue(undefined),\n withToggle: PropTypes.bool.description('POC purpose this prop will not remain').defaultValue('false'),\n withoutPortal: PropTypes.bool\n .description('Whether the combobox menu is rendered in a portal or not')\n .defaultValue(false),\n zIndex: PropTypes.number.description('The z-index of the combobox menu').defaultValue(10),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAEnB,MAAM,YAAY;AAAA,EACvB,aAAa,4BAAU,OAAO,YAAY,6BAA6B,aAAa;AAAA,EACpF,SAAS,4BAAU,UAAU,CAAC,4BAAU,OAAO,4BAAU,SAAS,YAAY,mBAAmB,aAAa;AAAA,EAC9G,gBAAgB,4BAAU,UAAU,CAAC,4BAAU,QAAQ,4BAAU,SAAS,4BAAU,SAAS,YAC3F;AAAA,EAEF,WAAW,4BAAU,KAAK,YAAY,gDAAgD,aAAa;AAAA,EACnG,UAAU,4BAAU,KAAK,YAAY,0CAA0C,aAAa;AAAA,EAC5F,UAAU,4BAAU,KACjB,YAAY,mFACZ,aAAa;AAAA,EAChB,aAAa,4BAAU,KACpB,YAAY,4EACZ,aAAa;AAAA,EAChB,UAAU,4BAAU,KAAK,YAAY,2DAA2D,aAAa;AAAA,EAC7G,UAAU,4BAAU,KACjB,YACC,0GAED,aAAa;AAAA,EAChB,YAAY,4BAAU,KACnB,YAAY,8EACZ,aAAa;AAAA,EAChB,UAAU,4BAAU,KAAK,YAAY,8CAA8C,aAAa;AAAA,EAChG,YAAY,4BAAU,KAAK,YAAY,mDAAmD,aAAa;AAAA,EACvG,eAAe,4BAAU,IAAI,YAAY,oDAAoD,aAAa;AAAA,EAC1G,cAAc,4BAAU,IAAI,YAAY,uCAAuC,aAAa;AAAA,EAC5F,eAAe,4BAAU,IAAI,YAAY,wCAAwC,aAAa;AAAA,EAC9F,YAAY,4BAAU,KAAK,YAAY,yCAAyC,aAAa;AAAA,EAC7F,eAAe,4BAAU,KACtB,YAAY,4DACZ,aAAa;AAAA,EAChB,QAAQ,4BAAU,OAAO,YAAY,oCAAoC,aAAa;AAAA;",
6
6
  "names": []
7
7
  }
@@ -36,14 +36,27 @@ var import_listHelper = require("../listHelper");
36
36
  const isOptionFocuseable = (opt) => !["section", "separator"].includes(opt.type);
37
37
  const useKeyboardNavigation = () => {
38
38
  const {
39
- props: { inline, onSelectAll, onCancel, onKeyDown, onChange, onCreate, options, selectedValues, onFilter },
39
+ props: {
40
+ inline,
41
+ onSelectAll,
42
+ onCancel,
43
+ onKeyDown,
44
+ onChange,
45
+ onCreate,
46
+ options,
47
+ selectedValues,
48
+ onFilter,
49
+ withoutPortal
50
+ },
40
51
  setShowPopover,
41
52
  showPopover,
42
53
  setShowSelectedValue,
43
54
  focusOptionIdx,
44
55
  inputRef,
45
56
  setCurrentOption,
46
- scrollOptionIntoView
57
+ scrollOptionIntoView,
58
+ selectAllCheckboxRef,
59
+ toggleSelectionButtonRef
47
60
  } = (0, import_react.useContext)(import_ComboBoxCTX.ComboBoxContext);
48
61
  const multiple = Array.isArray(selectedValues);
49
62
  const currentItemIndex = options.findIndex((opt) => opt.dsId === focusOptionIdx);
@@ -140,6 +153,13 @@ const useKeyboardNavigation = () => {
140
153
  onFilter("");
141
154
  setShowSelectedValue(true);
142
155
  }
156
+ if (e.key === "Tab" && !inline && !withoutPortal) {
157
+ const element = selectAllCheckboxRef.current ?? toggleSelectionButtonRef.current;
158
+ if (element) {
159
+ e.preventDefault();
160
+ element.focus();
161
+ }
162
+ }
143
163
  if (e.key === "Tab" && inline) {
144
164
  }
145
165
  }, [
@@ -161,7 +181,10 @@ const useKeyboardNavigation = () => {
161
181
  setShowPopover,
162
182
  setShowSelectedValue,
163
183
  selectOption,
164
- onCancel
184
+ onCancel,
185
+ selectAllCheckboxRef,
186
+ toggleSelectionButtonRef,
187
+ withoutPortal
165
188
  ]);
166
189
  return { onInputKeyDown };
167
190
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/controlled-combobox/utils/hooks/useKeyboardNavigation.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext } from 'react';\nimport { CBOptionT } from '../../index.d';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport { findInCircularList } from '../listHelper';\n\nconst isOptionFocuseable = (opt: CBOptionT): boolean => !['section', 'separator'].includes(opt.type);\n\nexport const useKeyboardNavigation = () => {\n const {\n props: { inline, onSelectAll, onCancel, onKeyDown, onChange, onCreate, options, selectedValues, onFilter },\n setShowPopover,\n showPopover,\n setShowSelectedValue,\n focusOptionIdx,\n inputRef,\n setCurrentOption,\n scrollOptionIntoView,\n } = useContext(ComboBoxContext);\n\n const multiple = Array.isArray(selectedValues);\n\n const currentItemIndex = options.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = options.find((item) => item.dsId === focusOptionIdx);\n const selectOption = useCallback(() => {\n if (multiple) {\n if (inputRef.current) onFilter(inputRef.current.value);\n } else {\n onFilter('');\n if (inputRef.current) inputRef.current.value = '';\n setShowSelectedValue(true);\n }\n onChange(options.find((item) => item.dsId === focusOptionIdx));\n setShowPopover(multiple ? true : !showPopover);\n }, [\n multiple,\n options,\n focusOptionIdx,\n setShowPopover,\n showPopover,\n onFilter,\n inputRef,\n setShowSelectedValue,\n onChange,\n ]);\n\n const onInputKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n const targetElement = e.target as HTMLInputElement;\n\n // =============================================================================\n // CUSTOM KEYS\n // =============================================================================\n onKeyDown(e, currentItem);\n // =============================================================================\n // ENTER KEY TO CREATE ELEMENTS\n // =============================================================================\n if (e.key === 'Enter' && currentItem?.type === 'creatable') {\n onCreate(targetElement.value);\n onFilter('');\n if (inputRef.current) inputRef.current.value = '';\n return;\n }\n\n // =============================================================================\n // Enter and space on selection\n // =============================================================================\n if (e.key === 'Enter' || (e.keyCode === 32 && e.altKey)) {\n e.preventDefault();\n if (!showPopover && !inline) {\n setShowPopover(true);\n } else {\n selectOption();\n }\n }\n\n if (e.key === 'Enter' && e.altKey) {\n setShowPopover(false);\n }\n\n if (e.key === 'a' && e.ctrlKey && multiple) {\n onSelectAll();\n }\n // =============================================================================\n // ARROWS UP AND DOWN\n // =============================================================================\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n if (showPopover || inline) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n } else {\n setShowPopover(true);\n }\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n if (showPopover || inline) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n } else {\n setShowPopover(true);\n setTimeout(() => {\n const nextItemIndex = findInCircularList(options, 0, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n });\n }\n }\n // =============================================================================\n // ESCAPE\n // =============================================================================\n if (e.key === 'Escape') {\n if (onCancel) onCancel();\n if (inputRef.current && inputRef.current?.value !== '') {\n onFilter('');\n inputRef.current.value = '';\n }\n if (!inline) setShowPopover(false);\n }\n // =============================================================================\n // BACKSPACE\n // =============================================================================\n if (e.key === 'Backspace' && targetElement.value.length <= 0 && !inline) {\n if (multiple && !targetElement.value) {\n if (selectedValues.length > 0) onChange(selectedValues[selectedValues.length - 1]);\n } else {\n onChange(null);\n }\n onFilter('');\n setShowSelectedValue(true);\n }\n\n if (e.key === 'Tab' && inline) {\n // TODO confirm funcionality\n // e.preventDefault();\n }\n },\n [\n currentItemIndex,\n options,\n currentItem,\n inputRef,\n multiple,\n showPopover,\n selectedValues,\n inline,\n scrollOptionIntoView,\n onKeyDown,\n onSelectAll,\n onChange,\n onCreate,\n onFilter,\n setCurrentOption,\n setShowPopover,\n setShowSelectedValue,\n selectOption,\n onCancel,\n ],\n );\n\n return { onInputKeyDown };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AA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;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAIJ,SAAO,EAAE;AAAA;",
4
+ "sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext } from 'react';\nimport { CBOptionT } from '../../index.d';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport { findInCircularList } from '../listHelper';\n\nconst isOptionFocuseable = (opt: CBOptionT): boolean => !['section', 'separator'].includes(opt.type);\n\nexport const useKeyboardNavigation = () => {\n const {\n props: {\n inline,\n onSelectAll,\n onCancel,\n onKeyDown,\n onChange,\n onCreate,\n options,\n selectedValues,\n onFilter,\n withoutPortal,\n },\n setShowPopover,\n showPopover,\n setShowSelectedValue,\n focusOptionIdx,\n inputRef,\n setCurrentOption,\n scrollOptionIntoView,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n } = useContext(ComboBoxContext);\n\n const multiple = Array.isArray(selectedValues);\n\n const currentItemIndex = options.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = options.find((item) => item.dsId === focusOptionIdx);\n const selectOption = useCallback(() => {\n if (multiple) {\n if (inputRef.current) onFilter(inputRef.current.value);\n } else {\n onFilter('');\n if (inputRef.current) inputRef.current.value = '';\n setShowSelectedValue(true);\n }\n onChange(options.find((item) => item.dsId === focusOptionIdx));\n setShowPopover(multiple ? true : !showPopover);\n }, [\n multiple,\n options,\n focusOptionIdx,\n setShowPopover,\n showPopover,\n onFilter,\n inputRef,\n setShowSelectedValue,\n onChange,\n ]);\n\n const onInputKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n const targetElement = e.target as HTMLInputElement;\n\n // =============================================================================\n // CUSTOM KEYS\n // =============================================================================\n onKeyDown(e, currentItem);\n // =============================================================================\n // ENTER KEY TO CREATE ELEMENTS\n // =============================================================================\n if (e.key === 'Enter' && currentItem?.type === 'creatable') {\n onCreate(targetElement.value);\n onFilter('');\n if (inputRef.current) inputRef.current.value = '';\n return;\n }\n\n // =============================================================================\n // Enter and space on selection\n // =============================================================================\n if (e.key === 'Enter' || (e.keyCode === 32 && e.altKey)) {\n e.preventDefault();\n if (!showPopover && !inline) {\n setShowPopover(true);\n } else {\n selectOption();\n }\n }\n\n if (e.key === 'Enter' && e.altKey) {\n setShowPopover(false);\n }\n\n if (e.key === 'a' && e.ctrlKey && multiple) {\n onSelectAll();\n }\n // =============================================================================\n // ARROWS UP AND DOWN\n // =============================================================================\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n if (showPopover || inline) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n } else {\n setShowPopover(true);\n }\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n if (showPopover || inline) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n } else {\n setShowPopover(true);\n setTimeout(() => {\n const nextItemIndex = findInCircularList(options, 0, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n });\n }\n }\n // =============================================================================\n // ESCAPE\n // =============================================================================\n if (e.key === 'Escape') {\n if (onCancel) onCancel();\n if (inputRef.current && inputRef.current?.value !== '') {\n onFilter('');\n inputRef.current.value = '';\n }\n if (!inline) setShowPopover(false);\n }\n // =============================================================================\n // BACKSPACE\n // =============================================================================\n if (e.key === 'Backspace' && targetElement.value.length <= 0 && !inline) {\n if (multiple && !targetElement.value) {\n if (selectedValues.length > 0) onChange(selectedValues[selectedValues.length - 1]);\n } else {\n onChange(null);\n }\n onFilter('');\n setShowSelectedValue(true);\n }\n\n if (e.key === 'Tab' && !inline && !withoutPortal) {\n const element = selectAllCheckboxRef.current ?? toggleSelectionButtonRef.current;\n if (element) {\n e.preventDefault();\n element.focus();\n }\n }\n\n if (e.key === 'Tab' && inline) {\n // TODO confirm funcionality\n // e.preventDefault();\n }\n },\n [\n currentItemIndex,\n options,\n currentItem,\n inputRef,\n multiple,\n showPopover,\n selectedValues,\n inline,\n scrollOptionIntoView,\n onKeyDown,\n onSelectAll,\n onChange,\n onCreate,\n onFilter,\n setCurrentOption,\n setShowPopover,\n setShowSelectedValue,\n selectOption,\n onCancel,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n withoutPortal,\n ],\n );\n\n return { onInputKeyDown };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAwC;AAExC,yBAAgC;AAChC,wBAAmC;AAEnC,MAAM,qBAAqB,CAAC,QAA4B,CAAC,CAAC,WAAW,aAAa,SAAS,IAAI;AAExF,MAAM,wBAAwB,MAAM;AACzC,QAAM;AAAA,IACJ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAEF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,6BAAW;AAEf,QAAM,WAAW,MAAM,QAAQ;AAE/B,QAAM,mBAAmB,QAAQ,UAAU,CAAC,QAAQ,IAAI,SAAS;AACjE,QAAM,cAAc,QAAQ,KAAK,CAAC,SAAS,KAAK,SAAS;AACzD,QAAM,eAAe,8BAAY,MAAM;AACrC,QAAI,UAAU;AACZ,UAAI,SAAS;AAAS,iBAAS,SAAS,QAAQ;AAAA,WAC3C;AACL,eAAS;AACT,UAAI,SA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AAiB,QAAQ,eAAe;AACxC,+BAAqB,QAAQ,eAAe;AAAA;AAAA;AAAA;AAOlD,QAAI,EAAE,QAAQ,UAAU;AACtB,UAAI;AAAU;AACd,UAAI,SAAS,WAAW,SAAS,SAAS,UAAU,IAAI;AACtD,iBAAS;AACT,iBAAS,QAAQ,QAAQ;AAAA;AAE3B,UAAI,CAAC;AAAQ,uBAAe;AAAA;AAK9B,QAAI,EAAE,QAAQ,eAAe,cAAc,MAAM,UAAU,KAAK,CAAC,QAAQ;AACvE,UAAI,YAAY,CAAC,cAAc,OAAO;AACpC,YAAI,eAAe,SAAS;AAAG,mBAAS,eAAe,eAAe,SAAS;AAAA,aAC1E;AACL,iBAAS;AAAA;AAEX,eAAS;AACT,2BAAqB;AAAA;AAGvB,QAAI,EAAE,QAAQ,SAAS,CAAC,UAAU,CAAC,eAAe;AAChD,YAAM,UAAU,qBAAqB,WAAW,yBAAyB;AACzE,UAAI,SAAS;AACX,UAAE;AACF,gBAAQ;AAAA;AAAA;AAIZ,QAAI,EAAE,QAAQ,SAAS,QAAQ;AAAA;AAAA,KAKjC;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAIJ,SAAO,EAAE;AAAA;",
6
6
  "names": []
7
7
  }
@@ -11,7 +11,7 @@ const propTypes = {
11
11
  disabled: PropTypes.bool.description("Whether the checkbox is disabled or not."),
12
12
  ariaControls: PropTypes.string.description("This string is required when you use a mixed checkbox. It contains all the ids that this checkbox is controlling."),
13
13
  ariaLabel: PropTypes.string.description("Checkbox aria-label property. This property is going to be required if there is no label property added."),
14
- innerRef: PropTypes.func.description("Checkbox input ref."),
14
+ innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description("Checkbox input ref."),
15
15
  autoFocus: PropTypes.bool.description("Whether you want the checkbox to be autofocused on render")
16
16
  };
17
17
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/controlled-checkbox/propTypes.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from 'react-desc';\n\nexport const propTypes = {\n checked: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['mixed'])]).isRequired.description(\n 'Whether the checkbox is invalid or not.',\n ),\n value: PropTypes.string.description('Checkbox value property.'),\n name: PropTypes.string.isRequired.description('Checkbox name property.'),\n label: PropTypes.string.description(\n 'Checkbox Label property. This label is also going to be used as an aria-label for screen readers.',\n ),\n id: PropTypes.string.isRequired.description(\n 'Checkbox unique id property, this property is required for accesibility purposes.',\n ),\n readOnly: PropTypes.bool.description('Checkbox readOnly property.'),\n hasError: PropTypes.bool.description('Whether the checkbox has error or not.'),\n disabled: PropTypes.bool.description('Whether the checkbox is disabled or not.'),\n ariaControls: PropTypes.string.description(\n 'This string is required when you use a mixed checkbox. It contains all the ids that this checkbox is controlling.',\n ),\n ariaLabel: PropTypes.string.description(\n 'Checkbox aria-label property. This property is going to be required if there is no label property added.',\n ),\n innerRef: PropTypes.func.description('Checkbox input ref.'),\n autoFocus: PropTypes.bool.description('Whether you want the checkbox to be autofocused on render'),\n};\n"],
5
- "mappings": "AAAA;ACAA;AAEO,MAAM,YAAY;AAAA,EACvB,SAAS,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU,MAAM,CAAC,YAAY,WAAW,YACpF;AAAA,EAEF,OAAO,UAAU,OAAO,YAAY;AAAA,EACpC,MAAM,UAAU,OAAO,WAAW,YAAY;AAAA,EAC9C,OAAO,UAAU,OAAO,YACtB;AAAA,EAEF,IAAI,UAAU,OAAO,WAAW,YAC9B;AAAA,EAEF,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,cAAc,UAAU,OAAO,YAC7B;AAAA,EAEF,WAAW,UAAU,OAAO,YAC1B;AAAA,EAEF,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,WAAW,UAAU,KAAK,YAAY;AAAA;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from 'react-desc';\n\nexport const propTypes = {\n checked: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['mixed'])]).isRequired.description(\n 'Whether the checkbox is invalid or not.',\n ),\n value: PropTypes.string.description('Checkbox value property.'),\n name: PropTypes.string.isRequired.description('Checkbox name property.'),\n label: PropTypes.string.description(\n 'Checkbox Label property. This label is also going to be used as an aria-label for screen readers.',\n ),\n id: PropTypes.string.isRequired.description(\n 'Checkbox unique id property, this property is required for accesibility purposes.',\n ),\n readOnly: PropTypes.bool.description('Checkbox readOnly property.'),\n hasError: PropTypes.bool.description('Whether the checkbox has error or not.'),\n disabled: PropTypes.bool.description('Whether the checkbox is disabled or not.'),\n ariaControls: PropTypes.string.description(\n 'This string is required when you use a mixed checkbox. It contains all the ids that this checkbox is controlling.',\n ),\n ariaLabel: PropTypes.string.description(\n 'Checkbox aria-label property. This property is going to be required if there is no label property added.',\n ),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Checkbox input ref.'),\n autoFocus: PropTypes.bool.description('Whether you want the checkbox to be autofocused on render'),\n};\n"],
5
+ "mappings": "AAAA;ACAA;AAEO,MAAM,YAAY;AAAA,EACvB,SAAS,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU,MAAM,CAAC,YAAY,WAAW,YACpF;AAAA,EAEF,OAAO,UAAU,OAAO,YAAY;AAAA,EACpC,MAAM,UAAU,OAAO,WAAW,YAAY;AAAA,EAC9C,OAAO,UAAU,OAAO,YACtB;AAAA,EAEF,IAAI,UAAU,OAAO,WAAW,YAC9B;AAAA,EAEF,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,cAAc,UAAU,OAAO,YAC7B;AAAA,EAEF,WAAW,UAAU,OAAO,YAC1B;AAAA,EAEF,UAAU,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU,SAAS,YAAY;AAAA,EAC9E,WAAW,UAAU,KAAK,YAAY;AAAA;",
6
6
  "names": []
7
7
  }
@@ -14,6 +14,8 @@ const defaultProps = {
14
14
  onSelectAll: noop,
15
15
  onCreate: noop,
16
16
  withToggle: false,
17
+ withoutPortal: true,
18
+ zIndex: 10,
17
19
  onChange: noop,
18
20
  onKeyDown: noop,
19
21
  onFilter: noop,
@@ -34,6 +36,8 @@ const defaultContext = {
34
36
  wrapperListRef: createRef(),
35
37
  controlsWrapperRef: createRef(),
36
38
  selectedOptionsRef: createRef(),
39
+ selectAllCheckboxRef: createRef(),
40
+ toggleSelectionButtonRef: createRef(),
37
41
  showSelectedValue: false,
38
42
  setShowSelectedValue: noop,
39
43
  focusOptionIdx: "",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/controlled-combobox/ComboBoxCTX.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext, createRef } from 'react';\nimport { noop } from 'lodash';\nimport { ComboBoxPropsT, ComboBoxContextT } from './index.d';\n// eslint-disable-next-line @typescript-eslint/no-empty-function\n\nexport const defaultProps: ComboBoxPropsT = {\n placeholder: '',\n options: [],\n selectedValues: null,\n hasError: false,\n inline: false,\n autoFocus: false,\n startPlacementPreference: 'bottom-start',\n placementOrderPreference: ['bottom-start', 'bottom-end'],\n onClearAll: noop,\n onSelectAll: noop,\n onCreate: noop,\n withToggle: false,\n onChange: noop,\n onKeyDown: noop,\n onFilter: noop,\n onMenuOpen: noop,\n};\nconst defaultContext = {\n props: defaultProps,\n showPopover: false,\n setShowPopover: noop,\n scrollOptionIntoView: noop,\n referenceElement: null,\n hasFocus: false,\n setHasFocus: noop,\n pillGroupRef: createRef<HTMLDivElement>(),\n setReferenceElement: noop,\n inputRef: createRef<HTMLInputElement>(),\n listRef: createRef<HTMLDivElement>(),\n wrapperListRef: createRef<HTMLDivElement>(),\n controlsWrapperRef: createRef<HTMLInputElement>(),\n selectedOptionsRef: createRef<HTMLInputElement>(),\n showSelectedValue: false,\n setShowSelectedValue: noop,\n focusOptionIdx: '',\n setCurrentOption: noop,\n showSelectedOptions: false,\n setShowSelectedOptions: noop,\n};\n/** Context for cross component communication */\nexport const ComboBoxContext = createContext<ComboBoxContextT>(defaultContext);\n\nexport default ComboBoxContext;\n"],
5
- "mappings": "AAAA;ACAA;AACA;AAIO,MAAM,eAA+B;AAAA,EAC1C,aAAa;AAAA,EACb,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,gBAAgB;AAAA,EAC3C,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA;AAEd,MAAM,iBAAiB;AAAA,EACrB,OAAO;AAAA,EACP,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,aAAa;AAAA,EACb,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,UAAU;AAAA,EACV,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,wBAAwB;AAAA;AAGnB,MAAM,kBAAkB,cAAgC;AAE/D,IAAO,sBAAQ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext, createRef } from 'react';\nimport { noop } from 'lodash';\nimport { ComboBoxPropsT, ComboBoxContextT } from './index.d';\n// eslint-disable-next-line @typescript-eslint/no-empty-function\n\nexport const defaultProps: ComboBoxPropsT = {\n placeholder: '',\n options: [],\n selectedValues: null,\n hasError: false,\n inline: false,\n autoFocus: false,\n startPlacementPreference: 'bottom-start',\n placementOrderPreference: ['bottom-start', 'bottom-end'],\n onClearAll: noop,\n onSelectAll: noop,\n onCreate: noop,\n withToggle: false,\n withoutPortal: true,\n zIndex: 10,\n onChange: noop,\n onKeyDown: noop,\n onFilter: noop,\n onMenuOpen: noop,\n};\nconst defaultContext = {\n props: defaultProps,\n showPopover: false,\n setShowPopover: noop,\n scrollOptionIntoView: noop,\n referenceElement: null,\n hasFocus: false,\n setHasFocus: noop,\n pillGroupRef: createRef<HTMLDivElement>(),\n setReferenceElement: noop,\n inputRef: createRef<HTMLInputElement>(),\n listRef: createRef<HTMLDivElement>(),\n wrapperListRef: createRef<HTMLDivElement>(),\n controlsWrapperRef: createRef<HTMLInputElement>(),\n selectedOptionsRef: createRef<HTMLInputElement>(),\n selectAllCheckboxRef: createRef<HTMLInputElement>(),\n toggleSelectionButtonRef: createRef<HTMLButtonElement>(),\n showSelectedValue: false,\n setShowSelectedValue: noop,\n focusOptionIdx: '',\n setCurrentOption: noop,\n showSelectedOptions: false,\n setShowSelectedOptions: noop,\n};\n/** Context for cross component communication */\nexport const ComboBoxContext = createContext<ComboBoxContextT>(defaultContext);\n\nexport default ComboBoxContext;\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AAIO,MAAM,eAA+B;AAAA,EAC1C,aAAa;AAAA,EACb,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,gBAAgB;AAAA,EAC3C,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA;AAEd,MAAM,iBAAiB;AAAA,EACrB,OAAO;AAAA,EACP,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,aAAa;AAAA,EACb,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,UAAU;AAAA,EACV,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,0BAA0B;AAAA,EAC1B,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,wBAAwB;AAAA;AAGnB,MAAM,kBAAkB,cAAgC;AAE/D,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
@@ -16,6 +16,8 @@ const useComboBox = (props) => {
16
16
  const wrapperListRef = useRef(null);
17
17
  const selectedOptionsRef = useRef(null);
18
18
  const controlsWrapperRef = useRef(null);
19
+ const selectAllCheckboxRef = useRef(null);
20
+ const toggleSelectionButtonRef = useRef(null);
19
21
  const pillGroupRef = useRef(null);
20
22
  const propsWithDefaults = useGetComboBoxWithDefaultsProps(props);
21
23
  const { options, selectedValues, onCreate } = propsWithDefaults;
@@ -75,6 +77,8 @@ const useComboBox = (props) => {
75
77
  focusOptionIdx,
76
78
  selectedOptionsRef,
77
79
  controlsWrapperRef,
80
+ selectAllCheckboxRef,
81
+ toggleSelectionButtonRef,
78
82
  hasFocus,
79
83
  pillGroupRef,
80
84
  showSelectedOptions,
@@ -101,6 +105,8 @@ const useComboBox = (props) => {
101
105
  inputRef,
102
106
  selectedOptionsRef,
103
107
  controlsWrapperRef,
108
+ selectAllCheckboxRef,
109
+ toggleSelectionButtonRef,
104
110
  hasFocus,
105
111
  listRef
106
112
  ]);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/controlled-combobox/config/useComboBox.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useMemo, useState, useRef, useCallback } from 'react';\nimport { noop } from 'lodash';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { useVirtual } from 'react-virtual';\nimport { useGetComboBoxWithDefaultsProps } from './useGetPropsWithDefault';\nimport type { ComboBoxPropsT, ComboBoxContextT, CBOptionT, CBItemCreatableOption } from '../index.d';\n\nexport const useComboBox = (props: Partial<ComboBoxPropsT>): ComboBoxContextT => {\n const [showPopover, setShowPopover] = useState<boolean>(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n const [showSelectedValue, setShowSelectedValue] = useState<boolean>(false);\n const [showSelectedOptions, setShowSelectedOptions] = useState<boolean>(false);\n\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n const [focusOptionIdx, setCurrentOption] = useState<string>('');\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const wrapperListRef = useRef<HTMLDivElement>(null);\n\n const selectedOptionsRef = useRef<HTMLDivElement>(null);\n const controlsWrapperRef = useRef<HTMLDivElement>(null);\n const pillGroupRef = useRef<HTMLDivElement>(null);\n\n const propsWithDefaults = useGetComboBoxWithDefaultsProps(props);\n const { options, selectedValues, onCreate } = propsWithDefaults;\n\n // ---------------------------------------------------------------------------\n // Menu Options with/out selected filter\n // ---------------------------------------------------------------------------\n\n const selectedValuesWithSections = useCallback(() => {\n const multiSelectedValue = selectedValues as CBOptionT[];\n const items = [] as CBOptionT[];\n\n options.forEach((option) => {\n const isSelectedValue = multiSelectedValue.find((item) => item.dsId === option.dsId);\n if (isSelectedValue) {\n items.push(option);\n }\n\n if (option.type === 'section') {\n if (items[items.length - 1]?.type === 'section') {\n items[items.length - 1] = option;\n } else {\n items.push(option);\n }\n }\n });\n if (items[items.length - 1]?.type === 'section') {\n items.pop();\n }\n\n return items;\n }, [options, selectedValues]);\n\n const correctOptions = useMemo(() => {\n if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {\n return selectedValuesWithSections();\n }\n if (onCreate !== noop && inputRef.current && inputRef.current.value !== '') {\n const creatableUuid = uuidv4() as string;\n const creatableItem: CBItemCreatableOption = {\n dsId: `creatable-${creatableUuid}`,\n label: inputRef.current?.value,\n type: 'creatable',\n };\n return [creatableItem, ...options];\n }\n return options;\n }, [options, onCreate, selectedValuesWithSections, selectedValues, showSelectedOptions]);\n\n // ===========================================================================\n // Virtualization setup\n // ===========================================================================\n\n const virtualListHelpers: ReturnType<typeof useVirtual> = useVirtual({\n size: correctOptions.length,\n parentRef: listRef,\n overscan: 15,\n paddingStart: 0,\n });\n\n // ===========================================================================\n // Scroll into view function\n // ===========================================================================\n const scrollOptionIntoView = useCallback(\n (dsId: string, opts = { align: 'center' }) => {\n virtualListHelpers.scrollToIndex(\n correctOptions.findIndex((opt) => opt.dsId === dsId),\n opts,\n );\n },\n [correctOptions, virtualListHelpers],\n );\n\n const ctx = useMemo(\n () => ({\n props: { ...propsWithDefaults, options: correctOptions },\n virtualListHelpers,\n showPopover,\n referenceElement,\n inputRef,\n showSelectedValue,\n listRef,\n focusOptionIdx,\n selectedOptionsRef,\n controlsWrapperRef,\n hasFocus,\n pillGroupRef,\n showSelectedOptions,\n wrapperListRef,\n setShowSelectedOptions,\n setHasFocus,\n setCurrentOption,\n scrollOptionIntoView,\n setShowSelectedValue,\n setReferenceElement,\n setShowPopover,\n }),\n [\n scrollOptionIntoView,\n correctOptions,\n propsWithDefaults,\n virtualListHelpers,\n focusOptionIdx,\n showSelectedValue,\n wrapperListRef,\n showSelectedOptions,\n showPopover,\n pillGroupRef,\n referenceElement,\n inputRef,\n selectedOptionsRef,\n controlsWrapperRef,\n hasFocus,\n listRef,\n ],\n );\n\n return ctx;\n};\n"],
5
- "mappings": "AAAA;ACIA;AACA;AACA;AAEA;AACA;AAGO,MAAM,cAAc,CAAC,UAAqD;AAC/E,QAAM,CAAC,aAAa,kBAAkB,SAAkB;AACxD,QAAM,CAAC,kBAAkB,uBAAuB,SAA6B;AAC7E,QAAM,CAAC,mBAAmB,wBAAwB,SAAkB;AACpE,QAAM,CAAC,qBAAqB,0BAA0B,SAAkB;AAExE,QAAM,CAAC,UAAU,eAAe,SAAkB;AAClD,QAAM,CAAC,gBAAgB,oBAAoB,SAAiB;AAC5D,QAAM,WAAW,OAAyB;AAC1C,QAAM,UAAU,OAAuB;AACvC,QAAM,iBAAiB,OAAuB;AAE9C,QAAM,qBAAqB,OAAuB;AAClD,QAAM,qBAAqB,OAAuB;AAClD,QAAM,eAAe,OAAuB;AAE5C,QAAM,oBAAoB,gCAAgC;AAC1D,QAAM,EAAE,SAAS,gBAAgB,aAAa;AAM9C,QAAM,6BAA6B,YAAY,MAAM;AACnD,UAAM,qBAAqB;AAC3B,UAAM,QAAQ;AAEd,YAAQ,QAAQ,CAAC,WAAW;AAC1B,YAAM,kBAAkB,mBAAmB,KAAK,CAAC,SAAS,KAAK,SAAS,OAAO;AAC/E,UAAI,iBAAiB;AACnB,cAAM,KAAK;AAAA;AAGb,UAAI,OAAO,SAAS,WAAW;AAC7B,YAAI,MAAM,MAAM,SAAS,IAAI,SAAS,WAAW;AAC/C,gBAAM,MAAM,SAAS,KAAK;AAAA,eACrB;AACL,gBAAM,KAAK;AAAA;AAAA;AAAA;AAIjB,QAAI,MAAM,MAAM,SAAS,IAAI,SAAS,WAAW;AAC/C,YAAM;AAAA;AAGR,WAAO;AAAA,KACN,CAAC,SAAS;AAEb,QAAM,iBAAiB,QAAQ,MAAM;AACnC,QAAI,uBAAuB,MAAM,QAAQ,mBAAmB,eAAe,SAAS,GAAG;AACrF,aAAO;AAAA;AAET,QAAI,aAAa,QAAQ,SAAS,WAAW,SAAS,QAAQ,UAAU,IAAI;AAC1E,YAAM,gBAAgB;AACtB,YAAM,gBAAuC;AAAA,QAC3C,MAAM,aAAa;AAAA,QACnB,OAAO,SAAS,SAAS;AAAA,QACzB,MAAM;AAAA;AAER,aAAO,CAAC,eAAe,GAAG;AAAA;AAE5B,WAAO;AAAA,KACN,CAAC,SAAS,UAAU,4BAA4B,gBAAgB;AAMnE,QAAM,qBAAoD,WAAW;AAAA,IACnE,MAAM,eAAe;AAAA,IACrB,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA;AAMhB,QAAM,uBAAuB,YAC3B,CAAC,MAAc,OAAO,EAAE,OAAO,eAAe;AAC5C,uBAAmB,cACjB,eAAe,UAAU,CAAC,QAAQ,IAAI,SAAS,OAC/C;AAAA,KAGJ,CAAC,gBAAgB;AAGnB,QAAM,MAAM,QACV,MAAO;AAAA,IACL,OAAO,KAAK,mBAAmB,SAAS;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAEF;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAIJ,SAAO;AAAA;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useMemo, useState, useRef, useCallback } from 'react';\nimport { noop } from 'lodash';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { useVirtual } from 'react-virtual';\nimport { useGetComboBoxWithDefaultsProps } from './useGetPropsWithDefault';\nimport type { ComboBoxPropsT, ComboBoxContextT, CBOptionT, CBItemCreatableOption } from '../index.d';\n\nexport const useComboBox = (props: Partial<ComboBoxPropsT>): ComboBoxContextT => {\n const [showPopover, setShowPopover] = useState<boolean>(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n const [showSelectedValue, setShowSelectedValue] = useState<boolean>(false);\n const [showSelectedOptions, setShowSelectedOptions] = useState<boolean>(false);\n\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n const [focusOptionIdx, setCurrentOption] = useState<string>('');\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const wrapperListRef = useRef<HTMLDivElement>(null);\n\n const selectedOptionsRef = useRef<HTMLDivElement>(null);\n const controlsWrapperRef = useRef<HTMLDivElement>(null);\n const selectAllCheckboxRef = useRef<HTMLInputElement>(null);\n const toggleSelectionButtonRef = useRef<HTMLButtonElement>(null);\n const pillGroupRef = useRef<HTMLDivElement>(null);\n\n const propsWithDefaults = useGetComboBoxWithDefaultsProps(props);\n const { options, selectedValues, onCreate } = propsWithDefaults;\n\n // ---------------------------------------------------------------------------\n // Menu Options with/out selected filter\n // ---------------------------------------------------------------------------\n\n const selectedValuesWithSections = useCallback(() => {\n const multiSelectedValue = selectedValues as CBOptionT[];\n const items = [] as CBOptionT[];\n\n options.forEach((option) => {\n const isSelectedValue = multiSelectedValue.find((item) => item.dsId === option.dsId);\n if (isSelectedValue) {\n items.push(option);\n }\n\n if (option.type === 'section') {\n if (items[items.length - 1]?.type === 'section') {\n items[items.length - 1] = option;\n } else {\n items.push(option);\n }\n }\n });\n if (items[items.length - 1]?.type === 'section') {\n items.pop();\n }\n\n return items;\n }, [options, selectedValues]);\n\n const correctOptions = useMemo(() => {\n if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {\n return selectedValuesWithSections();\n }\n if (onCreate !== noop && inputRef.current && inputRef.current.value !== '') {\n const creatableUuid = uuidv4();\n const creatableItem: CBItemCreatableOption = {\n dsId: `creatable-${creatableUuid}`,\n label: inputRef.current?.value,\n type: 'creatable',\n };\n return [creatableItem, ...options];\n }\n return options;\n }, [options, onCreate, selectedValuesWithSections, selectedValues, showSelectedOptions]);\n\n // ===========================================================================\n // Virtualization setup\n // ===========================================================================\n\n const virtualListHelpers: ReturnType<typeof useVirtual> = useVirtual({\n size: correctOptions.length,\n parentRef: listRef,\n overscan: 15,\n paddingStart: 0,\n });\n\n // ===========================================================================\n // Scroll into view function\n // ===========================================================================\n const scrollOptionIntoView = useCallback(\n (dsId: string, opts = { align: 'center' }) => {\n virtualListHelpers.scrollToIndex(\n correctOptions.findIndex((opt) => opt.dsId === dsId),\n opts,\n );\n },\n [correctOptions, virtualListHelpers],\n );\n\n const ctx = useMemo(\n () => ({\n props: { ...propsWithDefaults, options: correctOptions },\n virtualListHelpers,\n showPopover,\n referenceElement,\n inputRef,\n showSelectedValue,\n listRef,\n focusOptionIdx,\n selectedOptionsRef,\n controlsWrapperRef,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n hasFocus,\n pillGroupRef,\n showSelectedOptions,\n wrapperListRef,\n setShowSelectedOptions,\n setHasFocus,\n setCurrentOption,\n scrollOptionIntoView,\n setShowSelectedValue,\n setReferenceElement,\n setShowPopover,\n }),\n [\n scrollOptionIntoView,\n correctOptions,\n propsWithDefaults,\n virtualListHelpers,\n focusOptionIdx,\n showSelectedValue,\n wrapperListRef,\n showSelectedOptions,\n showPopover,\n pillGroupRef,\n referenceElement,\n inputRef,\n selectedOptionsRef,\n controlsWrapperRef,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n hasFocus,\n listRef,\n ],\n );\n\n return ctx;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,QAAQ,SAAS,WAAW,SAAS,QAAQ,UAAU,IAAI;AAC1E,YAAM,gBAAgB;AACtB,YAAM,gBAAuC;AAAA,QAC3C,MAAM,aAAa;AAAA,QACnB,OAAO,SAAS,SAAS;AAAA,QACzB,MAAM;AAAA;AAER,aAAO,CAAC,eAAe,GAAG;AAAA;AAE5B,WAAO;AAAA,KACN,CAAC,SAAS,UAAU,4BAA4B,gBAAgB;AAMnE,QAAM,qBAAoD,WAAW;AAAA,IACnE,MAAM,eAAe;AAAA,IACrB,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA;AAMhB,QAAM,uBAAuB,YAC3B,CAAC,MAAc,OAAO,EAAE,OAAO,eAAe;AAC5C,uBAAmB,cACjB,eAAe,UAAU,CAAC,QAAQ,IAAI,SAAS,OAC/C;AAAA,KAGJ,CAAC,gBAAgB;AAGnB,QAAM,MAAM,QACV,MAAO;AAAA,IACL,OAAO,KAAK,mBAAmB,SAAS;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAEF;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAIJ,SAAO;AAAA;",
6
6
  "names": []
7
7
  }
@@ -7,7 +7,7 @@ import { Controls } from "../controls";
7
7
  import { MenuList } from "../menu-list";
8
8
  const Container = () => {
9
9
  const {
10
- props: { inline, startPlacementPreference, placementOrderPreference },
10
+ props: { inline, startPlacementPreference, placementOrderPreference, withoutPortal, zIndex },
11
11
  showPopover,
12
12
  inputRef,
13
13
  setReferenceElement,
@@ -36,10 +36,10 @@ const Container = () => {
36
36
  showPopover,
37
37
  startPlacementPreference,
38
38
  placementOrderPreference,
39
- withoutPortal: true,
39
+ withoutPortal,
40
40
  withoutArrow: true,
41
41
  withoutAnimation: true,
42
- zIndex: 10
42
+ zIndex
43
43
  }, /* @__PURE__ */ React2.createElement(StyledPopperWrapper, {
44
44
  tabIndex: -1,
45
45
  onMouseDown: handleMouseDown
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/controlled-combobox/parts/container/Container.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useCallback, useContext } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport { StyledContainerWithPopper, StyledContainerInline, StyledPopperWrapper } from './styled';\nimport { Controls } from '../controls';\nimport { MenuList } from '../menu-list';\nconst Container = (): JSX.Element => {\n const {\n props: { inline, startPlacementPreference, placementOrderPreference },\n showPopover,\n inputRef,\n setReferenceElement,\n setShowPopover,\n referenceElement,\n } = useContext(ComboBoxContext);\n\n const handleCloseMenu = useCallback(() => {\n setShowPopover(false);\n if (inputRef.current) inputRef.current.blur();\n }, [inputRef, setShowPopover]);\n\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n }, []);\n\n const handleOnClickContainer = useCallback(() => {\n setShowPopover(!showPopover);\n }, [setShowPopover, showPopover]);\n\n const StyledContainer = inline ? StyledContainerInline : StyledContainerWithPopper;\n return (\n <>\n <StyledContainer ref={setReferenceElement} onClick={handleOnClickContainer}>\n <Controls />\n {inline ? <MenuList /> : null}\n </StyledContainer>\n {!inline ? (\n <DSPopperJS\n customOffset={[0, 5]}\n closeContextMenu={handleCloseMenu}\n referenceElement={referenceElement}\n showPopover={showPopover}\n startPlacementPreference={startPlacementPreference}\n placementOrderPreference={placementOrderPreference}\n withoutPortal\n withoutArrow\n withoutAnimation\n zIndex={10}\n >\n <StyledPopperWrapper tabIndex={-1} onMouseDown={handleMouseDown}>\n <MenuList />\n </StyledPopperWrapper>\n </DSPopperJS>\n ) : null}\n </>\n );\n};\n\nexport { Container };\n"],
5
- "mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,YAAY,MAAmB;AACnC,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ,0BAA0B;AAAA,IAC3C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW;AAEf,QAAM,kBAAkB,YAAY,MAAM;AACxC,mBAAe;AACf,QAAI,SAAS;AAAS,eAAS,QAAQ;AAAA,KACtC,CAAC,UAAU;AAEd,QAAM,kBAAkB,YAAY,CAAC,MAAwB;AAC3D,MAAE;AAAA,KACD;AAEH,QAAM,yBAAyB,YAAY,MAAM;AAC/C,mBAAe,CAAC;AAAA,KACf,CAAC,gBAAgB;AAEpB,QAAM,kBAAkB,SAAS,wBAAwB;AACzD,SACE,4DACE,qCAAC,iBAAD;AAAA,IAAiB,KAAK;AAAA,IAAqB,SAAS;AAAA,KAClD,qCAAC,UAAD,OACC,SAAS,qCAAC,UAAD,QAAe,OAE1B,CAAC,SACA,qCAAC,YAAD;AAAA,IACE,cAAc,CAAC,GAAG;AAAA,IAClB,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAa;AAAA,IACb,cAAY;AAAA,IACZ,kBAAgB;AAAA,IAChB,QAAQ;AAAA,KAER,qCAAC,qBAAD;AAAA,IAAqB,UAAU;AAAA,IAAI,aAAa;AAAA,KAC9C,qCAAC,UAAD,UAGF;AAAA;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useCallback, useContext } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport { StyledContainerWithPopper, StyledContainerInline, StyledPopperWrapper } from './styled';\nimport { Controls } from '../controls';\nimport { MenuList } from '../menu-list';\nconst Container = (): JSX.Element => {\n const {\n props: { inline, startPlacementPreference, placementOrderPreference, withoutPortal, zIndex },\n showPopover,\n inputRef,\n setReferenceElement,\n setShowPopover,\n referenceElement,\n } = useContext(ComboBoxContext);\n\n const handleCloseMenu = useCallback(() => {\n setShowPopover(false);\n if (inputRef.current) inputRef.current.blur();\n }, [inputRef, setShowPopover]);\n\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n }, []);\n\n const handleOnClickContainer = useCallback(() => {\n setShowPopover(!showPopover);\n }, [setShowPopover, showPopover]);\n\n const StyledContainer = inline ? StyledContainerInline : StyledContainerWithPopper;\n return (\n <>\n <StyledContainer ref={setReferenceElement} onClick={handleOnClickContainer}>\n <Controls />\n {inline ? <MenuList /> : null}\n </StyledContainer>\n {!inline ? (\n <DSPopperJS\n customOffset={[0, 5]}\n closeContextMenu={handleCloseMenu}\n referenceElement={referenceElement}\n showPopover={showPopover}\n startPlacementPreference={startPlacementPreference}\n placementOrderPreference={placementOrderPreference}\n withoutPortal={withoutPortal}\n withoutArrow\n withoutAnimation\n zIndex={zIndex}\n >\n <StyledPopperWrapper tabIndex={-1} onMouseDown={handleMouseDown}>\n <MenuList />\n </StyledPopperWrapper>\n </DSPopperJS>\n ) : null}\n </>\n );\n};\n\nexport { Container };\n"],
5
+ "mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,YAAY,MAAmB;AACnC,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ,0BAA0B,0BAA0B,eAAe;AAAA,IACpF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW;AAEf,QAAM,kBAAkB,YAAY,MAAM;AACxC,mBAAe;AACf,QAAI,SAAS;AAAS,eAAS,QAAQ;AAAA,KACtC,CAAC,UAAU;AAEd,QAAM,kBAAkB,YAAY,CAAC,MAAwB;AAC3D,MAAE;AAAA,KACD;AAEH,QAAM,yBAAyB,YAAY,MAAM;AAC/C,mBAAe,CAAC;AAAA,KACf,CAAC,gBAAgB;AAEpB,QAAM,kBAAkB,SAAS,wBAAwB;AACzD,SACE,4DACE,qCAAC,iBAAD;AAAA,IAAiB,KAAK;AAAA,IAAqB,SAAS;AAAA,KAClD,qCAAC,UAAD,OACC,SAAS,qCAAC,UAAD,QAAe,OAE1B,CAAC,SACA,qCAAC,YAAD;AAAA,IACE,cAAc,CAAC,GAAG;AAAA,IAClB,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAY;AAAA,IACZ,kBAAgB;AAAA,IAChB;AAAA,KAEA,qCAAC,qBAAD;AAAA,IAAqB,UAAU;AAAA,IAAI,aAAa;AAAA,KAC9C,qCAAC,UAAD,UAGF;AAAA;",
6
6
  "names": []
7
7
  }
@@ -16,7 +16,9 @@ const HeaderList = () => {
16
16
  const {
17
17
  props: { onSelectAll, onClearAll, selectedValues },
18
18
  showSelectedOptions,
19
- inputRef
19
+ inputRef,
20
+ selectAllCheckboxRef,
21
+ toggleSelectionButtonRef
20
22
  } = useContext(ComboBoxContext);
21
23
  const isSelectAllSupplied = onSelectAll !== noop;
22
24
  const isClearAllSupplied = onClearAll !== noop;
@@ -37,7 +39,8 @@ const HeaderList = () => {
37
39
  if (multiSelectedValues.length === 0) {
38
40
  setTimeout(() => inputRef.current?.focus());
39
41
  }
40
- }
42
+ },
43
+ innerRef: selectAllCheckboxRef
41
44
  })), /* @__PURE__ */ React2.createElement(StyledSelectedItems, null, multiSelectedValues.length > 0 ? /* @__PURE__ */ React2.createElement(StyledButtonSelection, {
42
45
  onBlur: () => {
43
46
  setTimeout(() => inputRef.current?.focus());
@@ -46,7 +49,8 @@ const HeaderList = () => {
46
49
  onClick: handleToggle,
47
50
  labelText: !showSelectedOptions ? `SHOW SELECTED [${multiSelectedValues.length}]` : "SHOW ALL",
48
51
  size: "s",
49
- "data-testid": ComboboxDataTestid.SHOW_SELECTED_OPTIONS_TOGGLE
52
+ "data-testid": ComboboxDataTestid.SHOW_SELECTED_OPTIONS_TOGGLE,
53
+ innerRef: toggleSelectionButtonRef
50
54
  }) : /* @__PURE__ */ React2.createElement(StyledNoOptionsSelected, null, "0 SELECTED")));
51
55
  };
52
56
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/controlled-combobox/parts/header-list/HeaderList.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport React, { useContext } from 'react';\nimport { noop } from 'lodash';\nimport { DSControlledCheckbox } from '@elliemae/ds-controlled-form';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport {\n StyledHeaderListWrapper,\n StyledButtonSelection,\n StyledSelectedItems,\n StyledSelectAllCheckbox,\n StyledNoOptionsSelected,\n} from './styled';\nimport { CBItemOption } from '../../index.d';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport { useHeaderListHandlers } from './useHeaderListHandlers';\nconst HeaderList = (): JSX.Element => {\n const {\n props: { onSelectAll, onClearAll, selectedValues },\n showSelectedOptions,\n inputRef,\n } = useContext(ComboBoxContext);\n\n const isSelectAllSupplied = onSelectAll !== noop;\n const isClearAllSupplied = onClearAll !== noop;\n\n const multiSelectedValues = selectedValues as CBItemOption[];\n const { handleKeyDown, handleOnMouseDown, handleToggle, checkboxStatus, handleSelectAllCheckboxChange } =\n useHeaderListHandlers();\n\n return (\n <StyledHeaderListWrapper onKeyDown={handleKeyDown} onMouseDown={handleOnMouseDown}>\n <StyledSelectAllCheckbox>\n {isSelectAllSupplied && isClearAllSupplied && (\n <DSControlledCheckbox\n checked={checkboxStatus}\n ariaControls={checkboxStatus === 'mixed' ? multiSelectedValues.map((item) => item.dsId).join(' ') : ''}\n name=\"select-all-checkbox\"\n ariaLabel=\"Select/Unselect All Items\"\n id=\"select-all-checkbox\"\n onChange={handleSelectAllCheckboxChange}\n data-testid={ComboboxDataTestid.SELECT_ALL_CHECKBOX}\n onBlur={() => {\n if (multiSelectedValues.length === 0) {\n setTimeout(() => inputRef.current?.focus());\n }\n }}\n />\n )}\n </StyledSelectAllCheckbox>\n <StyledSelectedItems>\n {multiSelectedValues.length > 0 ? (\n <StyledButtonSelection\n onBlur={() => {\n setTimeout(() => inputRef.current?.focus());\n }}\n buttonType=\"text\"\n onClick={handleToggle}\n labelText={!showSelectedOptions ? `SHOW SELECTED [${multiSelectedValues.length}]` : 'SHOW ALL'}\n size=\"s\"\n data-testid={ComboboxDataTestid.SHOW_SELECTED_OPTIONS_TOGGLE}\n />\n ) : (\n <StyledNoOptionsSelected>0 SELECTED</StyledNoOptionsSelected>\n )}\n </StyledSelectedItems>\n </StyledHeaderListWrapper>\n );\n};\n\nexport { HeaderList };\n"],
5
- "mappings": "AAAA;ACGA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AACA;AACA,MAAM,aAAa,MAAmB;AACpC,QAAM;AAAA,IACJ,OAAO,EAAE,aAAa,YAAY;AAAA,IAClC;AAAA,IACA;AAAA,MACE,WAAW;AAEf,QAAM,sBAAsB,gBAAgB;AAC5C,QAAM,qBAAqB,eAAe;AAE1C,QAAM,sBAAsB;AAC5B,QAAM,EAAE,eAAe,mBAAmB,cAAc,gBAAgB,kCACtE;AAEF,SACE,qCAAC,yBAAD;AAAA,IAAyB,WAAW;AAAA,IAAe,aAAa;AAAA,KAC9D,qCAAC,yBAAD,MACG,uBAAuB,sBACtB,qCAAC,sBAAD;AAAA,IACE,SAAS;AAAA,IACT,cAAc,mBAAmB,UAAU,oBAAoB,IAAI,CAAC,SAAS,KAAK,MAAM,KAAK,OAAO;AAAA,IACpG,MAAK;AAAA,IACL,WAAU;AAAA,IACV,IAAG;AAAA,IACH,UAAU;AAAA,IACV,eAAa,mBAAmB;AAAA,IAChC,QAAQ,MAAM;AACZ,UAAI,oBAAoB,WAAW,GAAG;AACpC,mBAAW,MAAM,SAAS,SAAS;AAAA;AAAA;AAAA,OAM7C,qCAAC,qBAAD,MACG,oBAAoB,SAAS,IAC5B,qCAAC,uBAAD;AAAA,IACE,QAAQ,MAAM;AACZ,iBAAW,MAAM,SAAS,SAAS;AAAA;AAAA,IAErC,YAAW;AAAA,IACX,SAAS;AAAA,IACT,WAAW,CAAC,sBAAsB,kBAAkB,oBAAoB,YAAY;AAAA,IACpF,MAAK;AAAA,IACL,eAAa,mBAAmB;AAAA,OAGlC,qCAAC,yBAAD,MAAyB;AAAA;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport React, { useContext } from 'react';\nimport { noop } from 'lodash';\nimport { DSControlledCheckbox } from '@elliemae/ds-controlled-form';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport {\n StyledHeaderListWrapper,\n StyledButtonSelection,\n StyledSelectedItems,\n StyledSelectAllCheckbox,\n StyledNoOptionsSelected,\n} from './styled';\nimport { CBItemOption } from '../../index.d';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport { useHeaderListHandlers } from './useHeaderListHandlers';\nconst HeaderList = (): JSX.Element => {\n const {\n props: { onSelectAll, onClearAll, selectedValues },\n showSelectedOptions,\n inputRef,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n } = useContext(ComboBoxContext);\n\n const isSelectAllSupplied = onSelectAll !== noop;\n const isClearAllSupplied = onClearAll !== noop;\n\n const multiSelectedValues = selectedValues as CBItemOption[];\n const { handleKeyDown, handleOnMouseDown, handleToggle, checkboxStatus, handleSelectAllCheckboxChange } =\n useHeaderListHandlers();\n\n return (\n <StyledHeaderListWrapper onKeyDown={handleKeyDown} onMouseDown={handleOnMouseDown}>\n <StyledSelectAllCheckbox>\n {isSelectAllSupplied && isClearAllSupplied && (\n <DSControlledCheckbox\n checked={checkboxStatus}\n ariaControls={checkboxStatus === 'mixed' ? multiSelectedValues.map((item) => item.dsId).join(' ') : ''}\n name=\"select-all-checkbox\"\n ariaLabel=\"Select/Unselect All Items\"\n id=\"select-all-checkbox\"\n onChange={handleSelectAllCheckboxChange}\n data-testid={ComboboxDataTestid.SELECT_ALL_CHECKBOX}\n onBlur={() => {\n if (multiSelectedValues.length === 0) {\n setTimeout(() => inputRef.current?.focus());\n }\n }}\n innerRef={selectAllCheckboxRef}\n />\n )}\n </StyledSelectAllCheckbox>\n <StyledSelectedItems>\n {multiSelectedValues.length > 0 ? (\n <StyledButtonSelection\n onBlur={() => {\n setTimeout(() => inputRef.current?.focus());\n }}\n buttonType=\"text\"\n onClick={handleToggle}\n labelText={!showSelectedOptions ? `SHOW SELECTED [${multiSelectedValues.length}]` : 'SHOW ALL'}\n size=\"s\"\n data-testid={ComboboxDataTestid.SHOW_SELECTED_OPTIONS_TOGGLE}\n innerRef={toggleSelectionButtonRef}\n />\n ) : (\n <StyledNoOptionsSelected>0 SELECTED</StyledNoOptionsSelected>\n )}\n </StyledSelectedItems>\n </StyledHeaderListWrapper>\n );\n};\n\nexport { HeaderList };\n"],
5
+ "mappings": "AAAA;ACGA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AACA;AACA,MAAM,aAAa,MAAmB;AACpC,QAAM;AAAA,IACJ,OAAO,EAAE,aAAa,YAAY;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW;AAEf,QAAM,sBAAsB,gBAAgB;AAC5C,QAAM,qBAAqB,eAAe;AAE1C,QAAM,sBAAsB;AAC5B,QAAM,EAAE,eAAe,mBAAmB,cAAc,gBAAgB,kCACtE;AAEF,SACE,qCAAC,yBAAD;AAAA,IAAyB,WAAW;AAAA,IAAe,aAAa;AAAA,KAC9D,qCAAC,yBAAD,MACG,uBAAuB,sBACtB,qCAAC,sBAAD;AAAA,IACE,SAAS;AAAA,IACT,cAAc,mBAAmB,UAAU,oBAAoB,IAAI,CAAC,SAAS,KAAK,MAAM,KAAK,OAAO;AAAA,IACpG,MAAK;AAAA,IACL,WAAU;AAAA,IACV,IAAG;AAAA,IACH,UAAU;AAAA,IACV,eAAa,mBAAmB;AAAA,IAChC,QAAQ,MAAM;AACZ,UAAI,oBAAoB,WAAW,GAAG;AACpC,mBAAW,MAAM,SAAS,SAAS;AAAA;AAAA;AAAA,IAGvC,UAAU;AAAA,OAIhB,qCAAC,qBAAD,MACG,oBAAoB,SAAS,IAC5B,qCAAC,uBAAD;AAAA,IACE,QAAQ,MAAM;AACZ,iBAAW,MAAM,SAAS,SAAS;AAAA;AAAA,IAErC,YAAW;AAAA,IACX,SAAS;AAAA,IACT,WAAW,CAAC,sBAAsB,kBAAkB,oBAAoB,YAAY;AAAA,IACpF,MAAK;AAAA,IACL,eAAa,mBAAmB;AAAA,IAChC,UAAU;AAAA,OAGZ,qCAAC,yBAAD,MAAyB;AAAA;",
6
6
  "names": []
7
7
  }
@@ -16,7 +16,9 @@ const propTypes = {
16
16
  inputMinWidth: PropTypes.any.description("Minimum width for the combo box input controller").defaultValue(void 0),
17
17
  menuMinWidth: PropTypes.any.description("Minimum width for the dropdown menu").defaultValue(void 0),
18
18
  menuMaxHeight: PropTypes.any.description("Maximum height for the dropdown menu").defaultValue(void 0),
19
- withToggle: PropTypes.bool.description("POC purpose this prop will not remain").defaultValue("false")
19
+ withToggle: PropTypes.bool.description("POC purpose this prop will not remain").defaultValue("false"),
20
+ withoutPortal: PropTypes.bool.description("Whether the combobox menu is rendered in a portal or not").defaultValue(false),
21
+ zIndex: PropTypes.number.description("The z-index of the combobox menu").defaultValue(10)
20
22
  };
21
23
  export {
22
24
  propTypes
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/controlled-combobox/propTypes.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from 'react-desc';\n\nexport const propTypes = {\n placeholder: PropTypes.string.description('input s placeholder value').defaultValue(''),\n options: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).description('List of options').defaultValue([]),\n selectedValues: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]).description(\n 'Array of option or single option selected',\n ),\n autoFocus: PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),\n hasError: PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),\n onChange: PropTypes.func\n .description('function triggered when an option is selected it will send the options selected')\n .defaultValue(''),\n onSelectAll: PropTypes.func\n .description('function triggered when ALL button is selected from the header menu list')\n .defaultValue(''),\n onFilter: PropTypes.func.description('function triggered when user type in the combobox input').defaultValue(''),\n onCreate: PropTypes.func\n .description(\n 'function triggered when user select \"create\" a new item whenever is not a match in the all option list',\n )\n .defaultValue(''),\n onClearAll: PropTypes.func\n .description('function triggered when user select CLEAR button from the header menu list')\n .defaultValue(''),\n onCancel: PropTypes.func.description('function triggered when user press ESC key').defaultValue(''),\n onMenuOpen: PropTypes.func.description('function triggered when user open the menu list').defaultValue(''),\n inputMinWidth: PropTypes.any.description('Minimum width for the combo box input controller').defaultValue(undefined),\n menuMinWidth: PropTypes.any.description('Minimum width for the dropdown menu').defaultValue(undefined),\n menuMaxHeight: PropTypes.any.description('Maximum height for the dropdown menu').defaultValue(undefined),\n withToggle: PropTypes.bool.description('POC purpose this prop will not remain').defaultValue('false'),\n};\n"],
5
- "mappings": "AAAA;ACAA;AAEO,MAAM,YAAY;AAAA,EACvB,aAAa,UAAU,OAAO,YAAY,6BAA6B,aAAa;AAAA,EACpF,SAAS,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,SAAS,YAAY,mBAAmB,aAAa;AAAA,EAC9G,gBAAgB,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,SAAS,UAAU,SAAS,YAC3F;AAAA,EAEF,WAAW,UAAU,KAAK,YAAY,gDAAgD,aAAa;AAAA,EACnG,UAAU,UAAU,KAAK,YAAY,0CAA0C,aAAa;AAAA,EAC5F,UAAU,UAAU,KACjB,YAAY,mFACZ,aAAa;AAAA,EAChB,aAAa,UAAU,KACpB,YAAY,4EACZ,aAAa;AAAA,EAChB,UAAU,UAAU,KAAK,YAAY,2DAA2D,aAAa;AAAA,EAC7G,UAAU,UAAU,KACjB,YACC,0GAED,aAAa;AAAA,EAChB,YAAY,UAAU,KACnB,YAAY,8EACZ,aAAa;AAAA,EAChB,UAAU,UAAU,KAAK,YAAY,8CAA8C,aAAa;AAAA,EAChG,YAAY,UAAU,KAAK,YAAY,mDAAmD,aAAa;AAAA,EACvG,eAAe,UAAU,IAAI,YAAY,oDAAoD,aAAa;AAAA,EAC1G,cAAc,UAAU,IAAI,YAAY,uCAAuC,aAAa;AAAA,EAC5F,eAAe,UAAU,IAAI,YAAY,wCAAwC,aAAa;AAAA,EAC9F,YAAY,UAAU,KAAK,YAAY,yCAAyC,aAAa;AAAA;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from 'react-desc';\n\nexport const propTypes = {\n placeholder: PropTypes.string.description('input s placeholder value').defaultValue(''),\n options: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).description('List of options').defaultValue([]),\n selectedValues: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]).description(\n 'Array of option or single option selected',\n ),\n autoFocus: PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),\n hasError: PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),\n onChange: PropTypes.func\n .description('function triggered when an option is selected it will send the options selected')\n .defaultValue(''),\n onSelectAll: PropTypes.func\n .description('function triggered when ALL button is selected from the header menu list')\n .defaultValue(''),\n onFilter: PropTypes.func.description('function triggered when user type in the combobox input').defaultValue(''),\n onCreate: PropTypes.func\n .description(\n 'function triggered when user select \"create\" a new item whenever is not a match in the all option list',\n )\n .defaultValue(''),\n onClearAll: PropTypes.func\n .description('function triggered when user select CLEAR button from the header menu list')\n .defaultValue(''),\n onCancel: PropTypes.func.description('function triggered when user press ESC key').defaultValue(''),\n onMenuOpen: PropTypes.func.description('function triggered when user open the menu list').defaultValue(''),\n inputMinWidth: PropTypes.any.description('Minimum width for the combo box input controller').defaultValue(undefined),\n menuMinWidth: PropTypes.any.description('Minimum width for the dropdown menu').defaultValue(undefined),\n menuMaxHeight: PropTypes.any.description('Maximum height for the dropdown menu').defaultValue(undefined),\n withToggle: PropTypes.bool.description('POC purpose this prop will not remain').defaultValue('false'),\n withoutPortal: PropTypes.bool\n .description('Whether the combobox menu is rendered in a portal or not')\n .defaultValue(false),\n zIndex: PropTypes.number.description('The z-index of the combobox menu').defaultValue(10),\n};\n"],
5
+ "mappings": "AAAA;ACAA;AAEO,MAAM,YAAY;AAAA,EACvB,aAAa,UAAU,OAAO,YAAY,6BAA6B,aAAa;AAAA,EACpF,SAAS,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,SAAS,YAAY,mBAAmB,aAAa;AAAA,EAC9G,gBAAgB,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,SAAS,UAAU,SAAS,YAC3F;AAAA,EAEF,WAAW,UAAU,KAAK,YAAY,gDAAgD,aAAa;AAAA,EACnG,UAAU,UAAU,KAAK,YAAY,0CAA0C,aAAa;AAAA,EAC5F,UAAU,UAAU,KACjB,YAAY,mFACZ,aAAa;AAAA,EAChB,aAAa,UAAU,KACpB,YAAY,4EACZ,aAAa;AAAA,EAChB,UAAU,UAAU,KAAK,YAAY,2DAA2D,aAAa;AAAA,EAC7G,UAAU,UAAU,KACjB,YACC,0GAED,aAAa;AAAA,EAChB,YAAY,UAAU,KACnB,YAAY,8EACZ,aAAa;AAAA,EAChB,UAAU,UAAU,KAAK,YAAY,8CAA8C,aAAa;AAAA,EAChG,YAAY,UAAU,KAAK,YAAY,mDAAmD,aAAa;AAAA,EACvG,eAAe,UAAU,IAAI,YAAY,oDAAoD,aAAa;AAAA,EAC1G,cAAc,UAAU,IAAI,YAAY,uCAAuC,aAAa;AAAA,EAC5F,eAAe,UAAU,IAAI,YAAY,wCAAwC,aAAa;AAAA,EAC9F,YAAY,UAAU,KAAK,YAAY,yCAAyC,aAAa;AAAA,EAC7F,eAAe,UAAU,KACtB,YAAY,4DACZ,aAAa;AAAA,EAChB,QAAQ,UAAU,OAAO,YAAY,oCAAoC,aAAa;AAAA;",
6
6
  "names": []
7
7
  }
@@ -5,14 +5,27 @@ import { findInCircularList } from "../listHelper";
5
5
  const isOptionFocuseable = (opt) => !["section", "separator"].includes(opt.type);
6
6
  const useKeyboardNavigation = () => {
7
7
  const {
8
- props: { inline, onSelectAll, onCancel, onKeyDown, onChange, onCreate, options, selectedValues, onFilter },
8
+ props: {
9
+ inline,
10
+ onSelectAll,
11
+ onCancel,
12
+ onKeyDown,
13
+ onChange,
14
+ onCreate,
15
+ options,
16
+ selectedValues,
17
+ onFilter,
18
+ withoutPortal
19
+ },
9
20
  setShowPopover,
10
21
  showPopover,
11
22
  setShowSelectedValue,
12
23
  focusOptionIdx,
13
24
  inputRef,
14
25
  setCurrentOption,
15
- scrollOptionIntoView
26
+ scrollOptionIntoView,
27
+ selectAllCheckboxRef,
28
+ toggleSelectionButtonRef
16
29
  } = useContext(ComboBoxContext);
17
30
  const multiple = Array.isArray(selectedValues);
18
31
  const currentItemIndex = options.findIndex((opt) => opt.dsId === focusOptionIdx);
@@ -109,6 +122,13 @@ const useKeyboardNavigation = () => {
109
122
  onFilter("");
110
123
  setShowSelectedValue(true);
111
124
  }
125
+ if (e.key === "Tab" && !inline && !withoutPortal) {
126
+ const element = selectAllCheckboxRef.current ?? toggleSelectionButtonRef.current;
127
+ if (element) {
128
+ e.preventDefault();
129
+ element.focus();
130
+ }
131
+ }
112
132
  if (e.key === "Tab" && inline) {
113
133
  }
114
134
  }, [
@@ -130,7 +150,10 @@ const useKeyboardNavigation = () => {
130
150
  setShowPopover,
131
151
  setShowSelectedValue,
132
152
  selectOption,
133
- onCancel
153
+ onCancel,
154
+ selectAllCheckboxRef,
155
+ toggleSelectionButtonRef,
156
+ withoutPortal
134
157
  ]);
135
158
  return { onInputKeyDown };
136
159
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/controlled-combobox/utils/hooks/useKeyboardNavigation.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext } from 'react';\nimport { CBOptionT } from '../../index.d';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport { findInCircularList } from '../listHelper';\n\nconst isOptionFocuseable = (opt: CBOptionT): boolean => !['section', 'separator'].includes(opt.type);\n\nexport const useKeyboardNavigation = () => {\n const {\n props: { inline, onSelectAll, onCancel, onKeyDown, onChange, onCreate, options, selectedValues, onFilter },\n setShowPopover,\n showPopover,\n setShowSelectedValue,\n focusOptionIdx,\n inputRef,\n setCurrentOption,\n scrollOptionIntoView,\n } = useContext(ComboBoxContext);\n\n const multiple = Array.isArray(selectedValues);\n\n const currentItemIndex = options.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = options.find((item) => item.dsId === focusOptionIdx);\n const selectOption = useCallback(() => {\n if (multiple) {\n if (inputRef.current) onFilter(inputRef.current.value);\n } else {\n onFilter('');\n if (inputRef.current) inputRef.current.value = '';\n setShowSelectedValue(true);\n }\n onChange(options.find((item) => item.dsId === focusOptionIdx));\n setShowPopover(multiple ? true : !showPopover);\n }, [\n multiple,\n options,\n focusOptionIdx,\n setShowPopover,\n showPopover,\n onFilter,\n inputRef,\n setShowSelectedValue,\n onChange,\n ]);\n\n const onInputKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n const targetElement = e.target as HTMLInputElement;\n\n // =============================================================================\n // CUSTOM KEYS\n // =============================================================================\n onKeyDown(e, currentItem);\n // =============================================================================\n // ENTER KEY TO CREATE ELEMENTS\n // =============================================================================\n if (e.key === 'Enter' && currentItem?.type === 'creatable') {\n onCreate(targetElement.value);\n onFilter('');\n if (inputRef.current) inputRef.current.value = '';\n return;\n }\n\n // =============================================================================\n // Enter and space on selection\n // =============================================================================\n if (e.key === 'Enter' || (e.keyCode === 32 && e.altKey)) {\n e.preventDefault();\n if (!showPopover && !inline) {\n setShowPopover(true);\n } else {\n selectOption();\n }\n }\n\n if (e.key === 'Enter' && e.altKey) {\n setShowPopover(false);\n }\n\n if (e.key === 'a' && e.ctrlKey && multiple) {\n onSelectAll();\n }\n // =============================================================================\n // ARROWS UP AND DOWN\n // =============================================================================\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n if (showPopover || inline) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n } else {\n setShowPopover(true);\n }\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n if (showPopover || inline) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n } else {\n setShowPopover(true);\n setTimeout(() => {\n const nextItemIndex = findInCircularList(options, 0, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n });\n }\n }\n // =============================================================================\n // ESCAPE\n // =============================================================================\n if (e.key === 'Escape') {\n if (onCancel) onCancel();\n if (inputRef.current && inputRef.current?.value !== '') {\n onFilter('');\n inputRef.current.value = '';\n }\n if (!inline) setShowPopover(false);\n }\n // =============================================================================\n // BACKSPACE\n // =============================================================================\n if (e.key === 'Backspace' && targetElement.value.length <= 0 && !inline) {\n if (multiple && !targetElement.value) {\n if (selectedValues.length > 0) onChange(selectedValues[selectedValues.length - 1]);\n } else {\n onChange(null);\n }\n onFilter('');\n setShowSelectedValue(true);\n }\n\n if (e.key === 'Tab' && inline) {\n // TODO confirm funcionality\n // e.preventDefault();\n }\n },\n [\n currentItemIndex,\n options,\n currentItem,\n inputRef,\n multiple,\n showPopover,\n selectedValues,\n inline,\n scrollOptionIntoView,\n onKeyDown,\n onSelectAll,\n onChange,\n onCreate,\n onFilter,\n setCurrentOption,\n setShowPopover,\n setShowSelectedValue,\n selectOption,\n onCancel,\n ],\n );\n\n return { onInputKeyDown };\n};\n"],
5
- "mappings": "AAAA;ACIA;AAEA;AACA;AAEA,MAAM,qBAAqB,CAAC,QAA4B,CAAC,CAAC,WAAW,aAAa,SAAS,IAAI;AAExF,MAAM,wBAAwB,MAAM;AACzC,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ,aAAa,UAAU,WAAW,UAAU,UAAU,SAAS,gBAAgB;AAAA,IAChG;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW;AAEf,QAAM,WAAW,MAAM,QAAQ;AAE/B,QAAM,mBAAmB,QAAQ,UAAU,CAAC,QAAQ,IAAI,SAAS;AACjE,QAAM,cAAc,QAAQ,KAAK,CAAC,SAAS,KAAK,SAAS;AACzD,QAAM,eAAe,YAAY,MAAM;AACrC,QAAI,UAAU;AACZ,UAAI,SAAS;AAAS,iBAAS,SAAS,QAAQ;AAAA,WAC3C;AACL,eAAS;AACT,UAAI,SAAS;AAAS,iBAAS,QAAQ,QAAQ;AAC/C,2BAAqB;AAAA;AAEvB,aAAS,QAAQ,KAAK,CAAC,SAAS,KAAK,SAAS;AAC9C,mBAAe,WAAW,OAAO,CAAC;AAAA,KACjC;AAAA,IACD;AAAA,IACA;AAAA,IAC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,iBAAS,QAAQ,QAAQ;AAAA;AAE3B,UAAI,CAAC;AAAQ,uBAAe;AAAA;AAK9B,QAAI,EAAE,QAAQ,eAAe,cAAc,MAAM,UAAU,KAAK,CAAC,QAAQ;AACvE,UAAI,YAAY,CAAC,cAAc,OAAO;AACpC,YAAI,eAAe,SAAS;AAAG,mBAAS,eAAe,eAAe,SAAS;AAAA,aAC1E;AACL,iBAAS;AAAA;AAEX,eAAS;AACT,2BAAqB;AAAA;AAGvB,QAAI,EAAE,QAAQ,SAAS,QAAQ;AAAA;AAAA,KAKjC;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAIJ,SAAO,EAAE;AAAA;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext } from 'react';\nimport { CBOptionT } from '../../index.d';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport { findInCircularList } from '../listHelper';\n\nconst isOptionFocuseable = (opt: CBOptionT): boolean => !['section', 'separator'].includes(opt.type);\n\nexport const useKeyboardNavigation = () => {\n const {\n props: {\n inline,\n onSelectAll,\n onCancel,\n onKeyDown,\n onChange,\n onCreate,\n options,\n selectedValues,\n onFilter,\n withoutPortal,\n },\n setShowPopover,\n showPopover,\n setShowSelectedValue,\n focusOptionIdx,\n inputRef,\n setCurrentOption,\n scrollOptionIntoView,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n } = useContext(ComboBoxContext);\n\n const multiple = Array.isArray(selectedValues);\n\n const currentItemIndex = options.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = options.find((item) => item.dsId === focusOptionIdx);\n const selectOption = useCallback(() => {\n if (multiple) {\n if (inputRef.current) onFilter(inputRef.current.value);\n } else {\n onFilter('');\n if (inputRef.current) inputRef.current.value = '';\n setShowSelectedValue(true);\n }\n onChange(options.find((item) => item.dsId === focusOptionIdx));\n setShowPopover(multiple ? true : !showPopover);\n }, [\n multiple,\n options,\n focusOptionIdx,\n setShowPopover,\n showPopover,\n onFilter,\n inputRef,\n setShowSelectedValue,\n onChange,\n ]);\n\n const onInputKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n const targetElement = e.target as HTMLInputElement;\n\n // =============================================================================\n // CUSTOM KEYS\n // =============================================================================\n onKeyDown(e, currentItem);\n // =============================================================================\n // ENTER KEY TO CREATE ELEMENTS\n // =============================================================================\n if (e.key === 'Enter' && currentItem?.type === 'creatable') {\n onCreate(targetElement.value);\n onFilter('');\n if (inputRef.current) inputRef.current.value = '';\n return;\n }\n\n // =============================================================================\n // Enter and space on selection\n // =============================================================================\n if (e.key === 'Enter' || (e.keyCode === 32 && e.altKey)) {\n e.preventDefault();\n if (!showPopover && !inline) {\n setShowPopover(true);\n } else {\n selectOption();\n }\n }\n\n if (e.key === 'Enter' && e.altKey) {\n setShowPopover(false);\n }\n\n if (e.key === 'a' && e.ctrlKey && multiple) {\n onSelectAll();\n }\n // =============================================================================\n // ARROWS UP AND DOWN\n // =============================================================================\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n if (showPopover || inline) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n } else {\n setShowPopover(true);\n }\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n if (showPopover || inline) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n } else {\n setShowPopover(true);\n setTimeout(() => {\n const nextItemIndex = findInCircularList(options, 0, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n });\n }\n }\n // =============================================================================\n // ESCAPE\n // =============================================================================\n if (e.key === 'Escape') {\n if (onCancel) onCancel();\n if (inputRef.current && inputRef.current?.value !== '') {\n onFilter('');\n inputRef.current.value = '';\n }\n if (!inline) setShowPopover(false);\n }\n // =============================================================================\n // BACKSPACE\n // =============================================================================\n if (e.key === 'Backspace' && targetElement.value.length <= 0 && !inline) {\n if (multiple && !targetElement.value) {\n if (selectedValues.length > 0) onChange(selectedValues[selectedValues.length - 1]);\n } else {\n onChange(null);\n }\n onFilter('');\n setShowSelectedValue(true);\n }\n\n if (e.key === 'Tab' && !inline && !withoutPortal) {\n const element = selectAllCheckboxRef.current ?? toggleSelectionButtonRef.current;\n if (element) {\n e.preventDefault();\n element.focus();\n }\n }\n\n if (e.key === 'Tab' && inline) {\n // TODO confirm funcionality\n // e.preventDefault();\n }\n },\n [\n currentItemIndex,\n options,\n currentItem,\n inputRef,\n multiple,\n showPopover,\n selectedValues,\n inline,\n scrollOptionIntoView,\n onKeyDown,\n onSelectAll,\n onChange,\n onCreate,\n onFilter,\n setCurrentOption,\n setShowPopover,\n setShowSelectedValue,\n selectOption,\n onCancel,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n withoutPortal,\n ],\n );\n\n return { onInputKeyDown };\n};\n"],
5
+ "mappings": "AAAA;ACIA;AAEA;AACA;AAEA,MAAM,qBAAqB,CAAC,QAA4B,CAAC,CAAC,WAAW,aAAa,SAAS,IAAI;AAExF,MAAM,wBAAwB,MAAM;AACzC,QAAM;AAAA,IACJ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAEF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,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A,IACA;AAAA;AAIJ,SAAO,EAAE;AAAA;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-controlled-form",
3
- "version": "2.3.0-alpha.2",
3
+ "version": "2.3.0-alpha.3",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Controlled Form Controllers",
6
6
  "module": "./esm/index.js",
@@ -744,15 +744,15 @@
744
744
  "build": "node ../../scripts/build/build.js"
745
745
  },
746
746
  "dependencies": {
747
- "@elliemae/ds-button": "2.3.0-alpha.2",
748
- "@elliemae/ds-form-layout-blocks": "2.3.0-alpha.2",
749
- "@elliemae/ds-grid": "2.3.0-alpha.2",
750
- "@elliemae/ds-icon": "2.3.0-alpha.2",
751
- "@elliemae/ds-icons": "2.3.0-alpha.2",
752
- "@elliemae/ds-props-helpers": "2.3.0-alpha.2",
753
- "@elliemae/ds-system": "2.3.0-alpha.2",
754
- "@elliemae/ds-tooltip": "2.3.0-alpha.2",
755
- "@elliemae/ds-truncated-tooltip-text": "2.3.0-alpha.2",
747
+ "@elliemae/ds-button": "2.3.0-alpha.3",
748
+ "@elliemae/ds-form-layout-blocks": "2.3.0-alpha.3",
749
+ "@elliemae/ds-grid": "2.3.0-alpha.3",
750
+ "@elliemae/ds-icon": "2.3.0-alpha.3",
751
+ "@elliemae/ds-icons": "2.3.0-alpha.3",
752
+ "@elliemae/ds-props-helpers": "2.3.0-alpha.3",
753
+ "@elliemae/ds-system": "2.3.0-alpha.3",
754
+ "@elliemae/ds-tooltip": "2.3.0-alpha.3",
755
+ "@elliemae/ds-truncated-tooltip-text": "2.3.0-alpha.3",
756
756
  "prop-types": "~15.7.2",
757
757
  "react-desc": "~4.1.3",
758
758
  "react-popper": "~2.2.5",
@@ -55,6 +55,12 @@ declare const DSComboBox: {
55
55
  withToggle: {
56
56
  deprecated: import("react-desc").PropTypesDescValidator;
57
57
  };
58
+ withoutPortal: {
59
+ deprecated: import("react-desc").PropTypesDescValidator;
60
+ };
61
+ zIndex: {
62
+ deprecated: import("react-desc").PropTypesDescValidator;
63
+ };
58
64
  };
59
65
  };
60
66
  declare const DSComboBoxWithSchema: {
@@ -51,4 +51,10 @@ export declare const propTypes: {
51
51
  withToggle: {
52
52
  deprecated: import("react-desc").PropTypesDescValidator;
53
53
  };
54
+ withoutPortal: {
55
+ deprecated: import("react-desc").PropTypesDescValidator;
56
+ };
57
+ zIndex: {
58
+ deprecated: import("react-desc").PropTypesDescValidator;
59
+ };
54
60
  };