@codeleap/web 7.0.0 → 7.0.2
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 +46 -0
- package/dist/components/ActivityIndicator/index.js.map +1 -0
- package/dist/components/ActivityIndicator/styles.js +3 -0
- package/dist/components/ActivityIndicator/styles.js.map +1 -0
- package/dist/components/ActivityIndicator/types.js +3 -0
- package/dist/components/ActivityIndicator/types.js.map +1 -0
- package/dist/components/Badge/index.js +86 -0
- package/dist/components/Badge/index.js.map +1 -0
- package/dist/components/Badge/styles.js +3 -0
- package/dist/components/Badge/styles.js.map +1 -0
- package/dist/components/Badge/types.js +3 -0
- package/dist/components/Badge/types.js.map +1 -0
- package/dist/components/Button/index.js +69 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Button/styles.js +3 -0
- package/dist/components/Button/styles.js.map +1 -0
- package/dist/components/Button/types.js +3 -0
- package/dist/components/Button/types.js.map +1 -0
- package/dist/components/Calendar/index.js +67 -0
- package/dist/components/Calendar/index.js.map +1 -0
- package/dist/components/Calendar/styles.js +3 -0
- package/dist/components/Calendar/styles.js.map +1 -0
- package/dist/components/Calendar/types.js +3 -0
- package/dist/components/Calendar/types.js.map +1 -0
- package/dist/components/Carousel/index.js +171 -0
- package/dist/components/Carousel/index.js.map +1 -0
- package/dist/components/Carousel/styles.js +3 -0
- package/dist/components/Carousel/styles.js.map +1 -0
- package/dist/components/Carousel/types.js +3 -0
- package/dist/components/Carousel/types.js.map +1 -0
- package/dist/components/Checkbox/index.js +62 -0
- package/dist/components/Checkbox/index.js.map +1 -0
- package/dist/components/Checkbox/styles.js +3 -0
- package/dist/components/Checkbox/styles.js.map +1 -0
- package/dist/components/Checkbox/types.js +3 -0
- package/dist/components/Checkbox/types.js.map +1 -0
- package/dist/components/Collapse/index.js +45 -0
- package/dist/components/Collapse/index.js.map +1 -0
- package/dist/components/Collapse/styles.js +3 -0
- package/dist/components/Collapse/styles.js.map +1 -0
- package/dist/components/Collapse/types.js +3 -0
- package/dist/components/Collapse/types.js.map +1 -0
- package/dist/components/ColorPicker/index.js +83 -0
- package/dist/components/ColorPicker/index.js.map +1 -0
- package/dist/components/ColorPicker/styles.js +3 -0
- package/dist/components/ColorPicker/styles.js.map +1 -0
- package/dist/components/ColorPicker/types.js +3 -0
- package/dist/components/ColorPicker/types.js.map +1 -0
- package/dist/components/CropPicker/hooks.d.ts +2 -2
- package/dist/components/CropPicker/hooks.js +133 -0
- package/dist/components/CropPicker/hooks.js.map +1 -0
- package/dist/components/CropPicker/index.js +56 -0
- package/dist/components/CropPicker/index.js.map +1 -0
- package/dist/components/CropPicker/styles.js +3 -0
- package/dist/components/CropPicker/styles.js.map +1 -0
- package/dist/components/CropPicker/types.js +3 -0
- package/dist/components/CropPicker/types.js.map +1 -0
- package/dist/components/CropPicker/utils.js +76 -0
- package/dist/components/CropPicker/utils.js.map +1 -0
- package/dist/components/DatePicker/index.js +87 -0
- package/dist/components/DatePicker/index.js.map +1 -0
- package/dist/components/DatePicker/styles.js +3 -0
- package/dist/components/DatePicker/styles.js.map +1 -0
- package/dist/components/DatePicker/types.js +3 -0
- package/dist/components/DatePicker/types.js.map +1 -0
- package/dist/components/Drawer/index.js +68 -0
- package/dist/components/Drawer/index.js.map +1 -0
- package/dist/components/Drawer/styles.js +3 -0
- package/dist/components/Drawer/styles.js.map +1 -0
- package/dist/components/Drawer/types.js +3 -0
- package/dist/components/Drawer/types.js.map +1 -0
- package/dist/components/Dropzone/context.js +44 -0
- package/dist/components/Dropzone/context.js.map +1 -0
- package/dist/components/Dropzone/elements.js +57 -0
- package/dist/components/Dropzone/elements.js.map +1 -0
- package/dist/components/Dropzone/index.js +89 -0
- package/dist/components/Dropzone/index.js.map +1 -0
- package/dist/components/Dropzone/styles.js +3 -0
- package/dist/components/Dropzone/styles.js.map +1 -0
- package/dist/components/Dropzone/types.js +3 -0
- package/dist/components/Dropzone/types.js.map +1 -0
- package/dist/components/Dropzone/useDropzone.js +20 -0
- package/dist/components/Dropzone/useDropzone.js.map +1 -0
- package/dist/components/EmptyPlaceholder/index.js +86 -0
- package/dist/components/EmptyPlaceholder/index.js.map +1 -0
- package/dist/components/EmptyPlaceholder/styles.js +3 -0
- package/dist/components/EmptyPlaceholder/styles.js.map +1 -0
- package/dist/components/EmptyPlaceholder/types.js +3 -0
- package/dist/components/EmptyPlaceholder/types.js.map +1 -0
- package/dist/components/Field/context.js +58 -0
- package/dist/components/Field/context.js.map +1 -0
- package/dist/components/Field/elements.js +92 -0
- package/dist/components/Field/elements.js.map +1 -0
- package/dist/components/Field/index.js +55 -0
- package/dist/components/Field/index.js.map +1 -0
- package/dist/components/Field/styles.js +3 -0
- package/dist/components/Field/styles.js.map +1 -0
- package/dist/components/Field/types.js +3 -0
- package/dist/components/Field/types.js.map +1 -0
- package/dist/components/Field/useFieldInput.d.ts +1 -1
- package/dist/components/Field/useFieldInput.js +50 -0
- package/dist/components/Field/useFieldInput.js.map +1 -0
- package/dist/components/FileInput/index.js +73 -0
- package/dist/components/FileInput/index.js.map +1 -0
- package/dist/components/FileInput/types.js +3 -0
- package/dist/components/FileInput/types.js.map +1 -0
- package/dist/components/Icon/index.js +69 -0
- package/dist/components/Icon/index.js.map +1 -0
- package/dist/components/Icon/styles.js +3 -0
- package/dist/components/Icon/styles.js.map +1 -0
- package/dist/components/Icon/types.js +3 -0
- package/dist/components/Icon/types.js.map +1 -0
- package/dist/components/List/context.js +81 -0
- package/dist/components/List/context.js.map +1 -0
- package/dist/components/List/elements.js +164 -0
- package/dist/components/List/elements.js.map +1 -0
- package/dist/components/List/index.js +52 -0
- package/dist/components/List/index.js.map +1 -0
- package/dist/components/List/scroll.js +80 -0
- package/dist/components/List/scroll.js.map +1 -0
- package/dist/components/List/styles.js +3 -0
- package/dist/components/List/styles.js.map +1 -0
- package/dist/components/List/types.js +3 -0
- package/dist/components/List/types.js.map +1 -0
- package/dist/components/LoadingOverlay/index.js +50 -0
- package/dist/components/LoadingOverlay/index.js.map +1 -0
- package/dist/components/LoadingOverlay/styles.js +3 -0
- package/dist/components/LoadingOverlay/styles.js.map +1 -0
- package/dist/components/LoadingOverlay/types.js +3 -0
- package/dist/components/LoadingOverlay/types.js.map +1 -0
- package/dist/components/MaskedTextInput/index.js +52 -0
- package/dist/components/MaskedTextInput/index.js.map +1 -0
- package/dist/components/MaskedTextInput/mask.js +37 -0
- package/dist/components/MaskedTextInput/mask.js.map +1 -0
- package/dist/components/MaskedTextInput/types.js +3 -0
- package/dist/components/MaskedTextInput/types.js.map +1 -0
- package/dist/components/Modal/context.js +41 -0
- package/dist/components/Modal/context.js.map +1 -0
- package/dist/components/Modal/elements.js +74 -0
- package/dist/components/Modal/elements.js.map +1 -0
- package/dist/components/Modal/index.js +52 -0
- package/dist/components/Modal/index.js.map +1 -0
- package/dist/components/Modal/styles.js +3 -0
- package/dist/components/Modal/styles.js.map +1 -0
- package/dist/components/Modal/types.js +3 -0
- package/dist/components/Modal/types.js.map +1 -0
- package/dist/components/NumberIncrement/index.js +83 -0
- package/dist/components/NumberIncrement/index.js.map +1 -0
- package/dist/components/NumberIncrement/styles.js +3 -0
- package/dist/components/NumberIncrement/styles.js.map +1 -0
- package/dist/components/NumberIncrement/types.js +3 -0
- package/dist/components/NumberIncrement/types.js.map +1 -0
- package/dist/components/NumberIncrement/useNumberIncrement.js +116 -0
- package/dist/components/NumberIncrement/useNumberIncrement.js.map +1 -0
- package/dist/components/Overlay/index.js +62 -0
- package/dist/components/Overlay/index.js.map +1 -0
- package/dist/components/Overlay/styles.js +3 -0
- package/dist/components/Overlay/styles.js.map +1 -0
- package/dist/components/Overlay/types.js +3 -0
- package/dist/components/Overlay/types.js.map +1 -0
- package/dist/components/PaginationButtons/index.js +118 -0
- package/dist/components/PaginationButtons/index.js.map +1 -0
- package/dist/components/PaginationButtons/styles.js +3 -0
- package/dist/components/PaginationButtons/styles.js.map +1 -0
- package/dist/components/PaginationButtons/types.js +3 -0
- package/dist/components/PaginationButtons/types.js.map +1 -0
- package/dist/components/PaginationIndicator/index.js +59 -0
- package/dist/components/PaginationIndicator/index.js.map +1 -0
- package/dist/components/PaginationIndicator/styles.js +3 -0
- package/dist/components/PaginationIndicator/styles.js.map +1 -0
- package/dist/components/PaginationIndicator/types.js +3 -0
- package/dist/components/PaginationIndicator/types.js.map +1 -0
- package/dist/components/Progress/Bar/Segmented.js +41 -0
- package/dist/components/Progress/Bar/Segmented.js.map +1 -0
- package/dist/components/Progress/Bar/index.js +62 -0
- package/dist/components/Progress/Bar/index.js.map +1 -0
- package/dist/components/Progress/Bar/styles.js +3 -0
- package/dist/components/Progress/Bar/styles.js.map +1 -0
- package/dist/components/Progress/Bar/types.js +3 -0
- package/dist/components/Progress/Bar/types.js.map +1 -0
- package/dist/components/Progress/Circle/Segmented.js +64 -0
- package/dist/components/Progress/Circle/Segmented.js.map +1 -0
- package/dist/components/Progress/Circle/index.js +83 -0
- package/dist/components/Progress/Circle/index.js.map +1 -0
- package/dist/components/Progress/Circle/styles.js +3 -0
- package/dist/components/Progress/Circle/styles.js.map +1 -0
- package/dist/components/Progress/Circle/types.js +3 -0
- package/dist/components/Progress/Circle/types.js.map +1 -0
- package/dist/components/Progress/index.js +19 -0
- package/dist/components/Progress/index.js.map +1 -0
- package/dist/components/Progress/utils.js +7 -0
- package/dist/components/Progress/utils.js.map +1 -0
- package/dist/components/RadioInput/index.js +68 -0
- package/dist/components/RadioInput/index.js.map +1 -0
- package/dist/components/RadioInput/styles.js +3 -0
- package/dist/components/RadioInput/styles.js.map +1 -0
- package/dist/components/RadioInput/types.js +3 -0
- package/dist/components/RadioInput/types.js.map +1 -0
- package/dist/components/SearchInput/index.js +98 -0
- package/dist/components/SearchInput/index.js.map +1 -0
- package/dist/components/SectionFilters/index.js +166 -0
- package/dist/components/SectionFilters/index.js.map +1 -0
- package/dist/components/SectionFilters/styles.js +3 -0
- package/dist/components/SectionFilters/styles.js.map +1 -0
- package/dist/components/SectionFilters/types.js +3 -0
- package/dist/components/SectionFilters/types.js.map +1 -0
- package/dist/components/Select/context.js +162 -0
- package/dist/components/Select/context.js.map +1 -0
- package/dist/components/Select/elements.js +53 -0
- package/dist/components/Select/elements.js.map +1 -0
- package/dist/components/Select/index.js +70 -0
- package/dist/components/Select/index.js.map +1 -0
- package/dist/components/Select/styles.js +3 -0
- package/dist/components/Select/styles.js.map +1 -0
- package/dist/components/Select/types.js +3 -0
- package/dist/components/Select/types.js.map +1 -0
- package/dist/components/Select/useTriggerWidth.js +30 -0
- package/dist/components/Select/useTriggerWidth.js.map +1 -0
- package/dist/components/Slider/index.js +160 -0
- package/dist/components/Slider/index.js.map +1 -0
- package/dist/components/Slider/styles.js +3 -0
- package/dist/components/Slider/styles.js.map +1 -0
- package/dist/components/Slider/types.js +3 -0
- package/dist/components/Slider/types.js.map +1 -0
- package/dist/components/Switch/index.js +66 -0
- package/dist/components/Switch/index.js.map +1 -0
- package/dist/components/Switch/styles.js +3 -0
- package/dist/components/Switch/styles.js.map +1 -0
- package/dist/components/Switch/types.js +3 -0
- package/dist/components/Switch/types.js.map +1 -0
- package/dist/components/Tag/index.js +74 -0
- package/dist/components/Tag/index.js.map +1 -0
- package/dist/components/Tag/styles.js +3 -0
- package/dist/components/Tag/styles.js.map +1 -0
- package/dist/components/Tag/types.js +3 -0
- package/dist/components/Tag/types.js.map +1 -0
- package/dist/components/Text/index.js +115 -0
- package/dist/components/Text/index.js.map +1 -0
- package/dist/components/Text/styles.js +3 -0
- package/dist/components/Text/styles.js.map +1 -0
- package/dist/components/Text/types.js +3 -0
- package/dist/components/Text/types.js.map +1 -0
- package/dist/components/TextEditor/index.js +111 -0
- package/dist/components/TextEditor/index.js.map +1 -0
- package/dist/components/TextEditor/styles.js +3 -0
- package/dist/components/TextEditor/styles.js.map +1 -0
- package/dist/components/TextEditor/types.js +3 -0
- package/dist/components/TextEditor/types.js.map +1 -0
- package/dist/components/TextInput/index.js +86 -0
- package/dist/components/TextInput/index.js.map +1 -0
- package/dist/components/TextInput/styles.js +3 -0
- package/dist/components/TextInput/styles.js.map +1 -0
- package/dist/components/TextInput/types.js +3 -0
- package/dist/components/TextInput/types.js.map +1 -0
- package/dist/components/TextInput/useTextInput.d.ts +2 -2
- package/dist/components/TextInput/useTextInput.js +67 -0
- package/dist/components/TextInput/useTextInput.js.map +1 -0
- package/dist/components/Tooltip/index.js +115 -0
- package/dist/components/Tooltip/index.js.map +1 -0
- package/dist/components/Tooltip/styles.js +3 -0
- package/dist/components/Tooltip/styles.js.map +1 -0
- package/dist/components/Tooltip/types.js +3 -0
- package/dist/components/Tooltip/types.js.map +1 -0
- package/dist/components/Touchable/index.js +100 -0
- package/dist/components/Touchable/index.js.map +1 -0
- package/dist/components/Touchable/styles.js +3 -0
- package/dist/components/Touchable/styles.js.map +1 -0
- package/dist/components/Touchable/types.js +3 -0
- package/dist/components/Touchable/types.js.map +1 -0
- package/dist/components/View/index.js +56 -0
- package/dist/components/View/index.js.map +1 -0
- package/dist/components/View/styles.js +3 -0
- package/dist/components/View/styles.js.map +1 -0
- package/dist/components/View/types.js +3 -0
- package/dist/components/View/types.js.map +1 -0
- package/dist/components/components.js +58 -0
- package/dist/components/components.js.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/ListMasonry.js +95 -0
- package/dist/lib/ListMasonry.js.map +1 -0
- package/dist/lib/ThemeVariables.js +27 -0
- package/dist/lib/ThemeVariables.js.map +1 -0
- package/dist/lib/WebStyleRegistry.js +73 -0
- package/dist/lib/WebStyleRegistry.js.map +1 -0
- package/dist/lib/hooks/index.js +39 -0
- package/dist/lib/hooks/index.js.map +1 -0
- package/dist/lib/hooks/useAnimatedStyle.js +27 -0
- package/dist/lib/hooks/useAnimatedStyle.js.map +1 -0
- package/dist/lib/hooks/useAnimatedVariantStyles.js +23 -0
- package/dist/lib/hooks/useAnimatedVariantStyles.js.map +1 -0
- package/dist/lib/hooks/useAsyncSelect.js +60 -0
- package/dist/lib/hooks/useAsyncSelect.js.map +1 -0
- package/dist/lib/hooks/useBreakpointMatch.js +111 -0
- package/dist/lib/hooks/useBreakpointMatch.js.map +1 -0
- package/dist/lib/hooks/useClick.js +41 -0
- package/dist/lib/hooks/useClick.js.map +1 -0
- package/dist/lib/hooks/useClickOutside.js +34 -0
- package/dist/lib/hooks/useClickOutside.js.map +1 -0
- package/dist/lib/hooks/useFileInput.js +21 -0
- package/dist/lib/hooks/useFileInput.js.map +1 -0
- package/dist/lib/hooks/useIsomorphicEffect.js +10 -0
- package/dist/lib/hooks/useIsomorphicEffect.js.map +1 -0
- package/dist/lib/hooks/useKeydown.js +43 -0
- package/dist/lib/hooks/useKeydown.js.map +1 -0
- package/dist/lib/hooks/useListFocus.js +49 -0
- package/dist/lib/hooks/useListFocus.js.map +1 -0
- package/dist/lib/hooks/useMediaQuery.js +28 -0
- package/dist/lib/hooks/useMediaQuery.js.map +1 -0
- package/dist/lib/hooks/usePageExitBlocker.js +48 -0
- package/dist/lib/hooks/usePageExitBlocker.js.map +1 -0
- package/dist/lib/hooks/usePagination.js +93 -0
- package/dist/lib/hooks/usePagination.js.map +1 -0
- package/dist/lib/hooks/usePopState.js +35 -0
- package/dist/lib/hooks/usePopState.js.map +1 -0
- package/dist/lib/hooks/usePopoverDismiss.js +35 -0
- package/dist/lib/hooks/usePopoverDismiss.js.map +1 -0
- package/dist/lib/hooks/useRefresh.js +74 -0
- package/dist/lib/hooks/useRefresh.js.map +1 -0
- package/dist/lib/hooks/useScrollEffect.js +22 -0
- package/dist/lib/hooks/useScrollEffect.js.map +1 -0
- package/dist/lib/hooks/useSearchParams.js +51 -0
- package/dist/lib/hooks/useSearchParams.js.map +1 -0
- package/dist/lib/hooks/useStaticAnimationStyles.js +19 -0
- package/dist/lib/hooks/useStaticAnimationStyles.js.map +1 -0
- package/dist/lib/hooks/useStylesFor.js +40 -0
- package/dist/lib/hooks/useStylesFor.js.map +1 -0
- package/dist/lib/hooks/useTouchableEvents.js +37 -0
- package/dist/lib/hooks/useTouchableEvents.js.map +1 -0
- package/dist/lib/hooks/useWindowFocus.js +34 -0
- package/dist/lib/hooks/useWindowFocus.js.map +1 -0
- package/dist/lib/hooks/useWindowSize.js +32 -0
- package/dist/lib/hooks/useWindowSize.js.map +1 -0
- package/dist/lib/index.js +23 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/tools/index.js +20 -0
- package/dist/lib/tools/index.js.map +1 -0
- package/dist/lib/tools/localStorage.js +159 -0
- package/dist/lib/tools/localStorage.js.map +1 -0
- package/dist/lib/tools/mediaQuery.js +38 -0
- package/dist/lib/tools/mediaQuery.js.map +1 -0
- package/dist/lib/tools/modal.js +60 -0
- package/dist/lib/tools/modal.js.map +1 -0
- package/dist/lib/utils/attributes.js +26 -0
- package/dist/lib/utils/attributes.js.map +1 -0
- package/dist/lib/utils/cache.d.ts +2 -2
- package/dist/lib/utils/cache.js +17 -0
- package/dist/lib/utils/cache.js.map +1 -0
- package/dist/lib/utils/index.js +22 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/lib/utils/pollyfils/scroll.js +70 -0
- package/dist/lib/utils/pollyfils/scroll.js.map +1 -0
- package/dist/lib/utils/stopPropagation.js +22 -0
- package/dist/lib/utils/stopPropagation.js.map +1 -0
- package/dist/lib/utils/test.js +18 -0
- package/dist/lib/utils/test.js.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/utility.js +3 -0
- package/dist/types/utility.js.map +1 -0
- package/package.json +18 -18
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/Switch/styles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Switch/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.Tag = void 0;
|
|
21
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
22
|
+
const react_1 = __importDefault(require("react"));
|
|
23
|
+
const types_1 = require("@codeleap/types");
|
|
24
|
+
const Icon_1 = require("../Icon");
|
|
25
|
+
const Text_1 = require("../Text");
|
|
26
|
+
const Touchable_1 = require("../Touchable");
|
|
27
|
+
const View_1 = require("../View");
|
|
28
|
+
const Badge_1 = require("../Badge");
|
|
29
|
+
const useStylesFor_1 = require("../../lib/hooks/useStylesFor");
|
|
30
|
+
const WebStyleRegistry_1 = require("../../lib/WebStyleRegistry");
|
|
31
|
+
const styles_1 = require("@codeleap/styles");
|
|
32
|
+
const lib_1 = require("../../lib");
|
|
33
|
+
__exportStar(require("./styles"), exports);
|
|
34
|
+
__exportStar(require("./types"), exports);
|
|
35
|
+
/**
|
|
36
|
+
* Compact label chip that composes text, icons, badges, and arbitrary slot elements with pressable and disabled state variants.
|
|
37
|
+
* Renders as a `Touchable` (`<button>`) when `onPress` is provided, otherwise as a `View` (`<div>`); `:pressable` and `:disabled` style variants are applied accordingly.
|
|
38
|
+
* Uses: `Touchable`, `Icon`, `Text`, `Badge`
|
|
39
|
+
*/
|
|
40
|
+
const Tag = (props) => {
|
|
41
|
+
const { rightComponent, leftComponent, style, leftIcon, text, textProps, rightIcon, rightIconProps, leftIconProps, leftBadgeProps, leftBadge, rightBadge, rightBadgeProps, children, onPress, disabled, context, ...touchableProps } = {
|
|
42
|
+
...exports.Tag.defaultProps,
|
|
43
|
+
...props,
|
|
44
|
+
};
|
|
45
|
+
const styles = (0, useStylesFor_1.useStylesFor)(exports.Tag.styleRegistryName, style, context);
|
|
46
|
+
const compositionStyles = (0, styles_1.useCompositionStyles)(['rightBadge', 'leftBadge'], styles);
|
|
47
|
+
const isPressable = types_1.TypeGuards.isFunction(onPress);
|
|
48
|
+
const Wrapper = isPressable ? Touchable_1.Touchable : View_1.View;
|
|
49
|
+
const wrapperProps = isPressable ? { onPress, ...touchableProps } : touchableProps;
|
|
50
|
+
const getStylesByKey = (styleKey) => (0, styles_1.mergeStyles)([
|
|
51
|
+
styles?.[styleKey],
|
|
52
|
+
isPressable && styles[`${styleKey}:pressable`],
|
|
53
|
+
disabled && styles[`${styleKey}:disabled`],
|
|
54
|
+
]);
|
|
55
|
+
const wrapperStyles = react_1.default.useMemo(() => getStylesByKey('wrapper'), [styles, disabled, isPressable, style]);
|
|
56
|
+
const textStyles = react_1.default.useMemo(() => getStylesByKey('text'), [styles, disabled, isPressable]);
|
|
57
|
+
const leftIconStyles = react_1.default.useMemo(() => getStylesByKey('leftIcon'), [styles, disabled, isPressable]);
|
|
58
|
+
const rightIconStyles = react_1.default.useMemo(() => getStylesByKey('rightIcon'), [styles, disabled, isPressable]);
|
|
59
|
+
const dataAttrs = (0, lib_1.toDataAttrs)(context);
|
|
60
|
+
return ((0, jsx_runtime_1.jsxs)(Wrapper, { component: isPressable ? 'button' : 'div', disabled: disabled, ...wrapperProps, style: wrapperStyles, className: 'tag__wrapper', ...dataAttrs, children: [leftComponent, leftBadge && ((0, jsx_runtime_1.jsx)(Badge_1.Badge, { debugName: `${touchableProps?.debugName}:leftBadge`, style: compositionStyles.leftBadge, badge: leftBadge, disabled: disabled, className: 'tag__badge tag__left_badge', ...leftBadgeProps })), !types_1.TypeGuards.isNil(leftIcon) && ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { debugName: `${touchableProps?.debugName}:leftIcon`, style: leftIconStyles, icon: leftIcon, className: 'tag__icon tag__left_icon', ...leftIconProps })), types_1.TypeGuards.isString(text) ? (0, jsx_runtime_1.jsx)(Text_1.Text, { text: text, style: textStyles, ...textProps, className: 'tag__text' }) : text, children, !types_1.TypeGuards.isNil(rightIcon) && ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { debugName: `${touchableProps?.debugName}:rightIcon`, style: rightIconStyles, icon: rightIcon, className: 'tag__icon tag__right_icon', ...rightIconProps })), rightBadge && ((0, jsx_runtime_1.jsx)(Badge_1.Badge, { debugName: `${touchableProps?.debugName}:rightBadge`, style: compositionStyles.rightBadge, badge: rightBadge, disabled: disabled, className: 'tag__badge tag__right_badge', ...rightBadgeProps })), rightComponent] }));
|
|
61
|
+
};
|
|
62
|
+
exports.Tag = Tag;
|
|
63
|
+
exports.Tag.styleRegistryName = 'Tag';
|
|
64
|
+
exports.Tag.elements = ['wrapper', 'text', 'leftIcon', 'rightIcon', 'leftBadge', 'rightBadge'];
|
|
65
|
+
exports.Tag.rootElement = 'wrapper';
|
|
66
|
+
exports.Tag.withVariantTypes = (styles) => {
|
|
67
|
+
return exports.Tag;
|
|
68
|
+
};
|
|
69
|
+
exports.Tag.defaultProps = {
|
|
70
|
+
debugName: 'Tag component',
|
|
71
|
+
disabled: false,
|
|
72
|
+
};
|
|
73
|
+
WebStyleRegistry_1.WebStyleRegistry.registerComponent(exports.Tag);
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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,CAAA;AAC9E,CAAC,CAAA;AAED,WAAG,CAAC,YAAY,GAAG;IACjB,SAAS,EAAE,eAAe;IAC1B,QAAQ,EAAE,KAAK;CACK,CAAA;AAEtB,mCAAgB,CAAC,iBAAiB,CAAC,WAAG,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/Tag/styles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Tag/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.Text = void 0;
|
|
21
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
22
|
+
const types_1 = require("@codeleap/types");
|
|
23
|
+
const react_1 = require("motion/react");
|
|
24
|
+
const react_2 = __importDefault(require("react"));
|
|
25
|
+
const useStylesFor_1 = require("../../lib/hooks/useStylesFor");
|
|
26
|
+
const WebStyleRegistry_1 = require("../../lib/WebStyleRegistry");
|
|
27
|
+
function getVariantElement(registryName, style) {
|
|
28
|
+
const variants = typeof style === 'string'
|
|
29
|
+
? [style]
|
|
30
|
+
: Array.isArray(style)
|
|
31
|
+
? style.filter((s) => typeof s === 'string')
|
|
32
|
+
: [];
|
|
33
|
+
let result;
|
|
34
|
+
for (const variant of variants) {
|
|
35
|
+
const el = WebStyleRegistry_1.WebStyleRegistry.current?.variantElementFor(registryName, variant);
|
|
36
|
+
if (el)
|
|
37
|
+
result = el;
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
__exportStar(require("./styles"), exports);
|
|
42
|
+
__exportStar(require("./types"), exports);
|
|
43
|
+
/**
|
|
44
|
+
* Pressable text element with debounced click handling, Framer Motion animation
|
|
45
|
+
* support, and style-variant-based element selection.
|
|
46
|
+
* Includes `Text.Span` for inline rendering.
|
|
47
|
+
* Uses: `useStylesFor`, `WebStyleRegistry`
|
|
48
|
+
*/
|
|
49
|
+
const Text = (textProps) => {
|
|
50
|
+
const { style, text, children, component, debugName, onPress, debounce, pressDisabled, onClick, animated, animatedProps, getComponent, ref, ...props } = {
|
|
51
|
+
...exports.Text.defaultProps,
|
|
52
|
+
...textProps,
|
|
53
|
+
};
|
|
54
|
+
const styles = (0, useStylesFor_1.useStylesFor)(exports.Text.styleRegistryName, style);
|
|
55
|
+
const defaultElement = getVariantElement(exports.Text.styleRegistryName, style);
|
|
56
|
+
const pressedRef = react_2.default.useRef(false);
|
|
57
|
+
const isPressable = (types_1.TypeGuards.isFunction(onPress) || types_1.TypeGuards.isFunction(onClick)) && !pressDisabled;
|
|
58
|
+
const disabled = isPressable === false;
|
|
59
|
+
const _onPress = (e) => {
|
|
60
|
+
if (disabled)
|
|
61
|
+
return;
|
|
62
|
+
const handlePress = () => {
|
|
63
|
+
onClick?.(e);
|
|
64
|
+
onPress?.(e);
|
|
65
|
+
};
|
|
66
|
+
if (types_1.TypeGuards.isNumber(debounce)) {
|
|
67
|
+
if (pressedRef.current) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
pressedRef.current = true;
|
|
71
|
+
handlePress();
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
pressedRef.current = false;
|
|
74
|
+
}, debounce);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
handlePress();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const pressProps = isPressable ? {
|
|
81
|
+
onClick: disabled ? null : _onPress,
|
|
82
|
+
} : {};
|
|
83
|
+
const componentProps = {
|
|
84
|
+
...props,
|
|
85
|
+
...pressProps,
|
|
86
|
+
...animatedProps,
|
|
87
|
+
};
|
|
88
|
+
const Component = getComponent
|
|
89
|
+
? getComponent(textProps, componentProps)
|
|
90
|
+
: animated
|
|
91
|
+
? (react_1.motion?.[(component ?? defaultElement)] || react_1.motion.p)
|
|
92
|
+
: (component ?? defaultElement ?? 'p');
|
|
93
|
+
return ((0, jsx_runtime_1.jsx)(Component, { ...componentProps, ref: ref, css: [styles.text, disabled && styles['text:disabled']], children: text || children }));
|
|
94
|
+
};
|
|
95
|
+
exports.Text = Text;
|
|
96
|
+
exports.Text.Span = (props) => {
|
|
97
|
+
return (0, jsx_runtime_1.jsx)(exports.Text, { component: 'span', ...props });
|
|
98
|
+
};
|
|
99
|
+
exports.Text.styleRegistryName = 'Text';
|
|
100
|
+
exports.Text.elements = ['text'];
|
|
101
|
+
exports.Text.rootElement = 'text';
|
|
102
|
+
exports.Text.withVariantTypes = (styles) => {
|
|
103
|
+
return exports.Text;
|
|
104
|
+
};
|
|
105
|
+
exports.Text.defaultProps = {
|
|
106
|
+
debugName: 'Text component',
|
|
107
|
+
component: undefined,
|
|
108
|
+
text: null,
|
|
109
|
+
debounce: null,
|
|
110
|
+
pressDisabled: false,
|
|
111
|
+
animated: false,
|
|
112
|
+
animatedProps: {},
|
|
113
|
+
};
|
|
114
|
+
WebStyleRegistry_1.WebStyleRegistry.registerComponent(exports.Text);
|
|
115
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Text/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,wCAAqC;AACrC,kDAAsD;AAEtD,+DAA2D;AAC3D,iEAA6D;AAG7D,SAAS,iBAAiB,CAAC,YAAoB,EAAE,KAA0B;IACzE,MAAM,QAAQ,GAAa,OAAO,KAAK,KAAK,QAAQ;QAClD,CAAC,CAAC,CAAC,KAAK,CAAC;QACT,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YACpB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;YACzD,CAAC,CAAC,EAAE,CAAA;IAER,IAAI,MAA+B,CAAA;IACnC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,EAAE,GAAG,mCAAgB,CAAC,OAAO,EAAE,iBAAiB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAC7E,IAAI,EAAE;YAAE,MAAM,GAAG,EAAuB,CAAA;IAC1C,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,2CAAwB;AACxB,0CAAuB;AAEvB;;;;;GAKG;AACI,MAAM,IAAI,GAAG,CAAC,SAAoB,EAAE,EAAE;IAC3C,MAAM,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,aAAa,EACb,OAAO,EACP,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,GAAG,EACH,GAAG,KAAK,EACT,GAAG;QACF,GAAG,YAAI,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C,iBAAiB,CAAC,YAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/Text/styles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Text/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.TextEditor = void 0;
|
|
21
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
22
|
+
const react_1 = __importDefault(require("react"));
|
|
23
|
+
const hooks_1 = require("@codeleap/hooks");
|
|
24
|
+
// import { BubbleMenu, FloatingMenu, EditorContent } from '@tiptap/react'
|
|
25
|
+
const components_1 = require("../components");
|
|
26
|
+
const useStylesFor_1 = require("../../lib/hooks/useStylesFor");
|
|
27
|
+
const WebStyleRegistry_1 = require("../../lib/WebStyleRegistry");
|
|
28
|
+
const form_1 = require("@codeleap/form");
|
|
29
|
+
const types_1 = require("@codeleap/types");
|
|
30
|
+
__exportStar(require("./styles"), exports);
|
|
31
|
+
__exportStar(require("./types"), exports);
|
|
32
|
+
/**
|
|
33
|
+
* Shell for a rich-text editing surface that wraps an external Tiptap editor instance with optional validation, a toolbar slot, and a hidden `FileInput` for media uploads.
|
|
34
|
+
* Renders `null` when no `editor` is provided; validation errors surface as an inline `Text` element below the editor.
|
|
35
|
+
* Uses: `FileInput`, `View`, `Text`
|
|
36
|
+
*/
|
|
37
|
+
const TextEditor = (props) => {
|
|
38
|
+
const { children, editor, style, bubbleMenuProps, floatingMenuProps, toolbarComponent, fileInputRef, validate, } = {
|
|
39
|
+
...exports.TextEditor.defaultProps,
|
|
40
|
+
...props,
|
|
41
|
+
};
|
|
42
|
+
const styles = (0, useStylesFor_1.useStylesFor)(exports.TextEditor.styleRegistryName, style);
|
|
43
|
+
const validation = (0, form_1.useValidate)(editor?.getText() ?? '', validate);
|
|
44
|
+
const isDisabled = types_1.TypeGuards.isNil(editor?.isEditable) ? null : !editor.isEditable;
|
|
45
|
+
const handleBlur = react_1.default.useCallback(() => {
|
|
46
|
+
validation?.onInputBlurred();
|
|
47
|
+
}, [validation?.onInputBlurred]);
|
|
48
|
+
const handleFocus = react_1.default.useCallback(() => { }, []);
|
|
49
|
+
(0, hooks_1.onUpdate)(() => {
|
|
50
|
+
editor?.on('blur', handleBlur);
|
|
51
|
+
editor?.on('focus', handleFocus);
|
|
52
|
+
return () => {
|
|
53
|
+
editor?.off('blur', handleBlur);
|
|
54
|
+
editor?.off('focus', handleFocus);
|
|
55
|
+
};
|
|
56
|
+
}, [editor, handleBlur, handleFocus]);
|
|
57
|
+
const _BubbleMenu = (0, hooks_1.useCallback)(() => {
|
|
58
|
+
return null;
|
|
59
|
+
// return (
|
|
60
|
+
// // @ts-expect-error icss type
|
|
61
|
+
// <BubbleMenu css={[styles.bubbleMenu]} {...bubbleMenuProps} editor={editor}>
|
|
62
|
+
// <View style={styles.bubbleMenuInnerWrapper}>
|
|
63
|
+
// {bubbleMenuProps?.renderContent}
|
|
64
|
+
// </View>
|
|
65
|
+
// </BubbleMenu>
|
|
66
|
+
// )
|
|
67
|
+
}, [editor]);
|
|
68
|
+
const _FloatingMenu = (0, hooks_1.useCallback)(() => {
|
|
69
|
+
return null;
|
|
70
|
+
// return (
|
|
71
|
+
// // @ts-expect-error icss type
|
|
72
|
+
// <FloatingMenu css={[styles.floatingMenu]} {...floatingMenuProps} editor={editor}>
|
|
73
|
+
// <View style={styles.floatingMenuInnerWrapper}>
|
|
74
|
+
// {floatingMenuProps?.renderContent}
|
|
75
|
+
// </View>
|
|
76
|
+
// </FloatingMenu>
|
|
77
|
+
// )
|
|
78
|
+
}, [editor]);
|
|
79
|
+
const editorStyles = [
|
|
80
|
+
styles.editor,
|
|
81
|
+
validation?.showError && styles['editor:error'],
|
|
82
|
+
isDisabled && styles['editor:disabled'],
|
|
83
|
+
];
|
|
84
|
+
if (!editor)
|
|
85
|
+
return null;
|
|
86
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.View, { style: [
|
|
87
|
+
styles.wrapper,
|
|
88
|
+
validation?.showError && styles['wrapper:error'],
|
|
89
|
+
{
|
|
90
|
+
'.tiptap': editorStyles,
|
|
91
|
+
},
|
|
92
|
+
], children: [toolbarComponent, children, (0, jsx_runtime_1.jsx)(_BubbleMenu, {}), (0, jsx_runtime_1.jsx)(_FloatingMenu, {}), validation?.showError ? (0, jsx_runtime_1.jsx)(components_1.Text, { text: validation?.message, style: styles['errorMessage:error'] }) : null, (0, jsx_runtime_1.jsx)(components_1.FileInput, { ref: fileInputRef })] }));
|
|
93
|
+
};
|
|
94
|
+
exports.TextEditor = TextEditor;
|
|
95
|
+
exports.TextEditor.styleRegistryName = 'TextEditor';
|
|
96
|
+
exports.TextEditor.elements = [
|
|
97
|
+
'wrapper',
|
|
98
|
+
'editor',
|
|
99
|
+
'floatingMenu',
|
|
100
|
+
'bubbleMenu',
|
|
101
|
+
'bubbleMenuInnerWrapper',
|
|
102
|
+
'floatingMenuInnerWrapper',
|
|
103
|
+
'errorMessage',
|
|
104
|
+
];
|
|
105
|
+
exports.TextEditor.rootElement = 'wrapper';
|
|
106
|
+
exports.TextEditor.withVariantTypes = (styles) => {
|
|
107
|
+
return exports.TextEditor;
|
|
108
|
+
};
|
|
109
|
+
exports.TextEditor.defaultProps = {};
|
|
110
|
+
WebStyleRegistry_1.WebStyleRegistry.registerComponent(exports.TextEditor);
|
|
111
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TextEditor/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,2CAAuD;AACvD,0EAA0E;AAC1E,8CAAqD;AAErD,+DAA2D;AAC3D,iEAA6D;AAE7D,yCAA4C;AAC5C,2CAA4C;AAE5C,2CAAwB;AACxB,0CAAuB;AAEvB;;;;GAIG;AACI,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;IACnD,MAAM,EACJ,QAAQ,EACR,MAAM,EACN,KAAK,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,QAAQ,GACT,GAAG;QACF,GAAG,kBAAU,CAAC,YAAY;QAC1B,GAAG,KAAK;KACT,CAAA;IAED,MAAM,MAAM,GAAG,IAAA,2BAAY,EAAC,kBAAU,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAA;IAEhE,MAAM,UAAU,GAAG,IAAA,kBAAW,EAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAA;IAEjE,MAAM,UAAU,GAAG,kBAAU,CAAC,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,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
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/TextEditor/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.TextInput = void 0;
|
|
21
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
22
|
+
const react_1 = require("react");
|
|
23
|
+
const react_textarea_autosize_1 = __importDefault(require("react-textarea-autosize"));
|
|
24
|
+
const test_1 = require("../../lib/utils/test");
|
|
25
|
+
const useStylesFor_1 = require("../../lib/hooks/useStylesFor");
|
|
26
|
+
const WebStyleRegistry_1 = require("../../lib/WebStyleRegistry");
|
|
27
|
+
const useTextInput_1 = require("./useTextInput");
|
|
28
|
+
const Field_1 = require("../Field");
|
|
29
|
+
__exportStar(require("./types"), exports);
|
|
30
|
+
__exportStar(require("./styles"), exports);
|
|
31
|
+
/**
|
|
32
|
+
* Single-line (or auto-growing multiline) text field with full `Field` layout support including label, helper text, left/right sections, and validation error display.
|
|
33
|
+
* Renders a plain `<input>` or `TextareaAutosize` depending on the `multiline` prop; pass `ref` to get the underlying `HTMLInputElement`.
|
|
34
|
+
* Uses: `Field.Provider`, `Field.Wrapper`, `Field.Box`, `Field.Heading`, `Field.Helper`, `Field.SectionSlot`, `useTextInput`
|
|
35
|
+
*/
|
|
36
|
+
const TextInput = (props) => {
|
|
37
|
+
const allProps = {
|
|
38
|
+
...exports.TextInput.defaultProps,
|
|
39
|
+
...props,
|
|
40
|
+
};
|
|
41
|
+
const { style, debugName, onPress, focused, ref: inputRef, disabled, label, helper, leftSection, rightSection, wrapperRef, boxRef, multiline, onValueChange, field, onBlur, forceError, value, onChangeText, ...textInputProps } = allProps;
|
|
42
|
+
const styles = (0, useStylesFor_1.useStylesFor)(exports.TextInput.styleRegistryName, style);
|
|
43
|
+
const fieldBaseId = (0, react_1.useId)();
|
|
44
|
+
const { label: labelId, helper: helperId } = (0, Field_1.getFieldIds)(fieldBaseId);
|
|
45
|
+
const { isMultiline, isFocused: isInputFocused, handleBlur, handleFocus, handleChange, innerInputRef, errorMessage, hasMultipleLines, hasError, inputValue, } = (0, useTextInput_1.useTextInput)({
|
|
46
|
+
multiline,
|
|
47
|
+
onValueChange,
|
|
48
|
+
field,
|
|
49
|
+
onBlur,
|
|
50
|
+
forceError,
|
|
51
|
+
value,
|
|
52
|
+
onChangeText,
|
|
53
|
+
});
|
|
54
|
+
const isFocused = isInputFocused || focused;
|
|
55
|
+
const isDisabled = disabled;
|
|
56
|
+
const InputElement = isMultiline ? react_textarea_autosize_1.default : 'input';
|
|
57
|
+
(0, react_1.useImperativeHandle)(inputRef, () => {
|
|
58
|
+
return innerInputRef?.current;
|
|
59
|
+
}, []);
|
|
60
|
+
const testId = (0, test_1.getTestId)(allProps);
|
|
61
|
+
const fieldContext = {
|
|
62
|
+
disabled,
|
|
63
|
+
focused: isFocused,
|
|
64
|
+
hasValue: !!inputValue?.length,
|
|
65
|
+
error: hasError,
|
|
66
|
+
};
|
|
67
|
+
const _helper = (hasError ? errorMessage : (helper ?? null));
|
|
68
|
+
return (0, jsx_runtime_1.jsx)(Field_1.Field.Provider, { id: fieldBaseId, context: fieldContext, label: label, helper: _helper, rightSection: rightSection, leftSection: leftSection, wrapperRef: wrapperRef, boxRef: boxRef, componentName: 'text_input', children: (0, jsx_runtime_1.jsxs)(Field_1.Field.Wrapper, { style: styles.wrapper, children: [(0, jsx_runtime_1.jsx)(Field_1.Field.Heading, { style: styles.heading }), (0, jsx_runtime_1.jsxs)(Field_1.Field.Box, { style: styles.box, onPress: onPress, children: [(0, jsx_runtime_1.jsx)(Field_1.Field.SectionSlot, { position: 'left', style: styles.leftSection }), (0, jsx_runtime_1.jsx)(InputElement, { disabled: disabled, onBlur: handleBlur, onFocus: handleFocus, "aria-labelledby": label ? labelId : undefined, "aria-describedby": _helper ? helperId : undefined, className: 'text_input__input', css: [
|
|
69
|
+
styles.input,
|
|
70
|
+
isMultiline && styles['input:multiline'],
|
|
71
|
+
isFocused && styles['input:focus'],
|
|
72
|
+
hasError && styles['input:error'],
|
|
73
|
+
isDisabled && styles['input:disabled'],
|
|
74
|
+
hasMultipleLines && styles['input:hasMultipleLines']
|
|
75
|
+
], onChange: handleChange, ref: innerInputRef, value: inputValue, "data-testid": testId, ...textInputProps }), (0, jsx_runtime_1.jsx)(Field_1.Field.SectionSlot, { position: 'right', style: styles.rightSection })] }), (0, jsx_runtime_1.jsx)(Field_1.Field.Helper, { style: styles.helper })] }) });
|
|
76
|
+
};
|
|
77
|
+
exports.TextInput = TextInput;
|
|
78
|
+
exports.TextInput.styleRegistryName = 'TextInput';
|
|
79
|
+
exports.TextInput.elements = [...Field_1.Field.elements, 'input', 'placeholder', 'selection'];
|
|
80
|
+
exports.TextInput.rootElement = 'wrapper';
|
|
81
|
+
exports.TextInput.withVariantTypes = (styles) => {
|
|
82
|
+
return exports.TextInput;
|
|
83
|
+
};
|
|
84
|
+
exports.TextInput.defaultProps = {};
|
|
85
|
+
WebStyleRegistry_1.WebStyleRegistry.registerComponent(exports.TextInput);
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TextInput/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,iCAAyD;AACzD,sFAAsD;AAEtD,+CAAgD;AAGhD,+DAA2D;AAC3D,iEAA6D;AAC7D,iDAA6C;AAC7C,oCAA6C;AAG7C,0CAAuB;AACvB,2CAAwB;AAExB;;;;GAIG;AACI,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,EAAE;IACjD,MAAM,QAAQ,GAAG;QACf,GAAG,iBAAS,CAAC,YAAY;QACzB,GAAG,KAAK;KACT,CAAA;IAED,MAAM,EACJ,KAAK,EACL,SAAS,EACT,OAAO,EACP,OAAO,EACP,GAAG,EAAE,QAAQ,EACb,QAAQ,EACR,KAAK,EACL,MAAM,EACN,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EAEN,SAAS,EACT,aAAa,EACb,KAAK,EACL,MAAM,EACN,UAAU,EACV,KAAK,EACL,YAAY,EAEZ,GAAG,cAAc,EAClB,GAAG,QAA0B,CAAA;IAE9B,MAAM,MAAM,GAAG,IAAA,2BAAY,EAAC,iBAAS,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAA;IAE/D,MAAM,WAAW,GAAG,IAAA,aAAK,GAAE,CAAA;IAC3B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,mBAAW,EAAC,WAAW,CAAC,CAAA;IAErE,MAAM,EACJ,WAAW,EACX,SAAS,EAAE,cAAc,EAEzB,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EAEb,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,UAAU,GAEX,GAAG,IAAA,2BAAY,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iBAAiF,CAAA;AAC1F,CAAC,CAAA;AAED,iBAAS,CAAC,YAAY,GAAG,EAEN,CAAA;AAEnB,mCAAgB,CAAC,iBAAiB,CAAC,iBAAS,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/TextInput/styles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/TextInput/types.ts"],"names":[],"mappings":""}
|
|
@@ -46,9 +46,9 @@ export declare function useTextInput(props: Props): {
|
|
|
46
46
|
showError: boolean;
|
|
47
47
|
isUnset: boolean;
|
|
48
48
|
validation: import("@codeleap/form").ValidationResult<any, any>;
|
|
49
|
-
value: V | import("nanostores").StoreValue<V extends object ? import("nanostores").MapStore<V> : never>;
|
|
49
|
+
value: V | import("nanostores", { with: { "resolution-mode": "import" } }).StoreValue<V extends object ? import("nanostores", { with: { "resolution-mode": "import" } }).MapStore<V> : never>;
|
|
50
50
|
};
|
|
51
|
-
value: V | import("nanostores").StoreValue<V extends object ? import("nanostores").MapStore<V> : never>;
|
|
51
|
+
value: V | import("nanostores", { with: { "resolution-mode": "import" } }).StoreValue<V extends object ? import("nanostores", { with: { "resolution-mode": "import" } }).MapStore<V> : never>;
|
|
52
52
|
setValue: (to: V) => void;
|
|
53
53
|
changed: boolean;
|
|
54
54
|
representation: any;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTextInput = useTextInput;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const types_1 = require("@codeleap/types");
|
|
6
|
+
const Field_1 = require("../Field");
|
|
7
|
+
const form_1 = require("@codeleap/form");
|
|
8
|
+
/**
|
|
9
|
+
* Manages focus state, change handling, and form-field validation wiring for `TextInput`.
|
|
10
|
+
* Bridges the native `onChange` event with both controlled `onValueChange` and `@codeleap/form` field APIs.
|
|
11
|
+
* No provider required; designed to be called only inside `TextInput`.
|
|
12
|
+
*/
|
|
13
|
+
function useTextInput(props) {
|
|
14
|
+
const { onFocus, onBlur, field, multiline: isMultiline, forceError, value, onValueChange, onChangeText, } = props;
|
|
15
|
+
const [isFocused, setIsFocused] = (0, react_1.useState)(false);
|
|
16
|
+
const [secureTextEntry, setSecureTextEntry] = (0, react_1.useState)(true);
|
|
17
|
+
const toggleSecureTextEntry = () => setSecureTextEntry(s => !s);
|
|
18
|
+
const { fieldHandle, validation, innerInputRef, wrapperRef, onInputValueChange, inputValue, } = (0, Field_1.useFieldInput)(field, form_1.fields.text, { value, onValueChange: onValueChange ?? onChangeText }, {
|
|
19
|
+
revealValue() {
|
|
20
|
+
setSecureTextEntry(false);
|
|
21
|
+
},
|
|
22
|
+
hideValue() {
|
|
23
|
+
setSecureTextEntry(true);
|
|
24
|
+
},
|
|
25
|
+
toggleValueVisibility() {
|
|
26
|
+
toggleSecureTextEntry();
|
|
27
|
+
},
|
|
28
|
+
}, [setSecureTextEntry]);
|
|
29
|
+
const handleBlur = (0, react_1.useCallback)((e) => {
|
|
30
|
+
validation?.onInputBlurred?.();
|
|
31
|
+
setIsFocused(false);
|
|
32
|
+
onBlur?.(e);
|
|
33
|
+
}, [validation?.onInputBlurred, onBlur]);
|
|
34
|
+
const handleFocus = (0, react_1.useCallback)((e) => {
|
|
35
|
+
setIsFocused(true);
|
|
36
|
+
onFocus?.(e);
|
|
37
|
+
}, [onFocus]);
|
|
38
|
+
const handleChange = (0, react_1.useCallback)((event) => {
|
|
39
|
+
if (types_1.TypeGuards.isFunction(onChangeText))
|
|
40
|
+
return onChangeText(event);
|
|
41
|
+
const inputValue = event?.target?.value;
|
|
42
|
+
onInputValueChange(inputValue);
|
|
43
|
+
}, [onInputValueChange, onChangeText]);
|
|
44
|
+
const rows = (isMultiline ? 2 : undefined);
|
|
45
|
+
const hasMultipleLines = isMultiline && (String(inputValue)?.includes('\n') || !!rows);
|
|
46
|
+
const hasError = validation?.showError || !!forceError;
|
|
47
|
+
const errorMessage = validation?.message || forceError;
|
|
48
|
+
return {
|
|
49
|
+
isMultiline,
|
|
50
|
+
isFocused,
|
|
51
|
+
secureTextEntry,
|
|
52
|
+
handleBlur,
|
|
53
|
+
handleFocus,
|
|
54
|
+
handleChange,
|
|
55
|
+
fieldHandle,
|
|
56
|
+
validation,
|
|
57
|
+
innerInputRef,
|
|
58
|
+
wrapperRef,
|
|
59
|
+
errorMessage,
|
|
60
|
+
toggleSecureTextEntry,
|
|
61
|
+
hasMultipleLines,
|
|
62
|
+
hasError,
|
|
63
|
+
inputValue: inputValue || '',
|
|
64
|
+
onInputValueChange,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=useTextInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTextInput.js","sourceRoot":"","sources":["../../../src/components/TextInput/useTextInput.ts"],"names":[],"mappings":";;AAsBA,oCAqFC;AA3GD,iCAAoD;AAEpD,2CAA4C;AAC5C,oCAAwC;AACxC,yCAAuC;AAavC;;;;GAIG;AACH,SAAgB,YAAY,CAAC,KAAW;IACtC,MAAM,EACJ,OAAO,EACP,MAAM,EACN,KAAK,EACL,SAAS,EAAE,WAAW,EACtB,UAAU,EACV,KAAK,EACL,aAAa,EACb,YAAY,GAEb,GAAG,KAAK,CAAA;IAET,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IAEjD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAA;IAE5D,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IAE/D,MAAM,EACJ,WAAW,EACX,UAAU,EACV,aAAa,EACb,UAAU,E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