@economic/taco 1.34.2 → 1.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/components/Provider/Localization.d.ts +3 -0
  2. package/dist/components/Select2/Select2.d.ts +2 -2
  3. package/dist/components/Select2/hooks/useChildren.d.ts +3 -4
  4. package/dist/components/Select2/types.d.ts +3 -0
  5. package/dist/components/Table2/Table2.d.ts +3 -0
  6. package/dist/components/Table2/types.d.ts +2 -0
  7. package/dist/esm/packages/taco/src/components/Provider/Localization.js +3 -0
  8. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  9. package/dist/esm/packages/taco/src/components/Select2/Select2.js +20 -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 -1
  12. package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Select2/hooks/useChildren.js +2 -9
  14. package/dist/esm/packages/taco/src/components/Select2/hooks/useChildren.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Table2/Table2.js +10 -1
  16. package/dist/esm/packages/taco/src/components/Table2/Table2.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js +4 -3
  18. package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js +4 -1
  20. package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js +4 -0
  22. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js.map +1 -1
  23. package/dist/esm/packages/taco/src/components/Table2/types.js.map +1 -1
  24. package/dist/taco.cjs.development.js +48 -16
  25. package/dist/taco.cjs.development.js.map +1 -1
  26. package/dist/taco.cjs.production.min.js +1 -1
  27. package/dist/taco.cjs.production.min.js.map +1 -1
  28. package/package.json +2 -2
  29. package/types.json +30 -3
@@ -137,6 +137,9 @@ export declare const defaultLocalisationTexts: {
137
137
  };
