@codeleap/web 7.0.2 → 7.1.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.
- package/dist/components/ActivityIndicator/index.js +16 -34
- package/dist/components/ActivityIndicator/index.js.map +1 -1
- package/dist/components/ActivityIndicator/styles.js +1 -2
- package/dist/components/ActivityIndicator/types.js +1 -2
- package/dist/components/Badge/index.js +24 -42
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Badge/styles.js +1 -2
- package/dist/components/Badge/types.js +1 -2
- package/dist/components/Button/index.js +19 -36
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/styles.js +1 -2
- package/dist/components/Button/types.js +1 -2
- package/dist/components/Calendar/index.js +12 -29
- package/dist/components/Calendar/index.js.map +1 -1
- package/dist/components/Calendar/styles.js +1 -2
- package/dist/components/Calendar/types.js +1 -2
- package/dist/components/Carousel/index.js +40 -82
- package/dist/components/Carousel/index.js.map +1 -1
- package/dist/components/Carousel/styles.js +1 -2
- package/dist/components/Carousel/types.js +1 -2
- package/dist/components/Checkbox/index.js +24 -42
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Checkbox/styles.js +1 -2
- package/dist/components/Checkbox/types.js +1 -2
- package/dist/components/Collapse/index.js +17 -35
- package/dist/components/Collapse/index.js.map +1 -1
- package/dist/components/Collapse/styles.js +1 -2
- package/dist/components/Collapse/types.js +1 -2
- package/dist/components/ColorPicker/index.js +33 -51
- package/dist/components/ColorPicker/index.js.map +1 -1
- package/dist/components/ColorPicker/styles.js +1 -2
- package/dist/components/ColorPicker/types.js +1 -2
- package/dist/components/CropPicker/hooks.d.ts +2 -2
- package/dist/components/CropPicker/hooks.js +17 -20
- package/dist/components/CropPicker/hooks.js.map +1 -1
- package/dist/components/CropPicker/index.js +22 -40
- package/dist/components/CropPicker/index.js.map +1 -1
- package/dist/components/CropPicker/styles.js +1 -2
- package/dist/components/CropPicker/types.js +1 -2
- package/dist/components/CropPicker/utils.js +3 -9
- package/dist/components/CropPicker/utils.js.map +1 -1
- package/dist/components/DatePicker/index.js +23 -40
- package/dist/components/DatePicker/index.js.map +1 -1
- package/dist/components/DatePicker/styles.js +1 -2
- package/dist/components/DatePicker/types.js +1 -2
- package/dist/components/Drawer/index.js +22 -40
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Drawer/styles.js +1 -2
- package/dist/components/Drawer/types.js +1 -2
- package/dist/components/Dropzone/context.js +11 -16
- package/dist/components/Dropzone/context.js.map +1 -1
- package/dist/components/Dropzone/elements.js +13 -19
- package/dist/components/Dropzone/elements.js.map +1 -1
- package/dist/components/Dropzone/index.js +35 -53
- package/dist/components/Dropzone/index.js.map +1 -1
- package/dist/components/Dropzone/styles.js +1 -2
- package/dist/components/Dropzone/types.js +1 -2
- package/dist/components/Dropzone/useDropzone.js +3 -6
- package/dist/components/Dropzone/useDropzone.js.map +1 -1
- package/dist/components/EmptyPlaceholder/index.js +40 -61
- package/dist/components/EmptyPlaceholder/index.js.map +1 -1
- package/dist/components/EmptyPlaceholder/styles.js +1 -2
- package/dist/components/EmptyPlaceholder/types.js +1 -2
- package/dist/components/Field/context.js +11 -17
- package/dist/components/Field/context.js.map +1 -1
- package/dist/components/Field/elements.js +31 -39
- package/dist/components/Field/elements.js.map +1 -1
- package/dist/components/Field/index.js +23 -41
- package/dist/components/Field/index.js.map +1 -1
- package/dist/components/Field/styles.js +1 -2
- package/dist/components/Field/types.js +1 -2
- package/dist/components/Field/useFieldInput.d.ts +1 -1
- package/dist/components/Field/useFieldInput.js +8 -11
- package/dist/components/Field/useFieldInput.js.map +1 -1
- package/dist/components/FileInput/index.js +14 -32
- package/dist/components/FileInput/index.js.map +1 -1
- package/dist/components/FileInput/types.js +1 -2
- package/dist/components/Icon/index.js +26 -44
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Icon/styles.js +1 -2
- package/dist/components/Icon/types.js +1 -2
- package/dist/components/List/context.js +20 -25
- package/dist/components/List/context.js.map +1 -1
- package/dist/components/List/elements.d.ts.map +1 -1
- package/dist/components/List/elements.js +58 -82
- package/dist/components/List/elements.js.map +1 -1
- package/dist/components/List/index.d.ts.map +1 -1
- package/dist/components/List/index.js +19 -36
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/List/scroll.d.ts.map +1 -1
- package/dist/components/List/scroll.js +20 -20
- package/dist/components/List/scroll.js.map +1 -1
- package/dist/components/List/styles.js +1 -2
- package/dist/components/List/types.d.ts +13 -4
- package/dist/components/List/types.d.ts.map +1 -1
- package/dist/components/List/types.js +1 -2
- package/dist/components/List/useScrollEdgeDetection.d.ts +12 -0
- package/dist/components/List/useScrollEdgeDetection.d.ts.map +1 -0
- package/dist/components/List/useScrollEdgeDetection.js +37 -0
- package/dist/components/List/useScrollEdgeDetection.js.map +1 -0
- package/dist/components/LoadingOverlay/index.js +20 -38
- package/dist/components/LoadingOverlay/index.js.map +1 -1
- package/dist/components/LoadingOverlay/styles.js +1 -2
- package/dist/components/LoadingOverlay/types.js +1 -2
- package/dist/components/MaskedTextInput/index.js +14 -32
- package/dist/components/MaskedTextInput/index.js.map +1 -1
- package/dist/components/MaskedTextInput/mask.js +1 -4
- package/dist/components/MaskedTextInput/mask.js.map +1 -1
- package/dist/components/MaskedTextInput/types.js +1 -2
- package/dist/components/Modal/context.js +9 -14
- package/dist/components/Modal/context.js.map +1 -1
- package/dist/components/Modal/elements.js +23 -31
- package/dist/components/Modal/elements.js.map +1 -1
- package/dist/components/Modal/index.js +22 -40
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/styles.js +1 -2
- package/dist/components/Modal/types.js +1 -2
- package/dist/components/NumberIncrement/index.js +29 -47
- package/dist/components/NumberIncrement/index.js.map +1 -1
- package/dist/components/NumberIncrement/styles.js +1 -2
- package/dist/components/NumberIncrement/types.js +1 -2
- package/dist/components/NumberIncrement/useNumberIncrement.js +21 -24
- package/dist/components/NumberIncrement/useNumberIncrement.js.map +1 -1
- package/dist/components/Overlay/index.js +21 -39
- package/dist/components/Overlay/index.js.map +1 -1
- package/dist/components/Overlay/styles.js +1 -2
- package/dist/components/Overlay/types.js +1 -2
- package/dist/components/PaginationButtons/index.js +26 -44
- package/dist/components/PaginationButtons/index.js.map +1 -1
- package/dist/components/PaginationButtons/styles.js +1 -2
- package/dist/components/PaginationButtons/types.js +1 -2
- package/dist/components/PaginationIndicator/ImperativePaginationIndicator.d.ts +13 -0
- package/dist/components/PaginationIndicator/ImperativePaginationIndicator.d.ts.map +1 -0
- package/dist/components/PaginationIndicator/ImperativePaginationIndicator.js +20 -0
- package/dist/components/PaginationIndicator/ImperativePaginationIndicator.js.map +1 -0
- package/dist/components/PaginationIndicator/index.d.ts +1 -0
- package/dist/components/PaginationIndicator/index.d.ts.map +1 -1
- package/dist/components/PaginationIndicator/index.js +25 -42
- package/dist/components/PaginationIndicator/index.js.map +1 -1
- package/dist/components/PaginationIndicator/styles.js +1 -2
- package/dist/components/PaginationIndicator/types.d.ts +9 -0
- package/dist/components/PaginationIndicator/types.d.ts.map +1 -1
- package/dist/components/PaginationIndicator/types.js +1 -2
- package/dist/components/Progress/Bar/Segmented.js +19 -23
- package/dist/components/Progress/Bar/Segmented.js.map +1 -1
- package/dist/components/Progress/Bar/index.js +29 -47
- package/dist/components/Progress/Bar/index.js.map +1 -1
- package/dist/components/Progress/Bar/styles.js +1 -2
- package/dist/components/Progress/Bar/types.js +1 -2
- package/dist/components/Progress/Circle/Segmented.js +22 -26
- package/dist/components/Progress/Circle/Segmented.js.map +1 -1
- package/dist/components/Progress/Circle/index.js +30 -48
- package/dist/components/Progress/Circle/index.js.map +1 -1
- package/dist/components/Progress/Circle/styles.js +1 -2
- package/dist/components/Progress/Circle/types.js +1 -2
- package/dist/components/Progress/index.js +2 -18
- package/dist/components/Progress/index.js.map +1 -1
- package/dist/components/Progress/utils.js +1 -4
- package/dist/components/Progress/utils.js.map +1 -1
- package/dist/components/RadioInput/index.js +26 -47
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/RadioInput/styles.js +1 -2
- package/dist/components/RadioInput/types.js +1 -2
- package/dist/components/SearchInput/index.js +14 -51
- package/dist/components/SearchInput/index.js.map +1 -1
- package/dist/components/SectionFilters/index.js +38 -56
- package/dist/components/SectionFilters/index.js.map +1 -1
- package/dist/components/SectionFilters/styles.js +1 -2
- package/dist/components/SectionFilters/types.js +1 -2
- package/dist/components/Select/context.js +44 -50
- package/dist/components/Select/context.js.map +1 -1
- package/dist/components/Select/elements.js +23 -29
- package/dist/components/Select/elements.js.map +1 -1
- package/dist/components/Select/index.js +24 -41
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/styles.js +1 -2
- package/dist/components/Select/types.js +1 -2
- package/dist/components/Select/useTriggerWidth.js +6 -9
- package/dist/components/Select/useTriggerWidth.js.map +1 -1
- package/dist/components/Slider/index.js +47 -68
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Slider/styles.js +1 -2
- package/dist/components/Slider/types.js +1 -2
- package/dist/components/Switch/index.js +22 -40
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/styles.js +1 -2
- package/dist/components/Switch/types.js +1 -2
- package/dist/components/Tag/index.js +34 -55
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Tag/styles.js +1 -2
- package/dist/components/Tag/types.js +1 -2
- package/dist/components/Text/index.js +27 -48
- package/dist/components/Text/index.js.map +1 -1
- package/dist/components/Text/styles.js +1 -2
- package/dist/components/Text/types.js +1 -2
- package/dist/components/TextEditor/index.js +29 -50
- package/dist/components/TextEditor/index.js.map +1 -1
- package/dist/components/TextEditor/styles.js +1 -2
- package/dist/components/TextEditor/types.js +1 -2
- package/dist/components/TextInput/index.js +28 -49
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/styles.js +1 -2
- package/dist/components/TextInput/types.js +1 -2
- package/dist/components/TextInput/useTextInput.d.ts +2 -2
- package/dist/components/TextInput/useTextInput.js +12 -15
- package/dist/components/TextInput/useTextInput.js.map +1 -1
- package/dist/components/Tooltip/index.js +33 -54
- package/dist/components/Tooltip/index.js.map +1 -1
- package/dist/components/Tooltip/styles.js +1 -2
- package/dist/components/Tooltip/types.js +1 -2
- package/dist/components/Touchable/index.js +23 -42
- package/dist/components/Touchable/index.js.map +1 -1
- package/dist/components/Touchable/styles.js +1 -2
- package/dist/components/Touchable/types.js +1 -2
- package/dist/components/View/index.js +15 -32
- package/dist/components/View/index.js.map +1 -1
- package/dist/components/View/styles.js +1 -2
- package/dist/components/View/types.js +1 -2
- package/dist/components/components.js +41 -57
- package/dist/components/components.js.map +1 -1
- package/dist/index.js +4 -20
- package/dist/index.js.map +1 -1
- package/dist/lib/ListMasonry.js +22 -31
- package/dist/lib/ListMasonry.js.map +1 -1
- package/dist/lib/ThemeVariables.js +6 -11
- package/dist/lib/ThemeVariables.js.map +1 -1
- package/dist/lib/WebStyleRegistry.js +3 -7
- package/dist/lib/WebStyleRegistry.js.map +1 -1
- package/dist/lib/hooks/index.js +22 -38
- package/dist/lib/hooks/index.js.map +1 -1
- package/dist/lib/hooks/useAnimatedStyle.js +5 -9
- package/dist/lib/hooks/useAnimatedStyle.js.map +1 -1
- package/dist/lib/hooks/useAnimatedVariantStyles.js +6 -9
- package/dist/lib/hooks/useAnimatedVariantStyles.js.map +1 -1
- package/dist/lib/hooks/useAsyncSelect.js +8 -11
- package/dist/lib/hooks/useAsyncSelect.js.map +1 -1
- package/dist/lib/hooks/useBreakpointMatch.js +19 -22
- package/dist/lib/hooks/useBreakpointMatch.js.map +1 -1
- package/dist/lib/hooks/useClick.js +7 -10
- package/dist/lib/hooks/useClick.js.map +1 -1
- package/dist/lib/hooks/useClickOutside.js +4 -7
- package/dist/lib/hooks/useClickOutside.js.map +1 -1
- package/dist/lib/hooks/useFileInput.js +3 -7
- package/dist/lib/hooks/useFileInput.js.map +1 -1
- package/dist/lib/hooks/useIsomorphicEffect.js +2 -5
- package/dist/lib/hooks/useIsomorphicEffect.js.map +1 -1
- package/dist/lib/hooks/useKeydown.js +9 -13
- package/dist/lib/hooks/useKeydown.js.map +1 -1
- package/dist/lib/hooks/useListFocus.js +4 -7
- package/dist/lib/hooks/useListFocus.js.map +1 -1
- package/dist/lib/hooks/useMediaQuery.js +8 -11
- package/dist/lib/hooks/useMediaQuery.js.map +1 -1
- package/dist/lib/hooks/usePageExitBlocker.js +6 -10
- package/dist/lib/hooks/usePageExitBlocker.js.map +1 -1
- package/dist/lib/hooks/usePagination.js +10 -13
- package/dist/lib/hooks/usePagination.js.map +1 -1
- package/dist/lib/hooks/usePopState.js +5 -9
- package/dist/lib/hooks/usePopState.js.map +1 -1
- package/dist/lib/hooks/usePopoverDismiss.js +5 -8
- package/dist/lib/hooks/usePopoverDismiss.js.map +1 -1
- package/dist/lib/hooks/useRefresh.js +9 -16
- package/dist/lib/hooks/useRefresh.js.map +1 -1
- package/dist/lib/hooks/useScrollEffect.js +3 -6
- package/dist/lib/hooks/useScrollEffect.js.map +1 -1
- package/dist/lib/hooks/useSearchParams.js +7 -10
- package/dist/lib/hooks/useSearchParams.js.map +1 -1
- package/dist/lib/hooks/useStaticAnimationStyles.js +3 -6
- package/dist/lib/hooks/useStaticAnimationStyles.js.map +1 -1
- package/dist/lib/hooks/useStylesFor.js +9 -13
- package/dist/lib/hooks/useStylesFor.js.map +1 -1
- package/dist/lib/hooks/useTouchableEvents.js +4 -7
- package/dist/lib/hooks/useTouchableEvents.js.map +1 -1
- package/dist/lib/hooks/useWindowFocus.js +7 -11
- package/dist/lib/hooks/useWindowFocus.js.map +1 -1
- package/dist/lib/hooks/useWindowSize.js +7 -10
- package/dist/lib/hooks/useWindowSize.js.map +1 -1
- package/dist/lib/index.js +6 -22
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/tools/index.js +3 -19
- package/dist/lib/tools/index.js.map +1 -1
- package/dist/lib/tools/localStorage.js +8 -12
- package/dist/lib/tools/localStorage.js.map +1 -1
- package/dist/lib/tools/mediaQuery.js +3 -8
- package/dist/lib/tools/mediaQuery.js.map +1 -1
- package/dist/lib/tools/modal.js +13 -18
- package/dist/lib/tools/modal.js.map +1 -1
- package/dist/lib/utils/attributes.js +3 -6
- package/dist/lib/utils/attributes.js.map +1 -1
- package/dist/lib/utils/cache.d.ts +2 -2
- package/dist/lib/utils/cache.js +4 -11
- package/dist/lib/utils/cache.js.map +1 -1
- package/dist/lib/utils/index.js +5 -21
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/pollyfils/scroll.js +1 -5
- package/dist/lib/utils/pollyfils/scroll.js.map +1 -1
- package/dist/lib/utils/stopPropagation.js +1 -4
- package/dist/lib/utils/stopPropagation.js.map +1 -1
- package/dist/lib/utils/test.js +3 -7
- package/dist/lib/utils/test.js.map +1 -1
- package/dist/types/index.js +1 -17
- package/dist/types/index.js.map +1 -1
- package/dist/types/utility.js +1 -2
- package/package.json +17 -17
- package/src/components/List/elements.tsx +35 -13
- package/src/components/List/index.tsx +12 -4
- package/src/components/List/scroll.ts +8 -3
- package/src/components/List/types.ts +13 -4
- package/src/components/List/useScrollEdgeDetection.ts +59 -0
- package/src/components/PaginationIndicator/ImperativePaginationIndicator.tsx +35 -0
- package/src/components/PaginationIndicator/index.tsx +1 -0
- package/src/components/PaginationIndicator/types.ts +11 -0
- package/src/components/Touchable/index.tsx +2 -1
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Field = void 0;
|
|
18
|
-
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
19
|
-
const context_1 = require("./context");
|
|
20
|
-
const elements_1 = require("./elements");
|
|
21
|
-
const lib_1 = require("../../lib");
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { FieldProvider, getFieldIds } from './context';
|
|
3
|
+
import { FieldBox, FieldHeading, FieldHelper, FieldWrapper, SectionSlot } from './elements';
|
|
4
|
+
import { WebStyleRegistry } from '../../lib';
|
|
22
5
|
/**
|
|
23
6
|
* Form field layout shell that composes a label, input box, helper text, and
|
|
24
7
|
* left/right section slots around any input child; distributes state (disabled,
|
|
@@ -28,28 +11,27 @@ const lib_1 = require("../../lib");
|
|
|
28
11
|
* Uses: `FieldProvider`, `FieldWrapper`, `FieldHeading`, `FieldBox`, `FieldHelper`,
|
|
29
12
|
* `SectionSlot`, `WebStyleRegistry`
|
|
30
13
|
*/
|
|
31
|
-
const Field = (props) => {
|
|
32
|
-
return (
|
|
14
|
+
export const Field = (props) => {
|
|
15
|
+
return _jsx(FieldProvider, { ...props, children: _jsxs(FieldWrapper, { children: [_jsx(FieldHeading, {}), _jsxs(FieldBox, { children: [_jsx(SectionSlot, { position: 'left' }), props?.children, _jsx(SectionSlot, { position: 'right' })] }), _jsx(FieldHelper, {})] }) });
|
|
33
16
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return exports.Field;
|
|
17
|
+
Field.withVariantTypes = (styles) => {
|
|
18
|
+
return Field;
|
|
37
19
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
Field.styleRegistryName = 'Field';
|
|
21
|
+
Field.rootElement = 'wrapper';
|
|
22
|
+
Field.elements = [
|
|
41
23
|
'wrapper', 'box', 'heading', 'helper', 'section', 'leftSection', 'rightSection',
|
|
42
24
|
];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
25
|
+
Field.SectionSlot = SectionSlot;
|
|
26
|
+
Field.Box = FieldBox;
|
|
27
|
+
Field.Wrapper = FieldWrapper;
|
|
28
|
+
Field.Heading = FieldHeading;
|
|
29
|
+
Field.Helper = FieldHelper;
|
|
30
|
+
Field.Provider = FieldProvider;
|
|
31
|
+
Field.getIds = getFieldIds;
|
|
32
|
+
WebStyleRegistry.registerComponent(Field);
|
|
33
|
+
export * from './context';
|
|
34
|
+
export * from './styles';
|
|
35
|
+
export * from './types';
|
|
36
|
+
export * from './useFieldInput';
|
|
55
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Field/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Field/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAG3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAA0C,EAAE,EAAE;IAElE,OAAO,KAAC,aAAa,OAAK,KAAK,YAC7B,MAAC,YAAY,eACX,KAAC,YAAY,KAAG,EAChB,MAAC,QAAQ,eACP,KAAC,WAAW,IAAC,QAAQ,EAAC,MAAM,GAAE,EAC7B,KAAK,EAAE,QAAQ,EAChB,KAAC,WAAW,IAAC,QAAQ,EAAC,OAAO,GAAE,IACtB,EACX,KAAC,WAAW,KAAG,IACF,GACD,CAAA;AAClB,CAAC,CAAA;AAED,KAAK,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IAC1D,OAAO,KAAyE,CAAA;AAClF,CAAC,CAAA;AAED,KAAK,CAAC,iBAAiB,GAAG,OAAO,CAAA;AACjC,KAAK,CAAC,WAAW,GAAG,SAAS,CAAA;AAC7B,KAAK,CAAC,QAAQ,GAAG;IACf,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc;CAChF,CAAA;AAED,KAAK,CAAC,WAAW,GAAG,WAAW,CAAA;AAC/B,KAAK,CAAC,GAAG,GAAG,QAAQ,CAAA;AACpB,KAAK,CAAC,OAAO,GAAG,YAAY,CAAA;AAC5B,KAAK,CAAC,OAAO,GAAG,YAAY,CAAA;AAC5B,KAAK,CAAC,MAAM,GAAG,WAAW,CAAA;AAC1B,KAAK,CAAC,QAAQ,GAAG,aAAa,CAAA;AAC9B,KAAK,CAAC,MAAM,GAAG,WAAW,CAAA;AAE1B,gBAAgB,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;AAEzC,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA"}
|
|
@@ -47,7 +47,7 @@ export declare function useFieldInput<V, T extends Field<V, any, any, any> = Fie
|
|
|
47
47
|
showError: boolean;
|
|
48
48
|
isUnset: boolean;
|
|
49
49
|
validation: import("@codeleap/form").ValidationResult<any, any>;
|
|
50
|
-
value: V | import("nanostores"
|
|
50
|
+
value: V | import("nanostores").StoreValue<V extends object ? import("nanostores").MapStore<V> : never>;
|
|
51
51
|
} | {
|
|
52
52
|
onInputBlurred(): void;
|
|
53
53
|
hasBlurred: boolean;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const form_1 = require("@codeleap/form");
|
|
6
|
-
const types_1 = require("@codeleap/types");
|
|
1
|
+
import { useMemo, useRef } from 'react';
|
|
2
|
+
import { fields, useField } from '@codeleap/form';
|
|
3
|
+
import { TypeGuards } from '@codeleap/types';
|
|
7
4
|
/**
|
|
8
5
|
* Bridges a `@codeleap/form` `Field` instance with an input element's DOM ref,
|
|
9
6
|
* or falls back to uncontrolled internal state when `onValueChange` and `value`
|
|
@@ -14,12 +11,12 @@ const types_1 = require("@codeleap/types");
|
|
|
14
11
|
*
|
|
15
12
|
* Requires a `@codeleap/form` `Field` instance; does not need a React context.
|
|
16
13
|
*/
|
|
17
|
-
function useFieldInput(field, defaultField =
|
|
14
|
+
export function useFieldInput(field, defaultField = fields.text, internalState, params = {}, deps = []) {
|
|
18
15
|
const { value, onValueChange } = internalState;
|
|
19
|
-
const hasInternalState =
|
|
20
|
-
const wrapperRef =
|
|
21
|
-
const innerInputRef =
|
|
22
|
-
const fieldHandle = hasInternalState ? {} :
|
|
16
|
+
const hasInternalState = useMemo(() => TypeGuards.isFunction(onValueChange) && !TypeGuards.isNil(value), []);
|
|
17
|
+
const wrapperRef = useRef(undefined);
|
|
18
|
+
const innerInputRef = useRef(null);
|
|
19
|
+
const fieldHandle = hasInternalState ? {} : useField(field, [
|
|
23
20
|
{
|
|
24
21
|
blur() {
|
|
25
22
|
innerInputRef.current.blur();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFieldInput.js","sourceRoot":"","sources":["../../../src/components/Field/useFieldInput.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFieldInput.js","sourceRoot":"","sources":["../../../src/components/Field/useFieldInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAoB,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAa,UAAU,EAA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AA;AACH,CAAC"}
|
|
@@ -1,43 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.FileInput = void 0;
|
|
18
|
-
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
19
|
-
const react_1 = require("react");
|
|
20
|
-
const types_1 = require("@codeleap/types");
|
|
21
|
-
const hooks_1 = require("@codeleap/hooks");
|
|
22
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useImperativeHandle, useRef } from 'react';
|
|
3
|
+
import { TypeGuards } from '@codeleap/types';
|
|
4
|
+
import { useCallback } from '@codeleap/hooks';
|
|
5
|
+
export * from './types';
|
|
23
6
|
/**
|
|
24
7
|
* Invisible file-input that delegates file selection to the browser's native picker, exposed imperatively via `ref`.
|
|
25
8
|
* Renders a zero-size hidden `<input type="file">` — pair with a visible trigger that calls `ref.current.openFilePicker()`.
|
|
26
9
|
* Uses: `FileInputRef`
|
|
27
10
|
*/
|
|
28
|
-
const FileInput = (props) => {
|
|
29
|
-
const inputRef =
|
|
11
|
+
export const FileInput = (props) => {
|
|
12
|
+
const inputRef = useRef(null);
|
|
30
13
|
const { onFileSelect, autoClear, onChange, ref, ...inputProps } = {
|
|
31
|
-
...
|
|
14
|
+
...FileInput.defaultProps,
|
|
32
15
|
...props,
|
|
33
16
|
};
|
|
34
|
-
const resolveWithFile =
|
|
35
|
-
const clearInput =
|
|
17
|
+
const resolveWithFile = useRef(undefined);
|
|
18
|
+
const clearInput = useCallback(() => {
|
|
36
19
|
if (!inputRef.current)
|
|
37
20
|
return;
|
|
38
21
|
inputRef.current.value = null;
|
|
39
22
|
}, []);
|
|
40
|
-
|
|
23
|
+
useImperativeHandle(ref, () => ({
|
|
41
24
|
openFilePicker: () => {
|
|
42
25
|
inputRef.current.click();
|
|
43
26
|
return new Promise((resolve) => {
|
|
@@ -49,7 +32,7 @@ const FileInput = (props) => {
|
|
|
49
32
|
async function handleChange(e) {
|
|
50
33
|
if (!e.target.files.length)
|
|
51
34
|
return;
|
|
52
|
-
if (
|
|
35
|
+
if (TypeGuards.isFunction(onChange))
|
|
53
36
|
onChange(e);
|
|
54
37
|
const fileArray = Array.from(e.target?.files || []);
|
|
55
38
|
const files = fileArray.map((obj) => ({
|
|
@@ -64,10 +47,9 @@ const FileInput = (props) => {
|
|
|
64
47
|
if (autoClear)
|
|
65
48
|
clearInput();
|
|
66
49
|
}
|
|
67
|
-
return ((
|
|
50
|
+
return (_jsx("input", { type: 'file', style: { visibility: 'hidden', width: 0, height: 0, opacity: 0, display: 'none' }, ...inputProps, ref: inputRef, onChange: handleChange }));
|
|
68
51
|
};
|
|
69
|
-
|
|
70
|
-
exports.FileInput.defaultProps = {
|
|
52
|
+
FileInput.defaultProps = {
|
|
71
53
|
autoClear: true,
|
|
72
54
|
};
|
|
73
55
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/FileInput/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/FileInput/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC1D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EAAE,KAAK,IAAI,EAAE,CAAW,CAAA;QAE7D,MAAM,KAAK,GAAmB,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACpD,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC;SAClC,CAAC,CAAC,CAAA;QAEH,YAAY,IAAI,YAAY,CAAC,KAAK,CAAC,CAAA;QAEnC,IAAI,eAAe,CAAC,OAAO,EAAE,CAAC;YAC5B,MAAM,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YACpC,eAAe,CAAC,OAAO,GAAG,SAAS,CAAA;QACrC,CAAC;QAED,IAAI,SAAS;YAAE,UAAU,EAAE,CAAA;IAC7B,CAAC;IAED,OAAO,CACL,gBACE,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAC7E,UAAU,EACd,GAAG,EAAE,QAAQ,EACb,QAAQ,EAAE,YAAY,GACtB,CACH,CAAA;AACH,CAAC,CAAA;AAED,SAAS,CAAC,YAAY,GAAG;IACvB,SAAS,EAAE,IAAI;CACW,CAAA"}
|
|
@@ -1,69 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Icon = void 0;
|
|
18
|
-
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
19
|
-
const View_1 = require("../View");
|
|
20
|
-
const useStylesFor_1 = require("../../lib/hooks/useStylesFor");
|
|
21
|
-
const styles_1 = require("@codeleap/styles");
|
|
22
|
-
const WebStyleRegistry_1 = require("../../lib/WebStyleRegistry");
|
|
23
|
-
const types_1 = require("@codeleap/types");
|
|
24
|
-
const Touchable_1 = require("../Touchable");
|
|
25
|
-
__exportStar(require("./styles"), exports);
|
|
26
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { View } from '../View';
|
|
3
|
+
import { useStylesFor } from '../../lib/hooks/useStylesFor';
|
|
4
|
+
import { useTheme } from '@codeleap/styles';
|
|
5
|
+
import { WebStyleRegistry } from '../../lib/WebStyleRegistry';
|
|
6
|
+
import { TypeGuards } from '@codeleap/types';
|
|
7
|
+
import { Touchable } from '../Touchable';
|
|
8
|
+
export * from './styles';
|
|
9
|
+
export * from './types';
|
|
27
10
|
/**
|
|
28
11
|
* Renders a theme-registered SVG icon; automatically wraps in `Touchable` when
|
|
29
12
|
* `onPress` is provided, and can render a sized empty placeholder when `icon` is absent.
|
|
30
13
|
* Uses: `Touchable`, `View`, `useStylesFor`, `WebStyleRegistry`
|
|
31
14
|
*/
|
|
32
|
-
const Icon = (props) => {
|
|
15
|
+
export const Icon = (props) => {
|
|
33
16
|
const { icon, style, onPress, renderEmptySpace, debugName, ...otherProps } = {
|
|
34
|
-
...
|
|
17
|
+
...Icon.defaultProps,
|
|
35
18
|
...props,
|
|
36
19
|
};
|
|
37
|
-
const themeIcons =
|
|
38
|
-
const styles =
|
|
20
|
+
const themeIcons = useTheme(store => store.theme?.icons);
|
|
21
|
+
const styles = useStylesFor(Icon.styleRegistryName, style);
|
|
39
22
|
const Component = themeIcons?.[icon];
|
|
40
23
|
if (!icon) {
|
|
41
24
|
const iconStyle = styles.icon;
|
|
42
|
-
return renderEmptySpace ? ((
|
|
25
|
+
return renderEmptySpace ? (_jsx(View, { style: {
|
|
43
26
|
height: iconStyle.size ?? iconStyle.height,
|
|
44
27
|
width: iconStyle.size ?? iconStyle.width,
|
|
45
28
|
} })) : null;
|
|
46
29
|
}
|
|
47
30
|
if (!Component)
|
|
48
31
|
return null;
|
|
49
|
-
if (
|
|
50
|
-
return (
|
|
32
|
+
if (TypeGuards.isFunction(onPress)) {
|
|
33
|
+
return _jsx(Touchable, { debugName: debugName, component: Component, onPress: onPress, ...otherProps, css: styles.icon });
|
|
51
34
|
}
|
|
52
|
-
return (
|
|
35
|
+
return _jsx(Component, { ...otherProps, css: styles.icon });
|
|
53
36
|
};
|
|
54
|
-
|
|
55
|
-
exports.Icon.Accessory = (props) => {
|
|
37
|
+
Icon.Accessory = (props) => {
|
|
56
38
|
const AcessoryIcon = (renderProps) => {
|
|
57
|
-
return (
|
|
39
|
+
return _jsx(Icon, { ...renderProps, ...props });
|
|
58
40
|
};
|
|
59
41
|
return AcessoryIcon;
|
|
60
42
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return
|
|
43
|
+
Icon.styleRegistryName = 'Icon';
|
|
44
|
+
Icon.elements = ['icon'];
|
|
45
|
+
Icon.rootElement = 'icon';
|
|
46
|
+
Icon.withVariantTypes = (styles) => {
|
|
47
|
+
return Icon;
|
|
66
48
|
};
|
|
67
|
-
|
|
68
|
-
|
|
49
|
+
Icon.defaultProps = {};
|
|
50
|
+
WebStyleRegistry.registerComponent(Icon);
|
|
69
51
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Icon/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Icon/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA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AC;QACnC,OAAO,KAAC,SAAS,IACf,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,KACZ,UAAU,EAAE,GAAG,EAAE,MAAM,CAAC,IAAI,GAChC,CAAA;IACJ,CAAC;IAED,OAAO,KAAC,SAAS,OAAK,UAAU,EAAE,GAAG,EAAE,MAAM,CAAC,IAAI,GAAI,CAAA;AACxD,CAAC,CAAA;AAED,IAAI,CAAC,SAAS,GAAG,CAAC,KAAe,EAAE,EAAE;IACnC,MAAM,YAAY,GAAI,CAAC,WAA+B,EAAE,EAAE;QACxD,OAAO,KAAC,IAAI,OACN,WAAW,KACX,KAAK,GACT,CAAA;IACJ,CAAC,CAAA;IACD,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA;AAED,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAA;AAC/B,IAAI,CAAC,QAAQ,GAAG,CAAC,MAAM,CAAC,CAAA;AACxB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAA;AAEzB,IAAI,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IACzD,OAAO,IAAuE,CAAA;AAChF,CAAC,CAAA;AAED,IAAI,CAAC,YAAY,GAAG,EAAwB,CAAA;AAE5C,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const useStylesFor_1 = require("../../lib/hooks/useStylesFor");
|
|
9
|
-
const useIsomorphicEffect_1 = require("../../lib/hooks/useIsomorphicEffect");
|
|
10
|
-
const scroll_1 = require("./scroll");
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useRef, useState } from 'react';
|
|
3
|
+
import { useDebounceCallback } from '@codeleap/hooks';
|
|
4
|
+
import { deepEqual } from '@codeleap/utils';
|
|
5
|
+
import { useStylesFor } from '../../lib/hooks/useStylesFor';
|
|
6
|
+
import { useIsomorphicEffect } from '../../lib/hooks/useIsomorphicEffect';
|
|
7
|
+
import { useElementScroll, useWindowScroll } from './scroll';
|
|
11
8
|
const LIST_STYLE_REGISTRY_NAME = 'List';
|
|
12
9
|
function resolvePadding(props, stylePositioner) {
|
|
13
10
|
const get = (key) => props[key] ?? stylePositioner?.[key];
|
|
@@ -22,17 +19,17 @@ function resolvePadding(props, stylePositioner) {
|
|
|
22
19
|
};
|
|
23
20
|
}
|
|
24
21
|
function useListProvider(props) {
|
|
25
|
-
const wrapperRef =
|
|
26
|
-
const [wrapperLayout, setWrapperLayout] =
|
|
27
|
-
const styles =
|
|
22
|
+
const wrapperRef = useRef(null);
|
|
23
|
+
const [wrapperLayout, setWrapperLayout] = useState(null);
|
|
24
|
+
const styles = useStylesFor(LIST_STYLE_REGISTRY_NAME, props.style);
|
|
28
25
|
const stylePositioner = styles?.positioner ?? {};
|
|
29
|
-
const update =
|
|
26
|
+
const update = useCallback((target) => {
|
|
30
27
|
const rect = target.getBoundingClientRect();
|
|
31
28
|
const next = { width: rect.width, offsetHeight: target.offsetHeight };
|
|
32
|
-
setWrapperLayout(current =>
|
|
29
|
+
setWrapperLayout(current => deepEqual(next, current) ? current : next);
|
|
33
30
|
}, []);
|
|
34
|
-
const { debounce: updateDebounced } =
|
|
35
|
-
|
|
31
|
+
const { debounce: updateDebounced } = useDebounceCallback(update, 200);
|
|
32
|
+
useIsomorphicEffect(() => {
|
|
36
33
|
if (typeof window === 'undefined')
|
|
37
34
|
return;
|
|
38
35
|
const el = wrapperRef.current;
|
|
@@ -45,7 +42,7 @@ function useListProvider(props) {
|
|
|
45
42
|
observer.observe(el);
|
|
46
43
|
return () => observer.disconnect();
|
|
47
44
|
}, [wrapperRef.current, update, updateDebounced]);
|
|
48
|
-
const scrollHook = props.scrollHook ?? (props.windowScroll ?
|
|
45
|
+
const scrollHook = props.scrollHook ?? (props.windowScroll ? useWindowScroll : useElementScroll);
|
|
49
46
|
const ready = !!wrapperLayout;
|
|
50
47
|
return {
|
|
51
48
|
wrapperRef,
|
|
@@ -57,25 +54,23 @@ function useListProvider(props) {
|
|
|
57
54
|
padding: resolvePadding(props, stylePositioner),
|
|
58
55
|
};
|
|
59
56
|
}
|
|
60
|
-
|
|
57
|
+
export const ListContext = createContext(null);
|
|
61
58
|
/**
|
|
62
59
|
* Returns the nearest `List.Provider` context value.
|
|
63
60
|
* Throws when `required` is `true` (default) and no provider is found; pass `false` to allow optional usage.
|
|
64
61
|
*/
|
|
65
|
-
const useListContext = (required = true) => {
|
|
66
|
-
const ctx =
|
|
62
|
+
export const useListContext = (required = true) => {
|
|
63
|
+
const ctx = useContext(ListContext);
|
|
67
64
|
if (!ctx && required)
|
|
68
65
|
throw new Error('useListContext must be used inside List.Provider');
|
|
69
66
|
return ctx;
|
|
70
67
|
};
|
|
71
|
-
exports.useListContext = useListContext;
|
|
72
68
|
/**
|
|
73
69
|
* Provides layout measurements, resolved styles, scroll state, and positioner config to all List sub-components.
|
|
74
70
|
* Must wrap `List.Wrapper` / `List.Items`; `List` renders this automatically when used as the top-level component.
|
|
75
71
|
*/
|
|
76
|
-
const ListProvider = (props) => {
|
|
72
|
+
export const ListProvider = (props) => {
|
|
77
73
|
const value = useListProvider(props);
|
|
78
|
-
return ((
|
|
74
|
+
return (_jsx(ListContext, { value: value, children: props.children }));
|
|
79
75
|
};
|
|
80
|
-
exports.ListProvider = ListProvider;
|
|
81
76
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/components/List/context.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/components/List/context.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAa,MAAM,EAAE,QAAQ,EAAE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,KAAK,GAAG,CAAC,CAAC,aAAa,CAAA;IAE7B,OAAO;QACL,UAAU;QACV,aAAa;QACb,MAAM,EAAE,MAAsC;QAC9C,KAAK;QACL,UAAU;QACV,KAAK;QACL,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,eAAe,CAAC;KAChD,CAAA;AACH,CAAC;AAID,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAA0B,IAAI,CAAC,CAAA;AAEvE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAQ,GAAC,IAAI,EAAoB,EAAE;IAChE,MAAM,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IACnC,IAAI,CAAC,GAAG,IAAI,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;IACzF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAE,EAAE;IACvD,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IACpC,OAAO,CACL,KAAC,WAAW,IAAC,KAAK,EAAE,KAAK,YACtB,KAAK,CAAC,QAAQ,GACH,CACf,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../../src/components/List/elements.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAQ,SAAS,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,EAAuC,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../../src/components/List/elements.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAQ,SAAS,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,EAAuC,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAGvF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,4BAA4B,SAAS,qDAOhE,CAAA;AAoHD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,QAAQ,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,2DAIrE;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,4BAA4B,SAAS,qDAO/D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,4BAA4B,SAAS,4DAa/D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,+DAK3B,CAAA"}
|