@deephaven/components 0.74.0 → 0.74.1-beta.1

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 (44) hide show
  1. package/dist/Button.d.ts +1 -1
  2. package/dist/Select.d.ts +1 -1
  3. package/dist/spectrum/ItemContent.d.ts.map +1 -1
  4. package/dist/spectrum/ItemContent.js +2 -1
  5. package/dist/spectrum/ItemContent.js.map +1 -1
  6. package/dist/spectrum/picker/Picker.d.ts +6 -8
  7. package/dist/spectrum/picker/Picker.d.ts.map +1 -1
  8. package/dist/spectrum/picker/Picker.js +54 -59
  9. package/dist/spectrum/picker/Picker.js.map +1 -1
  10. package/dist/spectrum/picker/PickerNormalized.d.ts +16 -0
  11. package/dist/spectrum/picker/PickerNormalized.d.ts.map +1 -0
  12. package/dist/spectrum/picker/PickerNormalized.js +88 -0
  13. package/dist/spectrum/picker/PickerNormalized.js.map +1 -0
  14. package/dist/spectrum/picker/index.d.ts +2 -0
  15. package/dist/spectrum/picker/index.d.ts.map +1 -1
  16. package/dist/spectrum/picker/index.js +2 -0
  17. package/dist/spectrum/picker/index.js.map +1 -1
  18. package/dist/spectrum/picker/usePickerScrollOnOpen.d.ts +22 -0
  19. package/dist/spectrum/picker/usePickerScrollOnOpen.d.ts.map +1 -0
  20. package/dist/spectrum/picker/usePickerScrollOnOpen.js +33 -0
  21. package/dist/spectrum/picker/usePickerScrollOnOpen.js.map +1 -0
  22. package/dist/spectrum/utils/index.d.ts +2 -0
  23. package/dist/spectrum/utils/index.d.ts.map +1 -1
  24. package/dist/spectrum/utils/index.js +2 -0
  25. package/dist/spectrum/utils/index.js.map +1 -1
  26. package/dist/spectrum/utils/itemUtils.d.ts +29 -3
  27. package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
  28. package/dist/spectrum/utils/itemUtils.js +69 -3
  29. package/dist/spectrum/utils/itemUtils.js.map +1 -1
  30. package/dist/spectrum/utils/itemWrapperUtils.d.ts +12 -0
  31. package/dist/spectrum/utils/itemWrapperUtils.d.ts.map +1 -0
  32. package/dist/spectrum/utils/itemWrapperUtils.js +65 -0
  33. package/dist/spectrum/utils/itemWrapperUtils.js.map +1 -0
  34. package/dist/spectrum/utils/useRenderNormalizedItem.d.ts.map +1 -1
  35. package/dist/spectrum/utils/useRenderNormalizedItem.js +3 -3
  36. package/dist/spectrum/utils/useRenderNormalizedItem.js.map +1 -1
  37. package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts.map +1 -1
  38. package/dist/spectrum/utils/useStringifiedMultiSelection.js +5 -2
  39. package/dist/spectrum/utils/useStringifiedMultiSelection.js.map +1 -1
  40. package/dist/spectrum/utils/useStringifiedSelection.d.ts +33 -0
  41. package/dist/spectrum/utils/useStringifiedSelection.d.ts.map +1 -0
  42. package/dist/spectrum/utils/useStringifiedSelection.js +50 -0
  43. package/dist/spectrum/utils/useStringifiedSelection.js.map +1 -0
  44. package/package.json +7 -7
