@economic/taco 2.26.19 → 2.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. package/dist/components/Report/Report.d.ts +1 -1
  2. package/dist/components/Report/types.d.ts +1 -1
  3. package/dist/components/Report/useReport.d.ts +2 -2
  4. package/dist/components/Select2/Select2.d.ts +2 -0
  5. package/dist/components/Select2/utilities.d.ts +2 -0
  6. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js +1 -1
  7. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
  8. package/dist/esm/packages/taco/src/components/Report/useReport.js.map +1 -1
  9. package/dist/esm/packages/taco/src/components/Select2/Select2.js +14 -2
  10. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/Select2/components/Option.js +2 -6
  12. package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +3 -6
  14. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Select2/utilities.js +14 -1
  16. package/dist/esm/packages/taco/src/components/Select2/utilities.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +2 -2
  18. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
  19. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +4 -2
  20. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  21. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +15 -6
  22. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  23. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js +15 -6
  24. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
  25. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +10 -3
  26. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  27. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  28. package/dist/esm/packages/taco/src/utils/date.js +2 -2
  29. package/dist/esm/packages/taco/src/utils/date.js.map +1 -1
  30. package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +11 -2
  31. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.d.ts +1 -1
  32. package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +1 -1
  33. package/dist/primitives/Table/Core/useTable.d.ts +1 -1
  34. package/dist/taco.cjs.development.js +73 -31
  35. package/dist/taco.cjs.development.js.map +1 -1
  36. package/dist/taco.cjs.production.min.js +1 -1
  37. package/dist/taco.cjs.production.min.js.map +1 -1
  38. package/dist/utils/date.d.ts +1 -1
  39. package/package.json +2 -2
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { ReportRef, ReportProps, ReportColumnProps, ReportGroupProps } from './types';
3
3
  declare function Column<TType = unknown>(_: ReportColumnProps<TType>): null;
4
4
  declare function Group(_: ReportGroupProps): null;