138
138
  table2: {
139
139
  columns: {
140
+ resize: {
141
+ tooltip: string;
142
+ };
140
143
  actions: {
141
144
  tooltip: string;
142
145
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Select2OptionValue, Select2Value } from './types';
2
+ import { Select2Children, Select2OptionValue, Select2Value } from './types';
3
3
  import { Select2OptionProps } from './components/Option';
4
4
  import { Select2GroupProps } from './components/Group';
5
5
  import { Select2TitleProps } from './components/Title';
@@ -17,7 +17,7 @@ declare type Select2Texts = {
17
17
  };
18
18
  declare type Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {
19
19
  autoFocus?: boolean;
20
- children: Array<React.ReactElement<Select2OptionProps> | React.ReactElement<Select2GroupProps>>;
20
+ children: Select2Children;
21
21
  defaultValue?: Select2Value;
22
22
  emptyValue?: Select2OptionValue;
23
23
  disabled?: boolean;
@@ -1,9 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Select2OptionProps } from '../components/Option';
3
- import { Select2GroupProps } from '../Select2';
4
- import { Select2OptionValue, Select2Value } from '../types';
3
+ import { Select2Children, Select2OptionValue, Select2Value } from '../types';
5
4
  export declare type useChildrenArgs = {
6
- children: Array<React.ReactElement<Select2OptionProps> | React.ReactElement<Select2GroupProps>>;
5
+ children: Select2Children;
7
6
  emptyValue?: Select2OptionValue;
8
7
  multiple?: boolean;
9
8
  open?: boolean;
@@ -12,7 +11,7 @@ export declare type useChildrenArgs = {
12
11
  };
13
12
  export declare const useChildren: ({ children: initialChildren, emptyValue, multiple, open, setValue, value }: useChildrenArgs) => {
14
13
  flattenedChildren: React.ReactElement<Select2OptionProps, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>[];
15
- filteredChildren: (React.ReactElement<Select2OptionProps, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactElement<Select2GroupProps, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>)[];
14
+ filteredChildren: Select2Children;
16
15
  searchQuery: string;
17
16
  setSearchQuery: React.Dispatch<React.SetStateAction<string>>;
18
17
  };
@@ -1,3 +1,6 @@
1
+ /// <reference types="react" />
1
2
  import { Listbox2OptionValue } from '../../primitives/Listbox2/types';
3
+ import { Select2GroupProps, Select2OptionProps } from './Select2';
2
4
  export declare type Select2OptionValue = Listbox2OptionValue;
3
5
  export declare type Select2Value = Select2OptionValue | Select2OptionValue[];
6
+ export declare type Select2Children = Array<React.ReactElement<Select2OptionProps> | React.ReactElement<Select2GroupProps>>;
@@ -2,6 +2,9 @@ import React from 'react';
2
2
  import { Table2Props, Table2ColumnProps } from './types';
3
3
  export declare type Table2Texts = {
4
4
  columns: {
5
+ resize: {
6
+ tooltip: string;
7
+ };
5
8
  actions: {
6
9
  tooltip: string;
7
10
  };
@@ -89,6 +89,7 @@ export declare type Table2Settings = {
89
89
  };
90
90
  export declare type RowClickHandler<TType = any> = (row: TType) => void;
91
91
  export declare type RowDragHandler<TType = any> = (rows: TType[], showPlaceholder: (string: any) => void, setDataTransfer: (data: string) => void) => void;
92
+ export declare type RowDropHandler<TType = any> = (event: React.DragEvent, row: TType) => void;
92
93
  export declare type RowSelectionHandler<TType = any> = (rows: TType[]) => void;
93
94
  export declare type RowExpansionRenderer<TType = any> = (row: TType) => (() => JSX.Element) | null;
94
95
  export declare type SortHandler = OnChangeFn<SortingState>;
@@ -128,6 +129,7 @@ export declare type Table2Props<TType = any> = Omit<React.HTMLAttributes<HTMLDiv
128
129
  onChangeSettings?: SettingsHandler;
129
130
  onRowClick?: RowClickHandler<TType>;
130
131
  onRowDrag?: RowDragHandler<TType>;
132
+ onRowDrop?: RowDropHandler<TType>;
131
133
  onRowSelect?: RowSelectionHandler<TType>;
132
134
  onSave?: SaveHandler<TType>;
133
135
  toolbarLeft?: JSX.Element;
@@ -70,6 +70,9 @@ const defaultLocalisationTexts = {
70
70
  },
71
71
  table2: {
72
72
  columns: {
73
+ resize: {
74
+ tooltip: 'Resize column'
75
+ },
73
76
  actions: {
74
77
  tooltip: 'Other actions'
75
78
  },
@@ -1 +1 @@
1
- {"version":3,"file":"Localization.js","sources":["../../../../../../../src/components/Provider/Localization.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Locale } from '../../types';\nimport { CalendarTexts } from '../Calendar/Calendar';\nimport { ComboboxTexts } from '../Combobox/Combobox';\nimport { DialogTexts } from '../Dialog/Dialog';\nimport { PaginationTexts } from '../Pagination/Pagination';\nimport { ListboxTexts } from '../Listbox/Listbox';\nimport { ToastsTexts } from '../Toast/Toast';\nimport { DatepickerTexts } from '../Datepicker/Datepicker';\nimport { HeaderTexts } from '../Header/Header';\nimport { HangerTexts } from '../Hanger/Hanger';\nimport { SelectTexts } from '../Select/Select';\nimport { TourTexts } from '../Tour/Tour';\nimport { TableTexts } from '../Table/Table';\nimport { Table2Texts } from '../Table2/Table2';\nimport { SearchInputTexts } from '../SearchInput/SearchInput';\nimport { Select2Texts } from '../Select2/Select2';\nimport { BannerTexts } from '../Banner/Banner';\nimport { DrawerTexts } from '../Drawer/Drawer';\n\nexport type LocalizationTexts = {\n /** Localized texts and aria-labels for [Banner](component:banner) component */\n banner: BannerTexts;\n /** Localized texts and aria-labels for [Calendar](component:calendar) component */\n calendar: CalendarTexts;\n /** Localized texts and aria-labels for [Combobox](component:combobox) component */\n combobox: ComboboxTexts;\n /** Localized texts and aria-labels for [DatePicker](component:datepicker) component */\n datepicker: DatepickerTexts;\n /** Localized texts and aria-labels for [Dialog](component:dialog) component */\n dialog: DialogTexts;\n /** Localized texts and aria-labels for [Hanger](component:hanger) component */\n hanger: HangerTexts;\n /** Localized texts and aria-labels for [Header](component:header) component */\n header: HeaderTexts;\n /** Localized texts and aria-labels for [Listbox](component:listbox) component */\n listbox: ListboxTexts;\n /** Localized texts and aria-labels for [Pagination](component:pagination) component */\n pagination: PaginationTexts;\n /** Localized texts and aria-labels for [Table](component:table) component */\n table: TableTexts;\n /** Localized texts and aria-labels for [Table2](component:table2) component */\n table2: Table2Texts;\n /** Localized texts and aria-labels for [SearchInput](component:searchinput) component */\n searchInput: SearchInputTexts;\n /** Localized texts and aria-labels for [Select](component:select) component */\n select: SelectTexts;\n /** Localized texts and aria-labels for [Select2](component:select2) component */\n select2: Select2Texts;\n /** Localized texts and aria-labels for [Toast](component:toast) component */\n toasts: ToastsTexts;\n /** Localized texts and aria-labels for [Tour](component:tour) component */\n tour: TourTexts;\n /** Localized texts and aria-labels for [Drawer](component:drawer) component */\n drawer: DrawerTexts;\n};\n\nexport type Localization = {\n /**\n * Provide the language code used in application.\n * Default value is `en-GB`\n */\n locale: Locale;\n /** Provide the texts and aria-labels for components used within the provider */\n texts: LocalizationTexts;\n /** Provide the formatting */\n formatting: {\n /** Default value is `dd.mm.yy` */\n date: string;\n };\n};\n\nexport const defaultLocalisationTexts = {\n banner: {\n close: 'Close',\n },\n calendar: {\n months: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ],\n weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n actions: {\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n previousYear: 'Previous year',\n nextYear: 'Next year',\n today: 'Today',\n },\n },\n combobox: {\n tooltip: 'Search in list',\n },\n datepicker: {\n calendar: 'Calendar',\n clear: 'Clear',\n expand: 'Show calendar',\n shortcuts: 'Shortcuts',\n },\n dialog: {\n close: 'Close',\n drag: 'Drag',\n },\n hanger: {\n close: 'Close',\n },\n header: {\n addAgreement: 'Add agreement',\n logout: 'Log off',\n more: 'More',\n new: 'New',\n search: 'Search for agreement...',\n },\n listbox: {\n loading: 'Loading results...',\n empty: 'No results found',\n allOption: 'All',\n },\n pagination: {\n label: 'Pagination',\n pageSize: 'Items per page',\n showingXofYofTotal: 'Showing [X] - [Y] of [total]',\n actions: {\n firstPage: 'Goto first page',\n firstPageWithShortcut: 'Goto first page (Home)',\n previousPage: 'Goto previous page',\n previousPageWithShortcut: 'Goto previous page (Page Up)',\n nextPage: 'Goto next page',\n nextPageWithShortcut: 'Goto next page (Page Down)',\n lastPage: 'Goto last page',\n lastPageWithShortcut: 'Goto last page (End)',\n pageX: 'Goto page [X]',\n },\n },\n table: {\n actions: 'Other actions',\n edit: 'Edit (e)',\n copy: 'Copy (c)',\n del: 'Delete (del)',\n newSubRow: 'New row (shift + n)',\n loading: 'Loading...',\n },\n table2: {\n columns: {\n actions: {\n tooltip: 'Other actions',\n },\n drag: {\n tooltip: 'Drag row',\n },\n expansion: {\n collapse: 'Collapse row',\n collapseAll: 'Collapse all rows',\n expand: 'Expand row',\n expandAll: 'Expand all rows',\n },\n select: {\n deselect: 'Deselect row',\n deselectAll: 'Deselect all rows',\n select: 'Select row',\n selectAll: 'Select all rows',\n },\n menu: {\n freezeColumns: (count = 1) => (count === 1 ? 'Freeze the first column' : `Freeze first ${count} columns`),\n unfreezeColumns: 'Unfreeze all columns',\n },\n },\n columnSettings: {\n search: 'Search column...',\n tooltip: 'Column settings',\n button: 'Columns',\n noResults: 'No results',\n },\n editing: {\n button: 'Edit',\n tooltip: 'Edit',\n tooltipDisabled: 'There are no visible columns that support editing',\n rowIndicator: {\n rowWillMove: 'Row will move due to sorting',\n rowWillBeHidden: 'Row will hide due to filtering',\n rowWillMoveReasonSearch:\n 'Due to a search filter applied to this table, this row will be hidden as soon as you select another row',\n rowWillMoveReasonFilter:\n \"Due to a filter applied to the column '[COLUMN]', this row will be hidden as soon as you select another row\",\n rowWillMoveReasonSorting:\n \"Due to sorting applied to the column '[COLUMN]', this row will move position as soon as you select another row\",\n },\n },\n filters: {\n button: 'Filters',\n buttons: {\n addFilter: 'Add Filter',\n clearFilters: 'Clear all filters',\n },\n comparators: {\n contains: 'Contains',\n doesNotContain: 'Does not contain',\n isEqualTo: 'Is',\n isNotEqualTo: 'Is not',\n isGreaterThan: 'Is greater than',\n isLessThan: 'Is less than',\n isBetween: 'Is between',\n isOneOf: 'Is one of',\n isNoneOf: 'Is none of',\n isAllOf: 'Is all of',\n isEmpty: 'Is empty',\n isNotEmpty: 'Is not empty',\n },\n tooltip: 'Apply filters',\n total: 'Viewing [CURRENT] of [TOTAL]',\n },\n rowDensity: {\n tooltip: 'Row density',\n },\n search: {\n placeholder: 'Search...',\n },\n shortcuts: {\n tooltip: 'View keyboard shortcuts',\n search: 'Search',\n filter: 'Filter',\n previousRow: 'Previous row',\n nextRow: 'Next row',\n editCell: 'Edit cell',\n previousColumn: 'Previous column',\n nextColumn: 'Next column',\n rowClick: 'Activate current row',\n selectRow: 'Select current row',\n selectAllRows: 'Select all rows',\n expandRow: 'Expand current row',\n collapseRow: 'Collapse current row',\n },\n },\n searchInput: {\n button: 'Search',\n placeholder: 'Search...',\n clear: 'Clear',\n },\n select: {\n allOptionsSelected: 'All',\n },\n select2: {\n allSelect: 'Select all',\n allDeselect: 'Deselect all',\n cancel: 'Cancel',\n chooseColor: 'Pick a color',\n create: 'Create',\n delete: 'Delete',\n save: 'Save',\n search: 'Search...',\n searchOrCreate: 'Search or create...',\n },\n toasts: {\n dismiss: 'Dismiss',\n },\n tour: {\n back: 'Back',\n close: 'Close',\n skip: 'Close and complete',\n last: 'Done',\n next: 'Next',\n open: 'Open',\n },\n drawer: {\n close: 'Close',\n },\n};\n\nexport const defaultLocalizationContext: Localization = {\n locale: 'en-GB',\n texts: defaultLocalisationTexts,\n formatting: {\n date: 'dd.mm.yy',\n },\n};\n\nexport const LocalizationContext = React.createContext<Localization>(defaultLocalizationContext);\nexport interface LocalizationProviderProps {\n children: React.ReactNode;\n localization?: Localization;\n}\nexport const LocalizationProvider: React.FC<LocalizationProviderProps> = ({ localization, children }) => {\n return (\n <LocalizationContext.Provider value={localization ?? defaultLocalizationContext}>{children}</LocalizationContext.Provider>\n );\n};\n\nexport const useLocalization = () => React.useContext(LocalizationContext);\n"],"names":["defaultLocalisationTexts","banner","close","calendar","months","weekdaysShort","weekdays","actions","previousMonth","nextMonth","previousYear","nextYear","today","combobox","tooltip","datepicker","clear","expand","shortcuts","dialog","drag","hanger","header","addAgreement","logout","more","new","search","listbox","loading","empty","allOption","pagination","label","pageSize","showingXofYofTotal","firstPage","firstPageWithShortcut","previousPage","previousPageWithShortcut","nextPage","nextPageWithShortcut","lastPage","lastPageWithShortcut","pageX","table","edit","copy","del","newSubRow","table2","columns","expansion","collapse","collapseAll","expandAll","select","deselect","deselectAll","selectAll","menu","freezeColumns","count","unfreezeColumns","columnSettings","button","noResults","editing","tooltipDisabled","rowIndicator","rowWillMove","rowWillBeHidden","rowWillMoveReasonSearch","rowWillMoveReasonFilter","rowWillMoveReasonSorting","filters","buttons","addFilter","clearFilters","comparators","contains","doesNotContain","isEqualTo","isNotEqualTo","isGreaterThan","isLessThan","isBetween","isOneOf","isNoneOf","isAllOf","isEmpty","isNotEmpty","total","rowDensity","placeholder","filter","previousRow","nextRow","editCell","previousColumn","nextColumn","rowClick","selectRow","selectAllRows","expandRow","collapseRow","searchInput","allOptionsSelected","select2","allSelect","allDeselect","cancel","chooseColor","create","delete","save","searchOrCreate","toasts","dismiss","tour","back","skip","last","next","open","drawer","defaultLocalizationContext","locale","texts","formatting","date","LocalizationContext","React","LocalizationProvider","localization","children","Provider","value","useLocalization"],"mappings":";;MAwEaA,wBAAwB,GAAG;EACpCC,MAAM,EAAE;IACJC,KAAK,EAAE;GACV;EACDC,QAAQ,EAAE;IACNC,MAAM,EAAE,CACJ,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAU,CACb;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AM,EAAE;IACJC,OAAO,EAAE;GACZ;EACDC,IAAI,EAAE;IACFC,IAAI,EAAE,MAAM;IACZtH,KAAK,EAAE,OAAO;IACduH,IAAI,EAAE,oBAAoB;IAC1BC,IAAI,EAAE,MAAM;IACZC,IAAI,EAAE,MAAM;IACZC,IAAI,EAAE;GACT;EACDC,MAAM,EAAE;IACJ3H,KAAK,EAAE;;;MAIF4H,0BAA0B,GAAiB;EACpDC,MAAM,EAAE,OAAO;EACfC,KAAK,EAAEhI,wBAAwB;EAC/BiI,UAAU,EAAE;IACRC,IAAI,EAAE;;;MAIDC,mBAAmB,gBAAGC,aAAmB,CAAeN,0BAA0B;MAKlFO,oBAAoB,GAAwC,CAAC;EAAEC,YAAY;EAAEC;CAAU;EAChG,oBACIH,cAACD,mBAAmB,CAACK,QAAQ;IAACC,KAAK,EAAEH,YAAY,aAAZA,YAAY,cAAZA,YAAY,GAAIR;KAA6BS,QAAQ,CAAgC;AAElI;MAEaG,eAAe,GAAG,MAAMN,UAAgB,CAACD,mBAAmB;;;;"}
1
+ {"version":3,"file":"Localization.js","sources":["../../../../../../../src/components/Provider/Localization.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Locale } from '../../types';\nimport { CalendarTexts } from '../Calendar/Calendar';\nimport { ComboboxTexts } from '../Combobox/Combobox';\nimport { DialogTexts } from '../Dialog/Dialog';\nimport { PaginationTexts } from '../Pagination/Pagination';\nimport { ListboxTexts } from '../Listbox/Listbox';\nimport { ToastsTexts } from '../Toast/Toast';\nimport { DatepickerTexts } from '../Datepicker/Datepicker';\nimport { HeaderTexts } from '../Header/Header';\nimport { HangerTexts } from '../Hanger/Hanger';\nimport { SelectTexts } from '../Select/Select';\nimport { TourTexts } from '../Tour/Tour';\nimport { TableTexts } from '../Table/Table';\nimport { Table2Texts } from '../Table2/Table2';\nimport { SearchInputTexts } from '../SearchInput/SearchInput';\nimport { Select2Texts } from '../Select2/Select2';\nimport { BannerTexts } from '../Banner/Banner';\nimport { DrawerTexts } from '../Drawer/Drawer';\n\nexport type LocalizationTexts = {\n /** Localized texts and aria-labels for [Banner](component:banner) component */\n banner: BannerTexts;\n /** Localized texts and aria-labels for [Calendar](component:calendar) component */\n calendar: CalendarTexts;\n /** Localized texts and aria-labels for [Combobox](component:combobox) component */\n combobox: ComboboxTexts;\n /** Localized texts and aria-labels for [DatePicker](component:datepicker) component */\n datepicker: DatepickerTexts;\n /** Localized texts and aria-labels for [Dialog](component:dialog) component */\n dialog: DialogTexts;\n /** Localized texts and aria-labels for [Hanger](component:hanger) component */\n hanger: HangerTexts;\n /** Localized texts and aria-labels for [Header](component:header) component */\n header: HeaderTexts;\n /** Localized texts and aria-labels for [Listbox](component:listbox) component */\n listbox: ListboxTexts;\n /** Localized texts and aria-labels for [Pagination](component:pagination) component */\n pagination: PaginationTexts;\n /** Localized texts and aria-labels for [Table](component:table) component */\n table: TableTexts;\n /** Localized texts and aria-labels for [Table2](component:table2) component */\n table2: Table2Texts;\n /** Localized texts and aria-labels for [SearchInput](component:searchinput) component */\n searchInput: SearchInputTexts;\n /** Localized texts and aria-labels for [Select](component:select) component */\n select: SelectTexts;\n /** Localized texts and aria-labels for [Select2](component:select2) component */\n select2: Select2Texts;\n /** Localized texts and aria-labels for [Toast](component:toast) component */\n toasts: ToastsTexts;\n /** Localized texts and aria-labels for [Tour](component:tour) component */\n tour: TourTexts;\n /** Localized texts and aria-labels for [Drawer](component:drawer) component */\n drawer: DrawerTexts;\n};\n\nexport type Localization = {\n /**\n * Provide the language code used in application.\n * Default value is `en-GB`\n */\n locale: Locale;\n /** Provide the texts and aria-labels for components used within the provider */\n texts: LocalizationTexts;\n /** Provide the formatting */\n formatting: {\n /** Default value is `dd.mm.yy` */\n date: string;\n };\n};\n\nexport const defaultLocalisationTexts = {\n banner: {\n close: 'Close',\n },\n calendar: {\n months: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ],\n weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n actions: {\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n previousYear: 'Previous year',\n nextYear: 'Next year',\n today: 'Today',\n },\n },\n combobox: {\n tooltip: 'Search in list',\n },\n datepicker: {\n calendar: 'Calendar',\n clear: 'Clear',\n expand: 'Show calendar',\n shortcuts: 'Shortcuts',\n },\n dialog: {\n close: 'Close',\n drag: 'Drag',\n },\n hanger: {\n close: 'Close',\n },\n header: {\n addAgreement: 'Add agreement',\n logout: 'Log off',\n more: 'More',\n new: 'New',\n search: 'Search for agreement...',\n },\n listbox: {\n loading: 'Loading results...',\n empty: 'No results found',\n allOption: 'All',\n },\n pagination: {\n label: 'Pagination',\n pageSize: 'Items per page',\n showingXofYofTotal: 'Showing [X] - [Y] of [total]',\n actions: {\n firstPage: 'Goto first page',\n firstPageWithShortcut: 'Goto first page (Home)',\n previousPage: 'Goto previous page',\n previousPageWithShortcut: 'Goto previous page (Page Up)',\n nextPage: 'Goto next page',\n nextPageWithShortcut: 'Goto next page (Page Down)',\n lastPage: 'Goto last page',\n lastPageWithShortcut: 'Goto last page (End)',\n pageX: 'Goto page [X]',\n },\n },\n table: {\n actions: 'Other actions',\n edit: 'Edit (e)',\n copy: 'Copy (c)',\n del: 'Delete (del)',\n newSubRow: 'New row (shift + n)',\n loading: 'Loading...',\n },\n table2: {\n columns: {\n resize: {\n tooltip: 'Resize column',\n },\n actions: {\n tooltip: 'Other actions',\n },\n drag: {\n tooltip: 'Drag row',\n },\n expansion: {\n collapse: 'Collapse row',\n collapseAll: 'Collapse all rows',\n expand: 'Expand row',\n expandAll: 'Expand all rows',\n },\n select: {\n deselect: 'Deselect row',\n deselectAll: 'Deselect all rows',\n select: 'Select row',\n selectAll: 'Select all rows',\n },\n menu: {\n freezeColumns: (count = 1) => (count === 1 ? 'Freeze the first column' : `Freeze first ${count} columns`),\n unfreezeColumns: 'Unfreeze all columns',\n },\n },\n columnSettings: {\n search: 'Search column...',\n tooltip: 'Column settings',\n button: 'Columns',\n noResults: 'No results',\n },\n editing: {\n button: 'Edit',\n tooltip: 'Edit',\n tooltipDisabled: 'There are no visible columns that support editing',\n rowIndicator: {\n rowWillMove: 'Row will move due to sorting',\n rowWillBeHidden: 'Row will hide due to filtering',\n rowWillMoveReasonSearch:\n 'Due to a search filter applied to this table, this row will be hidden as soon as you select another row',\n rowWillMoveReasonFilter:\n \"Due to a filter applied to the column '[COLUMN]', this row will be hidden as soon as you select another row\",\n rowWillMoveReasonSorting:\n \"Due to sorting applied to the column '[COLUMN]', this row will move position as soon as you select another row\",\n },\n },\n filters: {\n button: 'Filters',\n buttons: {\n addFilter: 'Add Filter',\n clearFilters: 'Clear all filters',\n },\n comparators: {\n contains: 'Contains',\n doesNotContain: 'Does not contain',\n isEqualTo: 'Is',\n isNotEqualTo: 'Is not',\n isGreaterThan: 'Is greater than',\n isLessThan: 'Is less than',\n isBetween: 'Is between',\n isOneOf: 'Is one of',\n isNoneOf: 'Is none of',\n isAllOf: 'Is all of',\n isEmpty: 'Is empty',\n isNotEmpty: 'Is not empty',\n },\n tooltip: 'Apply filters',\n total: 'Viewing [CURRENT] of [TOTAL]',\n },\n rowDensity: {\n tooltip: 'Row density',\n },\n search: {\n placeholder: 'Search...',\n },\n shortcuts: {\n tooltip: 'View keyboard shortcuts',\n search: 'Search',\n filter: 'Filter',\n previousRow: 'Previous row',\n nextRow: 'Next row',\n editCell: 'Edit cell',\n previousColumn: 'Previous column',\n nextColumn: 'Next column',\n rowClick: 'Activate current row',\n selectRow: 'Select current row',\n selectAllRows: 'Select all rows',\n expandRow: 'Expand current row',\n collapseRow: 'Collapse current row',\n },\n },\n searchInput: {\n button: 'Search',\n placeholder: 'Search...',\n clear: 'Clear',\n },\n select: {\n allOptionsSelected: 'All',\n },\n select2: {\n allSelect: 'Select all',\n allDeselect: 'Deselect all',\n cancel: 'Cancel',\n chooseColor: 'Pick a color',\n create: 'Create',\n delete: 'Delete',\n save: 'Save',\n search: 'Search...',\n searchOrCreate: 'Search or create...',\n },\n toasts: {\n dismiss: 'Dismiss',\n },\n tour: {\n back: 'Back',\n close: 'Close',\n skip: 'Close and complete',\n last: 'Done',\n next: 'Next',\n open: 'Open',\n },\n drawer: {\n close: 'Close',\n },\n};\n\nexport const defaultLocalizationContext: Localization = {\n locale: 'en-GB',\n texts: defaultLocalisationTexts,\n formatting: {\n date: 'dd.mm.yy',\n },\n};\n\nexport const LocalizationContext = React.createContext<Localization>(defaultLocalizationContext);\nexport interface LocalizationProviderProps {\n children: React.ReactNode;\n localization?: Localization;\n}\nexport const LocalizationProvider: React.FC<LocalizationProviderProps> = ({ localization, children }) => {\n return (\n <LocalizationContext.Provider value={localization ?? defaultLocalizationContext}>{children}</LocalizationContext.Provider>\n );\n};\n\nexport const useLocalization = () => React.useContext(LocalizationContext);\n"],"names":["defaultLocalisationTexts","banner","close","calendar","months","weekdaysShort","weekdays","actions","previousMonth","nextMonth","previousYear","nextYear","today","combobox","tooltip","datepicker","clear","expand","shortcuts","dialog","drag","hanger","header","addAgreement","logout","more","new","search","listbox","loading","empty","allOption","pagination","label","pageSize","showingXofYofTotal","firstPage","firstPageWithShortcut","previousPage","previousPageWithShortcut","nextPage","nextPageWithShortcut","lastPage","lastPageWithShortcut","pageX","table","edit","copy","del","newSubRow","table2","columns","resize","expansion","collapse","collapseAll","expandAll","select","deselect","deselectAll","selectAll","menu","freezeColumns","count","unfreezeColumns","columnSettings","button","noResults","editing","tooltipDisabled","rowIndicator","rowWillMove","rowWillBeHidden","rowWillMoveReasonSearch","rowWillMoveReasonFilter","rowWillMoveReasonSorting","filters","buttons","addFilter","clearFilters","comparators","contains","doesNotContain","isEqualTo","isNotEqualTo","isGreaterThan","isLessThan","isBetween","isOneOf","isNoneOf","isAllOf","isEmpty","isNotEmpty","total","rowDensity","placeholder","filter","previousRow","nextRow","editCell","previousColumn","nextColumn","rowClick","selectRow","selectAllRows","expandRow","collapseRow","searchInput","allOptionsSelected","select2","allSelect","allDeselect","cancel","chooseColor","create","delete","save","searchOrCreate","toasts","dismiss","tour","back","skip","last","next","open","drawer","defaultLocalizationContext","locale","texts","formatting","date","LocalizationContext","React","LocalizationProvider","localization","children","Provider","value","useLocalization"],"mappings":";;MAwEaA,wBAAwB,GAAG;EACpCC,MAAM,EAAE;IACJC,KAAK,EAAE;GACV;EACDC,QAAQ,EAAE;IACNC,MAAM,EAAE,CACJ,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAU,CACb;IACDC,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;IAChEC,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC;IACxFC,OAAO,EAAE;MACLC,aAAa,EAAE,gBAAgB;MAC/BC,SAAS,EAAE,YAAY;MACvBC,YAAY,EAAE,eAAe;MAC7BC,QAAQ,EAAE,WAAW;MACrBC,KAAK,EAAE;;GAEd;EACDC,QAAQ,EAAE;IACNC,OAAO,EAAE;GACZ;EACDC,UAAU,EAAE;IACRZ,QAAQ,EAAE,UAAU;IACpBa,KAAK,EAAE,OAAO;IACdC,MAAM,EAAE,eAAe;IACvBC,SAAS,EAAE;GACd;EACDC,MAAM,EAAE;IACJjB,KAAK,EAAE,OAAO;IACdkB,IAAI,EAAE;GACT;EACDC,MAAM,EAAE;IACJnB,KAAK,EAAE;GACV;EACDoB,MAAM,EAAE;IACJC,YAAY,EAAE,eAAe;IAC7BC,MAAM,EAAE,SAAS;IACjBC,IAAI,EAAE,MAAM;IACZC,GAAG,EAAE,KA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27
 
28
28
  const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, ref) {
29
29
  const {
30
- children: initialChildren,
30
+ children: initChildren,
31
31
  defaultValue: defaultProp,
32
32
  disabled = false,
33
33
  emptyValue = undefined,
@@ -44,6 +44,24 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
44
44
  value: prop,
45
45
  ...otherProps
46
46
  } = props;
47
+ const emptyOption = React__default.useMemo(() => {
48
+ if (emptyValue !== undefined && !multiple) {
49
+ // Empty option has 0px height, because it's empty, so need to apply height manually
50
+ return /*#__PURE__*/React__default.createElement(Option, {
51
+ key: "__empty",
52
+ children: "",
53
+ value: emptyValue,
54
+ className: "h-8"
55
+ });
56
+ }
57
+ return;
58
+ }, [emptyValue, multiple]);
59
+ const initialChildren = React__default.useMemo(() => {
60
+ if (emptyOption) {
61
+ return [emptyOption, ...initChildren];
62
+ }
63
+ return initChildren;
64
+ }, [emptyOption, initChildren]);
47
65
  // refs
48
66
  const internalRef = useMergedRef(ref);
49
67
  const listboxRef = React__default.useRef(null);
@@ -197,7 +215,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
197
215
  setValue: setValue,
198
216
  tabIndex: -1,
199
217
  value: value
200
- }, /*#__PURE__*/React__default.createElement(Collection, null, filteredChildren), onCreate ? /*#__PURE__*/React__default.createElement(Create, {
218
+ }, searchQuery === '' ? /*#__PURE__*/React__default.createElement(Collection, null, initialChildren) : /*#__PURE__*/React__default.createElement(Collection, null, filteredChildren), onCreate ? /*#__PURE__*/React__default.createElement(Create, {
201
219
  onCreate: onCreate,
202
220
  options: flattenedChildren
203
221
  }) : null))))));
@@ -1 +1 @@
1
- {"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\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 { Select2OptionValue, Select2Value } 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 { 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 { Color } from '../../types';\nimport { useIsHoverStatePaused } from '../../hooks/useIsHoverStatePaused';\nimport { isAriaDirectionKey } from '../../utils/aria';\n//import { All } from './components/All';\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};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n autoFocus?: boolean;\n children: Array<React.ReactElement<Select2OptionProps> | React.ReactElement<Select2GroupProps>>;\n defaultValue?: Select2Value;\n emptyValue?: Select2OptionValue;\n disabled?: boolean;\n highlighted?: boolean;\n invalid?: boolean;\n multiple?: boolean;\n name?: string;\n onChange?: (value: Select2Value) => void;\n onCreate?: (name: string, color: Color | undefined) => Promise<Select2OptionProps>;\n onDelete?: (value: Select2OptionValue) => Promise<void>;\n onEdit?: (value: Select2OptionValue, text: string, color: Color | undefined) => Promise<void>;\n readOnly?: boolean;\n required?: boolean;\n tags?: boolean;\n value?: Select2Value;\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: initialChildren,\n defaultValue: defaultProp,\n disabled = false,\n emptyValue = undefined,\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 ...otherProps\n } = props;\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 [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 validationError,\n value,\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (event.key === 'ArrowDown') {\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 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 onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n ref={internalRef}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onOpenAutoFocus={event => {\n event.preventDefault();\n event.stopPropagation();\n internalRef.current?.focus();\n }}\n onCloseAutoFocus={event => {\n event.preventDefault();\n event.stopPropagation();\n internalRef.current?.focus();\n }}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {flattenedChildren.length > 0 || onCreate ? (\n <Search\n placeholder={onCreate ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\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 {/*multiple && !searchQuery && Array.isArray(value) ? (\n <All\n children={flattenedChildren}\n onToggle={_setValue}\n selected={value.length === flattenedChildren.length}\n />\n ) : null*/}\n <Collection>{filteredChildren}</Collection>\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","initialChildren","defaultValue","defaultProp","disabled","emptyValue","undefined","highlighted","invalid","multiple","name","onChange","onCreate","onDelete","onEdit","readOnly","tags","value","prop","otherProps","internalRef","useMergedRef","listboxRef","useRef","searchRef","texts","useLocalization","dimensions","useBoundingClientRectListener","open","setOpen","useState","_setValue","useControllableState","setValue","ListboxPrimitive","validationError","setValidationError","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","flattenedChildren","filteredChildren","searchQuery","setSearchQuery","useChildren","context","handleKeyDown","event","preventDefault","key","current","dispatchEvent","createCustomKeyboardEvent","handleBlur","onBlur","elementGainingFocus","relatedTarget","portalId","closest","id","currentTarget","getAttribute","handleListboxKeyDown","isAriaDirectionKey","className","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","ControlledHiddenField","options","map","child","parentRef","asChild","Trigger","onKeyDown","align","onOpenAutoFocus","stopPropagation","focus","onCloseAutoFocus","sideOffset","tabIndex","style","minWidth","width","length","Search","placeholder","select2","searchOrCreate","search","role","customSelector","Collection","Create","Option","Group","Title","isFormControl","useIsFormControl","bubbleValue","Array","isArray","String","BubbleSelect","option","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;MAkEMA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAkC,SAASF,OAAO,CAACG,KAAK,EAAEC,GAAG;EACzF,MAAM;IACFC,QAAQ,EAAEC,eAAe;IACzBC,YAAY,EAAEC,WAAW;IACzBC,QAAQ,GAAG,KAAK;IAChBC,UAAU,GAAGC,SAAS;IACtBC,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;IACX,GA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,QAAQ,EAAE;QACVgG,WAAW,GAAGC,KAAK,CAACC,OAAO,CAAC1F,KAAK,CAAC,GAAGA,KAAK,CAACyD,GAAG,CAACkC,MAAM,CAAC,GAAG,CAAC3F,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG2F,MAAM,CAAC3F,KAAK,CAAC,CAAC;OACjG,MAAM;QACHwF,WAAW,GAAGxF,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG2F,MAAM,CAAC3F,KAAK,CAAC;;;IAIzD,oBACIrB,6BAACiH,YAAY;;MAAa3D,GAAG,EAAE0D,MAAM,CAACH,WAAW,CAAC;MAAEhG,QAAQ,EAAEA,QAAQ;MAAEC,IAAI,EAAEA,IAAI;MAAEO,KAAK,EAAEwF;OACtFpG,UAAU,KAAKC,SAAS,gBAAGV;MAAQqB,KAAK,EAAEZ;MAAc,GAAG,IAAI,EAC/DoE,OAAO,CAACC,GAAG,CAACoC,MAAM,iBACflH;MAAQsD,GAAG,EAAE0D,MAAM,CAACE,MAAM,CAAC;MAAE7F,KAAK,EAAE2F,MAAM,CAACE,MAAM;MACpD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACDnH,OAAO,CAACoH,WAAW,GAAG,SAAS;;;;"}
1
+ {"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\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 { Select2Children, Select2OptionValue, Select2Value } 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 { 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 { Color } from '../../types';\nimport { useIsHoverStatePaused } from '../../hooks/useIsHoverStatePaused';\nimport { isAriaDirectionKey } from '../../utils/aria';\n//import { All } from './components/All';\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};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n autoFocus?: boolean;\n children: Select2Children;\n defaultValue?: Select2Value;\n emptyValue?: Select2OptionValue;\n disabled?: boolean;\n highlighted?: boolean;\n invalid?: boolean;\n multiple?: boolean;\n name?: string;\n onChange?: (value: Select2Value) => void;\n onCreate?: (name: string, color: Color | undefined) => Promise<Select2OptionProps>;\n onDelete?: (value: Select2OptionValue) => Promise<void>;\n onEdit?: (value: Select2OptionValue, text: string, color: Color | undefined) => Promise<void>;\n readOnly?: boolean;\n required?: boolean;\n tags?: boolean;\n value?: Select2Value;\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 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 ...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 [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 validationError,\n value,\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (event.key === 'ArrowDown') {\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 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 onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n ref={internalRef}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onOpenAutoFocus={event => {\n event.preventDefault();\n event.stopPropagation();\n internalRef.current?.focus();\n }}\n onCloseAutoFocus={event => {\n event.preventDefault();\n event.stopPropagation();\n internalRef.current?.focus();\n }}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {flattenedChildren.length > 0 || onCreate ? (\n <Search\n placeholder={onCreate ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\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 {/*multiple && !searchQuery && Array.isArray(value) ? (\n <All\n children={flattenedChildren}\n onToggle={_setValue}\n selected={value.length === flattenedChildren.length}\n />\n ) : null*/}\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","highlighted","invalid","multiple","name","onChange","onCreate","onDelete","onEdit","readOnly","tags","value","prop","otherProps","emptyOption","useMemo","Option","key","className","initialChildren","internalRef","useMergedRef","listboxRef","useRef","searchRef","texts","useLocalization","dimensions","useBoundingClientRectListener","open","setOpen","useState","_setValue","useControllableState","setValue","ListboxPrimitive","validationError","setValidationError","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","flattenedChildren","filteredChildren","searchQuery","setSearchQuery","useChildren","context","handleKeyDown","event","preventDefault","current","dispatchEvent","createCustomKeyboardEvent","handleBlur","onBlur","elementGainingFocus","relatedTarget","portalId","closest","id","currentTarget","getAttribute","handleListboxKeyDown","isAriaDirectionKey","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","ControlledHiddenField","options","map","child","parentRef","asChild","Trigger","onKeyDown","align","onOpenAutoFocus","stopPropagation","focus","onCloseAutoFocus","sideOffset","tabIndex","style","minWidth","width","length","Search","placeholder","select2","searchOrCreate","search","role","customSelector","Collection","Create","Group","Title","isFormControl","useIsFormControl","bubbleValue","Array","isArray","String","BubbleSelect","option","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;MAkEMA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAkC,SAASF,OAAO,CAACG,KAAK,EAAEC,GAAG;EACzF,MAAM;IACFC,QAAQ,EAAEC,YAAY;IACtBC,YAAY,EAAEC,WAAW;IACzBC,QAAQ,GAAG,KAAK;IAChBC,UAAU,GAAGC,SAAS;IACtBC,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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M,iBACfrH;MAAQ2B,GAAG,EAAEwF,MAAM,CAACE,MAAM,CAAC;MAAEhG,KAAK,EAAE8F,MAAM,CAACE,MAAM;MACpD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACDtH,OAAO,CAACuH,WAAW,GAAG,SAAS;;;;"}
@@ -20,6 +20,7 @@ const Option = /*#__PURE__*/React__default.forwardRef(function Select2Option(pro
20
20
  color,
21
21
  description,
22
22
  icon,
23
+ className: cName,
23
24
  ...otherProps
24
25
  } = props;
25
26
  const {
@@ -33,7 +34,7 @@ const Option = /*#__PURE__*/React__default.forwardRef(function Select2Option(pro
33
34
  tags,
34
35
  value
35
36
  } = useSelect2Context();
36
- const className = createOptionClassName(shouldPauseHoverState);
37
+ const className = cn(createOptionClassName(shouldPauseHoverState), cName);
37
38
  const hasValue = Array.isArray(value) ? !!value.length : value !== undefined;
38
39
  const isTag = tags && !!color;
39
40
  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 'classnames';\nimport { Icon, IconName, IconProps } 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';\n\nexport type Select2OptionProps = Omit<ListboxPrimitive.Listbox2OptionProps, 'children'> & {\n children: string;\n color?: Color;\n description?: string;\n icon?: React.ReactElement<IconProps> | IconName;\n textValue?: string;\n};\n\nexport const Option = React.forwardRef<HTMLDivElement, Select2OptionProps>(function Select2Option(props, ref) {\n const { children, color, description, icon, ...otherProps } = props;\n const {\n onDelete,\n onEdit,\n listboxRef,\n multiple,\n ref: selectRef,\n setOpen,\n shouldPauseHoverState,\n tags,\n value,\n } = useSelect2Context();\n const className = createOptionClassName(shouldPauseHoverState);\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 popover =\n 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={icon}>\n {children}\n </Tag>\n ) : (\n <>\n {icon ? typeof icon === 'string' ? <Icon name={icon} /> : icon : null}\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 </>\n )}\n {popover ? (\n <IconButton\n rounded\n icon=\"ellipsis-vertical\"\n appearance=\"discrete\"\n className={cn('group-aria-current:visible invisible ml-auto -mr-2 focus:!shadow-none group-hover:visible', {\n '!visible': isMobileDevice(window?.navigator),\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","icon","otherProps","onDelete","onEdit","listboxRef","multiple","selectRef","setOpen","shouldPauseHoverState","tags","value","useSelect2Context","className","createOptionClassName","hasValue","Array","isArray","length","undefined","isTag","handleClick","current","focus","handleKeyDown","event","isAriaSelectionKey","key","popover","popoverProps","EditPopover","textValue","String","text","ListboxPrimitive","onClick","onKeyDown","Icon","name","Tag","IconButton","rounded","appearance","cn","isMobileDevice","window","navigator","stopPropagation","setActiveIndex","currentTarget","parentElement","tabIndex"],"mappings":";;;;;;;;;;;;;;;MAqBaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAa,CAACC,KAAK,EAAEC,GAAG;;EACxG,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,WAAW;IAAEC,IAAI;IAAE,GAAGC;GAAY,GAAGN,KAAK;EACnE,MAAM;IACFO,QAAQ;IACRC,MAAM;IACNC,UAAU;IACVC,QAAQ;IACRT,GAAG,EAAEU,SAAS;IACdC,OAAO;IACPC,qBAAqB;IACrBC,IAAI;IACJC;GACH,GAAGC,iBAAiB,EAAE;EACvB,MAAMC,SAAS,GAAGC,qBAAqB,CAACL,qBAAqB,CAAC;EAE9D,MAAMM,QAAQ,GAAGC,KAAK,CAACC,OAAO,CAACN,KAAK,CAAC,GAAG,CAAC,CAACA,KAAK,CAACO,MAAM,GAAGP,KAAK,KAAKQ,SAAS;EAC5E,MAAMC,KAAK,GAAGV,IAAI,IAAI,CAAC,CAACX,KAAK;EAE7B,MAAMsB,WAAW,GAAG;IAChB,IAAI,CAACf,QAAQ,EAAE;MACXE,OAAO,CAAC,KAAK,CAAC;KACjB,MAAM;MAAA;MACH,sBAAAD,SAAS,CAACe,OAAO,uDAAjB,mBAAmBC,KAAK,EAAE;;GAEjC;EAED,MAAMC,aAAa,GAAIC,KAA0B;IAC7C,IAAIC,kBAAkB,CAACD,KAAK,CAAC,EAAE;MAC3B,IAAI,CAACnB,QAAQ,IAAImB,KAAK,CAACE,GAAG,KAAK,KAAK,EAAE;QAClCnB,OAAO,CAAC,KAAK,CAAC;;;GAGzB;EAED,MAAMo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N,QAAQC,SAAS;KAC/C,CAAC;IACFX,OAAO,EAAEV,KAAK;;MACVA,KAAK,CAACsB,eAAe,EAAE;MACvB1C,UAAU,aAAVA,UAAU,8CAAVA,UAAU,CAAEiB,OAAO,wDAAnB,oBAAqB0B,cAAc,CAACvB,KAAK,CAACwB,aAAa,CAACC,aAA+B,CAAC;KAC3F;IACDtB,OAAO,EAAEA,OAAO;IAChBuB,QAAQ,EAAE,CAAC;IACb,GACF,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 'classnames';\nimport { Icon, IconName, IconProps } 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';\n\nexport type Select2OptionProps = Omit<ListboxPrimitive.Listbox2OptionProps, 'children'> & {\n children: string;\n color?: Color;\n description?: string;\n icon?: React.ReactElement<IconProps> | IconName;\n textValue?: string;\n};\n\nexport const Option = React.forwardRef<HTMLDivElement, Select2OptionProps>(function Select2Option(props, ref) {\n const { children, color, description, icon, 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 } = useSelect2Context();\n const className = cn(createOptionClassName(shouldPauseHoverState), 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 popover =\n 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={icon}>\n {children}\n </Tag>\n ) : (\n <>\n {icon ? typeof icon === 'string' ? <Icon name={icon} /> : icon : null}\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 </>\n )}\n {popover ? (\n <IconButton\n rounded\n icon=\"ellipsis-vertical\"\n appearance=\"discrete\"\n className={cn('group-aria-current:visible invisible ml-auto -mr-2 focus:!shadow-none group-hover:visible', {\n '!visible': isMobileDevice(window?.navigator),\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","icon","className","cName","otherProps","onDelete","onEdit","listboxRef","multiple","selectRef","setOpen","shouldPauseHoverState","tags","value","useSelect2Context","cn","createOptionClassName","hasValue","Array","isArray","length","undefined","isTag","handleClick","current","focus","handleKeyDown","event","isAriaSelectionKey","key","popover","popoverProps","EditPopover","textValue","String","text","ListboxPrimitive","onClick","onKeyDown","Icon","name","Tag","IconButton","rounded","appearance","isMobileDevice","window","navigator","stopPropagation","setActiveIndex","currentTarget","parentElement","tabIndex"],"mappings":";;;;;;;;;;;;;;;M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CAAC;KAC3F;IACDrB,OAAO,EAAEA,OAAO;IAChBsB,QAAQ,EAAE,CAAC;IACb,GACF,IAAI,CACc;AAElC,CAAC;;;;"}
@@ -1,5 +1,4 @@
1
1
  import React__default from 'react';
2
- import { Option } from '../components/Option.js';
3
2
 
4
3
  const isGroup = child => !!child.props.heading;
5
4
  const useChildren = ({
@@ -18,17 +17,11 @@ const useChildren = ({
18
17
  if (isGroup(child)) {
19
18
  return child.props.children;
20
19
  }
20
+ // Since we are filtering out groups just above, then casting child to React.ReactElement<Select2OptionProps>, to avoid type inconsistency errors.
21
21
  return child;
22
22
  }).flatMap(c => c)) || [];
23
- if (emptyValue !== undefined && !multiple) {
24
- return [/*#__PURE__*/React__default.createElement(Option, {
25
- key: "__empty",
26
- children: "",
27
- value: emptyValue
28
- }), ...initial];
29
- }
30
23
  return initial;
31
- }, [initialChildren, emptyValue]);
24
+ }, [initialChildren]);
32
25
  // set an initial value if none is set, we have to trigger state updates for controlled components
33
26
  React__default.useEffect(() => {
34
27
  if (!multiple && emptyValue === undefined && value === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"useChildren.js","sources":["../../../../../../../../src/components/Select2/hooks/useChildren.tsx"],"sourcesContent":["import React from 'react';\nimport { Option, Select2OptionProps } from '../components/Option';\nimport { Select2GroupProps } from '../Select2';\nimport { Select2OptionValue, Select2Value } from '../types';\n\nconst isGroup = (child: React.ReactElement) => !!child.props.heading;\n\nexport type useChildrenArgs = {\n children: Array<React.ReactElement<Select2OptionProps> | React.ReactElement<Select2GroupProps>>;\n emptyValue?: Select2OptionValue;\n multiple?: boolean;\n open?: boolean;\n setValue: (nextValue: Select2OptionValue) => void;\n value?: Select2Value;\n};\nexport const useChildren = ({ children: initialChildren, emptyValue, multiple, open, setValue, value }: useChildrenArgs) => {\n const [searchQuery, setSearchQuery] = React.useState<string>('');\n\n // flatten children that might be inside groups\n // support empty value - probably a more elegant way to achieve this\n const flattenedChildren: React.ReactElement<Select2OptionProps>[] = React.useMemo(() => {\n const initial: Array<React.ReactElement<Select2OptionProps> | React.ReactElement<Select2GroupProps>> =\n initialChildren\n ?.map(child => {\n if (isGroup(child)) {\n return (child as React.ReactElement<Select2GroupProps>).props.children;\n }\n return child;\n })\n .flatMap(c => c) || [];\n\n if (emptyValue !== undefined && !multiple) {\n return [<Option key=\"__empty\" children=\"\" value={emptyValue} />, ...initial];\n }\n\n return initial;\n }, [initialChildren, emptyValue]);\n\n // set an initial value if none is set, we have to trigger state updates for controlled components\n React.useEffect(() => {\n if (!multiple && emptyValue === undefined && value === undefined) {\n setValue(flattenedChildren?.[0]?.props.value);\n }\n }, []);\n\n React.useEffect(() => {\n if (!open) {\n setSearchQuery('');\n }\n }, [open]);\n\n // apply filtering\n const filteredChildren = React.useMemo(() => {\n return initialChildren\n .map(child => {\n if (isGroup(child)) {\n const filteredGroupChildren = (child as React.ReactElement<Select2GroupProps>).props.children.filter(\n groupChild => filterOption(groupChild as React.ReactElement<Select2OptionProps>, searchQuery)\n );\n return filteredGroupChildren.length\n ? React.cloneElement(child as React.ReactElement<Select2OptionProps>, {}, filteredGroupChildren)\n : null;\n }\n\n return filterOption(child as React.ReactElement<Select2OptionProps>, searchQuery) ? child : null;\n })\n .filter(child => !!child) as Array<React.ReactElement<Select2OptionProps> | React.ReactElement<Select2GroupProps>>;\n }, [flattenedChildren, searchQuery]);\n\n return {\n flattenedChildren,\n filteredChildren,\n searchQuery,\n setSearchQuery,\n };\n};\n\nconst filterOption = (child: React.ReactElement<Select2OptionProps>, searchQuery: string) => {\n if (child.props.textValue?.toLowerCase().includes(searchQuery.toLowerCase())) {\n return true;\n }\n\n if (child.props.description?.toLowerCase().includes(searchQuery.toLowerCase())) {\n return true;\n }\n\n return String(child.props.children).toLowerCase().includes(searchQuery.toLowerCase());\n};\n"],"names":["isGroup","child","props","heading","useChildren","children","initialChildren","emptyValue","multiple","open","setValue","value","searchQuery","setSearchQuery","React","useState","flattenedChildren","useMemo","initial","map","flatMap","c","undefined","Option","key","useEffect","filteredChildren","filteredGroupChildren","filter","groupChild","filterOption","length","cloneElement","textValue","toLowerCase","includes","description","String"],"mappings":";;;AAKA,MAAMA,OAAO,GAAIC,KAAyB,IAAK,CAAC,CAACA,KAAK,CAACC,KAAK,CAACC,OAAO;MAUvDC,WAAW,GAAG,CAAC;EAAEC,QAAQ,EAAEC,eAAe;EAAEC,UAAU;EAAEC,QAAQ;EAAEC,IAAI;EAAEC,QAAQ;EAAEC;CAAwB;EACnH,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAS,EAAE,CAAC;;;EAIhE,MAAMC,iBAAiB,GAA6CF,cAAK,CAACG,OAAO,CAAC;IAC9E,MAAMC,OAAO,GACT,CAAAZ,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CACTa,GAAG,CAAClB,KAAK;MACP,IAAID,OAAO,CAACC,KAAK,CAAC,EAAE;QAChB,OAAQA,KAA+C,CAACC,KAAK,CAACG,QAAQ;;MAE1E,OAAOJ,KAAK;KACf,CAAC,CACDmB,OAAO,CAACC,CAAC,IAAIA,CAAC,CAAC,KAAI,EAAE;IAE9B,IAAId,UAAU,KAAKe,SAAS,IAAI,CAACd,QAAQ,EAAE;MACvC,OAAO,cAACM,6BAACS,MAAM;QAACC,GAAG,EAAC,SAAS;QAACnB,QAAQ,EAAC,EAAE;QAACM,KAAK,EAAEJ;QAAc,EAAE,GAAGW,OAAO,CAAC;;IAGhF,OAAOA,OAAO;GACjB,EAAE,CAACZ,eAAe,EAAEC,UAAU,CAAC,CAAC;;EAGjCO,cAAK,CAACW,SAAS,CAAC;IACZ,IAAI,CAACjB,QAAQ,IAAID,UAAU,KAAKe,SAAS,IAAIX,KAAK,KAAKW,SAAS,EAAE;MAAA;MAC9DZ,QAAQ,CAACM,iBAAiB,aAAjBA,iBAAiB,8CAAjBA,iBAAiB,CAAG,CAAC,CAAC,wDAAtB,oBAAwBd,KAAK,CAACS,KAAK,CAAC;;GAEpD,EAAE,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CAACC,KAAK,CAACG,QAAQ,CAAC,CAAC6B,WAAW,EAAE,CAACC,QAAQ,CAACvB,WAAW,CAACsB,WAAW,EAAE,CAAC;AACzF,CAAC;;;;"}
1
+ {"version":3,"file":"useChildren.js","sources":["../../../../../../../../src/components/Select2/hooks/useChildren.tsx"],"sourcesContent":["import React from 'react';\nimport { Select2OptionProps } from '../components/Option';\nimport { Select2GroupProps } from '../Select2';\nimport { Select2Children, Select2OptionValue, Select2Value } from '../types';\n\nconst isGroup = (child: React.ReactElement) => !!child.props.heading;\n\nexport type useChildrenArgs = {\n children: Select2Children;\n emptyValue?: Select2OptionValue;\n multiple?: boolean;\n open?: boolean;\n setValue: (nextValue: Select2OptionValue) => void;\n value?: Select2Value;\n};\nexport const useChildren = ({ children: initialChildren, emptyValue, multiple, open, setValue, value }: useChildrenArgs) => {\n const [searchQuery, setSearchQuery] = React.useState<string>('');\n\n // flatten children that might be inside groups\n // support empty value - probably a more elegant way to achieve this\n const flattenedChildren: React.ReactElement<Select2OptionProps>[] = React.useMemo(() => {\n const initial: React.ReactElement<Select2OptionProps>[] =\n initialChildren\n ?.map(child => {\n if (isGroup(child)) {\n return (child as React.ReactElement<Select2GroupProps>).props.children;\n }\n // Since we are filtering out groups just above, then casting child to React.ReactElement<Select2OptionProps>, to avoid type inconsistency errors.\n return child as React.ReactElement<Select2OptionProps>;\n })\n .flatMap(c => c) || [];\n\n return initial;\n }, [initialChildren]);\n\n // set an initial value if none is set, we have to trigger state updates for controlled components\n React.useEffect(() => {\n if (!multiple && emptyValue === undefined && value === undefined) {\n setValue(flattenedChildren?.[0]?.props.value);\n }\n }, []);\n\n React.useEffect(() => {\n if (!open) {\n setSearchQuery('');\n }\n }, [open]);\n\n // apply filtering\n const filteredChildren = React.useMemo(() => {\n return initialChildren\n .map(child => {\n if (isGroup(child)) {\n const filteredGroupChildren = (child as React.ReactElement<Select2GroupProps>).props.children.filter(\n groupChild => filterOption(groupChild as React.ReactElement<Select2OptionProps>, searchQuery)\n );\n return filteredGroupChildren.length\n ? React.cloneElement(child as React.ReactElement<Select2OptionProps>, {}, filteredGroupChildren)\n : null;\n }\n\n return filterOption(child as React.ReactElement<Select2OptionProps>, searchQuery) ? child : null;\n })\n .filter(child => !!child) as Select2Children;\n }, [flattenedChildren, searchQuery]);\n\n return {\n flattenedChildren,\n filteredChildren,\n searchQuery,\n setSearchQuery,\n };\n};\n\nconst filterOption = (child: React.ReactElement<Select2OptionProps>, searchQuery: string) => {\n if (child.props.textValue?.toLowerCase().includes(searchQuery.toLowerCase())) {\n return true;\n }\n\n if (child.props.description?.toLowerCase().includes(searchQuery.toLowerCase())) {\n return true;\n }\n\n return String(child.props.children).toLowerCase().includes(searchQuery.toLowerCase());\n};\n"],"names":["isGroup","child","props","heading","useChildren","children","initialChildren","emptyValue","multiple","open","setValue","value","searchQuery","setSearchQuery","React","useState","flattenedChildren","useMemo","initial","map","flatMap","c","useEffect","undefined","filteredChildren","filteredGroupChildren","filter","groupChild","filterOption","length","cloneElement","textValue","toLowerCase","includes","description","String"],"mappings":";;AAKA,MAAMA,OAAO,GAAIC,KAAyB,IAAK,CAAC,CAACA,KAAK,CAACC,KAAK,CAACC,OAAO;MAUvDC,WAAW,GAAG,CAAC;EAAEC,QAAQ,EAAEC,eAAe;EAAEC,UAAU;EAAEC,QAAQ;EAAEC,IAAI;EAAEC,QAAQ;EAAEC;CAAwB;EACnH,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAS,EAAE,CAAC;;;EAIhE,MAAMC,iBAAiB,GAA6CF,cAAK,CAACG,OAAO,CAAC;IAC9E,MAAMC,OAAO,GACT,CAAAZ,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CACTa,GAAG,CAAClB,KAAK;MACP,IAAID,OAAO,CAACC,KAAK,CAAC,EAAE;QAChB,OAAQA,KAA+C,CAACC,KAAK,CAACG,QAAQ;;;MAG1E,OAAOJ,KAA+C;KACzD,CAAC,CACDmB,OA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3B,KAA6C,EAAEW,WAAmB;;EACpF,6BAAIX,KAAK,CAACC,KAAK,CAAC6B,SAAS,kDAArB,sBAAuBC,WAAW,EAAE,CAACC,QAAQ,CAACrB,WAAW,CAACoB,WAAW,EAAE,CAAC,EAAE;IAC1E,OAAO,IAAI;;EAGf,6BAAI/B,KAAK,CAACC,KAAK,CAACgC,WAAW,kDAAvB,sBAAyBF,WAAW,EAAE,CAACC,QAAQ,CAACrB,WAAW,CAACoB,WAAW,EAAE,CAAC,EAAE;IAC5E,OAAO,IAAI;;EAGf,OAAOG,MAAM,CAAClC,KAAK,CAACC,KAAK,CAACG,QAAQ,CAAC,CAAC2B,WAAW,EAAE,CAACC,QAAQ,CAACrB,WAAW,CAACoB,WAAW,EAAE,CAAC;AACzF,CAAC;;;;"}
@@ -22,7 +22,7 @@ function Column(_) {
22
22
  return null;
23
23
  }
24
24
  Column.displayName = 'Table2Column';
25
- const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref) {
25
+ const BaseTable2 = /*#__PURE__*/React__default.forwardRef(function BaseTable2(props, ref) {
26
26
  // dom
27
27
  const {
28
28
  emptyState: EmptyState,
@@ -30,6 +30,7 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
30
30
  length = props.data.length,
31
31
  loadMore,
32
32
  onRowClick,
33
+ onRowDrop,
33
34
  toolbarLeft,
34
35
  toolbarRight,
35
36
  _experimentalActionsForTable,
@@ -343,6 +344,7 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
343
344
  key: row.id
344
345
  }, /*#__PURE__*/React__default.createElement(Row, {
345
346
  className: "group/row contents",
347
+ onRowDrop: onRowDrop,
346
348
  row: row,
347
349
  rowIndex: virtualRow.index,
348
350
  table: table
@@ -390,6 +392,13 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
390
392
  table: table
391
393
  }) : null);
392
394
  });
395
+ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref) {
396
+ const key = React__default.useMemo(() => String('tableKey_' + String(props.children)), [props.children]);
397
+ return /*#__PURE__*/React__default.createElement(BaseTable2, Object.assign({}, props, {
398
+ key: key,
399
+ ref: ref
400
+ }));
401
+ });
393
402
  Table2.Column = Column;
394
403
 
395
404
  export { Table2 };