@codeleap/web 7.0.2 → 7.1.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 +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 +18 -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,29 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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");
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { TypeGuards } from '@codeleap/types';
|
|
3
|
+
import { motion } from 'motion/react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useStylesFor } from '../../lib/hooks/useStylesFor';
|
|
6
|
+
import { WebStyleRegistry } from '../../lib/WebStyleRegistry';
|
|
27
7
|
function getVariantElement(registryName, style) {
|
|
28
8
|
const variants = typeof style === 'string'
|
|
29
9
|
? [style]
|
|
@@ -32,29 +12,29 @@ function getVariantElement(registryName, style) {
|
|
|
32
12
|
: [];
|
|
33
13
|
let result;
|
|
34
14
|
for (const variant of variants) {
|
|
35
|
-
const el =
|
|
15
|
+
const el = WebStyleRegistry.current?.variantElementFor(registryName, variant);
|
|
36
16
|
if (el)
|
|
37
17
|
result = el;
|
|
38
18
|
}
|
|
39
19
|
return result;
|
|
40
20
|
}
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
export * from './styles';
|
|
22
|
+
export * from './types';
|
|
43
23
|
/**
|
|
44
24
|
* Pressable text element with debounced click handling, Framer Motion animation
|
|
45
25
|
* support, and style-variant-based element selection.
|
|
46
26
|
* Includes `Text.Span` for inline rendering.
|
|
47
27
|
* Uses: `useStylesFor`, `WebStyleRegistry`
|
|
48
28
|
*/
|
|
49
|
-
const Text = (textProps) => {
|
|
29
|
+
export const Text = (textProps) => {
|
|
50
30
|
const { style, text, children, component, debugName, onPress, debounce, pressDisabled, onClick, animated, animatedProps, getComponent, ref, ...props } = {
|
|
51
|
-
...
|
|
31
|
+
...Text.defaultProps,
|
|
52
32
|
...textProps,
|
|
53
33
|
};
|
|
54
|
-
const styles =
|
|
55
|
-
const defaultElement = getVariantElement(
|
|
56
|
-
const pressedRef =
|
|
57
|
-
const isPressable = (
|
|
34
|
+
const styles = useStylesFor(Text.styleRegistryName, style);
|
|
35
|
+
const defaultElement = getVariantElement(Text.styleRegistryName, style);
|
|
36
|
+
const pressedRef = React.useRef(false);
|
|
37
|
+
const isPressable = (TypeGuards.isFunction(onPress) || TypeGuards.isFunction(onClick)) && !pressDisabled;
|
|
58
38
|
const disabled = isPressable === false;
|
|
59
39
|
const _onPress = (e) => {
|
|
60
40
|
if (disabled)
|
|
@@ -63,7 +43,7 @@ const Text = (textProps) => {
|
|
|
63
43
|
onClick?.(e);
|
|
64
44
|
onPress?.(e);
|
|
65
45
|
};
|
|
66
|
-
if (
|
|
46
|
+
if (TypeGuards.isNumber(debounce)) {
|
|
67
47
|
if (pressedRef.current) {
|
|
68
48
|
return;
|
|
69
49
|
}
|
|
@@ -88,21 +68,20 @@ const Text = (textProps) => {
|
|
|
88
68
|
const Component = getComponent
|
|
89
69
|
? getComponent(textProps, componentProps)
|
|
90
70
|
: animated
|
|
91
|
-
? (
|
|
71
|
+
? (motion?.[(component ?? defaultElement)] || motion.p)
|
|
92
72
|
: (component ?? defaultElement ?? 'p');
|
|
93
|
-
return ((
|
|
73
|
+
return (_jsx(Component, { ...componentProps, ref: ref, css: [styles.text, disabled && styles['text:disabled']], children: text || children }));
|
|
94
74
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return (0, jsx_runtime_1.jsx)(exports.Text, { component: 'span', ...props });
|
|
75
|
+
Text.Span = (props) => {
|
|
76
|
+
return _jsx(Text, { component: 'span', ...props });
|
|
98
77
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return
|
|
78
|
+
Text.styleRegistryName = 'Text';
|
|
79
|
+
Text.elements = ['text'];
|
|
80
|
+
Text.rootElement = 'text';
|
|
81
|
+
Text.withVariantTypes = (styles) => {
|
|
82
|
+
return Text;
|
|
104
83
|
};
|
|
105
|
-
|
|
84
|
+
Text.defaultProps = {
|
|
106
85
|
debugName: 'Text component',
|
|
107
86
|
component: undefined,
|
|
108
87
|
text: null,
|
|
@@ -111,5 +90,5 @@ exports.Text.defaultProps = {
|
|
|
111
90
|
animated: false,
|
|
112
91
|
animatedProps: {},
|
|
113
92
|
};
|
|
114
|
-
|
|
93
|
+
WebStyleRegistry.registerComponent(Text);
|
|
115
94
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Text/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Text/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,KAAkC,MAAM,OAAO,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;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,KAA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MAAM,KAAM,KAAK,GAAI,CAAA;AAC/C,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,IAAuG,CAAA;AAChH,CAAC,CAAA;AAED,IAAI,CAAC,YAAY,GAAG;IAClB,SAAS,EAAE,gBAAgB;IAC3B,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,IAAI;IACd,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,KAAK;IACf,aAAa,EAAE,EAAE;CACI,CAAA;AAEvB,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1,52 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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");
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { onUpdate, useCallback } from '@codeleap/hooks';
|
|
24
4
|
// import { BubbleMenu, FloatingMenu, EditorContent } from '@tiptap/react'
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
5
|
+
import { FileInput, Text, View } from '../components';
|
|
6
|
+
import { useStylesFor } from '../../lib/hooks/useStylesFor';
|
|
7
|
+
import { WebStyleRegistry } from '../../lib/WebStyleRegistry';
|
|
8
|
+
import { useValidate } from '@codeleap/form';
|
|
9
|
+
import { TypeGuards } from '@codeleap/types';
|
|
10
|
+
export * from './styles';
|
|
11
|
+
export * from './types';
|
|
32
12
|
/**
|
|
33
13
|
* 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
14
|
* Renders `null` when no `editor` is provided; validation errors surface as an inline `Text` element below the editor.
|
|
35
15
|
* Uses: `FileInput`, `View`, `Text`
|
|
36
16
|
*/
|
|
37
|
-
const TextEditor = (props) => {
|
|
17
|
+
export const TextEditor = (props) => {
|
|
38
18
|
const { children, editor, style, bubbleMenuProps, floatingMenuProps, toolbarComponent, fileInputRef, validate, } = {
|
|
39
|
-
...
|
|
19
|
+
...TextEditor.defaultProps,
|
|
40
20
|
...props,
|
|
41
21
|
};
|
|
42
|
-
const styles =
|
|
43
|
-
const validation =
|
|
44
|
-
const isDisabled =
|
|
45
|
-
const handleBlur =
|
|
22
|
+
const styles = useStylesFor(TextEditor.styleRegistryName, style);
|
|
23
|
+
const validation = useValidate(editor?.getText() ?? '', validate);
|
|
24
|
+
const isDisabled = TypeGuards.isNil(editor?.isEditable) ? null : !editor.isEditable;
|
|
25
|
+
const handleBlur = React.useCallback(() => {
|
|
46
26
|
validation?.onInputBlurred();
|
|
47
27
|
}, [validation?.onInputBlurred]);
|
|
48
|
-
const handleFocus =
|
|
49
|
-
|
|
28
|
+
const handleFocus = React.useCallback(() => { }, []);
|
|
29
|
+
onUpdate(() => {
|
|
50
30
|
editor?.on('blur', handleBlur);
|
|
51
31
|
editor?.on('focus', handleFocus);
|
|
52
32
|
return () => {
|
|
@@ -54,7 +34,7 @@ const TextEditor = (props) => {
|
|
|
54
34
|
editor?.off('focus', handleFocus);
|
|
55
35
|
};
|
|
56
36
|
}, [editor, handleBlur, handleFocus]);
|
|
57
|
-
const _BubbleMenu =
|
|
37
|
+
const _BubbleMenu = useCallback(() => {
|
|
58
38
|
return null;
|
|
59
39
|
// return (
|
|
60
40
|
// // @ts-expect-error icss type
|
|
@@ -65,7 +45,7 @@ const TextEditor = (props) => {
|
|
|
65
45
|
// </BubbleMenu>
|
|
66
46
|
// )
|
|
67
47
|
}, [editor]);
|
|
68
|
-
const _FloatingMenu =
|
|
48
|
+
const _FloatingMenu = useCallback(() => {
|
|
69
49
|
return null;
|
|
70
50
|
// return (
|
|
71
51
|
// // @ts-expect-error icss type
|
|
@@ -83,17 +63,16 @@ const TextEditor = (props) => {
|
|
|
83
63
|
];
|
|
84
64
|
if (!editor)
|
|
85
65
|
return null;
|
|
86
|
-
return ((
|
|
66
|
+
return (_jsxs(View, { style: [
|
|
87
67
|
styles.wrapper,
|
|
88
68
|
validation?.showError && styles['wrapper:error'],
|
|
89
69
|
{
|
|
90
70
|
'.tiptap': editorStyles,
|
|
91
71
|
},
|
|
92
|
-
], children: [toolbarComponent, children, (
|
|
72
|
+
], children: [toolbarComponent, children, _jsx(_BubbleMenu, {}), _jsx(_FloatingMenu, {}), validation?.showError ? _jsx(Text, { text: validation?.message, style: styles['errorMessage:error'] }) : null, _jsx(FileInput, { ref: fileInputRef })] }));
|
|
93
73
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
exports.TextEditor.elements = [
|
|
74
|
+
TextEditor.styleRegistryName = 'TextEditor';
|
|
75
|
+
TextEditor.elements = [
|
|
97
76
|
'wrapper',
|
|
98
77
|
'editor',
|
|
99
78
|
'floatingMenu',
|
|
@@ -102,10 +81,10 @@ exports.TextEditor.elements = [
|
|
|
102
81
|
'floatingMenuInnerWrapper',
|
|
103
82
|
'errorMessage',
|
|
104
83
|
];
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return
|
|
84
|
+
TextEditor.rootElement = 'wrapper';
|
|
85
|
+
TextEditor.withVariantTypes = (styles) => {
|
|
86
|
+
return TextEditor;
|
|
108
87
|
};
|
|
109
|
-
|
|
110
|
-
|
|
88
|
+
TextEditor.defaultProps = {};
|
|
89
|
+
WebStyleRegistry.registerComponent(TextEditor);
|
|
111
90
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TextEditor/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TextEditor/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACvD,0EAA0E;AAC1E,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB;;;;GAIG;AACH,MAAM,CAAC,MA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AwB;IACxB,0BAA0B;IAC1B,cAAc;CACf,CAAA;AAED,UAAU,CAAC,WAAW,GAAG,SAAS,CAAA;AAElC,UAAU,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IAC/D,OAAO,UAAmF,CAAA;AAC5F,CAAC,CAAA;AAED,UAAU,CAAC,YAAY,GAAG,EAA8B,CAAA;AAExD,gBAAgB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -1,48 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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);
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useId, useImperativeHandle } from 'react';
|
|
3
|
+
import TextareaAutosize from 'react-textarea-autosize';
|
|
4
|
+
import { getTestId } from '../../lib/utils/test';
|
|
5
|
+
import { useStylesFor } from '../../lib/hooks/useStylesFor';
|
|
6
|
+
import { WebStyleRegistry } from '../../lib/WebStyleRegistry';
|
|
7
|
+
import { useTextInput } from './useTextInput';
|
|
8
|
+
import { Field, getFieldIds } from '../Field';
|
|
9
|
+
export * from './types';
|
|
10
|
+
export * from './styles';
|
|
31
11
|
/**
|
|
32
12
|
* 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
13
|
* Renders a plain `<input>` or `TextareaAutosize` depending on the `multiline` prop; pass `ref` to get the underlying `HTMLInputElement`.
|
|
34
14
|
* Uses: `Field.Provider`, `Field.Wrapper`, `Field.Box`, `Field.Heading`, `Field.Helper`, `Field.SectionSlot`, `useTextInput`
|
|
35
15
|
*/
|
|
36
|
-
const TextInput = (props) => {
|
|
16
|
+
export const TextInput = (props) => {
|
|
37
17
|
const allProps = {
|
|
38
|
-
...
|
|
18
|
+
...TextInput.defaultProps,
|
|
39
19
|
...props,
|
|
40
20
|
};
|
|
41
21
|
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 =
|
|
43
|
-
const fieldBaseId =
|
|
44
|
-
const { label: labelId, helper: helperId } =
|
|
45
|
-
const { isMultiline, isFocused: isInputFocused, handleBlur, handleFocus, handleChange, innerInputRef, errorMessage, hasMultipleLines, hasError, inputValue, } =
|
|
22
|
+
const styles = useStylesFor(TextInput.styleRegistryName, style);
|
|
23
|
+
const fieldBaseId = useId();
|
|
24
|
+
const { label: labelId, helper: helperId } = getFieldIds(fieldBaseId);
|
|
25
|
+
const { isMultiline, isFocused: isInputFocused, handleBlur, handleFocus, handleChange, innerInputRef, errorMessage, hasMultipleLines, hasError, inputValue, } = useTextInput({
|
|
46
26
|
multiline,
|
|
47
27
|
onValueChange,
|
|
48
28
|
field,
|
|
@@ -53,11 +33,11 @@ const TextInput = (props) => {
|
|
|
53
33
|
});
|
|
54
34
|
const isFocused = isInputFocused || focused;
|
|
55
35
|
const isDisabled = disabled;
|
|
56
|
-
const InputElement = isMultiline ?
|
|
57
|
-
|
|
36
|
+
const InputElement = isMultiline ? TextareaAutosize : 'input';
|
|
37
|
+
useImperativeHandle(inputRef, () => {
|
|
58
38
|
return innerInputRef?.current;
|
|
59
39
|
}, []);
|
|
60
|
-
const testId =
|
|
40
|
+
const testId = getTestId(allProps);
|
|
61
41
|
const fieldContext = {
|
|
62
42
|
disabled,
|
|
63
43
|
focused: isFocused,
|
|
@@ -65,22 +45,21 @@ const TextInput = (props) => {
|
|
|
65
45
|
error: hasError,
|
|
66
46
|
};
|
|
67
47
|
const _helper = (hasError ? errorMessage : (helper ?? null));
|
|
68
|
-
return (
|
|
48
|
+
return _jsx(Field.Provider, { id: fieldBaseId, context: fieldContext, label: label, helper: _helper, rightSection: rightSection, leftSection: leftSection, wrapperRef: wrapperRef, boxRef: boxRef, componentName: 'text_input', children: _jsxs(Field.Wrapper, { style: styles.wrapper, children: [_jsx(Field.Heading, { style: styles.heading }), _jsxs(Field.Box, { style: styles.box, onPress: onPress, children: [_jsx(Field.SectionSlot, { position: 'left', style: styles.leftSection }), _jsx(InputElement, { disabled: disabled, onBlur: handleBlur, onFocus: handleFocus, "aria-labelledby": label ? labelId : undefined, "aria-describedby": _helper ? helperId : undefined, className: 'text_input__input', css: [
|
|
69
49
|
styles.input,
|
|
70
50
|
isMultiline && styles['input:multiline'],
|
|
71
51
|
isFocused && styles['input:focus'],
|
|
72
52
|
hasError && styles['input:error'],
|
|
73
53
|
isDisabled && styles['input:disabled'],
|
|
74
54
|
hasMultipleLines && styles['input:hasMultipleLines']
|
|
75
|
-
], onChange: handleChange, ref: innerInputRef, value: inputValue, "data-testid": testId, ...textInputProps }), (
|
|
55
|
+
], onChange: handleChange, ref: innerInputRef, value: inputValue, "data-testid": testId, ...textInputProps }), _jsx(Field.SectionSlot, { position: 'right', style: styles.rightSection })] }), _jsx(Field.Helper, { style: styles.helper })] }) });
|
|
76
56
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return exports.TextInput;
|
|
57
|
+
TextInput.styleRegistryName = 'TextInput';
|
|
58
|
+
TextInput.elements = [...Field.elements, 'input', 'placeholder', 'selection'];
|
|
59
|
+
TextInput.rootElement = 'wrapper';
|
|
60
|
+
TextInput.withVariantTypes = (styles) => {
|
|
61
|
+
return TextInput;
|
|
83
62
|
};
|
|
84
|
-
|
|
85
|
-
|
|
63
|
+
TextInput.defaultProps = {};
|
|
64
|
+
WebStyleRegistry.registerComponent(TextInput);
|
|
86
65
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TextInput/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TextInput/index.tsx"],"names":[],"mappings":";AACA,OAAc,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO,gBAAgB,MAAM,yBAAyB,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAG7C,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AAExB;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG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ClC,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC;gCACjC,UAAU,IAAI,MAAM,CAAC,gBAAgB,CAAC;gCACtC,gBAAgB,IAAI,MAAM,CAAC,wBAAwB,CAAC;6BAC9C,EACR,QAAQ,EAAE,YAAY,EACtB,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,UAAU,iBACJ,MAAM,KACf,cAAc,GAClB,EACF,KAAC,KAAK,CAAC,WAAW,IAAC,QAAQ,EAAC,OAAO,EAAC,KAAK,EAAE,MAAM,CAAC,YAAY,GAAG,IACvD,EACZ,KAAC,KAAK,CAAC,MAAM,IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,IACvB,GACD,CAAA;AAEnB,CAAC,CAAA;AAED,SAAS,CAAC,iBAAiB,GAAG,WAAW,CAAA;AACzC,SAAS,CAAC,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,CAAC,CAAA;AAC7E,SAAS,CAAC,WAAW,GAAG,SAAS,CAAA;AAEjC,SAAS,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IAC9D,OAAO,SAAiF,CAAA;AAC1F,CAAC,CAAA;AAED,SAAS,CAAC,YAAY,GAAG,EAEN,CAAA;AAEnB,gBAAgB,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAA"}
|
|
@@ -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"
|
|
49
|
+
value: V | import("nanostores").StoreValue<V extends object ? import("nanostores").MapStore<V> : never>;
|
|
50
50
|
};
|
|
51
|
-
value: V | import("nanostores"
|
|
51
|
+
value: V | import("nanostores").StoreValue<V extends object ? import("nanostores").MapStore<V> : never>;
|
|
52
52
|
setValue: (to: V) => void;
|
|
53
53
|
changed: boolean;
|
|
54
54
|
representation: any;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const types_1 = require("@codeleap/types");
|
|
6
|
-
const Field_1 = require("../Field");
|
|
7
|
-
const form_1 = require("@codeleap/form");
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { TypeGuards } from '@codeleap/types';
|
|
3
|
+
import { useFieldInput } from '../Field';
|
|
4
|
+
import { fields } from '@codeleap/form';
|
|
8
5
|
/**
|
|
9
6
|
* Manages focus state, change handling, and form-field validation wiring for `TextInput`.
|
|
10
7
|
* Bridges the native `onChange` event with both controlled `onValueChange` and `@codeleap/form` field APIs.
|
|
11
8
|
* No provider required; designed to be called only inside `TextInput`.
|
|
12
9
|
*/
|
|
13
|
-
function useTextInput(props) {
|
|
10
|
+
export function useTextInput(props) {
|
|
14
11
|
const { onFocus, onBlur, field, multiline: isMultiline, forceError, value, onValueChange, onChangeText, } = props;
|
|
15
|
-
const [isFocused, setIsFocused] =
|
|
16
|
-
const [secureTextEntry, setSecureTextEntry] =
|
|
12
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
13
|
+
const [secureTextEntry, setSecureTextEntry] = useState(true);
|
|
17
14
|
const toggleSecureTextEntry = () => setSecureTextEntry(s => !s);
|
|
18
|
-
const { fieldHandle, validation, innerInputRef, wrapperRef, onInputValueChange, inputValue, } =
|
|
15
|
+
const { fieldHandle, validation, innerInputRef, wrapperRef, onInputValueChange, inputValue, } = useFieldInput(field, fields.text, { value, onValueChange: onValueChange ?? onChangeText }, {
|
|
19
16
|
revealValue() {
|
|
20
17
|
setSecureTextEntry(false);
|
|
21
18
|
},
|
|
@@ -26,17 +23,17 @@ function useTextInput(props) {
|
|
|
26
23
|
toggleSecureTextEntry();
|
|
27
24
|
},
|
|
28
25
|
}, [setSecureTextEntry]);
|
|
29
|
-
const handleBlur =
|
|
26
|
+
const handleBlur = useCallback((e) => {
|
|
30
27
|
validation?.onInputBlurred?.();
|
|
31
28
|
setIsFocused(false);
|
|
32
29
|
onBlur?.(e);
|
|
33
30
|
}, [validation?.onInputBlurred, onBlur]);
|
|
34
|
-
const handleFocus =
|
|
31
|
+
const handleFocus = useCallback((e) => {
|
|
35
32
|
setIsFocused(true);
|
|
36
33
|
onFocus?.(e);
|
|
37
34
|
}, [onFocus]);
|
|
38
|
-
const handleChange =
|
|
39
|
-
if (
|
|
35
|
+
const handleChange = useCallback((event) => {
|
|
36
|
+
if (TypeGuards.isFunction(onChangeText))
|
|
40
37
|
return onChangeText(event);
|
|
41
38
|
const inputValue = event?.target?.value;
|
|
42
39
|
onInputValueChange(inputValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextInput.js","sourceRoot":"","sources":["../../../src/components/TextInput/useTextInput.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTextInput.js","sourceRoot":"","sources":["../../../src/components/TextInput/useTextInput.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAavC;;;;GAIG;AACH,MAAM,UAAU,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,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEjD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;IAE5D,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,kBAA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