5
- export declare const Report: (<TType = unknown>(props: (import("../..").TableClientProps<TType> & React.RefAttributes<import("../..").TableRef>) | (import("../..").TableServerProps<TType> & React.RefAttributes<import("../..").TableRef>)) => JSX.Element) & {
5
+ export declare const Report: (<TType = unknown>(props: Pick<import("../..").TableProps<TType>, "length" | "loadAll" | "loadPage" | "pageSize" | "enableFiltering" | "enableSearch" | "enableSorting" | "enableColumnFreezing" | "enableColumnHiding" | "enableColumnResizing" | "enableRowExpansion" | "enableRowSelection" | "enableRowSelectionSingle" | "enableColumnOrdering" | "enableFontSize" | "enableFooter" | "enablePrinting" | "enableRowActions" | "enableRowActive" | "enableRowClick" | "enableRowDrag" | "enableRowDrop" | "enableRowGoto" | "enableRowHeight" | "enableSaveSettings" | "children" | "data" | "id" | "customSettings" | "defaultColumnFreezingIndex" | "defaultRowActiveIndex" | "defaultRowGroupColumnId" | "defaultSettings" | "emptyState" | "rowActions" | "rowActionsForGroup" | "rowActionsLength" | "rowExpansionRenderer" | "rowIdentityColumnId" | "shortcuts" | "toolbarLeft" | "toolbarRight" | "toolbarPanel" | "onRowClick" | "onRowDrag" | "onRowDrop" | "onRowGoto" | "onRowSelect" | "onChangeFilter" | "onChangeSearch" | "onChangeSettings" | "onChangeSort"> & React.RefAttributes<import("../..").TableRef>) => JSX.Element) & {
6
6
  Column: typeof Column;
7
7
  Group: typeof Group;
8
8
  };
@@ -1,5 +1,5 @@
1
1
  import { TableProps, TableRef, TableColumnProps, TableGroupProps } from '../../primitives/Table/types';
2
2
  export declare type ReportRef = TableRef;
3
- export declare type ReportProps<TType = unknown> = TableProps<TType>;
3
+ export declare type ReportProps<TType = unknown> = Omit<TableProps<TType>, 'preset'>;
4
4
  export declare type ReportColumnProps<TType = unknown> = TableColumnProps<TType>;
5
5
  export declare type ReportGroupProps = TableGroupProps;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { TableRef } from '../../primitives/Table/types';
3
3
  import { useTableReturnValue } from '../../primitives/Table/Core/useTable';
4
- import { TableProps } from '../../primitives/Table/types';
5
- export declare function useReport<TType>(props: TableProps<TType>, ref: React.Ref<TableRef>): useTableReturnValue<TType>;
4
+ import { ReportProps } from './types';
5
+ export declare function useReport<TType>(props: ReportProps<TType>, ref: React.Ref<TableRef>): useTableReturnValue<TType>;
@@ -34,6 +34,8 @@ declare type Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'child
34
34
  highlighted?: boolean;
35
35
  /** Whether the Select2 is in an invalid state **/
36
36
  invalid?: boolean;
37
+ /** Whether the Select2 is loading the data **/
38
+ loading?: boolean;
37
39
  /** Whether the Select2 allows selecting multiple values **/
38
40
  multiple?: boolean;
39
41
  /** Whether the Select2 is in an invalid state **/
@@ -1,2 +1,4 @@
1
+ import { FontSize } from '../../types';
1
2
  export declare const createOptionClassName: (shouldPauseHoverState?: boolean) => string;
2
3
  export declare const createCollectionClassName: () => string;
4
+ export declare const getFontSize: (fontSize: FontSize) => "text-xs" | "text-sm" | "text-base";
@@ -32,7 +32,7 @@ const useDatepicker = ({
32
32
  // event handlers
33
33
  const handleInputBlur = event => {
34
34
  event.persist();
35
- const valueAsDate = parseFromCustomString(event.target.value);
35
+ const valueAsDate = parseFromCustomString(event.target.value, 'dd.mm.yy', value === null || value === void 0 ? void 0 : value.getFullYear());
36
36
  const formattedValue = valueAsDate ? format(valueAsDate) || '' : '';
37
37
  event.target.value = formattedValue;
38
38
  if (onChange) {
@@ -1 +1 @@
1
- {"version":3,"file":"useDatepicker.js","sources":["../../../../../../../src/components/Datepicker/useDatepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { parseFromCustomString, format } from '../../utils/date';\nimport { useLocalization } from '../Provider/Localization';\nimport { setInputValueByRef } from '../../utils/input';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { DatepickerProps } from './Datepicker';\nimport { CalendarProps } from '../Calendar/Calendar';\nimport { InputProps as BaseInputProps } from '../Input/Input';\nimport { isValid } from 'date-fns';\n\ntype InputProps = BaseInputProps & { ref: React.RefObject<HTMLInputElement> };\ntype useDatepicker = React.HTMLAttributes<HTMLDivElement> & {\n calendar: CalendarProps;\n input: InputProps;\n};\n\nexport const useDatepicker = (\n { defaultValue: _, calendar, onBlur, onChange, value, ...props }: DatepickerProps,\n ref: React.Ref<HTMLInputElement>\n): useDatepicker => {\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const { formatting } = useLocalization();\n const [internalValue, setInternalValue] = React.useState(value && isValid(value) ? format(value, formatting.date) : '');\n\n // update internal value if it changed 'externally'\n React.useEffect(() => {\n if (value && isValid(value)) {\n const formattedValue = format(value, formatting.date);\n\n if (formattedValue !== internalValue) {\n setInternalValue(formattedValue);\n }\n } else {\n setInternalValue('');\n }\n }, [value]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n const valueAsDate = parseFromCustomString(event.target.value);\n const formattedValue = valueAsDate ? format(valueAsDate) || '' : '';\n\n event.target.value = formattedValue;\n\n if (onChange) {\n (event as any).detail = valueAsDate;\n onChange(event);\n } else {\n // update the internal value to use the formatted date\n setInternalValue(formattedValue);\n }\n\n if (onBlur) {\n onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInternalValue(event.target.value);\n };\n\n const handleChange = date => {\n setInputValueByRef(inputRef.current, format(date, formatting.date), 'focusout');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (props.onKeyDown) {\n props.onKeyDown(event);\n }\n\n if (!event.isPropagationStopped() && !event.isDefaultPrevented() && event.key === 'Enter') {\n event.target.dispatchEvent(new Event('focusout', { bubbles: true }));\n }\n };\n\n const inputProps: InputProps = {\n ...props,\n autoComplete: 'off',\n onBlur: handleInputBlur,\n onChange: handleInputChange,\n onKeyDown: handleKeyDown,\n ref: inputRef,\n type: 'text',\n value: internalValue,\n };\n\n const calendarProps: CalendarProps = {\n ...calendar,\n onChange: handleChange,\n value,\n };\n\n return {\n input: inputProps,\n calendar: calendarProps,\n };\n};\n"],"names":["useDatepicker","defaultValue","_","calendar","onBlur","onChange","value","props","ref","inputRef","useMergedRef","formatting","useLocalization","internalValue","setInternalValue","React","isValid","format","date","formattedValue","handleInputBlur","event","persist","valueAsDate","parseFromCustomString","target","detail","handleInputChange","handleChange","setInputValueByRef","current","handleKeyDown","onKeyDown","isPropagationStopped","isDefaultPrevented","key","dispatchEvent","Event","bubbles","inputProps","autoComplete","type","calendarProps","input"],"mappings":";;;;;;;MAgBaA,aAAa,GAAGA,CACzB;EAAEC,YAAY,EAAEC,CAAC;EAAEC,QAAQ;EAAEC,MAAM;EAAEC,QAAQ;EAAEC,KAAK;EAAE,GAAGC;CAAwB,EACjFC,GAAgC;EAEhC,MAAMC,QAAQ,GAAGC,YAAY,CAAmBF,GAAG,CAAC;EACpD,MAAM;IAAEG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ACO,IAAI,CAAC,EAAE,UAAU,CAAC;GAClF;EAED,MAAMa,aAAa,GAAIV,KAA4C;IAC/D,IAAId,KAAK,CAACyB,SAAS,EAAE;MACjBzB,KAAK,CAACyB,SAAS,CAACX,KAAK,CAAC;;IAG1B,IAAI,CAACA,KAAK,CAACY,oBAAoB,EAAE,IAAI,CAACZ,KAAK,CAACa,kBAAkB,EAAE,IAAIb,KAAK,CAACc,GAAG,KAAK,OAAO,EAAE;MACvFd,KAAK,CAACI,MAAM,CAACW,aAAa,CAAC,IAAIC,KAAK,CAAC,UAAU,EAAE;QAAEC,OAAO,EAAE;OAAM,CAAC,CAAC;;GAE3E;EAED,MAAMC,UAAU,GAAe;IAC3B,GAAGhC,KAAK;IACRiC,YAAY,EAAE,KAAK;IACnBpC,MAAM,EAAEgB,eAAe;IACvBf,QAAQ,EAAEsB,iBAAiB;IAC3BK,SAAS,EAAED,aAAa;IACxBvB,GAAG,EAAEC,QAAQ;IACbgC,IAAI,EAAE,MAAM;IACZnC,KAAK,EAAEO;GACV;EAED,MAAM6B,aAAa,GAAkB;IACjC,GAAGvC,QAAQ;IACXE,QAAQ,EAAEuB,YAAY;IACtBtB;GACH;EAED,OAAO;IACHqC,KAAK,EAAEJ,UAAU;IACjBpC,QAAQ,EAAEuC;GACb;AACL;;;;"}
1
+ {"version":3,"file":"useDatepicker.js","sources":["../../../../../../../src/components/Datepicker/useDatepicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { parseFromCustomString, format } from '../../utils/date';\nimport { useLocalization } from '../Provider/Localization';\nimport { setInputValueByRef } from '../../utils/input';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { DatepickerProps } from './Datepicker';\nimport { CalendarProps } from '../Calendar/Calendar';\nimport { InputProps as BaseInputProps } from '../Input/Input';\nimport { isValid } from 'date-fns';\n\ntype InputProps = BaseInputProps & { ref: React.RefObject<HTMLInputElement> };\ntype useDatepicker = React.HTMLAttributes<HTMLDivElement> & {\n calendar: CalendarProps;\n input: InputProps;\n};\n\nexport const useDatepicker = (\n { defaultValue: _, calendar, onBlur, onChange, value, ...props }: DatepickerProps,\n ref: React.Ref<HTMLInputElement>\n): useDatepicker => {\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const { formatting } = useLocalization();\n const [internalValue, setInternalValue] = React.useState(value && isValid(value) ? format(value, formatting.date) : '');\n\n // update internal value if it changed 'externally'\n React.useEffect(() => {\n if (value && isValid(value)) {\n const formattedValue = format(value, formatting.date);\n\n if (formattedValue !== internalValue) {\n setInternalValue(formattedValue);\n }\n } else {\n setInternalValue('');\n }\n }, [value]);\n\n // event handlers\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>): void => {\n event.persist();\n\n const valueAsDate = parseFromCustomString(event.target.value, 'dd.mm.yy', value?.getFullYear());\n const formattedValue = valueAsDate ? format(valueAsDate) || '' : '';\n\n event.target.value = formattedValue;\n\n if (onChange) {\n (event as any).detail = valueAsDate;\n onChange(event);\n } else {\n // update the internal value to use the formatted date\n setInternalValue(formattedValue);\n }\n\n if (onBlur) {\n onBlur(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setInternalValue(event.target.value);\n };\n\n const handleChange = date => {\n setInputValueByRef(inputRef.current, format(date, formatting.date), 'focusout');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (props.onKeyDown) {\n props.onKeyDown(event);\n }\n\n if (!event.isPropagationStopped() && !event.isDefaultPrevented() && event.key === 'Enter') {\n event.target.dispatchEvent(new Event('focusout', { bubbles: true }));\n }\n };\n\n const inputProps: InputProps = {\n ...props,\n autoComplete: 'off',\n onBlur: handleInputBlur,\n onChange: handleInputChange,\n onKeyDown: handleKeyDown,\n ref: inputRef,\n type: 'text',\n value: internalValue,\n };\n\n const calendarProps: CalendarProps = {\n ...calendar,\n onChange: handleChange,\n value,\n };\n\n return {\n input: inputProps,\n calendar: calendarProps,\n };\n};\n"],"names":["useDatepicker","defaultValue","_","calendar","onBlur","onChange","value","props","ref","inputRef","useMergedRef","formatting","useLocalization","internalValue","setInternalValue","React","isValid","format","date","formattedValue","handleInputBlur","event","persist","valueAsDate","parseFromCustomString","target","getFullYear","detail","handleInputChange","handleChange","setInputValueByRef","current","handleKeyDown","onKeyDown","isPropagationStopped","isDefaultPrevented","key","dispatchEvent","Event","bubbles","inputProps","autoComplete","type","calendarProps","input"],"mappings":";;;;;;;MAgBaA,aAAa,GAAGA,CACzB;EAAEC,YAAY,EAAEC,CAAC;EAAEC,QAAQ;EAAEC,MAAM;EAAEC,QAAQ;EAAEC,KAAK;EAAE,GAAGC;CAAwB,EACjFC,GAAgC;EAEhC,MAAMC,QAAQ,GAAGC,YAAY,CAAmBF,GAAG,CAAC;EACpD,MAAM;IAAEG;GAAY,GAAGC,eAAe,EAAE;EACxC,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGC,QAAc,CAACT,KAAK,IAAIU,OAAO,CAACV,KAAK,CAAC,GAAGW,MAAM,CAACX,KAAK,EAAEK,UAAU,CAACO,IAAI,CAAC,GAAG,EAAE,CAAC;;EAGvHH,SAAe,CAAC;IACZ,IAAIT,KAAK,IAAIU,OAAO,CAACV,KAAK,CAAC,EAAE;MACzB,MAAMa,cAAc,GAAGF,MAAM,CAACX,KAAK,EAAEK,UAAU,CAACO,IAAI,CAAC;MAErD,IAAIC,cAAc,KAAKN,aAAa,EAAE;QAClCC,gBAAgB,CAACK,cAAc,CAAC;;KAEvC,MAAM;MACHL,gBAAgB,CAAC,EAAE,CAAC;;GAE3B,EAAE,CAACR,KAAK,CAAC,CAAC;;EAGX,MAAMc,eAAe,GAAIC,KAAyC;IAC9DA,KAAK,CAACC,OAAO,EAAE;IAEf,MAAMC,WAAW,GAAGC,qBAAqB,CAACH,KAAK,CAACI,MAAM,CAACnB,KAAK,EAAE,UAAU,EAAEA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEoB,WAAW,EAAE,CAAC;IAC/F,MAAMP,cAAc,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AGxC,QAAQ;IACXE,QAAQ,EAAEwB,YAAY;IACtBvB;GACH;EAED,OAAO;IACHsC,KAAK,EAAEJ,UAAU;IACjBrC,QAAQ,EAAEwC;GACb;AACL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useReport.js","sources":["../../../../../../../src/components/Report/useReport.tsx"],"sourcesContent":["import React from 'react';\nimport { TableRef } from '../../primitives/Table/types';\nimport { useTable, useTableReturnValue } from '../../primitives/Table/Core/useTable';\nimport { DisplayRow } from '../../primitives/Table/Core/components/Row/BuiltIns/DisplayRow';\nimport { DisplayCell } from '../../primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell';\nimport { TableProps } from '../../primitives/Table/types';\n\nconst RENDERERS = {\n row: DisplayRow,\n cell: DisplayCell,\n};\n\nexport function useReport<TType>(props: TableProps<TType>, ref: React.Ref<TableRef>): useTableReturnValue<TType> {\n return useTable<TType>(props, ref, RENDERERS);\n}\n"],"names":["RENDERERS","row","DisplayRow","cell","DisplayCell","useReport","props","ref","useTable"],"mappings":";;;;AAOA,MAAMA,SAAS,GAAG;EACdC,GAAG,EAAEC,UAAU;EACfC,IAAI,EAAEC;CACT;SAEeC,SAASA,CAAQC,KAAwB,EAAEC,GAAwB;EAC/E,OAAOC,QAAQ,CAAQF,KAAK,EAAEC,GAAG,EAAEP,SAAS,CAAC;AACjD;;;;"}
1
+ {"version":3,"file":"useReport.js","sources":["../../../../../../../src/components/Report/useReport.tsx"],"sourcesContent":["import React from 'react';\nimport { TableProps, TableRef } from '../../primitives/Table/types';\nimport { useTable, useTableReturnValue } from '../../primitives/Table/Core/useTable';\nimport { DisplayRow } from '../../primitives/Table/Core/components/Row/BuiltIns/DisplayRow';\nimport { DisplayCell } from '../../primitives/Table/Core/components/Columns/Cell/BuiltIns/DisplayCell';\nimport { ReportProps } from './types';\n\nconst RENDERERS = {\n row: DisplayRow,\n cell: DisplayCell,\n};\n\nexport function useReport<TType>(props: ReportProps<TType>, ref: React.Ref<TableRef>): useTableReturnValue<TType> {\n return useTable<TType>(props as TableProps<TType>, ref, RENDERERS);\n}\n"],"names":["RENDERERS","row","DisplayRow","cell","DisplayCell","useReport","props","ref","useTable"],"mappings":";;;;AAOA,MAAMA,SAAS,GAAG;EACdC,GAAG,EAAEC,UAAU;EACfC,IAAI,EAAEC;CACT;SAEeC,SAASA,CAAQC,KAAyB,EAAEC,GAAwB;EAChF,OAAOC,QAAQ,CAAQF,KAA0B,EAAEC,GAAG,EAAEP,SAAS,CAAC;AACtE;;;;"}
@@ -4,17 +4,19 @@ import { useMergedRef } from '../../hooks/useMergedRef.js';
4
4
  import { getNextFocussableElement } from '../../utils/dom.js';
5
5
  import { useLocalization } from '../Provider/Localization.js';
6
6
  import { Button } from '../Button/Button.js';
7
+ import { Spinner } from '../Spinner/Spinner.js';
7
8
  import { Root, Trigger, Portal, Content } from '@radix-ui/react-popover';
8
9
  import { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener.js';
9
10
  import { createCustomKeyboardEvent } from '../../utils/input.js';
10
11
  import { useControllableState } from '@radix-ui/react-use-controllable-state';
12
+ import { FontSizes } from '../../types.js';
11
13
  import { useIsHoverStatePaused } from '../../hooks/useIsHoverStatePaused.js';
12
14
  import { isAriaDirectionKey } from '../../utils/aria.js';
13
15
  import { Root as Root$1, createListboxValueSetter } from '../../primitives/Listbox2/components/Root.js';
14
16
  import '../../primitives/Listbox2/components/Option.js';
15
17
  import '../../primitives/Listbox2/components/Group.js';
16
18
  import '../../primitives/Listbox2/components/Title.js';
17
- import { createCollectionClassName } from './utilities.js';
19
+ import { createCollectionClassName, getFontSize } from './utilities.js';
18
20
  import { Select2Context } from './components/Context.js';
19
21
  import { Option } from './components/Option.js';
20
22
  import { Group } from './components/Group.js';
@@ -46,6 +48,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
46
48
  tags = false,
47
49
  value: prop,
48
50
  fontSize,
51
+ loading,
49
52
  ...otherProps
50
53
  } = props;
51
54
  const emptyOption = React__default.useMemo(() => {
@@ -258,7 +261,16 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
258
261
  onClick: areAllSelected ? deselectAll : selectAll
259
262
  }, selectAllText), /*#__PURE__*/React__default.createElement("div", {
260
263
  className: "border-grey-300 mx-3 rounded border-t"
261
- }))))) : null, flattenedChildren.length <= 0 ? ( /*#__PURE__*/React__default.createElement("div", {
264
+ }))))) : null, loading ? ( /*#__PURE__*/React__default.createElement("span", {
265
+ className: cn('text-grey-700 flex items-center italic', fontSize && getFontSize(fontSize))
266
+ }, /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(Spinner, {
267
+ delay: 0,
268
+ className: cn('ml-3 mr-2 mt-1.5 h-5 w-5', {
269
+ '!mt-1 !h-3.5 !w-3.5': fontSize === FontSizes.small,
270
+ '!h-4 !w-4': fontSize === FontSizes.medium,
271
+ '!h-5 !w-5': fontSize === FontSizes.large
272
+ })
273
+ })), /*#__PURE__*/React__default.createElement("span", null, texts.listbox.loading))) : flattenedChildren.length <= 0 ? ( /*#__PURE__*/React__default.createElement("div", {
262
274
  className: "text-grey-700 -mt-0.5 flex h-8 items-center px-2",
263
275
  role: "presentation"
264
276
  }, "No results found...")) : ( /*#__PURE__*/React__default.createElement(Root$1, {
@@ -1 +1 @@
1
- {"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport * as ListboxPrimitive from '../../primitives/Listbox2/Listbox2';\nimport {\n Select2Children,\n Select2CreateHandler,\n Select2DeleteHandler,\n Select2EditHandler,\n Select2OptionValue,\n Select2Value,\n} from './types';\nimport { Option, Select2OptionProps } from './components/Option';\nimport { Group, Select2GroupProps } from './components/Group';\nimport { Select2TitleProps, Title } from './components/Title';\nimport { Select2Context } from './components/Context';\nimport { createCollectionClassName } from './utilities';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { Trigger } from './components/Trigger';\nimport { useIsFormControl } from '../../hooks/useIsFormControl';\nimport { BubbleSelect } from '../../primitives/BubbleSelect';\nimport { Search } from './components/Search';\nimport { isGroup, useChildren } from './hooks/useChildren';\n\nimport { Create } from './components/Create';\nimport { Collection } from './components/Collection';\nimport { CollectionRef } from '../../primitives/Collection/Collection';\nimport { useLocalization } from '../Provider/Localization';\nimport { useIsHoverStatePaused } from '../../hooks/useIsHoverStatePaused';\nimport { isAriaDirectionKey } from '../../utils/aria';\nimport { getNextFocussableElement } from '../../utils/dom';\nimport { FontSize } from '../../types';\nimport { Button } from '../Button/Button';\n\ntype Select2Texts = {\n allSelect: string;\n allDeselect: string;\n cancel: string;\n chooseColor: string;\n create: string;\n delete: string;\n save: string;\n search: string;\n searchOrCreate: string;\n selectAll: string;\n selectAllResults: string;\n deselectAll: string;\n deselectAllResults: string;\n};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n /** Autofocus Select2 when loaded **/\n autoFocus?: boolean;\n /** Array of options in Select2 */\n children: Select2Children;\n /** Initial value of the input in Select2 */\n defaultValue?: Select2Value;\n /** Set what value should have an empty option in Select2 */\n emptyValue?: Select2OptionValue;\n /** Whether the Select2 is in a disabled state **/\n disabled?: boolean;\n /** Draws attention to the Select2 by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Whether the Select2 is in an invalid state **/\n invalid?: boolean;\n /** Whether the Select2 allows selecting multiple values **/\n multiple?: boolean;\n /** Whether the Select2 is in an invalid state **/\n name?: string;\n /** Handler called when user chooses an option from the provided options **/\n onChange?: (value: Select2Value) => void;\n /** Handler called when user creates a new option **/\n onCreate?: Select2CreateHandler;\n /** Handler called when user deletes an option **/\n onDelete?: Select2DeleteHandler;\n /** Handler called when user edits an option **/\n onEdit?: Select2EditHandler;\n /** Whether the Select2 is in a readonly state **/\n readOnly?: boolean;\n required?: boolean;\n /** Renders select options as tags **/\n tags?: boolean;\n /** Value of the input in select2 */\n value?: Select2Value;\n /** Font size of text in Select2 **/\n fontSize?: FontSize;\n /** Placeholder showed when nothing is selected **/\n placeholder?: string;\n};\ntype Select2PropsWithStatics = React.ForwardRefExoticComponent<Select2Props & React.RefAttributes<HTMLButtonElement>> & {\n Option: React.ForwardRefExoticComponent<Select2OptionProps>;\n Group: React.ForwardRefExoticComponent<Select2GroupProps>;\n Title: React.ForwardRefExoticComponent<Select2TitleProps>;\n};\n\nconst Select2 = React.forwardRef<HTMLButtonElement, Select2Props>(function Select2(props, ref) {\n const {\n children: initChildren,\n defaultValue: defaultProp,\n disabled = false,\n emptyValue = undefined,\n placeholder,\n highlighted = false,\n invalid = false,\n multiple = false,\n name,\n onChange,\n onCreate,\n onDelete,\n onEdit,\n readOnly = false,\n tags = false,\n value: prop,\n fontSize,\n ...otherProps\n } = props;\n\n const emptyOption: React.ReactElement<Select2OptionProps> | undefined = React.useMemo(() => {\n if (emptyValue !== undefined && !multiple) {\n // Empty option has 0px height, because it's empty, so need to apply height manually\n return <Option key=\"__empty\" children=\"\" value={emptyValue} className=\"h-8\" />;\n }\n return;\n }, [emptyValue, multiple]);\n\n const initialChildren = React.useMemo(() => {\n if (emptyOption) {\n return [emptyOption, ...initChildren] as Select2Children;\n }\n return initChildren;\n }, [emptyOption, initChildren]);\n\n // refs\n const internalRef = useMergedRef<HTMLButtonElement>(ref);\n const listboxRef = React.useRef<CollectionRef>(null);\n const searchRef = React.useRef<HTMLInputElement>(null);\n const { texts } = useLocalization();\n // align the listbox min width with the width of the input - it should never be smaller\n const dimensions = useBoundingClientRectListener(internalRef);\n\n // state\n const [tabTriggeredClose, setTabTriggeredClose] = React.useState(false);\n const [open, setOpen] = React.useState(false);\n const [value, _setValue] = useControllableState<Select2Value>({\n // uncontrolled\n defaultProp,\n // controlled\n onChange,\n prop,\n });\n const setValue = ListboxPrimitive.createListboxValueSetter(multiple, _setValue);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n const [shouldPauseHoverState, setShouldPauseHoverState] = useIsHoverStatePaused();\n\n const { flattenedChildren, filteredChildren, searchQuery, setSearchQuery } = useChildren({\n children: initialChildren,\n emptyValue,\n multiple,\n open,\n setValue,\n value,\n });\n\n // context\n const context = {\n disabled,\n highlighted,\n invalid,\n listboxRef,\n multiple,\n onCreate,\n onDelete,\n onEdit,\n open,\n readOnly,\n ref: internalRef,\n searchQuery,\n searchRef,\n setOpen,\n setSearchQuery,\n setValidationError,\n setValue,\n shouldPauseHoverState,\n setShouldPauseHoverState,\n tags,\n fontSize,\n validationError,\n value,\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {\n setOpen(true);\n }\n\n // the focus should always remain on the input, so we forward events on to the listbox\n listboxRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n };\n\n let handleBlur;\n\n if (otherProps.onBlur) {\n // we might be focusing on an input or something inside the dropdown that was triggered by the select\n // so see if the element gaining focus is inside a portal and look up its controller\n // if we don't do this, things like validate on blur occur while simply opening the select\n handleBlur = (event: React.FocusEvent<HTMLButtonElement>) => {\n const elementGainingFocus = event.relatedTarget;\n\n if (elementGainingFocus === undefined) {\n return;\n }\n\n const portalId = elementGainingFocus?.closest('[data-radix-popper-content-wrapper] > :first-child')?.id;\n\n if (!portalId || event.currentTarget.getAttribute(`aria-controls`) !== portalId) {\n otherProps.onBlur?.(event);\n }\n };\n }\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isAriaDirectionKey(event)) {\n setShouldPauseHoverState(true);\n }\n };\n\n const handleCloseAutoFocus = (event: Event) => {\n event.preventDefault();\n event.stopPropagation();\n\n if (tabTriggeredClose) {\n const nextFocussableElement = getNextFocussableElement(internalRef.current);\n\n if (nextFocussableElement) {\n // UX requirement: move focus to the next focussable element when tab key is pressed to select the value\n nextFocussableElement.focus();\n // Reset the tabTriggeredClose state\n setTabTriggeredClose(false);\n }\n } else {\n internalRef.current?.focus();\n }\n };\n\n const selectOptions =\n searchQuery === ''\n ? flattenedChildren.map(child => child.props.value)\n : filteredChildren\n .map(child =>\n isGroup(child)\n ? Array.isArray(child.props.children) && child.props.children.map(subChild => subChild.props.value)\n : child.props.value\n )\n .flatMap(c => c) || [];\n\n const areAllSelected = Array.isArray(value) && selectOptions.every(option => value.includes(option as string));\n\n const selectAllText = React.useMemo(() => {\n if (searchQuery === '') {\n if (areAllSelected) {\n return texts.select2.deselectAll;\n } else {\n return texts.select2.selectAll;\n }\n } else if (areAllSelected) {\n return texts.select2.deselectAllResults;\n } else {\n return texts.select2.selectAllResults;\n }\n }, [areAllSelected, searchQuery]);\n\n const selectAll = () => {\n if (!Array.isArray(value) || value.length === 0) {\n setValue(selectOptions);\n } else {\n // array of all available options which are not selected\n const preselectedValues = selectOptions.filter(option => !value.includes(option));\n setValue([...value, ...preselectedValues]);\n }\n };\n\n const deselectAll = () => {\n if (searchQuery === '') {\n setValue([]);\n } else {\n const nextValue = Array.isArray(value) && value.filter(subValue => !selectOptions.includes(subValue as string));\n setValue(nextValue);\n }\n };\n\n const className = cn('border-grey-300 rounded border bg-white py-1.5 shadow-md outline-none\"', createCollectionClassName());\n\n return (\n <Select2Context.Provider value={context}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <ControlledHiddenField\n emptyValue={emptyValue}\n multiple={multiple || tags}\n name={name}\n options={flattenedChildren.map(child => child.props.value)}\n parentRef={internalRef}\n setValue={setValue}\n value={value}\n />\n <PopoverPrimitive.Trigger asChild data-taco=\"Select2\">\n <Trigger\n {...otherProps}\n aria-haspopup=\"listbox\"\n emptyValue={emptyValue}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n ref={internalRef}\n fontSize={fontSize}\n placeholder={placeholder}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onOpenAutoFocus={() => {\n internalRef.current?.focus();\n }}\n onCloseAutoFocus={handleCloseAutoFocus}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {flattenedChildren.length > 0 || onCreate ? (\n <>\n <Search\n placeholder={onCreate ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\n onTabKeyPress={() => setTabTriggeredClose(true)}\n />\n {multiple && selectOptions.length > 1 && (\n <>\n <Button\n className=\"!justify-start\"\n appearance=\"discrete\"\n onClick={areAllSelected ? deselectAll : selectAll}>\n {selectAllText}\n </Button>\n <div className=\"border-grey-300 mx-3 rounded border-t\" />\n </>\n )}\n </>\n ) : null}\n {flattenedChildren.length <= 0 ? (\n <div className=\"text-grey-700 -mt-0.5 flex h-8 items-center px-2\" role=\"presentation\">\n No results found...\n </div>\n ) : (\n <ListboxPrimitive.Root\n className=\"flex flex-col gap-0.5\"\n customSelector=\":scope > button\"\n disabled={disabled}\n multiple={multiple}\n onKeyDown={handleListboxKeyDown}\n readOnly={readOnly}\n ref={listboxRef}\n setValue={setValue}\n tabIndex={-1}\n value={value}>\n {searchQuery === '' ? (\n <Collection>{initialChildren}</Collection>\n ) : (\n <Collection>{filteredChildren}</Collection>\n )}\n {onCreate ? <Create onCreate={onCreate} options={flattenedChildren} /> : null}\n </ListboxPrimitive.Root>\n )}\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </Select2Context.Provider>\n );\n}) as Select2PropsWithStatics;\nSelect2.Option = Option;\nSelect2.Group = Group;\nSelect2.Title = Title;\n\nconst ControlledHiddenField = props => {\n const { emptyValue, multiple, name, options, parentRef, value, setValue } = props;\n const isFormControl = useIsFormControl(parentRef, () => setValue(multiple ? [] : undefined));\n\n let bubbleValue;\n\n if (isFormControl) {\n if (value !== undefined) {\n if (multiple) {\n bubbleValue = Array.isArray(value) ? value.map(String) : [value === null ? '' : String(value)];\n } else {\n bubbleValue = value === null ? '' : String(value);\n }\n }\n\n return (\n <BubbleSelect aria-hidden key={String(bubbleValue)} multiple={multiple} name={name} value={bubbleValue}>\n {emptyValue !== undefined ? <option value={emptyValue} /> : null}\n {options.map(option => (\n <option key={String(option)} value={String(option)} />\n ))}\n </BubbleSelect>\n );\n }\n\n return null;\n};\nSelect2.displayName = 'Select2';\n\nexport { Select2 };\n\nexport type {\n Select2Texts,\n Select2GroupProps,\n Select2OptionProps,\n Select2OptionValue,\n Select2Value,\n Select2Props,\n Select2TitleProps,\n};\n"],"names":["Select2","React","forwardRef","props","ref","children","initChildren","defaultValue","defaultProp","disabled","emptyValue","undefined","placeholder","highlighted","invalid","multiple","name","onChange","onCreate","onDelete","onEdit","readOnly","tags","value","prop","fontSize","otherProps","emptyOption","useMemo","Option","key","className","initialChildren","internalRef","useMergedRef","listboxRef","useRef","searchRef","texts","useLocalization","dimensions","useBoundingClientRectListener","tabTriggeredClose","setTabTriggeredClose","useState","open","setOpen","_setValue","useControllableState","setValue","ListboxPrimitive","validationError","setValidationError","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","flattenedChildren","filteredChildren","searchQuery","setSearchQuery","useChildren","context","handleKeyDown","event","preventDefault","ctrlKey","metaKey","test","_listboxRef$current","current","dispatchEvent","createCustomKeyboardEvent","handleBlur","onBlur","elementGainingFocus","relatedTarget","portalId","_elementGainingFocus$","closest","id","currentTarget","getAttribute","_otherProps$onBlur","call","handleListboxKeyDown","isAriaDirectionKey","handleCloseAutoFocus","stopPropagation","nextFocussableElement","getNextFocussableElement","focus","_internalRef$current","selectOptions","map","child","isGroup","Array","isArray","subChild","flatMap","c","areAllSelected","every","option","includes","selectAllText","select2","deselectAll","selectAll","deselectAllResults","selectAllResults","length","preselectedValues","filter","nextValue","subValue","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","ControlledHiddenField","options","parentRef","asChild","Trigger","onKeyDown","align","onOpenAutoFocus","_internalRef$current2","onCloseAutoFocus","sideOffset","tabIndex","style","minWidth","width","Search","searchOrCreate","search","onTabKeyPress","Button","appearance","onClick","role","customSelector","Collection","Create","Group","Title","isFormControl","useIsFormControl","bubbleValue","String","BubbleSelect","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkGMA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAkC,SAASF,OAAOA,CAACG,KAAK,EAAEC,GAAG;EACzF,MAAM;IACFC,QAAQ,EAAEC,YAAY;IACtBC,YAAY,EAAEC,WAAW;IACzBC,QAAQ,GAAG,KAAK;IAChBC,UAAU,GAAGC,SAAS;IACtBC,WAAW;IACXC,WAAW,GAAG,KAAK;IACnBC,OAAO,GAAG,KAAK;IACfC,QAAQ,GAAG,KAAK;IAChBC,IAAI;IACJC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,MAAM;IACNC,QAAQ,GAAG,KAAK;IAChBC,IAAI,GAAG,KAAK;IACZC,KAAK,EAAEC,IAAI;IACXC,QAAQ;IACR,GAAGC;GACN,GAAGvB,KAAK;EAET,MAAMwB,WAAW,GAAuD1B,cAAK,CAAC2B,OAAO,CAAC;IAClF,IAAIlB,UAAU,KAAKC,SAAS,IAAI,CAACI,QAAQ,EAAE;;MAEvC,oBAAOd,6BAAC4B,MAAM;QAACC,GAAG,EAAC,SAAS;QAACzB,QAAQ,EAAC,EAAE;QAACkB,KAAK,EAAEb,UAAU;QAAEqB,SAAS,EAAC;QAAQ;;IAElF;GACH,EAAE,CAACrB,UAAU,EAAEK,QAAQ,CAAC,CAAC;EAE1B,MAAMiB,eAAe,GAAG/B,cAAK,CAAC2B,OAAO,CAAC;IAClC,IAAID,WAAW,EAAE;MACb,OAAO,CAACA,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zD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACDvG,OAAO,CAAC2J,WAAW,GAAG,SAAS;;;;"}
1
+ {"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport * as ListboxPrimitive from '../../primitives/Listbox2/Listbox2';\nimport {\n Select2Children,\n Select2CreateHandler,\n Select2DeleteHandler,\n Select2EditHandler,\n Select2OptionValue,\n Select2Value,\n} from './types';\nimport { Option, Select2OptionProps } from './components/Option';\nimport { Group, Select2GroupProps } from './components/Group';\nimport { Select2TitleProps, Title } from './components/Title';\nimport { Select2Context } from './components/Context';\nimport { createCollectionClassName, getFontSize } from './utilities';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { Trigger } from './components/Trigger';\nimport { useIsFormControl } from '../../hooks/useIsFormControl';\nimport { BubbleSelect } from '../../primitives/BubbleSelect';\nimport { Search } from './components/Search';\nimport { isGroup, useChildren } from './hooks/useChildren';\n\nimport { Create } from './components/Create';\nimport { Collection } from './components/Collection';\nimport { CollectionRef } from '../../primitives/Collection/Collection';\nimport { useLocalization } from '../Provider/Localization';\nimport { useIsHoverStatePaused } from '../../hooks/useIsHoverStatePaused';\nimport { isAriaDirectionKey } from '../../utils/aria';\nimport { getNextFocussableElement } from '../../utils/dom';\nimport { FontSize, FontSizes } from '../../types';\nimport { Button } from '../Button/Button';\nimport { Spinner } from '../Spinner/Spinner';\n\ntype Select2Texts = {\n allSelect: string;\n allDeselect: string;\n cancel: string;\n chooseColor: string;\n create: string;\n delete: string;\n save: string;\n search: string;\n searchOrCreate: string;\n selectAll: string;\n selectAllResults: string;\n deselectAll: string;\n deselectAllResults: string;\n};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n /** Autofocus Select2 when loaded **/\n autoFocus?: boolean;\n /** Array of options in Select2 */\n children: Select2Children;\n /** Initial value of the input in Select2 */\n defaultValue?: Select2Value;\n /** Set what value should have an empty option in Select2 */\n emptyValue?: Select2OptionValue;\n /** Whether the Select2 is in a disabled state **/\n disabled?: boolean;\n /** Draws attention to the Select2 by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Whether the Select2 is in an invalid state **/\n invalid?: boolean;\n /** Whether the Select2 is loading the data **/\n loading?: boolean;\n /** Whether the Select2 allows selecting multiple values **/\n multiple?: boolean;\n /** Whether the Select2 is in an invalid state **/\n name?: string;\n /** Handler called when user chooses an option from the provided options **/\n onChange?: (value: Select2Value) => void;\n /** Handler called when user creates a new option **/\n onCreate?: Select2CreateHandler;\n /** Handler called when user deletes an option **/\n onDelete?: Select2DeleteHandler;\n /** Handler called when user edits an option **/\n onEdit?: Select2EditHandler;\n /** Whether the Select2 is in a readonly state **/\n readOnly?: boolean;\n required?: boolean;\n /** Renders select options as tags **/\n tags?: boolean;\n /** Value of the input in select2 */\n value?: Select2Value;\n /** Font size of text in Select2 **/\n fontSize?: FontSize;\n /** Placeholder showed when nothing is selected **/\n placeholder?: string;\n};\ntype Select2PropsWithStatics = React.ForwardRefExoticComponent<Select2Props & React.RefAttributes<HTMLButtonElement>> & {\n Option: React.ForwardRefExoticComponent<Select2OptionProps>;\n Group: React.ForwardRefExoticComponent<Select2GroupProps>;\n Title: React.ForwardRefExoticComponent<Select2TitleProps>;\n};\n\nconst Select2 = React.forwardRef<HTMLButtonElement, Select2Props>(function Select2(props, ref) {\n const {\n children: initChildren,\n defaultValue: defaultProp,\n disabled = false,\n emptyValue = undefined,\n placeholder,\n highlighted = false,\n invalid = false,\n multiple = false,\n name,\n onChange,\n onCreate,\n onDelete,\n onEdit,\n readOnly = false,\n tags = false,\n value: prop,\n fontSize,\n loading,\n ...otherProps\n } = props;\n\n const emptyOption: React.ReactElement<Select2OptionProps> | undefined = React.useMemo(() => {\n if (emptyValue !== undefined && !multiple) {\n // Empty option has 0px height, because it's empty, so need to apply height manually\n return <Option key=\"__empty\" children=\"\" value={emptyValue} className=\"h-8\" />;\n }\n return;\n }, [emptyValue, multiple]);\n\n const initialChildren = React.useMemo(() => {\n if (emptyOption) {\n return [emptyOption, ...initChildren] as Select2Children;\n }\n return initChildren;\n }, [emptyOption, initChildren]);\n\n // refs\n const internalRef = useMergedRef<HTMLButtonElement>(ref);\n const listboxRef = React.useRef<CollectionRef>(null);\n const searchRef = React.useRef<HTMLInputElement>(null);\n const { texts } = useLocalization();\n // align the listbox min width with the width of the input - it should never be smaller\n const dimensions = useBoundingClientRectListener(internalRef);\n\n // state\n const [tabTriggeredClose, setTabTriggeredClose] = React.useState(false);\n const [open, setOpen] = React.useState(false);\n const [value, _setValue] = useControllableState<Select2Value>({\n // uncontrolled\n defaultProp,\n // controlled\n onChange,\n prop,\n });\n const setValue = ListboxPrimitive.createListboxValueSetter(multiple, _setValue);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n const [shouldPauseHoverState, setShouldPauseHoverState] = useIsHoverStatePaused();\n\n const { flattenedChildren, filteredChildren, searchQuery, setSearchQuery } = useChildren({\n children: initialChildren,\n emptyValue,\n multiple,\n open,\n setValue,\n value,\n });\n\n // context\n const context = {\n disabled,\n highlighted,\n invalid,\n listboxRef,\n multiple,\n onCreate,\n onDelete,\n onEdit,\n open,\n readOnly,\n ref: internalRef,\n searchQuery,\n searchRef,\n setOpen,\n setSearchQuery,\n setValidationError,\n setValue,\n shouldPauseHoverState,\n setShouldPauseHoverState,\n tags,\n fontSize,\n validationError,\n value,\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {\n setOpen(true);\n }\n\n // the focus should always remain on the input, so we forward events on to the listbox\n listboxRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n };\n\n let handleBlur;\n\n if (otherProps.onBlur) {\n // we might be focusing on an input or something inside the dropdown that was triggered by the select\n // so see if the element gaining focus is inside a portal and look up its controller\n // if we don't do this, things like validate on blur occur while simply opening the select\n handleBlur = (event: React.FocusEvent<HTMLButtonElement>) => {\n const elementGainingFocus = event.relatedTarget;\n\n if (elementGainingFocus === undefined) {\n return;\n }\n\n const portalId = elementGainingFocus?.closest('[data-radix-popper-content-wrapper] > :first-child')?.id;\n\n if (!portalId || event.currentTarget.getAttribute(`aria-controls`) !== portalId) {\n otherProps.onBlur?.(event);\n }\n };\n }\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isAriaDirectionKey(event)) {\n setShouldPauseHoverState(true);\n }\n };\n\n const handleCloseAutoFocus = (event: Event) => {\n event.preventDefault();\n event.stopPropagation();\n\n if (tabTriggeredClose) {\n const nextFocussableElement = getNextFocussableElement(internalRef.current);\n\n if (nextFocussableElement) {\n // UX requirement: move focus to the next focussable element when tab key is pressed to select the value\n nextFocussableElement.focus();\n // Reset the tabTriggeredClose state\n setTabTriggeredClose(false);\n }\n } else {\n internalRef.current?.focus();\n }\n };\n\n const selectOptions =\n searchQuery === ''\n ? flattenedChildren.map(child => child.props.value)\n : filteredChildren\n .map(child =>\n isGroup(child)\n ? Array.isArray(child.props.children) && child.props.children.map(subChild => subChild.props.value)\n : child.props.value\n )\n .flatMap(c => c) || [];\n\n const areAllSelected = Array.isArray(value) && selectOptions.every(option => value.includes(option as string));\n\n const selectAllText = React.useMemo(() => {\n if (searchQuery === '') {\n if (areAllSelected) {\n return texts.select2.deselectAll;\n } else {\n return texts.select2.selectAll;\n }\n } else if (areAllSelected) {\n return texts.select2.deselectAllResults;\n } else {\n return texts.select2.selectAllResults;\n }\n }, [areAllSelected, searchQuery]);\n\n const selectAll = () => {\n if (!Array.isArray(value) || value.length === 0) {\n setValue(selectOptions);\n } else {\n // array of all available options which are not selected\n const preselectedValues = selectOptions.filter(option => !value.includes(option));\n setValue([...value, ...preselectedValues]);\n }\n };\n\n const deselectAll = () => {\n if (searchQuery === '') {\n setValue([]);\n } else {\n const nextValue = Array.isArray(value) && value.filter(subValue => !selectOptions.includes(subValue as string));\n setValue(nextValue);\n }\n };\n\n const className = cn('border-grey-300 rounded border bg-white py-1.5 shadow-md outline-none\"', createCollectionClassName());\n\n return (\n <Select2Context.Provider value={context}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <ControlledHiddenField\n emptyValue={emptyValue}\n multiple={multiple || tags}\n name={name}\n options={flattenedChildren.map(child => child.props.value)}\n parentRef={internalRef}\n setValue={setValue}\n value={value}\n />\n <PopoverPrimitive.Trigger asChild data-taco=\"Select2\">\n <Trigger\n {...otherProps}\n aria-haspopup=\"listbox\"\n emptyValue={emptyValue}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n ref={internalRef}\n fontSize={fontSize}\n placeholder={placeholder}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onOpenAutoFocus={() => {\n internalRef.current?.focus();\n }}\n onCloseAutoFocus={handleCloseAutoFocus}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {flattenedChildren.length > 0 || onCreate ? (\n <>\n <Search\n placeholder={onCreate ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\n onTabKeyPress={() => setTabTriggeredClose(true)}\n />\n {multiple && selectOptions.length > 1 && (\n <>\n <Button\n className=\"!justify-start\"\n appearance=\"discrete\"\n onClick={areAllSelected ? deselectAll : selectAll}>\n {selectAllText}\n </Button>\n <div className=\"border-grey-300 mx-3 rounded border-t\" />\n </>\n )}\n </>\n ) : null}\n {loading ? (\n <span className={cn('text-grey-700 flex items-center italic', fontSize && getFontSize(fontSize))}>\n <span>\n <Spinner\n delay={0}\n className={cn('ml-3 mr-2 mt-1.5 h-5 w-5', {\n '!mt-1 !h-3.5 !w-3.5': fontSize === FontSizes.small,\n '!h-4 !w-4': fontSize === FontSizes.medium,\n '!h-5 !w-5': fontSize === FontSizes.large,\n })}\n />\n </span>\n <span>{texts.listbox.loading}</span>\n </span>\n ) : flattenedChildren.length <= 0 ? (\n <div className=\"text-grey-700 -mt-0.5 flex h-8 items-center px-2\" role=\"presentation\">\n No results found...\n </div>\n ) : (\n <ListboxPrimitive.Root\n className=\"flex flex-col gap-0.5\"\n customSelector=\":scope > button\"\n disabled={disabled}\n multiple={multiple}\n onKeyDown={handleListboxKeyDown}\n readOnly={readOnly}\n ref={listboxRef}\n setValue={setValue}\n tabIndex={-1}\n value={value}>\n {searchQuery === '' ? (\n <Collection>{initialChildren}</Collection>\n ) : (\n <Collection>{filteredChildren}</Collection>\n )}\n {onCreate ? <Create onCreate={onCreate} options={flattenedChildren} /> : null}\n </ListboxPrimitive.Root>\n )}\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </Select2Context.Provider>\n );\n}) as Select2PropsWithStatics;\nSelect2.Option = Option;\nSelect2.Group = Group;\nSelect2.Title = Title;\n\nconst ControlledHiddenField = props => {\n const { emptyValue, multiple, name, options, parentRef, value, setValue } = props;\n const isFormControl = useIsFormControl(parentRef, () => setValue(multiple ? [] : undefined));\n\n let bubbleValue;\n\n if (isFormControl) {\n if (value !== undefined) {\n if (multiple) {\n bubbleValue = Array.isArray(value) ? value.map(String) : [value === null ? '' : String(value)];\n } else {\n bubbleValue = value === null ? '' : String(value);\n }\n }\n\n return (\n <BubbleSelect aria-hidden key={String(bubbleValue)} multiple={multiple} name={name} value={bubbleValue}>\n {emptyValue !== undefined ? <option value={emptyValue} /> : null}\n {options.map(option => (\n <option key={String(option)} value={String(option)} />\n ))}\n </BubbleSelect>\n );\n }\n\n return null;\n};\nSelect2.displayName = 'Select2';\n\nexport { Select2 };\n\nexport type {\n Select2Texts,\n Select2GroupProps,\n Select2OptionProps,\n Select2OptionValue,\n Select2Value,\n Select2Props,\n Select2TitleProps,\n};\n"],"names":["Select2","React","forwardRef","props","ref","children","initChildren","defaultValue","defaultProp","disabled","emptyValue","undefined","placeholder","highlighted","invalid","multiple","name","onChange","onCreate","onDelete","onEdit","readOnly","tags","value","prop","fontSize","loading","otherProps","emptyOption","useMemo","Option","key","className","initialChildren","internalRef","useMergedRef","listboxRef","useRef","searchRef","texts","useLocalization","dimensions","useBoundingClientRectListener","tabTriggeredClose","setTabTriggeredClose","useState","open","setOpen","_setValue","useControllableState","setValue","ListboxPrimitive","validationError","setValidationError","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","flattenedChildren","filteredChildren","searchQuery","setSearchQuery","useChildren","context","handleKeyDown","event","preventDefault","ctrlKey","metaKey","test","_listboxRef$current","current","dispatchEvent","createCustomKeyboardEvent","handleBlur","onBlur","elementGainingFocus","relatedTarget","portalId","_elementGainingFocus$","closest","id","currentTarget","getAttribute","_otherProps$onBlur","call","handleListboxKeyDown","isAriaDirectionKey","handleCloseAutoFocus","stopPropagation","nextFocussableElement","getNextFocussableElement","focus","_internalRef$current","selectOptions","map","child","isGroup","Array","isArray","subChild","flatMap","c","areAllSelected","every","option","includes","selectAllText","select2","deselectAll","selectAll","deselectAllResults","selectAllResults","length","preselectedValues","filter","nextValue","subValue","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","ControlledHiddenField","options","parentRef","asChild","Trigger","onKeyDown","align","onOpenAutoFocus","_internalRef$current2","onCloseAutoFocus","sideOffset","tabIndex","style","minWidth","width","Search","searchOrCreate","search","onTabKeyPress","Button","appearance","onClick","getFontSize","Spinner","delay","FontSizes","small","medium","large","listbox","role","customSelector","Collection","Create","Group","Title","isFormControl","useIsFormControl","bubbleValue","String","BubbleSelect","displayName"],"mappings":";;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AAc,GAAG,IAAI,EAC/DkH,OAAO,CAAC9B,GAAG,CAACU,MAAM,mBACfvG;MAAQ8B,GAAG,EAAEmI,MAAM,CAAC1D,MAAM,CAAC;MAAEjF,KAAK,EAAE2I,MAAM,CAAC1D,MAAM;MAAK,CACzD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACDxG,OAAO,CAACoK,WAAW,GAAG,SAAS;;;;"}
@@ -9,7 +9,7 @@ import { Option as Option$1 } from '../../../primitives/Listbox2/components/Opti
9
9
  import '../../../primitives/Listbox2/components/Group.js';
10
10
  import '../../../primitives/Listbox2/components/Title.js';
11
11
  import { Tag } from '../../Tag/Tag.js';
12
- import { createOptionClassName } from '../utilities.js';
12
+ import { createOptionClassName, getFontSize } from '../utilities.js';
13
13
  import { useSelect2Context } from './Context.js';
14
14
  import { EditPopover } from './Edit.js';
15
15
  import { isMobileDevice } from '../../../utils/device.js';
@@ -37,11 +37,7 @@ const Option = /*#__PURE__*/React__default.forwardRef(function Select2Option(pro
37
37
  value,
38
38
  fontSize = FontSizes.medium
39
39
  } = useSelect2Context();
40
- const className = cn(createOptionClassName(shouldPauseHoverState), {
41
- 'text-xs': fontSize === FontSizes.small,
42
- 'text-sm': fontSize === FontSizes.medium,
43
- 'text-base': fontSize === FontSizes.large
44
- }, cName);
40
+ const className = cn(createOptionClassName(shouldPauseHoverState), fontSize && getFontSize(fontSize), cName);
45
41
  const hasValue = Array.isArray(value) ? !!value.length : value !== undefined;
46
42
  const isTag = tags && !!color;
47
43
  const handleClick = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"Option.js","sources":["../../../../../../../../src/components/Select2/components/Option.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Icon, IconName } from '../../Icon/Icon';\nimport { Tag } from '../../Tag/Tag';\nimport { isAriaSelectionKey } from '../../../utils/aria';\nimport * as ListboxPrimitive from '../../../primitives/Listbox2/Listbox2';\nimport { createOptionClassName } from '../utilities';\nimport { useSelect2Context } from './Context';\nimport { IconButton } from '../../IconButton/IconButton';\nimport { EditPopover } from './Edit';\nimport { isMobileDevice } from '../../../utils/device';\nimport { Color } from '../../../types';\nimport { FontSize, FontSizes } from '../../../types';\n\nexport type Select2OptionProps = Omit<ListboxPrimitive.Listbox2OptionProps, 'children' | 'prefix'> & {\n children: string;\n color?: Color;\n description?: string;\n fontSize?: FontSize;\n prefix?: IconName | JSX.Element;\n postfix?: IconName | JSX.Element;\n textValue?: string;\n};\n\nexport const Option = React.forwardRef<HTMLDivElement, Select2OptionProps>(function Select2Option(props, ref) {\n const { children, color, description, prefix, postfix, className: cName, ...otherProps } = props;\n const {\n onDelete,\n onEdit,\n listboxRef,\n multiple,\n ref: selectRef,\n setOpen,\n shouldPauseHoverState,\n tags,\n value,\n fontSize = FontSizes.medium,\n } = useSelect2Context();\n const className = cn(\n createOptionClassName(shouldPauseHoverState),\n {\n 'text-xs': fontSize === FontSizes.small,\n 'text-sm': fontSize === FontSizes.medium,\n 'text-base': fontSize === FontSizes.large,\n },\n cName\n );\n\n const hasValue = Array.isArray(value) ? !!value.length : value !== undefined;\n const isTag = tags && !!color;\n\n const handleClick = () => {\n if (!multiple) {\n setOpen(false);\n } else {\n selectRef.current?.focus();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (isAriaSelectionKey(event)) {\n if (!multiple || event.key === 'Tab') {\n setOpen(false);\n }\n }\n };\n\n const isEmptyOption = children !== '';\n\n const popover =\n isEmptyOption && (onEdit || onDelete)\n ? popoverProps => (\n <EditPopover\n {...popoverProps}\n color={props.color}\n key={props.textValue ?? String(props.children)}\n text={props.textValue ?? String(props.children)}\n value={props.value}\n />\n )\n : undefined;\n\n return (\n <ListboxPrimitive.Option {...otherProps} className={className} onClick={handleClick} onKeyDown={handleKeyDown} ref={ref}>\n {hasValue ? (\n <Icon name=\"tick\" className=\"pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible\" />\n ) : null}\n\n {isTag ? (\n <Tag className=\"pointer-events-none my-1\" color={color} icon={prefix}>\n {children}\n </Tag>\n ) : (\n <>\n {prefix ? typeof prefix === 'string' ? <Icon name={prefix} /> : prefix : null}\n <span className=\"flex w-full justify-between\">\n <span className=\"flex flex-col\">\n <span>{children}</span>\n {description ? <span className=\"text-grey-700 -mt-1.5 mb-1.5 text-xs\">{description}</span> : null}\n </span>\n <span className=\"flex flex-col self-center\">\n {postfix ? typeof postfix === 'string' ? <Icon name={postfix} /> : postfix : null}\n </span>\n </span>\n </>\n )}\n {popover ? (\n <IconButton\n icon=\"ellipsis-vertical\"\n appearance=\"discrete\"\n className={cn(\n 'group-aria-current:visible invisible -mr-1 ml-auto !h-5 min-h-[theme(spacing.6)] !w-5 min-w-[theme(spacing.6)] hover:!bg-black/[.08] focus:!shadow-none group-hover:visible',\n {\n '!visible': isMobileDevice(window?.navigator),\n }\n )}\n onClick={event => {\n event.stopPropagation();\n listboxRef?.current?.setActiveIndex(event.currentTarget.parentElement as HTMLDivElement);\n }}\n popover={popover}\n tabIndex={-1}\n />\n ) : null}\n </ListboxPrimitive.Option>\n );\n});\n"],"names":["Option","React","forwardRef","Select2Option","props","ref","children","color","description","prefix","postfix","className","cName","otherProps","onDelete","onEdit","listboxRef","multiple","selectRef","setOpen","shouldPauseHoverState","tags","value","fontSize","FontSizes","medium","useSelect2Context","cn","createOptionClassName","small","large","hasValue","Array","isArray","length","undefined","isTag","handleClick","_selectRef$current","current","focus","handleKeyDown","event","isAriaSelectionKey","key","isEmptyOption","popover","popoverProps","_props$textValue","_props$textValue2","EditPopover","textValue","String","text","ListboxPrimitive","onClick","onKeyDown","Icon","name","Tag","icon","IconButton","appearance","isMobileDevice","_window","window","navigator","stopPropagation","_listboxRef$current","setActiveIndex","currentTarget","parentElement","tabIndex"],"mappings":";;;;;;;;;;;;;;;;MAwBaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;;EACxG,MAAM;IAAEC,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OAAO,GAAG,OAAOA,OAAO,KAAK,QAAQ,gBAAGT,6BAACwD,IAAI;IAACC,IAAI,EAAEhD;IAAW,GAAGA,OAAO,GAAG,IAAI,CAC9E,CACJ,CACR,CACN,EACAoC,OAAO,kBACJ7C,6BAAC4D,UAAU;IACPD,IAAI,EAAC,mBAAmB;IACxBE,UAAU,EAAC,UAAU;IACrBnD,SAAS,EAAEgB,EAAE,CACT,6KAA6K,EAC7K;MACI,UAAU,EAAEoC,cAAc,EAAAC,OAAA,GAACC,MAAM,cAAAD,OAAA,uBAANA,OAAA,CAAQE,SAAS;KAC/C,CACJ;IACDX,OAAO,EAAEb,KAAK;;MACVA,KAAK,CAACyB,eAAe,EAAE;MACvBnD,UAAU,aAAVA,UAAU,wBAAAoD,mBAAA,GAAVpD,UAAU,CAAEuB,OAAO,cAAA6B,mBAAA,uBAAnBA,mBAAA,CAAqBC,cAAc,CAAC3B,KAAK,CAAC4B,aAAa,CAACC,aAA+B,CAAC;KAC3F;IACDzB,OAAO,EAAEA,OAAO;IAChB0B,QAAQ,EAAE,CAAC;IACb,IACF,IAAI,CACc;AAElC,CAAC;;;;"}
1
+ {"version":3,"file":"Option.js","sources":["../../../../../../../../src/components/Select2/components/Option.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Icon, IconName } from '../../Icon/Icon';\nimport { Tag } from '../../Tag/Tag';\nimport { isAriaSelectionKey } from '../../../utils/aria';\nimport * as ListboxPrimitive from '../../../primitives/Listbox2/Listbox2';\nimport { createOptionClassName, getFontSize } from '../utilities';\nimport { useSelect2Context } from './Context';\nimport { IconButton } from '../../IconButton/IconButton';\nimport { EditPopover } from './Edit';\nimport { isMobileDevice } from '../../../utils/device';\nimport { Color } from '../../../types';\nimport { FontSize, FontSizes } from '../../../types';\n\nexport type Select2OptionProps = Omit<ListboxPrimitive.Listbox2OptionProps, 'children' | 'prefix'> & {\n children: string;\n color?: Color;\n description?: string;\n fontSize?: FontSize;\n prefix?: IconName | JSX.Element;\n postfix?: IconName | JSX.Element;\n textValue?: string;\n};\n\nexport const Option = React.forwardRef<HTMLDivElement, Select2OptionProps>(function Select2Option(props, ref) {\n const { children, color, description, prefix, postfix, className: cName, ...otherProps } = props;\n const {\n onDelete,\n onEdit,\n listboxRef,\n multiple,\n ref: selectRef,\n setOpen,\n shouldPauseHoverState,\n tags,\n value,\n fontSize = FontSizes.medium,\n } = useSelect2Context();\n const className = cn(createOptionClassName(shouldPauseHoverState), fontSize && getFontSize(fontSize), cName);\n\n const hasValue = Array.isArray(value) ? !!value.length : value !== undefined;\n const isTag = tags && !!color;\n\n const handleClick = () => {\n if (!multiple) {\n setOpen(false);\n } else {\n selectRef.current?.focus();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (isAriaSelectionKey(event)) {\n if (!multiple || event.key === 'Tab') {\n setOpen(false);\n }\n }\n };\n\n const isEmptyOption = children !== '';\n\n const popover =\n isEmptyOption && (onEdit || onDelete)\n ? popoverProps => (\n <EditPopover\n {...popoverProps}\n color={props.color}\n key={props.textValue ?? String(props.children)}\n text={props.textValue ?? String(props.children)}\n value={props.value}\n />\n )\n : undefined;\n\n return (\n <ListboxPrimitive.Option {...otherProps} className={className} onClick={handleClick} onKeyDown={handleKeyDown} ref={ref}>\n {hasValue ? (\n <Icon name=\"tick\" className=\"pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible\" />\n ) : null}\n\n {isTag ? (\n <Tag className=\"pointer-events-none my-1\" color={color} icon={prefix}>\n {children}\n </Tag>\n ) : (\n <>\n {prefix ? typeof prefix === 'string' ? <Icon name={prefix} /> : prefix : null}\n <span className=\"flex w-full justify-between\">\n <span className=\"flex flex-col\">\n <span>{children}</span>\n {description ? <span className=\"text-grey-700 -mt-1.5 mb-1.5 text-xs\">{description}</span> : null}\n </span>\n <span className=\"flex flex-col self-center\">\n {postfix ? typeof postfix === 'string' ? <Icon name={postfix} /> : postfix : null}\n </span>\n </span>\n </>\n )}\n {popover ? (\n <IconButton\n icon=\"ellipsis-vertical\"\n appearance=\"discrete\"\n className={cn(\n 'group-aria-current:visible invisible -mr-1 ml-auto !h-5 min-h-[theme(spacing.6)] !w-5 min-w-[theme(spacing.6)] hover:!bg-black/[.08] focus:!shadow-none group-hover:visible',\n {\n '!visible': isMobileDevice(window?.navigator),\n }\n )}\n onClick={event => {\n event.stopPropagation();\n listboxRef?.current?.setActiveIndex(event.currentTarget.parentElement as HTMLDivElement);\n }}\n popover={popover}\n tabIndex={-1}\n />\n ) : null}\n </ListboxPrimitive.Option>\n );\n});\n"],"names":["Option","React","forwardRef","Select2Option","props","ref","children","color","description","prefix","postfix","className","cName","otherProps","onDelete","onEdit","listboxRef","multiple","selectRef","setOpen","shouldPauseHoverState","tags","value","fontSize","FontSizes","medium","useSelect2Context","cn","createOptionClassName","getFontSize","hasValue","Array","isArray","length","undefined","isTag","handleClick","_selectRef$current","current","focus","handleKeyDown","event","isAriaSelectionKey","key","isEmptyOption","popover","popoverProps","_props$textValue","_props$textValue2","EditPopover","textValue","String","text","ListboxPrimitive","onClick","onKeyDown","Icon","name","Tag","icon","IconButton","appearance","isMobileDevice","_window","window","navigator","stopPropagation","_listboxRef$current","setActiveIndex","currentTarget","parentElement","tabIndex"],"mappings":";;;;;;;;;;;;;;;;MAwBaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;;EACxG,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,WAAW;IAAEC,MAAM;IAAEC,OAAO;IAAEC,SAAS,EAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGT,KAAK;EAChG,MAAM;IACFU,QAAQ;IACRC,MAAM;IACNC,UAAU;IACVC,QAAQ;IACRZ,GAAG,EAAEa,SAAS;IACdC,OAAO;IACPC,qBAAqB;IACrBC,IAAI;IACJC,KAAK;IACLC,QAAQ,GAAGC,SAAS,CAACC;GACxB,GAAGC,iBAAiB,EAAE;EACvB,M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ACvBlD,UAAU,aAAVA,UAAU,wBAAAmD,mBAAA,GAAVnD,UAAU,CAAEsB,OAAO,cAAA6B,mBAAA,uBAAnBA,mBAAA,CAAqBC,cAAc,CAAC3B,KAAK,CAAC4B,aAAa,CAACC,aAA+B,CAAC;KAC3F;IACDzB,OAAO,EAAEA,OAAO;IAChB0B,QAAQ,EAAE,CAAC;IACb,IACF,IAAI,CACc;AAElC,CAAC;;;;"}
@@ -7,8 +7,8 @@ import { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom.js';
7
7
  import { Tooltip } from '../../Tooltip/Tooltip.js';
8
8
  import { getInputClasses } from '../../Input/util.js';
9
9
  import { ScrollArea } from '../../ScrollArea/ScrollArea.js';
10
- import { FontSizes } from '../../../types.js';
11
10
  import { Tag } from '../../Tag/Tag.js';
11
+ import { getFontSize } from '../utilities.js';
12
12
  import { useSelect2Context } from './Context.js';
13
13
 
14
14
  const Trigger = /*#__PURE__*/React__default.forwardRef(function Select2Trigger(props, ref) {
@@ -50,11 +50,8 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Select2TriggerBut
50
50
  highlighted,
51
51
  invalid,
52
52
  readOnly
53
- }).replace('w-full', '').replace('px-2', ''), {
54
- 'w-full': !((_props$className = props.className) !== null && _props$className !== void 0 && _props$className.includes('w-')),
55
- 'text-xs': fontSize === FontSizes.small,
56
- 'text-sm': fontSize === FontSizes.medium,
57
- 'text-base': fontSize === FontSizes.large
53
+ }).replace('w-full', '').replace('px-2', ''), fontSize && getFontSize(fontSize), {
54
+ 'w-full': !((_props$className = props.className) !== null && _props$className !== void 0 && _props$className.includes('w-'))
58
55
  }, props.className);
59
56
  const handleClick = event => {
60
57
  if (disabled || readOnly) {
@@ -1 +1 @@
1
- {"version":3,"file":"Trigger.js","sources":["../../../../../../../../src/components/Select2/components/Trigger.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Tag } from '../../Tag/Tag';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Icon } from '../../Icon/Icon';\nimport { Badge } from '../../Badge/Badge';\nimport { getInputClasses } from '../../Input/util';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { FontSize, FontSizes } from '../../../types';\n\ntype Select2TriggerProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n emptyValue?: Select2OptionValue;\n placeholder?: string;\n children: React.ReactElement<Select2OptionProps>[];\n fontSize?: FontSize;\n};\n\nexport const Trigger = React.forwardRef<HTMLButtonElement, Select2TriggerProps>(function Select2Trigger(props, ref) {\n const { multiple, value } = useSelect2Context();\n\n if (Array.isArray(value) || multiple) {\n const values = Array.isArray(value) ? value : value !== undefined ? [value] : undefined;\n return <Multiple {...props} ref={ref} values={values} />;\n }\n\n return <Single {...props} ref={ref} value={value} />;\n});\n\ntype ButtonProps = React.HTMLAttributes<HTMLButtonElement> &\n Omit<Select2TriggerProps, 'children' | 'open' | 'setValue' | 'value'>;\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Select2TriggerButton(props, ref) {\n const { children, onClick, tabIndex = 0, fontSize, ...otherProps } = props;\n const { disabled, highlighted, invalid, open, readOnly } = useSelect2Context();\n\n const className = cn(\n 'cursor-pointer px-1.5 h-fit',\n getInputClasses({ ...props, disabled, highlighted, invalid, readOnly })\n .replace('w-full', '')\n .replace('px-2', ''),\n {\n 'w-full': !props.className?.includes('w-'),\n 'text-xs': fontSize === FontSizes.small,\n 'text-sm': fontSize === FontSizes.medium,\n 'text-base': fontSize === FontSizes.large,\n },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || readOnly) {\n event.preventDefault();\n return;\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n };\n\n return (\n <button\n {...otherProps}\n aria-invalid={invalid ? true : undefined}\n aria-readonly={readOnly ? true : undefined}\n className={className}\n disabled={disabled}\n onClick={handleClick}\n ref={ref}\n role=\"combobox\"\n tabIndex={disabled || readOnly ? -1 : tabIndex}\n type=\"button\">\n {children}\n <Icon name={open ? 'chevron-up' : 'chevron-down'} className=\"pointer-events-none -mr-1 ml-auto\" />\n </button>\n );\n});\n\ntype SingleProps = Omit<Select2TriggerProps, 'value'> & { value?: Select2OptionValue; placeholder?: string };\n\nconst Single = React.forwardRef<HTMLButtonElement, SingleProps>(function Select2TriggerSingle(props, ref) {\n const { children, emptyValue, value, placeholder, ...buttonProps } = props;\n const { disabled, readOnly, tags } = useSelect2Context();\n const contentClassName = cn('truncate items-center gap-1');\n\n const currentValue = children.find(matchesValue(value));\n\n let output;\n\n if (placeholder && currentValue === undefined) {\n output = <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>;\n } else if (currentValue) {\n if (tags && emptyValue !== value) {\n output = (\n <Tag\n className=\"truncate\"\n color={currentValue.props.color}\n disabled={disabled}\n icon={currentValue.props.prefix}\n readOnly={readOnly}>\n {currentValue.props.children}\n </Tag>\n );\n } else {\n output = (\n <>\n {currentValue.props.prefix ? (\n typeof currentValue.props.prefix === 'string' ? (\n <Icon name={currentValue.props.prefix} className=\"mr-1 !h-5 !w-5\" />\n ) : (\n currentValue.props.prefix\n )\n ) : null}\n {currentValue.props.children}\n </>\n );\n }\n }\n\n return (\n <Button {...buttonProps} ref={ref}>\n <div className={contentClassName}>{output}</div>\n </Button>\n );\n});\n\ntype MultipleProps = Omit<Select2TriggerProps, 'value'> & {\n values?: Select2OptionValue[];\n};\n\nconst Multiple = React.forwardRef<HTMLButtonElement, MultipleProps>(function Select2TriggerMultiple(props, ref) {\n const { children, emptyValue: _, values = [], placeholder, ...buttonProps } = props;\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const buttonRef = useMergedRef<HTMLButtonElement>(ref);\n\n const valuesAsChildren = values\n .map(value => children.find(c => c.props.value === value))\n .filter(c => !!c) as React.ReactElement<Select2OptionProps>[];\n\n let content;\n let { className } = buttonProps;\n\n if (open) {\n className = cn('!absolute z-20 !h-fit', buttonProps.className);\n content = (\n <ScrollArea className=\"my-1 flex max-h-[5.5rem] flex-col\">\n <div className=\"flex flex-wrap gap-1\">\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map(child => (\n <Tag\n key={String(child.props.value)}\n className=\"truncate\"\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(child.props.value);\n }\n }}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))\n )}\n </div>\n </ScrollArea>\n );\n } else {\n content = <MultipleValue key={String(open)} valuesAsChildren={valuesAsChildren} placeholder={placeholder} />;\n }\n\n return (\n <div\n className=\"relative inline-flex h-fit flex-grow\"\n data-taco=\"select2-container\"\n style={{ width: open ? buttonRef.current?.offsetWidth : undefined }}>\n <Button {...buttonProps} className={className} ref={buttonRef}>\n {content}\n </Button>\n </div>\n );\n});\n\ntype MultipleValueProps = Omit<Select2TriggerProps, 'value' | 'children'> & {\n valuesAsChildren: React.ReactElement<Select2OptionProps>[];\n placeholder?: string;\n};\n\nconst MultipleValue = ({ valuesAsChildren, placeholder }: MultipleValueProps) => {\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const [contentRef, setContentRef] = React.useState<HTMLDivElement | null>(null);\n const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n\n return (\n <div className=\"relative flex items-center gap-1 overflow-hidden\">\n <div className=\"flex gap-1 truncate\" ref={el => setContentRef(el)}>\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map((child, index) => {\n const tag = (\n <Tag\n key={String(child.props.value)}\n className={cn('cursor-pointer', {\n truncate: index === boundaryIndex,\n hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false,\n })}\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n );\n\n if (index === boundaryIndex) {\n return (\n <Tooltip key={String(child.props.value)} title={String(child.props.children)}>\n {tag}\n </Tooltip>\n );\n }\n\n return tag;\n })\n )}\n </div>\n {boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (\n <Tooltip\n title={valuesAsChildren\n .slice(boundaryIndex + 1)\n .map(child => (child ? String(child.props.children) : ''))\n .join(', ')}>\n <Badge className=\"flex-shrink-0\">+{valuesAsChildren.length - (boundaryIndex + 1)}</Badge>\n </Tooltip>\n ) : null}\n </div>\n );\n};\n\nconst matchesValue = (value: undefined | any | any[]) => (child: React.ReactElement<any>) => {\n if (Array.isArray(value)) {\n return value.includes(child.props.value);\n }\n\n return child.props.value === value;\n};\n"],"names":["Trigger","React","forwardRef","Select2Trigger","props","ref","multiple","value","useSelect2Context","Array","isArray","values","undefined","Multiple","Single","Button","Select2TriggerButton","children","onClick","tabIndex","fontSize","otherProps","disabled","highlighted","invalid","open","readOnly","className","cn","getInputClasses","replace","_props$className","includes","FontSizes","small","medium","large","handleClick","event","preventDefault","role","type","Icon","name","Select2TriggerSingle","emptyValue","placeholder","buttonProps","tags","contentClassName","currentValue","find","matchesValue","output","Tag","color","icon","prefix","Select2TriggerMultiple","_","setValue","buttonRef","useMergedRef","valuesAsChildren","map","c","filter","content","ScrollArea","length","child","key","String","onDelete","stopPropagation","MultipleValue","style","width","_buttonRef$current","current","offsetWidth","contentRef","setContentRef","useState","boundaryIndex","getIndexOfFirstChildOverflowingParent","createClickHandler","tagValue","el","index","tag","truncate","hidden","Tooltip","title","slice","join","Badge"],"mappings":";;;;;;;;;;;;;MAsBaA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAyC,SAASC,cAAcA,CAACC,KAAK,EAAEC,GAAG;EAC9G,MAAM;IAAEC,QAAQ;IAAEC;GAAO,GAAGC,iBAAiB,EAAE;EAE/C,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAID,QAAQ,EAAE;IAClC,MAAMK,MAAM,GAAGF,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,KAAKK,SAAS,GAAG,CAACL,KAAK,CAAC,GAAGK,SAAS;IACvF,oBAAOX,6BAACY,QAAQ,oBAAKT,KAAK;MAAEC,GAAG,EAAEA,GAAG;MAAEM,MAAM,EAAEA;OAAU;;EAG5D,oBAAOV,6BAACa,MAAM,oBAAKV,KAAK;IAAEC,GAAG,EAAEA,GAAG;IAAEE,KAAK,EAAEA;KAAS;AACxD,CAAC;AAKD,MAAMQ,MAAM,gBAAGd,cAAK,CAACC,UAAU,CAAiC,SAASc,oBAAoBA,CAACZ,KAAK,EAAEC,GAAG;;EACpG,MAAM;IAAEY,QAAQ;IAAEC,OAAO;IAAEC,QAAQ,GAAG,CAAC;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGjB,KAAK;EAC1E,MAAM;IAAEkB,QAAQ;IAAEC,WAAW;IAAEC,OAAO;IAAEC,IAAI;IAAEC;GAAU,GAAGlB,iBAAiB,EAAE;EAE9E,MAAMmB,SAAS,GAAGC,EAAE,CAChB,6BAA6B,EAC7BC,eAAe,CAAC;IAAE,GAAGzB,KAAK;IAAEkB,QAAQ;IAAEC,WAAW;IAAEC,OAAO;IAAEE;GAAU,CAAC,CAClEI,OAAO,CAA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K,KAAKA,KAAK;AACtC,CAAC;;;;"}
1
+ {"version":3,"file":"Trigger.js","sources":["../../../../../../../../src/components/Select2/components/Trigger.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Tag } from '../../Tag/Tag';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Icon } from '../../Icon/Icon';\nimport { Badge } from '../../Badge/Badge';\nimport { getInputClasses } from '../../Input/util';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { FontSize } from '../../../types';\nimport { getFontSize } from '../utilities';\n\ntype Select2TriggerProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n emptyValue?: Select2OptionValue;\n placeholder?: string;\n children: React.ReactElement<Select2OptionProps>[];\n fontSize?: FontSize;\n};\n\nexport const Trigger = React.forwardRef<HTMLButtonElement, Select2TriggerProps>(function Select2Trigger(props, ref) {\n const { multiple, value } = useSelect2Context();\n\n if (Array.isArray(value) || multiple) {\n const values = Array.isArray(value) ? value : value !== undefined ? [value] : undefined;\n return <Multiple {...props} ref={ref} values={values} />;\n }\n\n return <Single {...props} ref={ref} value={value} />;\n});\n\ntype ButtonProps = React.HTMLAttributes<HTMLButtonElement> &\n Omit<Select2TriggerProps, 'children' | 'open' | 'setValue' | 'value'>;\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Select2TriggerButton(props, ref) {\n const { children, onClick, tabIndex = 0, fontSize, ...otherProps } = props;\n const { disabled, highlighted, invalid, open, readOnly } = useSelect2Context();\n\n const className = cn(\n 'cursor-pointer px-1.5 h-fit',\n getInputClasses({ ...props, disabled, highlighted, invalid, readOnly })\n .replace('w-full', '')\n .replace('px-2', ''),\n fontSize && getFontSize(fontSize),\n {\n 'w-full': !props.className?.includes('w-'),\n },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || readOnly) {\n event.preventDefault();\n return;\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n };\n\n return (\n <button\n {...otherProps}\n aria-invalid={invalid ? true : undefined}\n aria-readonly={readOnly ? true : undefined}\n className={className}\n disabled={disabled}\n onClick={handleClick}\n ref={ref}\n role=\"combobox\"\n tabIndex={disabled || readOnly ? -1 : tabIndex}\n type=\"button\">\n {children}\n <Icon name={open ? 'chevron-up' : 'chevron-down'} className=\"pointer-events-none -mr-1 ml-auto\" />\n </button>\n );\n});\n\ntype SingleProps = Omit<Select2TriggerProps, 'value'> & { value?: Select2OptionValue; placeholder?: string };\n\nconst Single = React.forwardRef<HTMLButtonElement, SingleProps>(function Select2TriggerSingle(props, ref) {\n const { children, emptyValue, value, placeholder, ...buttonProps } = props;\n const { disabled, readOnly, tags } = useSelect2Context();\n const contentClassName = cn('truncate items-center gap-1');\n\n const currentValue = children.find(matchesValue(value));\n\n let output;\n\n if (placeholder && currentValue === undefined) {\n output = <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>;\n } else if (currentValue) {\n if (tags && emptyValue !== value) {\n output = (\n <Tag\n className=\"truncate\"\n color={currentValue.props.color}\n disabled={disabled}\n icon={currentValue.props.prefix}\n readOnly={readOnly}>\n {currentValue.props.children}\n </Tag>\n );\n } else {\n output = (\n <>\n {currentValue.props.prefix ? (\n typeof currentValue.props.prefix === 'string' ? (\n <Icon name={currentValue.props.prefix} className=\"mr-1 !h-5 !w-5\" />\n ) : (\n currentValue.props.prefix\n )\n ) : null}\n {currentValue.props.children}\n </>\n );\n }\n }\n\n return (\n <Button {...buttonProps} ref={ref}>\n <div className={contentClassName}>{output}</div>\n </Button>\n );\n});\n\ntype MultipleProps = Omit<Select2TriggerProps, 'value'> & {\n values?: Select2OptionValue[];\n};\n\nconst Multiple = React.forwardRef<HTMLButtonElement, MultipleProps>(function Select2TriggerMultiple(props, ref) {\n const { children, emptyValue: _, values = [], placeholder, ...buttonProps } = props;\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const buttonRef = useMergedRef<HTMLButtonElement>(ref);\n\n const valuesAsChildren = values\n .map(value => children.find(c => c.props.value === value))\n .filter(c => !!c) as React.ReactElement<Select2OptionProps>[];\n\n let content;\n let { className } = buttonProps;\n\n if (open) {\n className = cn('!absolute z-20 !h-fit', buttonProps.className);\n content = (\n <ScrollArea className=\"my-1 flex max-h-[5.5rem] flex-col\">\n <div className=\"flex flex-wrap gap-1\">\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map(child => (\n <Tag\n key={String(child.props.value)}\n className=\"truncate\"\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(child.props.value);\n }\n }}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))\n )}\n </div>\n </ScrollArea>\n );\n } else {\n content = <MultipleValue key={String(open)} valuesAsChildren={valuesAsChildren} placeholder={placeholder} />;\n }\n\n return (\n <div\n className=\"relative inline-flex h-fit flex-grow\"\n data-taco=\"select2-container\"\n style={{ width: open ? buttonRef.current?.offsetWidth : undefined }}>\n <Button {...buttonProps} className={className} ref={buttonRef}>\n {content}\n </Button>\n </div>\n );\n});\n\ntype MultipleValueProps = Omit<Select2TriggerProps, 'value' | 'children'> & {\n valuesAsChildren: React.ReactElement<Select2OptionProps>[];\n placeholder?: string;\n};\n\nconst MultipleValue = ({ valuesAsChildren, placeholder }: MultipleValueProps) => {\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const [contentRef, setContentRef] = React.useState<HTMLDivElement | null>(null);\n const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n\n return (\n <div className=\"relative flex items-center gap-1 overflow-hidden\">\n <div className=\"flex gap-1 truncate\" ref={el => setContentRef(el)}>\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map((child, index) => {\n const tag = (\n <Tag\n key={String(child.props.value)}\n className={cn('cursor-pointer', {\n truncate: index === boundaryIndex,\n hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false,\n })}\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n );\n\n if (index === boundaryIndex) {\n return (\n <Tooltip key={String(child.props.value)} title={String(child.props.children)}>\n {tag}\n </Tooltip>\n );\n }\n\n return tag;\n })\n )}\n </div>\n {boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (\n <Tooltip\n title={valuesAsChildren\n .slice(boundaryIndex + 1)\n .map(child => (child ? String(child.props.children) : ''))\n .join(', ')}>\n <Badge className=\"flex-shrink-0\">+{valuesAsChildren.length - (boundaryIndex + 1)}</Badge>\n </Tooltip>\n ) : null}\n </div>\n );\n};\n\nconst matchesValue = (value: undefined | any | any[]) => (child: React.ReactElement<any>) => {\n if (Array.isArray(value)) {\n return value.includes(child.props.value);\n }\n\n return child.props.value === value;\n};\n"],"names":["Trigger","React","forwardRef","Select2Trigger","props","ref","multiple","value","useSelect2Context","Array","isArray","values","undefined","Multiple","Single","Button","Select2TriggerButton","children","onClick","tabIndex","fontSize","otherProps","disabled","highlighted","invalid","open","readOnly","className","cn","getInputClasses","replace","getFontSize","_props$className","includes","handleClick","event","preventDefault","role","type","Icon","name","Select2TriggerSingle","emptyValue","placeholder","buttonProps","tags","contentClassName","currentValue","find","matchesValue","output","Tag","color","icon","prefix","Select2TriggerMultiple","_","setValue","buttonRef","useMergedRef","valuesAsChildren","map","c","filter","content","ScrollArea","length","child","key","String","onDelete","stopPropagation","MultipleValue","style","width","_buttonRef$current","current","offsetWidth","contentRef","setContentRef","useState","boundaryIndex","getIndexOfFirstChildOverflowingParent","createClickHandler","tagValue","el","index","tag","truncate","hidden","Tooltip","title","slice","join","Badge"],"mappings":";;;;;;;;;;;;;MAuBaA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAyC,SAASC,cAAcA,CAACC,KAAK,EAAEC,GAAG;EAC9G,MAAM;IAAEC,QAAQ;IAAEC;GAAO,GAAGC,iBAAiB,EAAE;EAE/C,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAID,QAAQ,EAAE;IAClC,MAAMK,MAAM,GAAGF,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,KAAKK,SAAS,GAAG,CAACL,KAAK,CAAC,GAAGK,SAAS;IACvF,oBAAOX,6BAACY,QAAQ,oBAAKT,KAAK;MAAEC,GAAG,EAAEA,GAAG;MAAEM,MAAM,EAAEA;OAAU;;EAG5D,oBAAOV,6BAACa,MAAM,oBAAKV,KAAK;IAAEC,GAAG,EAAEA,GAAG;IAAEE,KAAK,EAAEA;KAAS;AACxD,CAAC;AAKD,MAAMQ,MAAM,gBAAGd,cAAK,CAACC,UAAU,CAAiC,SAASc,oBAAoBA,CAACZ,KAAK,EAAEC,GAAG;;EACpG,MAAM;IAAEY,QAAQ;IAAEC,OAAO;IAAEC,QAAQ,GAAG,CAAC;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGjB,KAAK;EAC1E,MAAM;IAAEkB,QAAQ;IAAEC,WAAW;IAAEC,OAAO;IAAEC,IAAI;IAAEC;GAAU,GAAGlB,iBAAiB,EAAE;EAE9E,MAAMmB,SAAS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AK,CAAC;;EAG5C,OAAO4D,KAAK,CAAC/D,KAAK,CAACG,KAAK,KAAKA,KAAK;AACtC,CAAC;;;;"}
@@ -1,9 +1,22 @@
1
1
  import cn from 'clsx';
2
+ import { FontSizes } from '../../types.js';
2
3
 
3
4
  const createOptionClassName = (shouldPauseHoverState = false) => cn('group mb-px flex w-full text-sm flex-shrink-0 font-normal cursor-pointer items-center rounded bg-white px-2 leading-8 text-black aria-hidden:hidden gap-1.5 bg-white aria-current:wcag-grey-200 aria-disabled:text-black/25 aria-disabled:pointer-events-none', {
4
5
  'hover:wcag-grey-200': !shouldPauseHoverState
5
6
  });
6
7
  const createCollectionClassName = () => 'flex flex-col gap-px';
8
+ const getFontSize = fontSize => {
9
+ switch (fontSize) {
10
+ case FontSizes.small:
11
+ return 'text-xs';
12
+ case FontSizes.medium:
13
+ return 'text-sm';
14
+ case FontSizes.large:
15
+ return 'text-base';
16
+ default:
17
+ return 'text-sm';
18
+ }
19
+ };
7
20
 
8
- export { createCollectionClassName, createOptionClassName };
21
+ export { createCollectionClassName, createOptionClassName, getFontSize };
9
22
  //# sourceMappingURL=utilities.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.js","sources":["../../../../../../../src/components/Select2/utilities.ts"],"sourcesContent":["import cn from 'clsx';\n\nexport const createOptionClassName = (shouldPauseHoverState = false) =>\n cn(\n 'group mb-px flex w-full text-sm flex-shrink-0 font-normal cursor-pointer items-center rounded bg-white px-2 leading-8 text-black aria-hidden:hidden gap-1.5 bg-white aria-current:wcag-grey-200 aria-disabled:text-black/25 aria-disabled:pointer-events-none',\n\n {\n 'hover:wcag-grey-200': !shouldPauseHoverState,\n }\n );\n\nexport const createCollectionClassName = () => 'flex flex-col gap-px';\n"],"names":["createOptionClassName","shouldPauseHoverState","cn","createCollectionClassName"],"mappings":";;MAEaA,qBAAqB,GAAGA,CAACC,qBAAqB,GAAG,KAAK,KAC/DC,EAAE,CACE,+PAA+P,EAE/P;EACI,qBAAqB,EAAE,CAACD;CAC3B;MAGIE,yBAAyB,GAAGA,MAAM;;;;"}
1
+ {"version":3,"file":"utilities.js","sources":["../../../../../../../src/components/Select2/utilities.ts"],"sourcesContent":["import cn from 'clsx';\nimport { FontSize, FontSizes } from '../../types';\n\nexport const createOptionClassName = (shouldPauseHoverState = false) =>\n cn(\n 'group mb-px flex w-full text-sm flex-shrink-0 font-normal cursor-pointer items-center rounded bg-white px-2 leading-8 text-black aria-hidden:hidden gap-1.5 bg-white aria-current:wcag-grey-200 aria-disabled:text-black/25 aria-disabled:pointer-events-none',\n\n {\n 'hover:wcag-grey-200': !shouldPauseHoverState,\n }\n );\n\nexport const createCollectionClassName = () => 'flex flex-col gap-px';\n\nexport const getFontSize = (fontSize: FontSize) => {\n switch (fontSize) {\n case FontSizes.small:\n return 'text-xs';\n case FontSizes.medium:\n return 'text-sm';\n case FontSizes.large:\n return 'text-base';\n default:\n return 'text-sm';\n }\n};\n"],"names":["createOptionClassName","shouldPauseHoverState","cn","createCollectionClassName","getFontSize","fontSize","FontSizes","small","medium","large"],"mappings":";;;MAGaA,qBAAqB,GAAGA,CAACC,qBAAqB,GAAG,KAAK,KAC/DC,EAAE,CACE,+PAA+P,EAE/P;EACI,qBAAqB,EAAE,CAACD;CAC3B;MAGIE,yBAAyB,GAAGA,MAAM;MAElCC,WAAW,GAAIC,QAAkB;EAC1C,QAAQA,QAAQ;IACZ,KAAKC,SAAS,CAACC,KAAK;MAChB,OAAO,SAAS;IACpB,KAAKD,SAAS,CAACE,MAAM;MACjB,OAAO,SAAS;IACpB,KAAKF,SAAS,CAACG,KAAK;MAChB,OAAO,WAAW;IACtB;MACI,OAAO,SAAS;;AAE5B;;;;"}
@@ -50,8 +50,8 @@ function Alert(props) {
50
50
  if (pendingChangesWithErrors.length > 1 && index === pendingChangesWithErrors.length - 1) {
51
51
  links.push(validationTexts.alert.messageAnd);
52
52
  }
53
+ const rowIndex = table.getRowModel().rows.findIndex(row => row.id === error.rowId);
53
54
  const handleClick = () => {
54
- const rowIndex = table.getRowModel().rows.findIndex(row => row.id === error.rowId);
55
55
  if (rowIndex > -1) {
56
56
  scrollToRow(rowIndex);
57
57
  } else {
@@ -74,7 +74,7 @@ function Alert(props) {
74
74
  className: "text-blue",
75
75
  onClick: handleClick,
76
76
  role: "button"
77
- }, rowIdentityColumn ? error.pendingChange._meta.original[rowIdentityColumn.id] : error.rowId)));
77
+ }, rowIdentityColumn ? error.pendingChange._meta.original[rowIdentityColumn.id] : rowIndex + 1)));
78
78
  // if appropriate, concatenate the item with the text ","
79
79
  if (pendingChangesWithErrors.length > 2 && index < pendingChangesWithErrors.length - 2) {
80
80
  links.push(', ');