@cdx-ui/primitives 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/lib/commonjs/button/context.js +11 -0
- package/lib/commonjs/button/context.js.map +1 -0
- package/lib/commonjs/button/createButtonGroup.js +80 -0
- package/lib/commonjs/button/createButtonGroup.js.map +1 -0
- package/lib/commonjs/button/createButtonIcon.js +18 -0
- package/lib/commonjs/button/createButtonIcon.js.map +1 -0
- package/lib/commonjs/button/createButtonRoot.js +81 -0
- package/lib/commonjs/button/createButtonRoot.js.map +1 -0
- package/lib/commonjs/button/createButtonSpinner.js +34 -0
- package/lib/commonjs/button/createButtonSpinner.js.map +1 -0
- package/lib/commonjs/button/createButtonText.js +38 -0
- package/lib/commonjs/button/createButtonText.js.map +1 -0
- package/lib/commonjs/button/index.js +31 -0
- package/lib/commonjs/button/index.js.map +1 -0
- package/lib/commonjs/button/types.js +6 -0
- package/lib/commonjs/button/types.js.map +1 -0
- package/lib/commonjs/index.js +52 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/input/context.js +11 -0
- package/lib/commonjs/input/context.js.map +1 -0
- package/lib/commonjs/input/createInputField.js +90 -0
- package/lib/commonjs/input/createInputField.js.map +1 -0
- package/lib/commonjs/input/createInputIcon.js +20 -0
- package/lib/commonjs/input/createInputIcon.js.map +1 -0
- package/lib/commonjs/input/createInputRoot.js +82 -0
- package/lib/commonjs/input/createInputRoot.js.map +1 -0
- package/lib/commonjs/input/createInputSlot.js +44 -0
- package/lib/commonjs/input/createInputSlot.js.map +1 -0
- package/lib/commonjs/input/index.js +28 -0
- package/lib/commonjs/input/index.js.map +1 -0
- package/lib/commonjs/input/types.js +6 -0
- package/lib/commonjs/input/types.js.map +1 -0
- package/lib/commonjs/overlay/OverlayContainer.js +67 -0
- package/lib/commonjs/overlay/OverlayContainer.js.map +1 -0
- package/lib/commonjs/overlay/index.js +40 -0
- package/lib/commonjs/overlay/index.js.map +1 -0
- package/lib/commonjs/overlay/useAnchorPosition.js +68 -0
- package/lib/commonjs/overlay/useAnchorPosition.js.map +1 -0
- package/lib/commonjs/overlay/useDismissOverlay.js +14 -0
- package/lib/commonjs/overlay/useDismissOverlay.js.map +1 -0
- package/lib/commonjs/overlay/useDismissOverlay.web.js +46 -0
- package/lib/commonjs/overlay/useDismissOverlay.web.js.map +1 -0
- package/lib/commonjs/overlay/useOverlayPosition.js +93 -0
- package/lib/commonjs/overlay/useOverlayPosition.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/select/context.js +63 -0
- package/lib/commonjs/select/context.js.map +1 -0
- package/lib/commonjs/select/createSelectContent.js +102 -0
- package/lib/commonjs/select/createSelectContent.js.map +1 -0
- package/lib/commonjs/select/createSelectIcon.js +41 -0
- package/lib/commonjs/select/createSelectIcon.js.map +1 -0
- package/lib/commonjs/select/createSelectItem.js +101 -0
- package/lib/commonjs/select/createSelectItem.js.map +1 -0
- package/lib/commonjs/select/createSelectItemLabel.js +41 -0
- package/lib/commonjs/select/createSelectItemLabel.js.map +1 -0
- package/lib/commonjs/select/createSelectRoot.js +99 -0
- package/lib/commonjs/select/createSelectRoot.js.map +1 -0
- package/lib/commonjs/select/createSelectTrigger.js +138 -0
- package/lib/commonjs/select/createSelectTrigger.js.map +1 -0
- package/lib/commonjs/select/createSelectValue.js +53 -0
- package/lib/commonjs/select/createSelectValue.js.map +1 -0
- package/lib/commonjs/select/index.js +38 -0
- package/lib/commonjs/select/index.js.map +1 -0
- package/lib/commonjs/select/types.js +6 -0
- package/lib/commonjs/select/types.js.map +1 -0
- package/lib/commonjs/select/useContentFocus.js +47 -0
- package/lib/commonjs/select/useContentFocus.js.map +1 -0
- package/lib/commonjs/select/useListboxNavigation.js +83 -0
- package/lib/commonjs/select/useListboxNavigation.js.map +1 -0
- package/lib/commonjs/uniwind.d.js +2 -0
- package/lib/commonjs/uniwind.d.js.map +1 -0
- package/lib/commonjs/utils/dataAttributes.js +32 -0
- package/lib/commonjs/utils/dataAttributes.js.map +1 -0
- package/lib/commonjs/utils/dataAttributes.web.js +31 -0
- package/lib/commonjs/utils/dataAttributes.web.js.map +1 -0
- package/lib/module/button/context.js +5 -0
- package/lib/module/button/context.js.map +1 -0
- package/lib/module/button/createButtonGroup.js +74 -0
- package/lib/module/button/createButtonGroup.js.map +1 -0
- package/lib/module/button/createButtonIcon.js +13 -0
- package/lib/module/button/createButtonIcon.js.map +1 -0
- package/lib/module/button/createButtonRoot.js +76 -0
- package/lib/module/button/createButtonRoot.js.map +1 -0
- package/lib/module/button/createButtonSpinner.js +29 -0
- package/lib/module/button/createButtonSpinner.js.map +1 -0
- package/lib/module/button/createButtonText.js +33 -0
- package/lib/module/button/createButtonText.js.map +1 -0
- package/lib/module/button/index.js +27 -0
- package/lib/module/button/index.js.map +1 -0
- package/lib/module/button/types.js +4 -0
- package/lib/module/button/types.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/input/context.js +5 -0
- package/lib/module/input/context.js.map +1 -0
- package/lib/module/input/createInputField.js +85 -0
- package/lib/module/input/createInputField.js.map +1 -0
- package/lib/module/input/createInputIcon.js +15 -0
- package/lib/module/input/createInputIcon.js.map +1 -0
- package/lib/module/input/createInputRoot.js +76 -0
- package/lib/module/input/createInputRoot.js.map +1 -0
- package/lib/module/input/createInputSlot.js +39 -0
- package/lib/module/input/createInputSlot.js.map +1 -0
- package/lib/module/input/index.js +23 -0
- package/lib/module/input/index.js.map +1 -0
- package/lib/module/input/types.js +4 -0
- package/lib/module/input/types.js.map +1 -0
- package/lib/module/overlay/OverlayContainer.js +62 -0
- package/lib/module/overlay/OverlayContainer.js.map +1 -0
- package/lib/module/overlay/index.js +7 -0
- package/lib/module/overlay/index.js.map +1 -0
- package/lib/module/overlay/useAnchorPosition.js +64 -0
- package/lib/module/overlay/useAnchorPosition.js.map +1 -0
- package/lib/module/overlay/useDismissOverlay.js +10 -0
- package/lib/module/overlay/useDismissOverlay.js.map +1 -0
- package/lib/module/overlay/useDismissOverlay.web.js +43 -0
- package/lib/module/overlay/useDismissOverlay.web.js.map +1 -0
- package/lib/module/overlay/useOverlayPosition.js +88 -0
- package/lib/module/overlay/useOverlayPosition.js.map +1 -0
- package/lib/module/select/context.js +56 -0
- package/lib/module/select/context.js.map +1 -0
- package/lib/module/select/createSelectContent.js +97 -0
- package/lib/module/select/createSelectContent.js.map +1 -0
- package/lib/module/select/createSelectIcon.js +36 -0
- package/lib/module/select/createSelectIcon.js.map +1 -0
- package/lib/module/select/createSelectItem.js +96 -0
- package/lib/module/select/createSelectItem.js.map +1 -0
- package/lib/module/select/createSelectItemLabel.js +36 -0
- package/lib/module/select/createSelectItemLabel.js.map +1 -0
- package/lib/module/select/createSelectRoot.js +94 -0
- package/lib/module/select/createSelectRoot.js.map +1 -0
- package/lib/module/select/createSelectTrigger.js +133 -0
- package/lib/module/select/createSelectTrigger.js.map +1 -0
- package/lib/module/select/createSelectValue.js +48 -0
- package/lib/module/select/createSelectValue.js.map +1 -0
- package/lib/module/select/index.js +34 -0
- package/lib/module/select/index.js.map +1 -0
- package/lib/module/select/types.js +4 -0
- package/lib/module/select/types.js.map +1 -0
- package/lib/module/select/useContentFocus.js +44 -0
- package/lib/module/select/useContentFocus.js.map +1 -0
- package/lib/module/select/useListboxNavigation.js +80 -0
- package/lib/module/select/useListboxNavigation.js.map +1 -0
- package/lib/module/uniwind.d.js +2 -0
- package/lib/module/uniwind.d.js.map +1 -0
- package/lib/module/utils/dataAttributes.js +28 -0
- package/lib/module/utils/dataAttributes.js.map +1 -0
- package/lib/module/utils/dataAttributes.web.js +27 -0
- package/lib/module/utils/dataAttributes.web.js.map +1 -0
- package/lib/typescript/button/context.d.ts +6 -0
- package/lib/typescript/button/context.d.ts.map +1 -0
- package/lib/typescript/button/createButtonGroup.d.ts +4 -0
- package/lib/typescript/button/createButtonGroup.d.ts.map +1 -0
- package/lib/typescript/button/createButtonIcon.d.ts +2 -0
- package/lib/typescript/button/createButtonIcon.d.ts.map +1 -0
- package/lib/typescript/button/createButtonRoot.d.ts +6 -0
- package/lib/typescript/button/createButtonRoot.d.ts.map +1 -0
- package/lib/typescript/button/createButtonSpinner.d.ts +4 -0
- package/lib/typescript/button/createButtonSpinner.d.ts.map +1 -0
- package/lib/typescript/button/createButtonText.d.ts +4 -0
- package/lib/typescript/button/createButtonText.d.ts.map +1 -0
- package/lib/typescript/button/index.d.ts +11 -0
- package/lib/typescript/button/index.d.ts.map +1 -0
- package/lib/typescript/button/types.d.ts +65 -0
- package/lib/typescript/button/types.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/input/context.d.ts +6 -0
- package/lib/typescript/input/context.d.ts.map +1 -0
- package/lib/typescript/input/createInputField.d.ts +4 -0
- package/lib/typescript/input/createInputField.d.ts.map +1 -0
- package/lib/typescript/input/createInputIcon.d.ts +4 -0
- package/lib/typescript/input/createInputIcon.d.ts.map +1 -0
- package/lib/typescript/input/createInputRoot.d.ts +4 -0
- package/lib/typescript/input/createInputRoot.d.ts.map +1 -0
- package/lib/typescript/input/createInputSlot.d.ts +4 -0
- package/lib/typescript/input/createInputSlot.d.ts.map +1 -0
- package/lib/typescript/input/index.d.ts +9 -0
- package/lib/typescript/input/index.d.ts.map +1 -0
- package/lib/typescript/input/types.d.ts +91 -0
- package/lib/typescript/input/types.d.ts.map +1 -0
- package/lib/typescript/overlay/OverlayContainer.d.ts +23 -0
- package/lib/typescript/overlay/OverlayContainer.d.ts.map +1 -0
- package/lib/typescript/overlay/index.d.ts +6 -0
- package/lib/typescript/overlay/index.d.ts.map +1 -0
- package/lib/typescript/overlay/useAnchorPosition.d.ts +15 -0
- package/lib/typescript/overlay/useAnchorPosition.d.ts.map +1 -0
- package/lib/typescript/overlay/useDismissOverlay.d.ts +7 -0
- package/lib/typescript/overlay/useDismissOverlay.d.ts.map +1 -0
- package/lib/typescript/overlay/useDismissOverlay.web.d.ts +8 -0
- package/lib/typescript/overlay/useDismissOverlay.web.d.ts.map +1 -0
- package/lib/typescript/overlay/useOverlayPosition.d.ts +45 -0
- package/lib/typescript/overlay/useOverlayPosition.d.ts.map +1 -0
- package/lib/typescript/select/context.d.ts +17 -0
- package/lib/typescript/select/context.d.ts.map +1 -0
- package/lib/typescript/select/createSelectContent.d.ts +4 -0
- package/lib/typescript/select/createSelectContent.d.ts.map +1 -0
- package/lib/typescript/select/createSelectIcon.d.ts +2 -0
- package/lib/typescript/select/createSelectIcon.d.ts.map +1 -0
- package/lib/typescript/select/createSelectItem.d.ts +6 -0
- package/lib/typescript/select/createSelectItem.d.ts.map +1 -0
- package/lib/typescript/select/createSelectItemLabel.d.ts +4 -0
- package/lib/typescript/select/createSelectItemLabel.d.ts.map +1 -0
- package/lib/typescript/select/createSelectRoot.d.ts +4 -0
- package/lib/typescript/select/createSelectRoot.d.ts.map +1 -0
- package/lib/typescript/select/createSelectTrigger.d.ts +12 -0
- package/lib/typescript/select/createSelectTrigger.d.ts.map +1 -0
- package/lib/typescript/select/createSelectValue.d.ts +4 -0
- package/lib/typescript/select/createSelectValue.d.ts.map +1 -0
- package/lib/typescript/select/index.d.ts +13 -0
- package/lib/typescript/select/index.d.ts.map +1 -0
- package/lib/typescript/select/types.d.ts +96 -0
- package/lib/typescript/select/types.d.ts.map +1 -0
- package/lib/typescript/select/useContentFocus.d.ts +19 -0
- package/lib/typescript/select/useContentFocus.d.ts.map +1 -0
- package/lib/typescript/select/useListboxNavigation.d.ts +13 -0
- package/lib/typescript/select/useListboxNavigation.d.ts.map +1 -0
- package/lib/typescript/utils/dataAttributes.d.ts +14 -0
- package/lib/typescript/utils/dataAttributes.d.ts.map +1 -0
- package/lib/typescript/utils/dataAttributes.web.d.ts +16 -0
- package/lib/typescript/utils/dataAttributes.web.d.ts.map +1 -0
- package/package.json +78 -0
- package/src/button/context.tsx +4 -0
- package/src/button/createButtonGroup.tsx +88 -0
- package/src/button/createButtonIcon.tsx +8 -0
- package/src/button/createButtonRoot.tsx +101 -0
- package/src/button/createButtonSpinner.tsx +20 -0
- package/src/button/createButtonText.tsx +22 -0
- package/src/button/index.tsx +53 -0
- package/src/button/types.ts +85 -0
- package/src/index.ts +4 -0
- package/src/input/context.tsx +4 -0
- package/src/input/createInputField.tsx +104 -0
- package/src/input/createInputIcon.tsx +12 -0
- package/src/input/createInputRoot.tsx +92 -0
- package/src/input/createInputSlot.tsx +39 -0
- package/src/input/index.tsx +51 -0
- package/src/input/types.ts +113 -0
- package/src/overlay/OverlayContainer.tsx +77 -0
- package/src/overlay/index.ts +10 -0
- package/src/overlay/useAnchorPosition.ts +72 -0
- package/src/overlay/useDismissOverlay.ts +14 -0
- package/src/overlay/useDismissOverlay.web.ts +51 -0
- package/src/overlay/useOverlayPosition.ts +96 -0
- package/src/select/context.tsx +56 -0
- package/src/select/createSelectContent.tsx +115 -0
- package/src/select/createSelectIcon.tsx +27 -0
- package/src/select/createSelectItem.tsx +121 -0
- package/src/select/createSelectItemLabel.tsx +30 -0
- package/src/select/createSelectRoot.tsx +130 -0
- package/src/select/createSelectTrigger.tsx +192 -0
- package/src/select/createSelectValue.tsx +38 -0
- package/src/select/index.tsx +73 -0
- package/src/select/types.ts +131 -0
- package/src/select/useContentFocus.ts +54 -0
- package/src/select/useListboxNavigation.ts +85 -0
- package/src/uniwind.d.ts +3 -0
- package/src/utils/dataAttributes.ts +28 -0
- package/src/utils/dataAttributes.web.ts +26 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useMemo } from 'react';
|
|
4
|
+
import { Platform } from 'react-native';
|
|
5
|
+
import { mergeRefs, useFormControl } from '@cdx-ui/utils';
|
|
6
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
7
|
+
import { useInputContext } from './context';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
export const createInputField = BaseInputField => /*#__PURE__*/forwardRef(({
|
|
10
|
+
children,
|
|
11
|
+
onKeyPress,
|
|
12
|
+
type = 'text',
|
|
13
|
+
'aria-label': ariaLabel = 'Input Field',
|
|
14
|
+
secureTextEntry,
|
|
15
|
+
editable,
|
|
16
|
+
disabled,
|
|
17
|
+
...props
|
|
18
|
+
}, ref) => {
|
|
19
|
+
const {
|
|
20
|
+
isDisabled,
|
|
21
|
+
isReadOnly,
|
|
22
|
+
isFocused,
|
|
23
|
+
isInvalid,
|
|
24
|
+
setIsFocused,
|
|
25
|
+
isHovered,
|
|
26
|
+
isFocusVisible,
|
|
27
|
+
inputFieldRef,
|
|
28
|
+
isRequired
|
|
29
|
+
} = useInputContext();
|
|
30
|
+
const inputProps = useFormControl({
|
|
31
|
+
isDisabled: props.isDisabled || disabled,
|
|
32
|
+
isInvalid: props.isInvalid,
|
|
33
|
+
isReadOnly: props.isReadOnly,
|
|
34
|
+
isRequired: props.isRequired,
|
|
35
|
+
id: props.id
|
|
36
|
+
});
|
|
37
|
+
const handleFocus = (focusState, callback) => {
|
|
38
|
+
setIsFocused(focusState);
|
|
39
|
+
callback();
|
|
40
|
+
};
|
|
41
|
+
const mergedRef = mergeRefs(ref, inputFieldRef);
|
|
42
|
+
const isEffectivelyDisabled = isDisabled || inputProps.disabled;
|
|
43
|
+
const editableProp = useMemo(() => {
|
|
44
|
+
if (editable !== undefined) {
|
|
45
|
+
return editable;
|
|
46
|
+
}
|
|
47
|
+
return !(isDisabled || inputProps.disabled || isReadOnly);
|
|
48
|
+
}, [isDisabled, inputProps.disabled, isReadOnly, editable]);
|
|
49
|
+
return /*#__PURE__*/_jsx(BaseInputField, {
|
|
50
|
+
...props,
|
|
51
|
+
type: type,
|
|
52
|
+
...dataAttributes({
|
|
53
|
+
focus: isFocused,
|
|
54
|
+
invalid: isInvalid,
|
|
55
|
+
readonly: isReadOnly,
|
|
56
|
+
required: isRequired,
|
|
57
|
+
hover: isHovered,
|
|
58
|
+
focusVisible: isFocusVisible,
|
|
59
|
+
disabled: isEffectivelyDisabled
|
|
60
|
+
}),
|
|
61
|
+
disabled: isEffectivelyDisabled,
|
|
62
|
+
secureTextEntry: secureTextEntry || type === 'password',
|
|
63
|
+
accessible: true,
|
|
64
|
+
"aria-label": ariaLabel,
|
|
65
|
+
"aria-required": isRequired || inputProps.required,
|
|
66
|
+
"aria-invalid": isInvalid || inputProps['aria-invalid'],
|
|
67
|
+
"aria-disabled": isEffectivelyDisabled,
|
|
68
|
+
"aria-selected": Platform.OS !== 'web' ? isFocused : undefined,
|
|
69
|
+
accessibilityElementsHidden: isEffectivelyDisabled,
|
|
70
|
+
readOnly: !editableProp,
|
|
71
|
+
onKeyPress: e => {
|
|
72
|
+
e.persist();
|
|
73
|
+
onKeyPress?.(e);
|
|
74
|
+
},
|
|
75
|
+
onFocus: e => {
|
|
76
|
+
handleFocus(true, () => props?.onFocus?.(e));
|
|
77
|
+
},
|
|
78
|
+
onBlur: e => {
|
|
79
|
+
handleFocus(false, () => props?.onBlur?.(e));
|
|
80
|
+
},
|
|
81
|
+
ref: mergedRef,
|
|
82
|
+
children: children
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=createInputField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useMemo","Platform","mergeRefs","useFormControl","dataAttributes","useInputContext","jsx","_jsx","createInputField","BaseInputField","children","onKeyPress","type","ariaLabel","secureTextEntry","editable","disabled","props","ref","isDisabled","isReadOnly","isFocused","isInvalid","setIsFocused","isHovered","isFocusVisible","inputFieldRef","isRequired","inputProps","id","handleFocus","focusState","callback","mergedRef","isEffectivelyDisabled","editableProp","undefined","focus","invalid","readonly","required","hover","focusVisible","accessible","OS","accessibilityElementsHidden","readOnly","e","persist","onFocus","onBlur"],"sourceRoot":"../../../src","sources":["input/createInputField.tsx"],"mappings":";;AACA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,SAGEC,QAAQ,QAEH,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A;EAAQ,CACK,CAAC;AAErB,CACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export const createInputIcon = BaseInputIcon => /*#__PURE__*/forwardRef(({
|
|
6
|
+
children,
|
|
7
|
+
...props
|
|
8
|
+
}, ref) => {
|
|
9
|
+
return /*#__PURE__*/_jsx(BaseInputIcon, {
|
|
10
|
+
ref: ref,
|
|
11
|
+
...props,
|
|
12
|
+
children: children
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=createInputIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","jsx","_jsx","createInputIcon","BaseInputIcon","children","props","ref"],"sourceRoot":"../../../src","sources":["input/createInputIcon.tsx"],"mappings":";;AACA,SAASA,UAAU,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGnC,OAAO,MAAMC,eAAe,GAAQC,aAAqC,iBACvEJ,UAAU,CAA2B,CAAC;EAAEK,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EACpE,oBACEL,IAAA,CAACE,aAAa;IAACG,GAAG,EAAEA,GAAI;IAAA,GAAMD,KAAK;IAAAD,QAAA,EAChCA;EAAQ,CACI,CAAC;AAEpB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
4
|
+
import { mergeRefs, useFormControlContext } from '@cdx-ui/utils';
|
|
5
|
+
import { useFocusRing } from '@react-native-aria/focus';
|
|
6
|
+
import { useHover } from '@react-native-aria/interactions';
|
|
7
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
8
|
+
import { InputProvider } from './context';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
// TODO: Does this need useControllableState?
|
|
11
|
+
|
|
12
|
+
export const createInputRoot = BaseInput => /*#__PURE__*/forwardRef(({
|
|
13
|
+
children,
|
|
14
|
+
isReadOnly,
|
|
15
|
+
isDisabled,
|
|
16
|
+
isInvalid,
|
|
17
|
+
isRequired,
|
|
18
|
+
isHovered: isHoveredProp,
|
|
19
|
+
isFocused: isFocusedProp,
|
|
20
|
+
isFocusVisible: isFocusVisibleProp,
|
|
21
|
+
...props
|
|
22
|
+
}, ref) => {
|
|
23
|
+
const inputRef = React.useRef(null);
|
|
24
|
+
const inputFieldRef = React.useRef(null);
|
|
25
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
26
|
+
const handleFocus = useCallback((focusState, callback) => {
|
|
27
|
+
setIsFocused(focusState);
|
|
28
|
+
callback();
|
|
29
|
+
}, []);
|
|
30
|
+
const inputProps = useFormControlContext();
|
|
31
|
+
const {
|
|
32
|
+
isHovered
|
|
33
|
+
} = useHover({}, inputRef);
|
|
34
|
+
const {
|
|
35
|
+
isFocusVisible
|
|
36
|
+
} = useFocusRing();
|
|
37
|
+
const resolvedDisabled = isDisabled || inputProps.isDisabled;
|
|
38
|
+
const resolvedInvalid = isInvalid || inputProps.isInvalid;
|
|
39
|
+
const resolvedReadOnly = isReadOnly || inputProps.isReadOnly;
|
|
40
|
+
const resolvedRequired = isRequired || inputProps.isRequired;
|
|
41
|
+
const resolvedHovered = isHoveredProp || isHovered;
|
|
42
|
+
const resolvedFocused = isFocusedProp || isFocused;
|
|
43
|
+
const resolvedFocusVisible = isFocusVisibleProp || isFocusVisible;
|
|
44
|
+
const contextValue = useMemo(() => ({
|
|
45
|
+
isDisabled: resolvedDisabled,
|
|
46
|
+
isInvalid: resolvedInvalid,
|
|
47
|
+
isHovered: resolvedHovered,
|
|
48
|
+
isFocused: resolvedFocused,
|
|
49
|
+
isFocusVisible: resolvedFocusVisible,
|
|
50
|
+
isReadOnly: resolvedReadOnly,
|
|
51
|
+
isRequired: resolvedRequired,
|
|
52
|
+
inputRef,
|
|
53
|
+
handleFocus,
|
|
54
|
+
setIsFocused,
|
|
55
|
+
inputFieldRef
|
|
56
|
+
}), [resolvedDisabled, resolvedInvalid, resolvedHovered, resolvedFocused, resolvedFocusVisible, resolvedReadOnly, resolvedRequired, handleFocus]);
|
|
57
|
+
return /*#__PURE__*/_jsx(BaseInput, {
|
|
58
|
+
...dataAttributes({
|
|
59
|
+
hover: resolvedHovered,
|
|
60
|
+
focus: resolvedFocused,
|
|
61
|
+
disabled: resolvedDisabled,
|
|
62
|
+
invalid: resolvedInvalid,
|
|
63
|
+
readonly: resolvedReadOnly,
|
|
64
|
+
required: resolvedRequired,
|
|
65
|
+
focusVisible: resolvedFocusVisible
|
|
66
|
+
}),
|
|
67
|
+
...props,
|
|
68
|
+
ref: mergeRefs(inputRef, ref) // TODO: Somehow utils and primitives package are resolving to different versions of react (@types/react?)
|
|
69
|
+
,
|
|
70
|
+
children: /*#__PURE__*/_jsx(InputProvider, {
|
|
71
|
+
value: contextValue,
|
|
72
|
+
children: children
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=createInputRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useCallback","useMemo","mergeRefs","useFormControlContext","useFocusRing","useHover","dataAttributes","InputProvider","jsx","_jsx","createInputRoot","BaseInput","children","isReadOnly","isDisabled","isInvalid","isRequired","isHovered","isHoveredProp","isFocused","isFocusedProp","isFocusVisible","isFocusVisibleProp","props","ref","inputRef","useRef","inputFieldRef","setIsFocused","useState","handleFocus","focusState","callback","inputProps","resolvedDisabled","resolvedInvalid","resolvedReadOnly","resolvedRequired","resolvedHovered","resolvedFocused","resolvedFocusVisible","contextValue","hover","focus","disabled","invalid","readonly","required","focusVisible","value"],"sourceRoot":"../../../src","sources":["input/createInputRoot.tsx"],"mappings":";;AAA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AAC;AAEhB,CACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { useFormControl } from '@cdx-ui/utils';
|
|
5
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
6
|
+
import { useInputContext } from './context';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export const createInputSlot = BaseInputSlot => /*#__PURE__*/forwardRef(({
|
|
9
|
+
children,
|
|
10
|
+
onPress,
|
|
11
|
+
focusOnPress = true,
|
|
12
|
+
...props
|
|
13
|
+
}, ref) => {
|
|
14
|
+
const {
|
|
15
|
+
inputFieldRef,
|
|
16
|
+
isDisabled
|
|
17
|
+
} = useInputContext();
|
|
18
|
+
const handleFocus = () => {
|
|
19
|
+
focusOnPress && inputFieldRef.current?.focus();
|
|
20
|
+
};
|
|
21
|
+
const inputProps = useFormControl({
|
|
22
|
+
isDisabled: props.isDisabled
|
|
23
|
+
});
|
|
24
|
+
return /*#__PURE__*/_jsx(BaseInputSlot, {
|
|
25
|
+
...dataAttributes({
|
|
26
|
+
disabled: isDisabled || inputProps.disabled
|
|
27
|
+
}),
|
|
28
|
+
onPress: () => {
|
|
29
|
+
onPress?.();
|
|
30
|
+
handleFocus();
|
|
31
|
+
},
|
|
32
|
+
accessibilityElementsHidden: true,
|
|
33
|
+
tabIndex: -1,
|
|
34
|
+
ref: ref,
|
|
35
|
+
...props,
|
|
36
|
+
children: children
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=createInputSlot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useFormControl","dataAttributes","useInputContext","jsx","_jsx","createInputSlot","BaseInputSlot","children","onPress","focusOnPress","props","ref","inputFieldRef","isDisabled","handleFocus","current","focus","inputProps","disabled","accessibilityElementsHidden","tabIndex"],"sourceRoot":"../../../src","sources":["input/createInputSlot.tsx"],"mappings":";;AACA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,eAAe,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG5C,OAAO,MAAMC,eAAe,GAAQC,aAAqC,iBACvEP,UAAU,CACR,CAAC;EAAEQ,QAAQ;EAAEC,OAAO;EAAEC,YAAY,GAAG,IAAI;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EAC7D,MAAM;IAAEC,aAAa;IAAEC;EAAW,CAAC,GAAGX,eAAe,CAAC,CAAC;EAEvD,MAAMY,WAAW,GAAGA,CAAA,KAAM;IACxBL,YAAY,IAAIG,aAAa,CAACG,OAAO,EAAEC,KAAK,CAAC,CAAC;EAChD,CAAC;EAED,MAAMC,UAAU,GAAGjB,cAAc,CAAC;IAChCa,UAAU,EAAEH,KAAK,CAACG;EACpB,CAAC,CAAC;EAEF,oBACET,IAAA,CAACE,aAAa;IAAA,GACRL,cAAc,CAAC;MACjBiB,QAAQ,EAAEL,UAAU,IAAII,UAAU,CAACC;IACrC,CAAC,CAAC;IACFV,OAAO,EAAEA,CAAA,KAAM;MACbA,OAAO,GAAG,CAAC;MACXM,WAAW,CAAC,CAAC;IACf,CAAE;IACFK,2BAA2B,EAAE,IAAK;IAClCC,QAAQ,EAAE,CAAC,CAAE;IACbT,GAAG,EAAEA,GAAI;IAAA,GACJD,KAAK;IAAAH,QAAA,EAETA;EAAQ,CACI,CAAC;AAEpB,CACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createInputField } from './createInputField';
|
|
4
|
+
import { createInputIcon } from './createInputIcon';
|
|
5
|
+
import { createInputRoot } from './createInputRoot';
|
|
6
|
+
import { createInputSlot } from './createInputSlot';
|
|
7
|
+
export const createInput = ({
|
|
8
|
+
Root,
|
|
9
|
+
Icon,
|
|
10
|
+
Slot,
|
|
11
|
+
Field
|
|
12
|
+
}) => {
|
|
13
|
+
const Input = createInputRoot(Root);
|
|
14
|
+
Input.Icon = createInputIcon(Icon);
|
|
15
|
+
Input.Slot = createInputSlot(Slot);
|
|
16
|
+
Input.Field = createInputField(Field);
|
|
17
|
+
Input.displayName = 'Input';
|
|
18
|
+
Input.Icon.displayName = 'Input.Icon';
|
|
19
|
+
Input.Slot.displayName = 'Input.Slot';
|
|
20
|
+
Input.Field.displayName = 'Input.Field';
|
|
21
|
+
return Input;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createInputField","createInputIcon","createInputRoot","createInputSlot","createInput","Root","Icon","Slot","Field","Input","displayName"],"sourceRoot":"../../../src","sources":["input/index.tsx"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,eAAe,QAAQ,mBAAmB;AAWnD,OAAO,MAAMC,WAAW,GAAGA,CAOzB;EACAC,IAAI;EACJC,IAAI;EACJC,IAAI;EACJC;AAMF,CAAC,KAAK;EACJ,MAAMC,KAAK,GAAGP,eAAe,CAACG,IAAI,CAAQ;EAC1CI,KAAK,CAACH,IAAI,GAAGL,eAAe,CAACK,IAAI,CAAC;EAClCG,KAAK,CAACF,IAAI,GAAGJ,eAAe,CAACI,IAAI,CAAC;EAClCE,KAAK,CAACD,KAAK,GAAGR,gBAAgB,CAACQ,KAAK,CAAC;EAErCC,KAAK,CAACC,WAAW,GAAG,OAAO;EAC3BD,KAAK,CAACH,IAAI,CAACI,WAAW,GAAG,YAAY;EACrCD,KAAK,CAACF,IAAI,CAACG,WAAW,GAAG,YAAY;EACrCD,KAAK,CAACD,KAAK,CAACE,WAAW,GAAG,aAAa;EAEvC,OAAOD,KAAK;AAQd,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["input/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Modal, Platform, Pressable, StyleSheet } from 'react-native';
|
|
4
|
+
import Animated from 'react-native-reanimated';
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
let createPortalFn;
|
|
7
|
+
if (Platform.OS === 'web') {
|
|
8
|
+
try {
|
|
9
|
+
createPortalFn = require('react-dom').createPortal;
|
|
10
|
+
} catch {}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Cross-platform overlay container.
|
|
14
|
+
*
|
|
15
|
+
* - Web: renders children into a `createPortal` at `document.body` with
|
|
16
|
+
* `position: fixed` and `zIndex: 50`.
|
|
17
|
+
* - Native: renders children inside a transparent `<Modal>` with a
|
|
18
|
+
* backdrop `<Pressable>` that calls `onDismiss` on press.
|
|
19
|
+
*
|
|
20
|
+
* The consumer is responsible for not mounting this component when the
|
|
21
|
+
* overlay should be hidden.
|
|
22
|
+
*/
|
|
23
|
+
export function OverlayContainer({
|
|
24
|
+
onDismiss,
|
|
25
|
+
entering,
|
|
26
|
+
exiting,
|
|
27
|
+
style,
|
|
28
|
+
children
|
|
29
|
+
}) {
|
|
30
|
+
if (Platform.OS === 'web' && createPortalFn) {
|
|
31
|
+
return createPortalFn(/*#__PURE__*/_jsx(Animated.View, {
|
|
32
|
+
entering: entering,
|
|
33
|
+
exiting: exiting,
|
|
34
|
+
style: [{
|
|
35
|
+
position: 'fixed',
|
|
36
|
+
zIndex: 50
|
|
37
|
+
}, style],
|
|
38
|
+
children: children
|
|
39
|
+
}), document.body);
|
|
40
|
+
}
|
|
41
|
+
return /*#__PURE__*/_jsxs(Modal, {
|
|
42
|
+
visible: true,
|
|
43
|
+
transparent: true,
|
|
44
|
+
animationType: "none",
|
|
45
|
+
statusBarTranslucent: true,
|
|
46
|
+
onRequestClose: onDismiss,
|
|
47
|
+
children: [/*#__PURE__*/_jsx(Pressable, {
|
|
48
|
+
style: StyleSheet.absoluteFill,
|
|
49
|
+
onPress: onDismiss,
|
|
50
|
+
accessible: false,
|
|
51
|
+
importantForAccessibility: "no-hide-descendants"
|
|
52
|
+
}), /*#__PURE__*/_jsx(Animated.View, {
|
|
53
|
+
entering: entering,
|
|
54
|
+
exiting: exiting,
|
|
55
|
+
style: [{
|
|
56
|
+
position: 'absolute'
|
|
57
|
+
}, style],
|
|
58
|
+
children: children
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=OverlayContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Modal","Platform","Pressable","StyleSheet","Animated","jsx","_jsx","jsxs","_jsxs","createPortalFn","OS","require","createPortal","OverlayContainer","onDismiss","entering","exiting","style","children","View","position","zIndex","document","body","visible","transparent","animationType","statusBarTranslucent","onRequestClose","absoluteFill","onPress","accessible","importantForAccessibility"],"sourceRoot":"../../../src","sources":["overlay/OverlayContainer.tsx"],"mappings":";;AACA,SACEA,KAAK,EACLC,QAAQ,EACRC,SAAS,EAETC,UAAU,QAEL,cAAc;AACrB,OAAOC,QAAQ,MAAsC,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE/E,IAAIC,cAES;AACb,IAAIR,QAAQ,CAACS,EAAE,KAAK,KAAK,EAAE;EACzB,IAAI;IACFD,cAAc,GAAGE,OAAO,CAAC,WAAW,CAAC,CAACC,YAAY;EACpD,CAAC,CAAC,MAAM,CAAC;AACX;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,SAAS;EACTC,QAAQ;EACRC,OAAO;EACPC,KAAK;EACLC;AAC+B,CAAC,EAAE;EAClC,IAAIjB,QAAQ,CAACS,EAAE,KAAK,KAAK,IAAID,cAAc,EAAE;IAC3C,OAAOA,cAAc,cACnBH,IAAA,CAACF,QAAQ,CAACe,IAAI;MACZJ,QAAQ,EAAEA,QAAS;MACnBC,OAAO,EAAEA,OAAQ;MACjBC,KAAK,EAAE,CAAC;QAAEG,QAAQ,EAAE,OAAc;QAAEC,MAAM,EAAE;MAAG,CAAC,EAAEJ,KAAK,CAAE;MAAAC,QAAA,EAExDA;IAAQ,CACI,CAAC,EAChBI,QAAQ,CAACC,IACX,CAAC;EACH;EAEA,oBACEf,KAAA,CAACR,KAAK;IAACwB,OAAO;IAACC,WAAW;IAACC,aAAa,EAAC,MAAM;IAACC,oBAAoB;IAACC,cAAc,EAAEd,SAAU;IAAAI,QAAA,gBAC7FZ,IAAA,CAACJ,SAAS;MACRe,KAAK,EAAEd,UAAU,CAAC0B,YAAa;MAC/BC,OAAO,EAAEhB,SAAU;MACnBiB,UAAU,EAAE,KAAM;MAClBC,yBAAyB,EAAC;IAAqB,CAChD,CAAC,eACF1B,IAAA,CAACF,QAAQ,CAACe,IAAI;MACZJ,QAAQ,EAAEA,QAAS;MACnBC,OAAO,EAAEA,OAAQ;MACjBC,KAAK,EAAE,CAAC;QAAEG,QAAQ,EAAE;MAAW,CAAC,EAAEH,KAAK,CAAE;MAAAC,QAAA,EAExCA;IAAQ,CACI,CAAC;EAAA,CACX,CAAC;AAEZ","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { OverlayContainer } from './OverlayContainer';
|
|
4
|
+
export { useAnchorPosition } from './useAnchorPosition';
|
|
5
|
+
export { useDismissOverlay } from './useDismissOverlay';
|
|
6
|
+
export { useOverlayPosition, OverlayInsetsProvider } from './useOverlayPosition';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OverlayContainer","useAnchorPosition","useDismissOverlay","useOverlayPosition","OverlayInsetsProvider"],"sourceRoot":"../../../src","sources":["overlay/index.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,iBAAiB,QAA2B,qBAAqB;AAC1E,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SACEC,kBAAkB,EAElBC,qBAAqB,QAEhB,sBAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useLayoutEffect, useState } from 'react';
|
|
4
|
+
import { Platform } from 'react-native';
|
|
5
|
+
const useIsomorphicLayoutEffect = Platform.OS === 'web' ? useLayoutEffect : useEffect;
|
|
6
|
+
function measureWeb(element) {
|
|
7
|
+
const rect = element.getBoundingClientRect();
|
|
8
|
+
return {
|
|
9
|
+
x: rect.left,
|
|
10
|
+
y: rect.top,
|
|
11
|
+
width: rect.width,
|
|
12
|
+
height: rect.height
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Measures an anchor element's position and size, re-measuring on scroll/resize
|
|
18
|
+
* (web) so a positioned overlay can track its anchor across layout changes.
|
|
19
|
+
*
|
|
20
|
+
* Returns `null` until the first measurement completes.
|
|
21
|
+
*/
|
|
22
|
+
export function useAnchorPosition(anchorRef, open) {
|
|
23
|
+
const [layout, setLayout] = useState(null);
|
|
24
|
+
useIsomorphicLayoutEffect(() => {
|
|
25
|
+
if (!open) {
|
|
26
|
+
setLayout(null);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const anchor = anchorRef.current;
|
|
30
|
+
if (!anchor) return;
|
|
31
|
+
let cancelled = false;
|
|
32
|
+
if (Platform.OS === 'web') {
|
|
33
|
+
setLayout(measureWeb(anchor));
|
|
34
|
+
} else {
|
|
35
|
+
anchor.measureInWindow((x, y, width, height) => {
|
|
36
|
+
if (!cancelled) {
|
|
37
|
+
setLayout({
|
|
38
|
+
x,
|
|
39
|
+
y,
|
|
40
|
+
width,
|
|
41
|
+
height
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return () => {
|
|
47
|
+
cancelled = true;
|
|
48
|
+
};
|
|
49
|
+
}, [open, anchorRef]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (!open || Platform.OS !== 'web') return;
|
|
52
|
+
const anchor = anchorRef.current;
|
|
53
|
+
if (!anchor) return;
|
|
54
|
+
const update = () => setLayout(measureWeb(anchor));
|
|
55
|
+
window.addEventListener('scroll', update, true);
|
|
56
|
+
window.addEventListener('resize', update);
|
|
57
|
+
return () => {
|
|
58
|
+
window.removeEventListener('scroll', update, true);
|
|
59
|
+
window.removeEventListener('resize', update);
|
|
60
|
+
};
|
|
61
|
+
}, [open, anchorRef]);
|
|
62
|
+
return layout;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=useAnchorPosition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","useState","Platform","useIsomorphicLayoutEffect","OS","measureWeb","element","rect","getBoundingClientRect","x","left","y","top","width","height","useAnchorPosition","anchorRef","open","layout","setLayout","anchor","current","cancelled","measureInWindow","update","window","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["overlay/useAnchorPosition.ts"],"mappings":";;AACA,SAASA,SAAS,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,SAASC,QAAQ,QAAQ,cAAc;AAEvC,MAAMC,yBAAyB,GAAGD,QAAQ,CAACE,EAAE,KAAK,KAAK,GAAGJ,eAAe,GAAGD,SAAS;AASrF,SAASM,UAAUA,CAACC,OAAY,EAAgB;EAC9C,MAAMC,IAAI,GAAID,OAAO,CAA4BE,qBAAqB,CAAC,CAAC;EACxE,OAAO;IAAEC,CAAC,EAAEF,IAAI,CAACG,IAAI;IAAEC,CAA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BAAgB,CAAC,QAAQ,EAAEF,MAAM,EAAE,IAAI,CAAC;IAC/CC,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAEF,MAAM,CAAC;IAEzC,OAAO,MAAM;MACXC,MAAM,CAACE,mBAAmB,CAAC,QAAQ,EAAEH,MAAM,EAAE,IAAI,CAAC;MAClDC,MAAM,CAACE,mBAAmB,CAAC,QAAQ,EAAEH,MAAM,CAAC;IAC9C,CAAC;EACH,CAAC,EAAE,CAACP,IAAI,EAAED,SAAS,CAAC,CAAC;EAErB,OAAOE,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* No-op on native — overlay dismissal is handled by backdrop press
|
|
7
|
+
* or the system back gesture / hardware button via Modal.
|
|
8
|
+
*/
|
|
9
|
+
export function useDismissOverlay(_open, _contentRef, _excludeRefs, _onDismiss) {}
|
|
10
|
+
//# sourceMappingURL=useDismissOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useDismissOverlay","_open","_contentRef","_excludeRefs","_onDismiss"],"sourceRoot":"../../../src","sources":["overlay/useDismissOverlay.ts"],"mappings":";;AAAA;;AAIA;AACA;AACA;AACA;AACA,OAAO,SAASA,iBAAiBA,CAC/BC,KAAc,EACdC,WAA2B,EAC3BC,YAA8B,EAC9BC,UAAsB,EACtB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Dismisses an overlay when the user clicks/presses outside of it or when
|
|
7
|
+
* focus moves to an element outside the overlay via keyboard.
|
|
8
|
+
* Events targeting `contentRef` or any of `excludeRefs` are ignored.
|
|
9
|
+
*/
|
|
10
|
+
export function useDismissOverlay(open, contentRef, excludeRefs, onDismiss) {
|
|
11
|
+
const onDismissRef = useRef(onDismiss);
|
|
12
|
+
onDismissRef.current = onDismiss;
|
|
13
|
+
const excludeRefsRef = useRef(excludeRefs);
|
|
14
|
+
excludeRefsRef.current = excludeRefs;
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!open) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const isInsideOverlay = target => {
|
|
20
|
+
if (contentRef.current?.contains?.(target)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
for (const ref of excludeRefsRef.current) {
|
|
24
|
+
if (ref.current?.contains?.(target)) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
};
|
|
30
|
+
const dismissIfOutside = e => {
|
|
31
|
+
if (!isInsideOverlay(e.target)) {
|
|
32
|
+
onDismissRef.current();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
document.addEventListener('pointerdown', dismissIfOutside);
|
|
36
|
+
document.addEventListener('focusin', dismissIfOutside);
|
|
37
|
+
return () => {
|
|
38
|
+
document.removeEventListener('pointerdown', dismissIfOutside);
|
|
39
|
+
document.removeEventListener('focusin', dismissIfOutside);
|
|
40
|
+
};
|
|
41
|
+
}, [open, contentRef]);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=useDismissOverlay.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useDismissOverlay","open","contentRef","excludeRefs","onDismiss","onDismissRef","current","excludeRefsRef","isInsideOverlay","target","contains","ref","dismissIfOutside","e","document","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["overlay/useDismissOverlay.web.ts"],"mappings":";;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;;AAEzC;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAC/BC,IAAa,EACbC,U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owDimensions } from 'react-native';
|
|
5
|
+
const DEFAULT_INSETS = {
|
|
6
|
+
top: 0,
|
|
7
|
+
right: 0,
|
|
8
|
+
bottom: 0,
|
|
9
|
+
left: 0
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Provides safe-area insets to overlay positioning hooks. Wrap your app
|
|
14
|
+
* root with this provider and pass values from `useSafeAreaInsets()` to
|
|
15
|
+
* enable safe-area-aware overlay placement.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
20
|
+
* import { OverlayInsetsProvider } from '@cdx-ui/primitives';
|
|
21
|
+
*
|
|
22
|
+
* function App() {
|
|
23
|
+
* const insets = useSafeAreaInsets();
|
|
24
|
+
* return (
|
|
25
|
+
* <OverlayInsetsProvider value={insets}>
|
|
26
|
+
* {children}
|
|
27
|
+
* </OverlayInsetsProvider>
|
|
28
|
+
* );
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export const OverlayInsetsContext = /*#__PURE__*/createContext(DEFAULT_INSETS);
|
|
33
|
+
export const OverlayInsetsProvider = OverlayInsetsContext.Provider;
|
|
34
|
+
|
|
35
|
+
/** Minimum gap (px) between the overlay edge and the viewport/safe-area boundary. */
|
|
36
|
+
const SCREEN_EDGE_PADDING = 8;
|
|
37
|
+
|
|
38
|
+
/** Minimum usable space (px) below the anchor before the overlay flips above. */
|
|
39
|
+
const MIN_CONTENT_HEIGHT = 200;
|
|
40
|
+
/**
|
|
41
|
+
* Computes viewport-aware overlay positioning relative to an anchor element.
|
|
42
|
+
* Automatically flips placement from bottom to top when insufficient space
|
|
43
|
+
* exists below the anchor. Constrains `maxHeight` to available space so
|
|
44
|
+
* content never extends beyond the screen edge.
|
|
45
|
+
*
|
|
46
|
+
* Respects safe-area insets provided via `OverlayInsetsProvider`.
|
|
47
|
+
*/
|
|
48
|
+
export function useOverlayPosition(anchorLayout) {
|
|
49
|
+
const {
|
|
50
|
+
height: viewportHeight
|
|
51
|
+
} = useWindowDimensions();
|
|
52
|
+
const {
|
|
53
|
+
top: insetTop,
|
|
54
|
+
bottom: insetBottom
|
|
55
|
+
} = useContext(OverlayInsetsContext);
|
|
56
|
+
return useMemo(() => {
|
|
57
|
+
if (!anchorLayout) return null;
|
|
58
|
+
const anchorBottom = anchorLayout.y + anchorLayout.height;
|
|
59
|
+
const spaceBelow = viewportHeight - anchorBottom - insetBottom - SCREEN_EDGE_PADDING;
|
|
60
|
+
const spaceAbove = anchorLayout.y - insetTop - SCREEN_EDGE_PADDING;
|
|
61
|
+
const preferBelow = spaceBelow >= MIN_CONTENT_HEIGHT || spaceBelow >= spaceAbove;
|
|
62
|
+
if (preferBelow) {
|
|
63
|
+
const maxHeight = Math.max(0, spaceBelow);
|
|
64
|
+
return {
|
|
65
|
+
style: {
|
|
66
|
+
top: anchorBottom,
|
|
67
|
+
left: anchorLayout.x,
|
|
68
|
+
width: anchorLayout.width,
|
|
69
|
+
maxHeight
|
|
70
|
+
},
|
|
71
|
+
maxHeight,
|
|
72
|
+
placement: 'bottom'
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const maxHeight = Math.max(0, spaceAbove);
|
|
76
|
+
return {
|
|
77
|
+
style: {
|
|
78
|
+
bottom: viewportHeight - anchorLayout.y,
|
|
79
|
+
left: anchorLayout.x,
|
|
80
|
+
width: anchorLayout.width,
|
|
81
|
+
maxHeight
|
|
82
|
+
},
|
|
83
|
+
maxHeight,
|
|
84
|
+
placement: 'top'
|
|
85
|
+
};
|
|
86
|
+
}, [anchorLayout, viewportHeight, insetTop, insetBottom]);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=useOverlayPosition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","useContext","useMemo","useWindowDimensions","DEFAULT_INSETS","top","right","bottom","left","OverlayInsetsContext","OverlayInsetsProvider","Provider","SCREEN_EDGE_PADDING","MIN_CONTENT_HEIGHT","useOverlayPosition","anchorLayout","height","viewportHeight","insetTop","insetBottom","anchorBottom","y","spaceBelow","spaceAbove","preferBelow","maxHeight","Math","max","style","x","width","placement"],"sourceRoot":"../../../src","sources":["overlay/useOverlayPosition.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC1D,SAASC,mBAAmB,QAAwB,cAAc;AAUlE,MAAMC,cAA0B,GAAG;EAAEC,GAAG,EAAE,CAAC;EAAEC,KAAK,EAAE,CAAC;EAAEC,MAAM,EAAE,CAAC;EAAEC,IAAI,EAAE;AAAE,CAAC;;AAE3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,gBAAGT,aAAa,CAAaI,cAAc,CAAC;AAC7E,OAAO,MAAMM,qBAAqB,GAAGD,oBAAoB,CAACE,QAAQ;;AAElE;AACA,MAAMC,mBAAmB,GAAG,CAAC;;AAE7B;AACA,MAAMC,kBAAkB,GAAG,GAAG;AAQ9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,YAAiC,EAA0B;EAC5F,MAAM;IAAEC,MAAM,EAAEC;EAAe,CAAC,GAAGd,mBAAmB,CAAC,CAAC;EACxD,MAAM;IAAEE,GAAG,EAAEa,QAAQ;IAAEX,MAAM,EAAEY;EAAY,CAAC,GAAGlB,UAAU,CAACQ,oBAAoB,CAAC;EAE/E,OAAOP,OAAO,CAAC,MAAM;IACnB,IAAI,CAACa,YAAY,EAAE,OAAO,IAAI;IAE9B,MAAMK,YAAY,GAAGL,YAAY,CAACM,CAAC,GAAGN,YAAY,CAACC,MAAM;IACzD,MAAMM,UAAU,GAAGL,cAAc,GAAGG,YAAY,GAAGD,WAAW,GAAGP,mBAAmB;IACpF,MAAMW,UAAU,GAAGR,YAAY,CAACM,CAAC,GAAGH,QAAQ,GAAGN,mBAAmB;IAElE,MAAMY,WAAW,GAAGF,UAAU,IAAIT,kBAAkB,IAAIS,UAAU,IAAIC,UAAU;IAEhF,IAAIC,WAAW,EAAE;MACf,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEL,UAAU,CAAC;MACzC,OAAO;QACLM,KAAK,EAAE;UACLvB,GAAG,EAAEe,YAAY;UACjBZ,IAAI,EAAEO,YAAY,CAACc,CAAC;UACpBC,KAAK,EAAEf,YAAY,CAACe,KAAK;UACzBL;QACF,CAAC;QACDA,SAAS;QACTM,SAAS,EAAE;MACb,CAAC;IACH;IAEA,MAAMN,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEJ,UAAU,CAAC;IACzC,OAAO;MACLK,KAAK,EAAE;QACLrB,MAAM,EAAEU,cAAc,GAAGF,YAAY,CAACM,CAAC;QACvCb,IAAI,EAAEO,YAAY,CAACc,CAAC;QACpBC,KAAK,EAAEf,YAAY,CAACe,KAAK;QACzBL;MACF,CAAC;MACDA,SAAS;MACTM,SAAS,EAAE;IACb,CAAC;EACH,CAAC,EAAE,CAAChB,YAAY,EAAEE,cAAc,EAAEC,QAAQ,EAAEC,WAAW,CAAC,CAAC;AAC3D","ignoreList":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
const defaultContextValue = {
|
|
5
|
+
open: false,
|
|
6
|
+
items: [],
|
|
7
|
+
setOpen: () => {},
|
|
8
|
+
value: undefined,
|
|
9
|
+
onValueChange: () => {},
|
|
10
|
+
disabled: false,
|
|
11
|
+
required: false,
|
|
12
|
+
invalid: false,
|
|
13
|
+
readOnly: false,
|
|
14
|
+
native: false,
|
|
15
|
+
triggerRef: {
|
|
16
|
+
current: null
|
|
17
|
+
},
|
|
18
|
+
contentId: '',
|
|
19
|
+
triggerId: '',
|
|
20
|
+
activeValue: undefined,
|
|
21
|
+
setActiveValue: () => {},
|
|
22
|
+
// TODO: Is this needed? At the very least it could be moved to SelectContent
|
|
23
|
+
accessibilityLabel: undefined
|
|
24
|
+
};
|
|
25
|
+
export const SelectContext = /*#__PURE__*/createContext(defaultContextValue);
|
|
26
|
+
export const useSelectContext = () => useContext(SelectContext);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Propagates the trigger's interaction state (hover, focus, active, etc.) to
|
|
30
|
+
* child components like SelectValue and SelectIcon so they can apply matching
|
|
31
|
+
* data-attribute styles.
|
|
32
|
+
*/
|
|
33
|
+
export const SelectTriggerContext = /*#__PURE__*/createContext({
|
|
34
|
+
hover: false,
|
|
35
|
+
focus: false,
|
|
36
|
+
active: false,
|
|
37
|
+
disabled: false,
|
|
38
|
+
focusVisible: false
|
|
39
|
+
});
|
|
40
|
+
export const useSelectTriggerContext = () => useContext(SelectTriggerContext);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Propagates the item's interaction and selection state (hover, focus, active,
|
|
44
|
+
* highlighted, checked, etc.) to child components like SelectItemLabel.
|
|
45
|
+
*/
|
|
46
|
+
export const SelectItemContext = /*#__PURE__*/createContext({
|
|
47
|
+
hover: false,
|
|
48
|
+
focus: false,
|
|
49
|
+
active: false,
|
|
50
|
+
disabled: false,
|
|
51
|
+
focusVisible: false,
|
|
52
|
+
highlighted: false,
|
|
53
|
+
checked: false
|
|
54
|
+
});
|
|
55
|
+
export const useSelectItemContext = () => useContext(SelectItemContext);
|
|
56
|
+
//# sourceMappingURL=context.js.map
|