@deephaven/components 0.72.1-xcomponent.2 → 0.73.1-beta.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.
- package/dist/Button.d.ts +1 -1
- package/dist/Select.d.ts +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/navigation/NavTab.d.ts.map +1 -1
- package/dist/navigation/NavTab.js +10 -2
- package/dist/navigation/NavTab.js.map +1 -1
- package/dist/navigation/NavTabList.d.ts +5 -0
- package/dist/navigation/NavTabList.d.ts.map +1 -1
- package/dist/navigation/NavTabList.js.map +1 -1
- package/dist/shortcuts/GlobalShortcuts.d.ts +1 -0
- package/dist/shortcuts/GlobalShortcuts.d.ts.map +1 -1
- package/dist/shortcuts/GlobalShortcuts.js +7 -0
- package/dist/shortcuts/GlobalShortcuts.js.map +1 -1
- package/dist/spectrum/Heading.d.ts +4 -1
- package/dist/spectrum/Heading.d.ts.map +1 -1
- package/dist/spectrum/Heading.js +5 -3
- package/dist/spectrum/Heading.js.map +1 -1
- package/dist/spectrum/ItemContent.d.ts +15 -0
- package/dist/spectrum/ItemContent.d.ts.map +1 -0
- package/dist/spectrum/{picker/PickerItemContent.js → ItemContent.js} +42 -18
- package/dist/spectrum/ItemContent.js.map +1 -0
- package/dist/spectrum/ItemTooltip.d.ts +12 -0
- package/dist/spectrum/ItemTooltip.d.ts.map +1 -0
- package/dist/spectrum/ItemTooltip.js +30 -0
- package/dist/spectrum/ItemTooltip.js.map +1 -0
- package/dist/spectrum/Text.d.ts +4 -1
- package/dist/spectrum/Text.d.ts.map +1 -1
- package/dist/spectrum/Text.js +5 -4
- package/dist/spectrum/Text.js.map +1 -1
- package/dist/spectrum/View.d.ts +4 -1
- package/dist/spectrum/View.d.ts.map +1 -1
- package/dist/spectrum/View.js +5 -3
- package/dist/spectrum/View.js.map +1 -1
- package/dist/spectrum/collections.d.ts +1 -1
- package/dist/spectrum/collections.d.ts.map +1 -1
- package/dist/spectrum/collections.js +1 -1
- package/dist/spectrum/collections.js.map +1 -1
- package/dist/spectrum/icons.d.ts +2 -0
- package/dist/spectrum/icons.d.ts.map +1 -0
- package/dist/spectrum/icons.js +3 -0
- package/dist/spectrum/icons.js.map +1 -0
- package/dist/spectrum/index.d.ts +4 -0
- package/dist/spectrum/index.d.ts.map +1 -1
- package/dist/spectrum/index.js +4 -0
- package/dist/spectrum/index.js.map +1 -1
- package/dist/spectrum/listView/ListView.d.ts +28 -0
- package/dist/spectrum/listView/ListView.d.ts.map +1 -0
- package/dist/spectrum/listView/ListView.js +91 -0
- package/dist/spectrum/listView/ListView.js.map +1 -0
- package/dist/spectrum/listView/index.d.ts +2 -0
- package/dist/spectrum/listView/index.d.ts.map +1 -0
- package/dist/spectrum/listView/index.js +2 -0
- package/dist/spectrum/listView/index.js.map +1 -0
- package/dist/spectrum/picker/Picker.d.ts.map +1 -1
- package/dist/spectrum/picker/Picker.js +9 -60
- package/dist/spectrum/picker/Picker.js.map +1 -1
- package/dist/spectrum/picker/index.d.ts +0 -1
- package/dist/spectrum/picker/index.d.ts.map +1 -1
- package/dist/spectrum/picker/index.js +0 -1
- package/dist/spectrum/picker/index.js.map +1 -1
- package/dist/spectrum/utils/index.d.ts +2 -0
- package/dist/spectrum/utils/index.d.ts.map +1 -1
- package/dist/spectrum/utils/index.js +2 -0
- package/dist/spectrum/utils/index.js.map +1 -1
- package/dist/spectrum/utils/itemUtils.d.ts +21 -11
- package/dist/spectrum/utils/itemUtils.d.ts.map +1 -1
- package/dist/spectrum/utils/itemUtils.js +23 -8
- package/dist/spectrum/utils/itemUtils.js.map +1 -1
- package/dist/spectrum/utils/useRenderNormalizedItem.d.ts +11 -0
- package/dist/spectrum/utils/useRenderNormalizedItem.d.ts.map +1 -0
- package/dist/spectrum/utils/useRenderNormalizedItem.js +40 -0
- package/dist/spectrum/utils/useRenderNormalizedItem.js.map +1 -0
- package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts +43 -0
- package/dist/spectrum/utils/useStringifiedMultiSelection.d.ts.map +1 -0
- package/dist/spectrum/utils/useStringifiedMultiSelection.js +50 -0
- package/dist/spectrum/utils/useStringifiedMultiSelection.js.map +1 -0
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +1 -0
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/useSpectrumThemeProvider.d.ts +4 -0
- package/dist/theme/useSpectrumThemeProvider.d.ts.map +1 -0
- package/dist/theme/useSpectrumThemeProvider.js +4 -0
- package/dist/theme/useSpectrumThemeProvider.js.map +1 -0
- package/package.json +7 -7
- package/dist/XComponent.d.ts +0 -43
- package/dist/XComponent.d.ts.map +0 -1
- package/dist/XComponent.js +0 -57
- package/dist/XComponent.js.map +0 -1
- package/dist/XComponentMap.d.ts +0 -14
- package/dist/XComponentMap.d.ts.map +0 -1
- package/dist/XComponentMap.js +0 -20
- package/dist/XComponentMap.js.map +0 -1
- package/dist/spectrum/picker/PickerItemContent.d.ts +0 -11
- package/dist/spectrum/picker/PickerItemContent.d.ts.map +0 -1
- package/dist/spectrum/picker/PickerItemContent.js.map +0 -1
|
@@ -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 selectedKeys The currently selected keys in the collection.
|
|
12
|
+
* @param defaultSelectedKeys The initial selected keys 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 UseStringifiedMultiSelectionResult with stringified key sets and
|
|
16
|
+
* string key selection change handler.
|
|
17
|
+
*/
|
|
18
|
+
export function useStringifiedMultiSelection(_ref) {
|
|
19
|
+
var {
|
|
20
|
+
normalizedItems,
|
|
21
|
+
defaultSelectedKeys,
|
|
22
|
+
disabledKeys,
|
|
23
|
+
selectedKeys,
|
|
24
|
+
onChange
|
|
25
|
+
} = _ref;
|
|
26
|
+
var selectedStringKeys = useMemo(() => itemSelectionToStringSet(selectedKeys), [selectedKeys]);
|
|
27
|
+
var defaultSelectedStringKeys = useMemo(() => itemSelectionToStringSet(defaultSelectedKeys), [defaultSelectedKeys]);
|
|
28
|
+
var disabledStringKeys = useMemo(() => itemSelectionToStringSet(disabledKeys), [disabledKeys]);
|
|
29
|
+
var onStringSelectionChange = useCallback(keys => {
|
|
30
|
+
if (keys === 'all') {
|
|
31
|
+
onChange === null || onChange === void 0 ? void 0 : onChange('all');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
var actualKeys = new Set();
|
|
35
|
+
normalizedItems.forEach(item => {
|
|
36
|
+
if (keys.has(String(getItemKey(item)))) {
|
|
37
|
+
actualKeys.add(getItemKey(item));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(actualKeys);
|
|
41
|
+
}, [normalizedItems, onChange]);
|
|
42
|
+
return {
|
|
43
|
+
selectedStringKeys,
|
|
44
|
+
defaultSelectedStringKeys,
|
|
45
|
+
disabledStringKeys,
|
|
46
|
+
onStringSelectionChange
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export default useStringifiedMultiSelection;
|
|
50
|
+
//# sourceMappingURL=useStringifiedMultiSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStringifiedMultiSelection.js","names":["useCallback","useMemo","getItemKey","itemSelectionToStringSet","useStringifiedMultiSelection","_ref","normalizedItems","defaultSelectedKeys","disabledKeys","selectedKeys","onChange","selectedStringKeys","defaultSelectedStringKeys","disabledStringKeys","onStringSelectionChange","keys","actualKeys","Set","forEach","item","has","String","add"],"sources":["../../../src/spectrum/utils/useStringifiedMultiSelection.ts"],"sourcesContent":["import { Key, useCallback, useMemo } from 'react';\nimport {\n getItemKey,\n ItemKey,\n ItemSelection,\n itemSelectionToStringSet,\n NormalizedItem,\n} from './itemUtils';\n\nexport interface UseStringifiedMultiSelectionOptions {\n normalizedItems: NormalizedItem[];\n selectedKeys?: 'all' | Iterable<ItemKey>;\n defaultSelectedKeys?: 'all' | Iterable<ItemKey>;\n disabledKeys?: Iterable<ItemKey>;\n /**\n * Handler that is called when the selection change.\n * Note that under the hood, this is just an alias for Spectrum's\n * `onSelectionChange`. We are renaming for better consistency with other\n * components.\n */\n onChange?: (keys: ItemSelection) => void;\n}\n\nexport interface UseStringifiedMultiSelectionResult {\n /** Stringified selection keys */\n selectedStringKeys?: 'all' | Set<Key>;\n /** Stringified default selection keys */\n defaultSelectedStringKeys?: 'all' | Set<Key>;\n /** Stringified disabled keys */\n disabledStringKeys?: 'all' | Set<Key>;\n /** Handler that is called when the string key selections change */\n onStringSelectionChange: (keys: 'all' | Set<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 selectedKeys The currently selected keys in the collection.\n * @param defaultSelectedKeys The initial selected keys 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 UseStringifiedMultiSelectionResult with stringified key sets and\n * string key selection change handler.\n */\nexport function useStringifiedMultiSelection({\n normalizedItems,\n defaultSelectedKeys,\n disabledKeys,\n selectedKeys,\n onChange,\n}: UseStringifiedMultiSelectionOptions): UseStringifiedMultiSelectionResult {\n const selectedStringKeys = useMemo(\n () => itemSelectionToStringSet(selectedKeys),\n [selectedKeys]\n );\n\n const defaultSelectedStringKeys = useMemo(\n () => itemSelectionToStringSet(defaultSelectedKeys),\n [defaultSelectedKeys]\n );\n\n const disabledStringKeys = useMemo(\n () => itemSelectionToStringSet(disabledKeys),\n [disabledKeys]\n );\n\n const onStringSelectionChange = useCallback(\n (keys: 'all' | Set<Key>) => {\n if (keys === 'all') {\n onChange?.('all');\n return;\n }\n\n const actualKeys = new Set<ItemKey>();\n\n normalizedItems.forEach(item => {\n if (keys.has(String(getItemKey(item)))) {\n actualKeys.add(getItemKey(item));\n }\n });\n\n onChange?.(actualKeys);\n },\n [normalizedItems, onChange]\n );\n\n return {\n selectedStringKeys,\n defaultSelectedStringKeys,\n disabledStringKeys,\n onStringSelectionChange,\n };\n}\n\nexport default useStringifiedMultiSelection;\n"],"mappings":"AAAA,SAAcA,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAEhDC,UAAU,EAGVC,wBAAwB;AA6B1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAAAC,IAAA,EAMgC;EAAA,IAN/B;IAC3CC,eAAe;IACfC,mBAAmB;IACnBC,YAAY;IACZC,YAAY;IACZC;EACmC,CAAC,GAAAL,IAAA;EACpC,IAAMM,kBAAkB,GAAGV,OAAO,CAChC,MAAME,wBAAwB,CAACM,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMG,yBAAyB,GAAGX,OAAO,CACvC,MAAME,wBAAwB,CAACI,mBAAmB,CAAC,EACnD,CAACA,mBAAmB,CACtB,CAAC;EAED,IAAMM,kBAAkB,GAAGZ,OAAO,CAChC,MAAME,wBAAwB,CAACK,YAAY,CAAC,EAC5C,CAACA,YAAY,CACf,CAAC;EAED,IAAMM,uBAAuB,GAAGd,WAAW,CACxCe,IAAsB,IAAK;IAC1B,IAAIA,IAAI,KAAK,KAAK,EAAE;MAClBL,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAG,KAAK,CAAC;MACjB;IACF;IAEA,IAAMM,UAAU,GAAG,IAAIC,GAAG,CAAU,CAAC;IAErCX,eAAe,CAACY,OAAO,CAACC,IAAI,IAAI;MAC9B,IAAIJ,IAAI,CAACK,GAAG,CAACC,MAAM,CAACnB,UAAU,CAACiB,IAAI,CAAC,CAAC,CAAC,EAAE;QACtCH,UAAU,CAACM,GAAG,CAACpB,UAAU,CAACiB,IAAI,CAAC,CAAC;MAClC;IACF,CAAC,CAAC;IAEFT,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAGM,UAAU,CAAC;EACxB,CAAC,EACD,CAACV,eAAe,EAAEI,QAAQ,CAC5B,CAAC;EAED,OAAO;IACLC,kBAAkB;IAClBC,yBAAyB;IACzBC,kBAAkB;IAClBC;EACF,CAAC;AACH;AAEA,eAAeV,4BAA4B"}
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC"}
|
package/dist/theme/index.js
CHANGED
package/dist/theme/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/theme/index.ts"],"sourcesContent":["export * from './theme-dark';\nexport * from './theme-light';\nexport * from './ThemeModel';\nexport * from './ThemePicker';\nexport * from './ThemeProvider';\nexport * from './ThemeUtils';\nexport * from './useTheme';\nexport * from './Logo';\nexport * from './colorUtils';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/theme/index.ts"],"sourcesContent":["export * from './theme-dark';\nexport * from './theme-light';\nexport * from './ThemeModel';\nexport * from './ThemePicker';\nexport * from './ThemeProvider';\nexport * from './ThemeUtils';\nexport * from './useTheme';\nexport * from './Logo';\nexport * from './colorUtils';\nexport * from './useSpectrumThemeProvider';\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSpectrumThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/useSpectrumThemeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,eAAO,MAAM,wBAAwB,oBAAc,CAAC;AAEpD,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSpectrumThemeProvider.js","names":["useProvider","useSpectrumThemeProvider"],"sources":["../../src/theme/useSpectrumThemeProvider.ts"],"sourcesContent":["import { useProvider } from '@adobe/react-spectrum';\n\nexport const useSpectrumThemeProvider = useProvider;\n\nexport default useSpectrumThemeProvider;\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,uBAAuB;AAEnD,OAAO,IAAMC,wBAAwB,GAAGD,WAAW;AAEnD,eAAeC,wBAAwB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.73.1-beta.0+111ea64c",
|
|
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.
|
|
29
|
-
"@deephaven/log": "^0.
|
|
30
|
-
"@deephaven/react-hooks": "^0.
|
|
31
|
-
"@deephaven/utils": "^0.
|
|
28
|
+
"@deephaven/icons": "^0.73.1-beta.0+111ea64c",
|
|
29
|
+
"@deephaven/log": "^0.73.1-beta.0+111ea64c",
|
|
30
|
+
"@deephaven/react-hooks": "^0.73.1-beta.0+111ea64c",
|
|
31
|
+
"@deephaven/utils": "^0.73.1-beta.0+111ea64c",
|
|
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.
|
|
58
|
+
"@deephaven/mocks": "^0.73.1-beta.0+111ea64c"
|
|
59
59
|
},
|
|
60
60
|
"files": [
|
|
61
61
|
"dist",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "111ea64c675190995f85789ce57ea055b8b7fd2b"
|
|
73
73
|
}
|
package/dist/XComponent.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { XComponentType } from './XComponentMap';
|
|
3
|
-
/**
|
|
4
|
-
* Helper function that will wrap the provided component, and return an ExtendableComponent type.
|
|
5
|
-
* Whenever that ExtendableComponent is used, it will check if there is a replacement component for the provided component on the context.
|
|
6
|
-
* If there is, it will use that component instead of the provided component.
|
|
7
|
-
* This is a similar concept to how swizzling is done in Docusaurus or obj-c, but for any React component.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
*
|
|
11
|
-
* ```tsx
|
|
12
|
-
* function MyComponent() {
|
|
13
|
-
* return <div>MyComponent</div>;
|
|
14
|
-
* }
|
|
15
|
-
* const XMyComponent = extendableComponent(MyComponent);
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* function MyReplacementComponent() {
|
|
19
|
-
* return <div>MyReplacementComponent</div>;
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* ...
|
|
24
|
-
*
|
|
25
|
-
* <XMyComponent /> // Will render MyComponent
|
|
26
|
-
*
|
|
27
|
-
* ...
|
|
28
|
-
*
|
|
29
|
-
* <XComponentMapProvider value={new Map([[XMyComponent, MyReplacementComponent]])}>
|
|
30
|
-
* <XMyComponent /> // Will render MyReplacementComponent
|
|
31
|
-
* </XComponentMapProvider>
|
|
32
|
-
*
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* Is useful in cases where we have a component deep down in the component tree that we want to replace with a different component, but don't want to
|
|
36
|
-
* have to provide props at the top level just to hook into that.
|
|
37
|
-
*
|
|
38
|
-
* @param Component The component to wrap
|
|
39
|
-
* @returns The wrapped component
|
|
40
|
-
*/
|
|
41
|
-
export declare function createXComponent<P extends Record<string, unknown>>(Component: React.ComponentType<P>): XComponentType<P>;
|
|
42
|
-
export default createXComponent;
|
|
43
|
-
//# sourceMappingURL=XComponent.d.ts.map
|
package/dist/XComponent.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"XComponent.d.ts","sourceRoot":"","sources":["../src/XComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAiB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAChC,cAAc,CAAC,CAAC,CAAC,CAUnB;AAED,eAAe,gBAAgB,CAAC"}
|
package/dist/XComponent.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
5
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import { useXComponent } from "./XComponentMap.js";
|
|
8
|
-
/**
|
|
9
|
-
* Helper function that will wrap the provided component, and return an ExtendableComponent type.
|
|
10
|
-
* Whenever that ExtendableComponent is used, it will check if there is a replacement component for the provided component on the context.
|
|
11
|
-
* If there is, it will use that component instead of the provided component.
|
|
12
|
-
* This is a similar concept to how swizzling is done in Docusaurus or obj-c, but for any React component.
|
|
13
|
-
*
|
|
14
|
-
* Usage:
|
|
15
|
-
*
|
|
16
|
-
* ```tsx
|
|
17
|
-
* function MyComponent() {
|
|
18
|
-
* return <div>MyComponent</div>;
|
|
19
|
-
* }
|
|
20
|
-
* const XMyComponent = extendableComponent(MyComponent);
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* function MyReplacementComponent() {
|
|
24
|
-
* return <div>MyReplacementComponent</div>;
|
|
25
|
-
* }
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* ...
|
|
29
|
-
*
|
|
30
|
-
* <XMyComponent /> // Will render MyComponent
|
|
31
|
-
*
|
|
32
|
-
* ...
|
|
33
|
-
*
|
|
34
|
-
* <XComponentMapProvider value={new Map([[XMyComponent, MyReplacementComponent]])}>
|
|
35
|
-
* <XMyComponent /> // Will render MyReplacementComponent
|
|
36
|
-
* </XComponentMapProvider>
|
|
37
|
-
*
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* Is useful in cases where we have a component deep down in the component tree that we want to replace with a different component, but don't want to
|
|
41
|
-
* have to provide props at the top level just to hook into that.
|
|
42
|
-
*
|
|
43
|
-
* @param Component The component to wrap
|
|
44
|
-
* @returns The wrapped component
|
|
45
|
-
*/
|
|
46
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
47
|
-
export function createXComponent(Component) {
|
|
48
|
-
var XComponent = function ExtendableComponent(props) {
|
|
49
|
-
var ReplacementComponent = useXComponent(XComponent);
|
|
50
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
51
|
-
return /*#__PURE__*/_jsx(ReplacementComponent, _objectSpread({}, props));
|
|
52
|
-
};
|
|
53
|
-
XComponent.Original = Component;
|
|
54
|
-
return XComponent;
|
|
55
|
-
}
|
|
56
|
-
export default createXComponent;
|
|
57
|
-
//# sourceMappingURL=XComponent.js.map
|
package/dist/XComponent.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"XComponent.js","names":["React","useXComponent","jsx","_jsx","createXComponent","Component","XComponent","ExtendableComponent","props","ReplacementComponent","_objectSpread","Original"],"sources":["../src/XComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { useXComponent, XComponentType } from './XComponentMap';\n\n/**\n * Helper function that will wrap the provided component, and return an ExtendableComponent type.\n * Whenever that ExtendableComponent is used, it will check if there is a replacement component for the provided component on the context.\n * If there is, it will use that component instead of the provided component.\n * This is a similar concept to how swizzling is done in Docusaurus or obj-c, but for any React component.\n *\n * Usage:\n *\n * ```tsx\n * function MyComponent() {\n * return <div>MyComponent</div>;\n * }\n * const XMyComponent = extendableComponent(MyComponent);\n *\n *\n * function MyReplacementComponent() {\n * return <div>MyReplacementComponent</div>;\n * }\n *\n *\n * ...\n *\n * <XMyComponent /> // Will render MyComponent\n *\n * ...\n *\n * <XComponentMapProvider value={new Map([[XMyComponent, MyReplacementComponent]])}>\n * <XMyComponent /> // Will render MyReplacementComponent\n * </XComponentMapProvider>\n *\n * ```\n *\n * Is useful in cases where we have a component deep down in the component tree that we want to replace with a different component, but don't want to\n * have to provide props at the top level just to hook into that.\n *\n * @param Component The component to wrap\n * @returns The wrapped component\n */\nexport function createXComponent<P extends Record<string, unknown>>(\n Component: React.ComponentType<P>\n): XComponentType<P> {\n const XComponent = function ExtendableComponent(props: P): JSX.Element {\n const ReplacementComponent = useXComponent(XComponent);\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <ReplacementComponent {...props} />;\n };\n\n XComponent.Original = Component;\n\n return XComponent;\n}\n\nexport default createXComponent;\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAAC,SACjBC,aAAa;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AArCA,SAAAC,GAAA,IAAAC,IAAA;AAsCA,OAAO,SAASC,gBAAgBA,CAC9BC,SAAiC,EACd;EACnB,IAAMC,UAAU,GAAG,SAASC,mBAAmBA,CAACC,KAAQ,EAAe;IACrE,IAAMC,oBAAoB,GAAGR,aAAa,CAACK,UAAU,CAAC;IACtD;IACA,oBAAOH,IAAA,CAACM,oBAAoB,EAAAC,aAAA,KAAKF,KAAK,CAAG,CAAC;EAC5C,CAAC;EAEDF,UAAU,CAACK,QAAQ,GAAGN,SAAS;EAE/B,OAAOC,UAAU;AACnB;AAEA,eAAeF,gBAAgB"}
|
package/dist/XComponentMap.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/** Type for an extended component. Can fetch the original component using `.original` */
|
|
3
|
-
export type XComponentType<P extends Record<string, unknown>> = React.ComponentType<P> & {
|
|
4
|
-
Original: React.ComponentType<P>;
|
|
5
|
-
};
|
|
6
|
-
export declare const XComponentMapContext: React.Context<Map<React.ComponentType<any>, React.ComponentType<any>>>;
|
|
7
|
-
export declare const XComponentMapProvider: React.Provider<Map<React.ComponentType<any>, React.ComponentType<any>>>;
|
|
8
|
-
/**
|
|
9
|
-
* Use the replacement component for the provided component if it exists, or just return the provided component.
|
|
10
|
-
* @param Component Component to check if there's a replacement for
|
|
11
|
-
* @returns The replacement component if it exists, otherwise the original component
|
|
12
|
-
*/
|
|
13
|
-
export declare function useXComponent<P extends Record<string, unknown>>(Component: XComponentType<P>): React.ComponentType<P>;
|
|
14
|
-
//# sourceMappingURL=XComponentMap.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"XComponentMap.d.ts","sourceRoot":"","sources":["../src/XComponentMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,yFAAyF;AACzF,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC1D,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG;IACvB,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC;AAEJ,eAAO,MAAM,oBAAoB,wEAGhC,CAAC;AAEF,eAAO,MAAM,qBAAqB,yEAAgC,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7D,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,GAC3B,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAGxB"}
|
package/dist/XComponentMap.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
/** Type for an extended component. Can fetch the original component using `.original` */
|
|
4
|
-
|
|
5
|
-
export var XComponentMapContext = /*#__PURE__*/React.createContext(
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
-
new Map());
|
|
8
|
-
export var XComponentMapProvider = XComponentMapContext.Provider;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Use the replacement component for the provided component if it exists, or just return the provided component.
|
|
12
|
-
* @param Component Component to check if there's a replacement for
|
|
13
|
-
* @returns The replacement component if it exists, otherwise the original component
|
|
14
|
-
*/
|
|
15
|
-
export function useXComponent(Component) {
|
|
16
|
-
var _ctx$get;
|
|
17
|
-
var ctx = useContext(XComponentMapContext);
|
|
18
|
-
return (_ctx$get = ctx.get(Component)) !== null && _ctx$get !== void 0 ? _ctx$get : Component.Original;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=XComponentMap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"XComponentMap.js","names":["React","useContext","XComponentMapContext","createContext","Map","XComponentMapProvider","Provider","useXComponent","Component","_ctx$get","ctx","get","Original"],"sources":["../src/XComponentMap.ts"],"sourcesContent":["import React, { useContext } from 'react';\n\n/** Type for an extended component. Can fetch the original component using `.original` */\nexport type XComponentType<P extends Record<string, unknown>> =\n React.ComponentType<P> & {\n Original: React.ComponentType<P>;\n };\n\nexport const XComponentMapContext = React.createContext(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new Map<React.ComponentType<any>, React.ComponentType<any>>()\n);\n\nexport const XComponentMapProvider = XComponentMapContext.Provider;\n\n/**\n * Use the replacement component for the provided component if it exists, or just return the provided component.\n * @param Component Component to check if there's a replacement for\n * @returns The replacement component if it exists, otherwise the original component\n */\nexport function useXComponent<P extends Record<string, unknown>>(\n Component: XComponentType<P>\n): React.ComponentType<P> {\n const ctx = useContext(XComponentMapContext);\n return ctx.get(Component) ?? Component.Original;\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;;AAEzC;;AAMA,OAAO,IAAMC,oBAAoB,gBAAGF,KAAK,CAACG,aAAa;AACrD;AACA,IAAIC,GAAG,CAAqD,CAC9D,CAAC;AAED,OAAO,IAAMC,qBAAqB,GAAGH,oBAAoB,CAACI,QAAQ;;AAElE;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3BC,SAA4B,EACJ;EAAA,IAAAC,QAAA;EACxB,IAAMC,GAAG,GAAGT,UAAU,CAACC,oBAAoB,CAAC;EAC5C,QAAAO,QAAA,GAAOC,GAAG,CAACC,GAAG,CAACH,SAAS,CAAC,cAAAC,QAAA,cAAAA,QAAA,GAAID,SAAS,CAACI,QAAQ;AACjD"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
export interface PickerItemContentProps {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Picker item content. Text content will be wrapped in a Spectrum Text
|
|
7
|
-
* component with ellipsis overflow handling.
|
|
8
|
-
*/
|
|
9
|
-
export declare function PickerItemContent({ children: content, }: PickerItemContentProps): JSX.Element | null;
|
|
10
|
-
export default PickerItemContent;
|
|
11
|
-
//# sourceMappingURL=PickerItemContent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PickerItemContent.d.ts","sourceRoot":"","sources":["../../../src/spectrum/picker/PickerItemContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,SAAS,EAAE,MAAM,OAAO,CAAC;AAM1E,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EAAE,OAAO,GAClB,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAyC7C;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PickerItemContent.js","names":["Children","cloneElement","isValidElement","Text","cl","isElementOfType","stylesCommon","jsx","_jsx","Fragment","_Fragment","PickerItemContent","_ref","children","content","String","Array","isArray","map","el","i","_objectSpread","props","UNSAFE_className","spectrumEllipsis"],"sources":["../../../src/spectrum/picker/PickerItemContent.tsx"],"sourcesContent":["import { Children, cloneElement, isValidElement, ReactNode } from 'react';\nimport { Text } from '@adobe/react-spectrum';\nimport cl from 'classnames';\nimport { isElementOfType } from '@deephaven/react-hooks';\nimport stylesCommon from '../../SpectrumComponent.module.scss';\n\nexport interface PickerItemContentProps {\n children: ReactNode;\n}\n\n/**\n * Picker item content. Text content will be wrapped in a Spectrum Text\n * component with ellipsis overflow handling.\n */\nexport function PickerItemContent({\n children: content,\n}: PickerItemContentProps): JSX.Element | null {\n if (isValidElement(content)) {\n return content;\n }\n\n /* eslint-disable no-param-reassign */\n if (content === '') {\n // Prevent the item height from collapsing when the content is empty\n content = '\\xa0'; // Non-breaking space\n } else if (typeof content === 'boolean') {\n // Boolean values need to be stringified to render\n content = String(content);\n } else if (Array.isArray(content)) {\n // For cases where there are multiple `Text` children, add a css class to\n // handle overflow. The primary use case for multiple text nodes is when a\n // description is provided for an item. e.g.\n // <Item textValue=\"Some Text\">\n // <SomeIcon />\n // <Text>Some Label</Text>\n // <Text slot=\"description\">Some Description</Text>\n // </Item>\n content = Children.map(content, (el, i) =>\n isElementOfType(el, Text)\n ? cloneElement(el, {\n ...el.props,\n UNSAFE_className: cl(\n el.props.UNSAFE_className,\n stylesCommon.spectrumEllipsis\n ),\n })\n : el\n );\n }\n /* eslint-enable no-param-reassign */\n\n return typeof content === 'string' || typeof content === 'number' ? (\n <Text UNSAFE_className={stylesCommon.spectrumEllipsis}>{content}</Text>\n ) : (\n // eslint-disable-next-line react/jsx-no-useless-fragment\n <>{content}</>\n );\n}\n\nexport default PickerItemContent;\n"],"mappings":";;;;;AAAA,SAASA,QAAQ,EAAEC,YAAY,EAAEC,cAAc,QAAmB,OAAO;AACzE,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,OAAOC,EAAE,MAAM,YAAY;AAC3B,SAASC,eAAe,QAAQ,wBAAwB;AAAC,OAClDC,YAAY;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAMnB;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAAC,IAAA,EAEc;EAAA,IAFb;IAChCC,QAAQ,EAAEC;EACY,CAAC,GAAAF,IAAA;EACvB,kBAAIV,cAAc,CAACY,OAAO,CAAC,EAAE;IAC3B,OAAOA,OAAO;EAChB;;EAEA;EACA,IAAIA,OAAO,KAAK,EAAE,EAAE;IAClB;IACAA,OAAO,GAAG,MAAM,CAAC,CAAC;EACpB,CAAC,MAAM,IAAI,OAAOA,OAAO,KAAK,SAAS,EAAE;IACvC;IACAA,OAAO,GAAGC,MAAM,CAACD,OAAO,CAAC;EAC3B,CAAC,MAAM,IAAIE,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,EAAE;IACjC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAA,OAAO,GAAGd,QAAQ,CAACkB,GAAG,CAACJ,OAAO,EAAE,CAACK,EAAE,EAAEC,CAAC,KACpCf,eAAe,CAACc,EAAE,EAAEhB,IAAI,CAAC,gBACrBF,YAAY,CAACkB,EAAE,EAAAE,aAAA,CAAAA,aAAA,KACVF,EAAE,CAACG,KAAK;MACXC,gBAAgB,EAAEnB,EAAE,CAClBe,EAAE,CAACG,KAAK,CAACC,gBAAgB,EACzBjB,YAAY,CAACkB,gBACf;IAAC,EACF,CAAC,GACFL,EACN,CAAC;EACH;EACA;;EAEA,OAAO,OAAOL,OAAO,KAAK,QAAQ,IAAI,OAAOA,OAAO,KAAK,QAAQ,gBAC/DN,IAAA,CAACL,IAAI;IAACoB,gBAAgB,EAAEjB,YAAY,CAACkB,gBAAiB;IAAAX,QAAA,EAAEC;EAAO,CAAO,CAAC;EAAA;EAEvE;EACAN,IAAA,CAAAE,SAAA;IAAAG,QAAA,EAAGC;EAAO,CAAG,CACd;AACH;AAEA,eAAeH,iBAAiB"}
|