@@ -0,0 +1,33 @@
1
+ import { Key } from 'react';
2
+ import { ItemKey, NormalizedItem, NormalizedSection } from './itemUtils';
3
+ export interface UseStringifiedSelectionOptions {
4
+ normalizedItems: (NormalizedItem | NormalizedSection)[];
5
+ selectedKey: ItemKey | null | undefined;
6
+ defaultSelectedKey: ItemKey | undefined;
7
+ disabledKeys: Iterable<ItemKey> | undefined;
8
+ onChange: ((key: ItemKey) => void) | undefined;
9
+ }
10
+ export interface UseStringifiedSelectionResult {
11
+ defaultSelectedStringKey?: Key;
12
+ selectedStringKey?: Key | null;
13
+ disabledStringKeys?: Set<Key>;
14
+ onStringSelectionChange: (key: Key) => void;
15
+ }
16
+ /**
17
+ * Spectrum collection components treat keys as strings if the `key` prop is
18
+ * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,
19
+ * we need to ensure that keys are strings in order for selection to work. We
20
+ * then need to convert back to the original key types in the onChange handler.
21
+ * This hook encapsulates converting to and from strings so that keys can match
22
+ * the original key type.
23
+ * @param normalizedItems The normalized items to select from.
24
+ * @param selectedKey The currently selected key in the collection.
25
+ * @param defaultSelectedKey The initial selected key in the collection.
26
+ * @param disabledKeys The currently disabled keys in the collection.
27
+ * @param onChange Handler that is called when the selection changes.
28
+ * @returns UseStringifiedSelectionResult with stringified key sets and string
29
+ * key selection change handler.
30
+ */
31
+ export declare function useStringifiedSelection({ normalizedItems, defaultSelectedKey, selectedKey, disabledKeys, onChange, }: UseStringifiedSelectionOptions): UseStringifiedSelectionResult;
32
+ export default useStringifiedSelection;
33
+ //# sourceMappingURL=useStringifiedSelection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStringifiedSelection.d.ts","sourceRoot":"","sources":["../../../src/spectrum/utils/useStringifiedSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwB,MAAM,OAAO,CAAC;AAClD,OAAO,EAEL,OAAO,EAEP,cAAc,EACd,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,8BAA8B;IAC7C,eAAe,EAAE,CAAC,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC;IACxD,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,kBAAkB,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAC5C,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,6BAA6B;IAC5C,wBAAwB,CAAC,EAAE,GAAG,CAAC;IAC/B,iBAAiB,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAC/B,kBAAkB,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,uBAAuB,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;CAC7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,QAAQ,GACT,EAAE,8BAA8B,GAAG,6BAA6B,CA6ChE;AAED,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { useCallback, useMemo } from 'react';
2
+ import { getItemKey, itemSelectionToStringSet } from "./itemUtils.js";
3
+ /**
4
+ * Spectrum collection components treat keys as strings if the `key` prop is
5
+ * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,
6
+ * we need to ensure that keys are strings in order for selection to work. We
7
+ * then need to convert back to the original key types in the onChange handler.
8
+ * This hook encapsulates converting to and from strings so that keys can match
9
+ * the original key type.
10
+ * @param normalizedItems The normalized items to select from.
11
+ * @param selectedKey The currently selected key in the collection.
12
+ * @param defaultSelectedKey The initial selected key in the collection.
13
+ * @param disabledKeys The currently disabled keys in the collection.
14
+ * @param onChange Handler that is called when the selection changes.
15
+ * @returns UseStringifiedSelectionResult with stringified key sets and string
16
+ * key selection change handler.
17
+ */
18
+ export function useStringifiedSelection(_ref) {
19
+ var {
20
+ normalizedItems,
21
+ defaultSelectedKey,
22
+ selectedKey,
23
+ disabledKeys,
24
+ onChange
25
+ } = _ref;
26
+ var selectedStringKey = useMemo(() => selectedKey == null ? selectedKey : String(selectedKey), [selectedKey]);
27
+ var defaultSelectedStringKey = useMemo(() => defaultSelectedKey == null ? defaultSelectedKey : String(defaultSelectedKey), [defaultSelectedKey]);
28
+ var disabledStringKeys = useMemo(() => itemSelectionToStringSet(disabledKeys), [disabledKeys]);
29
+ var onStringSelectionChange = useCallback(key => {
30
+ var _getItemKey;
31
+ if (onChange == null) {
32
+ return;
33
+ }
34
+
35
+ // The `key` arg will always be a string due to us setting the `Item` key
36
+ // prop in `renderItem`. We need to find the matching item to determine
37
+ // the actual key.
38
+ var selectedItem = normalizedItems.find(item => String(getItemKey(item)) === key);
39
+ var actualKey = (_getItemKey = getItemKey(selectedItem)) !== null && _getItemKey !== void 0 ? _getItemKey : key;
40
+ onChange(actualKey);
41
+ }, [normalizedItems, onChange]);
42
+ return {
43
+ selectedStringKey,
44
+ defaultSelectedStringKey,
45
+ disabledStringKeys,
46
+ onStringSelectionChange
47
+ };
48
+ }
49
+ export default useStringifiedSelection;
50
+ //# sourceMappingURL=useStringifiedSelection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStringifiedSelection.js","names":["useCallback","useMemo","getItemKey","itemSelectionToStringSet","useStringifiedSelection","_ref","normalizedItems","defaultSelectedKey","selectedKey","disabledKeys","onChange","selectedStringKey","String","defaultSelectedStringKey","disabledStringKeys","onStringSelectionChange","key","_getItemKey","selectedItem","find","item","actualKey"],"sources":["../../../src/spectrum/utils/useStringifiedSelection.ts"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport {\n getItemKey,\n ItemKey,\n itemSelectionToStringSet,\n NormalizedItem,\n NormalizedSection,\n} from './itemUtils';\n\nexport interface UseStringifiedSelectionOptions {\n normalizedItems: (NormalizedItem | NormalizedSection)[];\n selectedKey: ItemKey | null | undefined;\n defaultSelectedKey: ItemKey | undefined;\n disabledKeys: Iterable<ItemKey> | undefined;\n onChange: ((key: ItemKey) => void) | undefined;\n}\n\nexport interface UseStringifiedSelectionResult {\n defaultSelectedStringKey?: Key;\n selectedStringKey?: Key | null;\n disabledStringKeys?: Set<Key>;\n onStringSelectionChange: (key: Key) => void;\n}\n\n/**\n * Spectrum collection components treat keys as strings if the `key` prop is\n * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`,\n * we need to ensure that keys are strings in order for selection to work. We\n * then need to convert back to the original key types in the onChange handler.\n * This hook encapsulates converting to and from strings so that keys can match\n * the original key type.\n * @param normalizedItems The normalized items to select from.\n * @param selectedKey The currently selected key in the collection.\n * @param defaultSelectedKey The initial selected key in the collection.\n * @param disabledKeys The currently disabled keys in the collection.\n * @param onChange Handler that is called when the selection changes.\n * @returns UseStringifiedSelectionResult with stringified key sets and string\n * key selection change handler.\n */\nexport function useStringifiedSelection({\n normalizedItems,\n defaultSelectedKey,\n selectedKey,\n disabledKeys,\n onChange,\n}: UseStringifiedSelectionOptions): UseStringifiedSelectionResult {\n const selectedStringKey = useMemo(\n () => (selectedKey == null ? selectedKey : String(selectedKey)),\n [selectedKey]\n );\n\n const defaultSelectedStringKey = useMemo(\n () =>\n defaultSelectedKey == null\n ? defaultSelectedKey\n : String(defaultSelectedKey),\n [defaultSelectedKey]\n );\n\n const disabledStringKeys = useMemo(\n () => itemSelectionToStringSet(disabledKeys),\n [disabledKeys]\n );\n\n const onStringSelectionChange = useCallback(\n (key: Key): void => {\n if (onChange == null) {\n return;\n }\n\n // The `key` arg will always be a string due to us setting the `Item` key\n // prop in `renderItem`. We need to find the matching item to determine\n // the actual key.\n const selectedItem = normalizedItems.find(\n item => String(getItemKey(item)) === key\n );\n\n const actualKey = getItemKey(selectedItem) ?? key;\n\n onChange(actualKey);\n },\n [normalizedItems, onChange]\n );\n\n return {\n selectedStringKey,\n defaultSelectedStringKey,\n disabledStringKeys,\n onStringSelectionChange,\n };\n}\n\nexport default useStringifiedSelection;\n"],"mappings":"AAAA,SAAcA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAEhDC,UAAU,EAEVC,wBAAwB;AAoB1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAAC,IAAA,EAM2B;EAAA,IAN1B;IACtCC,eAAe;IACfC,kBAAkB;IAClBC,WAAW;IACXC,YAAY;IACZC;EAC8B,CAAC,GAAAL,IAAA;EAC/B,IAAMM,iBAAiB,GAAGV,OAAO,CAC/B,MAAOO,WAAW,IAAI,IAAI,GAAGA,WAAW,GAAGI,MAAM,CAACJ,WAAW,CAAE,EAC/D,CAACA,WAAW,CACd,CAAC;EAED,IAAMK,wBAAwB,GAAGZ,OAAO,CACtC,MACEM,kBAAkB,IAAI,IAAI,GACtBA,kBAAkB,GAClBK,MAAM,CAACL,kBAAkB,CAAC,EAChC,CAACA,kBAAkB,CACrB,CAAC;EAED,IAAMO,kBAAkB,GAAGb,OAAO,CAChC,MAAME,wBAAwB,CAACM,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMM,uBAAuB,GAAGf,WAAW,CACxCgB,GAAQ,IAAW;IAAA,IAAAC,WAAA;IAClB,IAAIP,QAAQ,IAAI,IAAI,EAAE;MACpB;IACF;;IAEA;IACA;IACA;IACA,IAAMQ,YAAY,GAAGZ,eAAe,CAACa,IAAI,CACvCC,IAAI,IAAIR,MAAM,CAACV,UAAU,CAACkB,IAAI,CAAC,CAAC,KAAKJ,GACvC,CAAC;IAED,IAAMK,SAAS,IAAAJ,WAAA,GAAGf,UAAU,CAACgB,YAAY,CAAC,cAAAD,WAAA,cAAAA,WAAA,GAAID,GAAG;IAEjDN,QAAQ,CAACW,SAAS,CAAC;EACrB,CAAC,EACD,CAACf,eAAe,EAAEI,QAAQ,CAC5B,CAAC;EAED,OAAO;IACLC,iBAAiB;IACjBE,wBAAwB;IACxBC,kBAAkB;IAClBC;EACF,CAAC;AACH;AAEA,eAAeX,uBAAuB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/components",
3
- "version": "0.74.0",
3
+ "version": "0.74.1-beta.1+5f497611",
4
4
  "description": "Deephaven React component library",
5
5
  "author": "Deephaven Data Labs LLC",
6
6
  "license": "Apache-2.0",
@@ -25,10 +25,10 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@adobe/react-spectrum": "^3.34.1",
28
- "@deephaven/icons": "^0.74.0",
29
- "@deephaven/log": "^0.74.0",
30
- "@deephaven/react-hooks": "^0.74.0",
31
- "@deephaven/utils": "^0.74.0",
28
+ "@deephaven/icons": "^0.74.1-beta.1+5f497611",
29
+ "@deephaven/log": "^0.74.1-beta.1+5f497611",
30
+ "@deephaven/react-hooks": "^0.74.1-beta.1+5f497611",
31
+ "@deephaven/utils": "^0.74.1-beta.1+5f497611",
32
32
  "@fortawesome/fontawesome-svg-core": "^6.2.1",
33
33
  "@fortawesome/react-fontawesome": "^0.2.0",
34
34
  "@react-spectrum/theme-default": "^3.5.1",
@@ -55,7 +55,7 @@
55
55
  "react-dom": ">=16.8.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@deephaven/mocks": "^0.74.0"
58
+ "@deephaven/mocks": "^0.74.1-beta.1+5f497611"
59
59
  },
60
60
  "files": [
61
61
  "dist",
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "0dbf17d6c463cb59e4ff4193828fecb346031b3e"
72
+ "gitHead": "5f4976115bfc016e6d9cbe9fd77413c3fd8f8353"
73
73
  }