@cdx-ui/components 0.3.2 → 0.3.4
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 +2 -2
- package/coverage.svg +1 -1
- package/docs/components/color-field/content.md +2 -2
- package/docs/components/content.md +6 -4
- package/docs/components/data-grid/content.md +125 -1
- package/docs/components/date-field/content.md +2 -2
- package/docs/components/date-time-field/content.md +2 -2
- package/docs/components/input/content.md +20 -2
- package/docs/components/input/design.md +1 -1
- package/docs/components/insight/content.md +644 -0
- package/docs/components/insight-stack/content.md +231 -0
- package/docs/components/insurance-disclosure/content.md +1 -1
- package/docs/components/otp-input/content.md +2 -2
- package/docs/components/select/content.md +223 -24
- package/docs/components/text/content.md +97 -0
- package/docs/foundations/styles/tokens/all-tokens/content.md +23 -3
- package/docs/llms.txt +8 -4
- package/docs/patterns/forms/content.md +407 -0
- package/docs/resources/release-notes/0.3.2/content.md +17 -0
- package/docs/resources/release-notes/0.3.3/content.md +23 -0
- package/docs/resources/release-notes/content.md +2 -0
- package/lib/commonjs/components/Drawer/index.js +1 -1
- package/lib/commonjs/components/Drawer/index.js.map +1 -1
- package/lib/commonjs/components/Input/index.js.map +1 -1
- package/lib/commonjs/components/Input/styles.js +13 -6
- package/lib/commonjs/components/Input/styles.js.map +1 -1
- package/lib/commonjs/components/Insight/index.js +438 -0
- package/lib/commonjs/components/Insight/index.js.map +1 -0
- package/lib/commonjs/components/Insight/insetRadius.js +35 -0
- package/lib/commonjs/components/Insight/insetRadius.js.map +1 -0
- package/lib/commonjs/components/Insight/styles.js +186 -0
- package/lib/commonjs/components/Insight/styles.js.map +1 -0
- package/lib/commonjs/components/InsightStack/index.js +93 -0
- package/lib/commonjs/components/InsightStack/index.js.map +1 -0
- package/lib/commonjs/components/InsightStack/styles.js +61 -0
- package/lib/commonjs/components/InsightStack/styles.js.map +1 -0
- package/lib/commonjs/components/OtpInput/index.js.map +1 -1
- package/lib/commonjs/components/Select/index.js +326 -24
- package/lib/commonjs/components/Select/index.js.map +1 -1
- package/lib/commonjs/components/Select/styles.js +32 -1
- package/lib/commonjs/components/Select/styles.js.map +1 -1
- package/lib/commonjs/components/index.js +24 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/picker/surfaces.js +18 -3
- package/lib/commonjs/components/picker/surfaces.js.map +1 -1
- package/lib/commonjs/figma/Insight.figma.js +73 -0
- package/lib/commonjs/figma/Insight.figma.js.map +1 -0
- package/lib/commonjs/figma/InsightStack.figma.js +39 -0
- package/lib/commonjs/figma/InsightStack.figma.js.map +1 -0
- package/lib/module/components/Drawer/index.js +1 -1
- package/lib/module/components/Drawer/index.js.map +1 -1
- package/lib/module/components/Input/index.js.map +1 -1
- package/lib/module/components/Input/styles.js +14 -6
- package/lib/module/components/Input/styles.js.map +1 -1
- package/lib/module/components/Insight/index.js +433 -0
- package/lib/module/components/Insight/index.js.map +1 -0
- package/lib/module/components/Insight/insetRadius.js +30 -0
- package/lib/module/components/Insight/insetRadius.js.map +1 -0
- package/lib/module/components/Insight/styles.js +183 -0
- package/lib/module/components/Insight/styles.js.map +1 -0
- package/lib/module/components/InsightStack/index.js +89 -0
- package/lib/module/components/InsightStack/index.js.map +1 -0
- package/lib/module/components/InsightStack/styles.js +58 -0
- package/lib/module/components/InsightStack/styles.js.map +1 -0
- package/lib/module/components/OtpInput/index.js.map +1 -1
- package/lib/module/components/Select/index.js +328 -26
- package/lib/module/components/Select/index.js.map +1 -1
- package/lib/module/components/Select/styles.js +31 -0
- package/lib/module/components/Select/styles.js.map +1 -1
- package/lib/module/components/index.js +2 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/picker/surfaces.js +17 -3
- package/lib/module/components/picker/surfaces.js.map +1 -1
- package/lib/module/figma/Insight.figma.js +67 -0
- package/lib/module/figma/Insight.figma.js.map +1 -0
- package/lib/module/figma/InsightStack.figma.js +33 -0
- package/lib/module/figma/InsightStack.figma.js.map +1 -0
- package/lib/typescript/components/ColorField/styles.d.ts +4 -2
- package/lib/typescript/components/ColorField/styles.d.ts.map +1 -1
- package/lib/typescript/components/DateField/styles.d.ts +4 -2
- package/lib/typescript/components/DateField/styles.d.ts.map +1 -1
- package/lib/typescript/components/Input/index.d.ts +3 -2
- package/lib/typescript/components/Input/index.d.ts.map +1 -1
- package/lib/typescript/components/Input/styles.d.ts +1 -1
- package/lib/typescript/components/Input/styles.d.ts.map +1 -1
- package/lib/typescript/components/Insight/index.d.ts +87 -0
- package/lib/typescript/components/Insight/index.d.ts.map +1 -0
- package/lib/typescript/components/Insight/insetRadius.d.ts +8 -0
- package/lib/typescript/components/Insight/insetRadius.d.ts.map +1 -0
- package/lib/typescript/components/Insight/styles.d.ts +33 -0
- package/lib/typescript/components/Insight/styles.d.ts.map +1 -0
- package/lib/typescript/components/InsightStack/index.d.ts +21 -0
- package/lib/typescript/components/InsightStack/index.d.ts.map +1 -0
- package/lib/typescript/components/InsightStack/styles.d.ts +11 -0
- package/lib/typescript/components/InsightStack/styles.d.ts.map +1 -0
- package/lib/typescript/components/OtpInput/index.d.ts +3 -2
- package/lib/typescript/components/OtpInput/index.d.ts.map +1 -1
- package/lib/typescript/components/Select/index.d.ts +73 -6
- package/lib/typescript/components/Select/index.d.ts.map +1 -1
- package/lib/typescript/components/Select/styles.d.ts +9 -0
- package/lib/typescript/components/Select/styles.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +2 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/picker/surfaces.d.ts +14 -3
- package/lib/typescript/components/picker/surfaces.d.ts.map +1 -1
- package/lib/typescript/figma/Insight.figma.d.ts +8 -0
- package/lib/typescript/figma/Insight.figma.d.ts.map +1 -0
- package/lib/typescript/figma/InsightStack.figma.d.ts +8 -0
- package/lib/typescript/figma/InsightStack.figma.d.ts.map +1 -0
- package/package.json +5 -5
- package/src/components/ColorField/styles.ts +3 -1
- package/src/components/DateField/styles.ts +6 -1
- package/src/components/Drawer/index.tsx +1 -1
- package/src/components/Input/index.tsx +3 -2
- package/src/components/Input/styles.ts +35 -15
- package/src/components/Insight/index.tsx +531 -0
- package/src/components/Insight/insetRadius.ts +30 -0
- package/src/components/Insight/styles.ts +193 -0
- package/src/components/InsightStack/index.tsx +86 -0
- package/src/components/InsightStack/styles.ts +61 -0
- package/src/components/OtpInput/index.tsx +3 -2
- package/src/components/Select/index.tsx +411 -29
- package/src/components/Select/styles.ts +36 -0
- package/src/components/index.ts +2 -0
- package/src/components/picker/surfaces.tsx +29 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cva","DISABLED_CURSOR","FRAME_WIDTH","SURFACE_RADIUS","SUMMARY_BODY","PRESS_REGION_STATE","join","insightFrameVariants","variants","layout","summary","detail","color","info","warning","danger","aiGenerated","true","false","compoundVariants","className","defaultVariants","insightSurfaceVariants","split","insightPressRegionVariants","insightIconVariants","insightSummaryTextVariants","hasClose","insightTagVariants","insightTagIconVariants","insightCloseVariants","insightHeaderVariants","insightTitleVariants","insightDescriptionVariants","insightContentVariants","insightFooterVariants"],"sourceRoot":"../../../../src","sources":["components/Insight/styles.ts"],"mappings":";;AAAA,SAASA,GAAG,QAA2B,eAAe;AACtD,SAASC,eAAe,QAAQ,wBAAwB;;AAExD;AACA,OAAO,MAAMC,WAAW,GAAG,CAAC;;AAE5B;AACA,MAAMC,cAAc,GAAG,kDAAkD;;AAEzE;AACA;AACA,MAAMC,YAAY,GAAG,+DAA+D;;AAEpF;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG,CACzB,kBAAkB,EAClBJ,eAAe,EACf,uLAAuL,CACxL,CAACK,IAAI,CAAC,GAAG,CAAC;;AAEX;;AAEA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAGP,GAAG,CACrC,CACE,gBAAgB,EAChB,wCAAwC,EACxC,wDAAwD,CACzD,EACD;EACEQ,QAAQ,EAAE;IACRC,MAAM,EAAE;MACNC,OAAO,EAAE,EAAE;MACX;MACA;MAC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jE;;AAEA,OAAO,MAAM+B,qBAAqB,GAAG/B,GAAG,CAAC,CAAC,gCAAgC,CAAC,CAAC;AAE5E,OAAO,MAAMgC,oBAAoB,GAAGhC,GAAG,CAAC,CAAC,iCAAiC,CAAC,EAAE;EAC3EQ,QAAQ,EAAE;IACRmB,QAAQ,EAAE;MACRV,IAAI,EAAE,MAAM;MACZC,KAAK,EAAE;IACT;EACF,CAAC;EACDG,eAAe,EAAE;IACfM,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAEF,OAAO,MAAMM,0BAA0B,GAAGjC,GAAG,CAAC,CAAC,8BAA8B,CAAC,CAAC;AAE/E,OAAO,MAAMkC,sBAAsB,GAAGlC,GAAG,CAAC,EAAE,CAAC;;AAE7C;AACA,OAAO,MAAMmC,qBAAqB,GAAGnC,GAAG,CAAC,CAAC,mDAAmD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { cloneElement, forwardRef, isValidElement } from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { Slot, dataAttributes, mergeDataAttributes } from '@cdx-ui/primitives';
|
|
6
|
+
import { cn } from '@cdx-ui/utils';
|
|
7
|
+
import { insightStackFrontVariants, insightStackLayerVariants, insightStackRootVariants } from './styles';
|
|
8
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
const layerCountFor = count => count >= 3 ? 2 : count >= 2 ? 1 : 0;
|
|
10
|
+
function InsightStackLayer({
|
|
11
|
+
depth,
|
|
12
|
+
layers
|
|
13
|
+
}) {
|
|
14
|
+
return /*#__PURE__*/_jsx(View, {
|
|
15
|
+
"aria-hidden": true,
|
|
16
|
+
accessibilityElementsHidden: true,
|
|
17
|
+
importantForAccessibility: "no-hide-descendants",
|
|
18
|
+
className: insightStackLayerVariants({
|
|
19
|
+
depth,
|
|
20
|
+
layers
|
|
21
|
+
}),
|
|
22
|
+
...dataAttributes({
|
|
23
|
+
slot: 'insight-stack-layer'
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function InsightStackBody({
|
|
28
|
+
layers,
|
|
29
|
+
children
|
|
30
|
+
}) {
|
|
31
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
32
|
+
children: [layers === 2 ? /*#__PURE__*/_jsx(InsightStackLayer, {
|
|
33
|
+
depth: 2,
|
|
34
|
+
layers: 2
|
|
35
|
+
}) : null, layers === 0 ? null : /*#__PURE__*/_jsx(InsightStackLayer, {
|
|
36
|
+
depth: 1,
|
|
37
|
+
layers: layers
|
|
38
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
39
|
+
className: insightStackFrontVariants(),
|
|
40
|
+
children: children
|
|
41
|
+
})]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Draws up to two decorative cards behind a summary Insight to show that more insights exist.
|
|
47
|
+
* The root adds no role, so the front Insight stays the only interactive element.
|
|
48
|
+
*/
|
|
49
|
+
export const InsightStack = /*#__PURE__*/forwardRef(({
|
|
50
|
+
count,
|
|
51
|
+
asChild = false,
|
|
52
|
+
className,
|
|
53
|
+
style,
|
|
54
|
+
children,
|
|
55
|
+
...props
|
|
56
|
+
}, ref) => {
|
|
57
|
+
const layers = layerCountFor(count);
|
|
58
|
+
const rootProps = {
|
|
59
|
+
className: cn(insightStackRootVariants({
|
|
60
|
+
layers
|
|
61
|
+
}), className),
|
|
62
|
+
style,
|
|
63
|
+
...props,
|
|
64
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
65
|
+
slot: 'insight-stack'
|
|
66
|
+
}))
|
|
67
|
+
};
|
|
68
|
+
if (asChild && /*#__PURE__*/isValidElement(children)) {
|
|
69
|
+
const child = children;
|
|
70
|
+
return /*#__PURE__*/_jsx(Slot, {
|
|
71
|
+
ref: ref,
|
|
72
|
+
...rootProps,
|
|
73
|
+
children: /*#__PURE__*/cloneElement(child, undefined, /*#__PURE__*/_jsx(InsightStackBody, {
|
|
74
|
+
layers: layers,
|
|
75
|
+
children: child.props.children
|
|
76
|
+
}))
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return /*#__PURE__*/_jsx(View, {
|
|
80
|
+
ref: ref,
|
|
81
|
+
...rootProps,
|
|
82
|
+
children: /*#__PURE__*/_jsx(InsightStackBody, {
|
|
83
|
+
layers: layers,
|
|
84
|
+
children: children
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
InsightStack.displayName = 'InsightStack';
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cloneElement","forwardRef","isValidElement","View","Slot","dataAttributes","mergeDataAttributes","cn","insightStackFrontVariants","insightStackLayerVariants","insightStackRootVariants","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","layerCountFor","count","InsightStackLayer","depth","layers","accessibilityElementsHidden","importantForAccessibility","className","slot","InsightStackBody","children","InsightStack","asChild","style","props","ref","rootProps","child","undefined","displayName"],"sourceRoot":"../../../../src","sources":["components/InsightStack/index.tsx"],"mappings":";;AAAA,SAASA,YAAY,EAAEC,UAAU,EAAEC,cAAc,QAA2C,OAAO;AACnG,SAASC,IAAI,QAAwB,cAAc;AACnD,SAASC,IAAI,EAAEC,cAAc,EAAEC,mBAAmB,QAAQ,oBAAoB;AAC9E,SAASC,EAAE,QAAQ,eAAe;AAClC,SACEC,yBAAyB,EACzBC,yBAAyB,EACzBC,wBAAwB,QACnB,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAIlB,MAAMC,aAAa,GAAIC,KAAa,IAAkBA,KAAK,IAAI,CAAC,GAAG,CAAC,GAAGA,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAE;AAgB1F,SAASC,iBAAiBA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AAE1B,cAAc,CAAC;MAAEoB,IAAI,EAAE;IAAgB,CAAC,CAAC;EACzE,CAAC;EAED,IAAII,OAAO,iBAAI3B,cAAc,CAACyB,QAAQ,CAAC,EAAE;IACvC,MAAMO,KAAK,GAAGP,QAAkD;IAChE,oBACEf,IAAA,CAACR,IAAI;MAAC4B,GAAG,EAAEA,GAAI;MAAA,GAAKC,SAAS;MAAAN,QAAA,eAC1B3B,YAAY,CACXkC,KAAK,EACLC,SAAS,eACTvB,IAAA,CAACc,gBAAgB;QAACL,MAAM,EAAEA,MAAO;QAAAM,QAAA,EAAEO,KAAK,CAACH,KAAK,CAACJ;MAAQ,CAAmB,CAC5E;IAAC,CACG,CAAC;EAEX;EAEA,oBACEf,IAAA,CAACT,IAAI;IAAC6B,GAAG,EAAEA,GAAI;IAAA,GAAKC,SAAS;IAAAN,QAAA,eAC3Bf,IAAA,CAACc,gBAAgB;MAACL,MAAM,EAAEA,MAAO;MAAAM,QAAA,EAAEA;IAAQ,CAAmB;EAAC,CAC3D,CAAC;AAEX,CACF,CAAC;AAEDC,YAAY,CAACQ,WAAW,GAAG,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { cva } from '@cdx-ui/utils';
|
|
4
|
+
|
|
5
|
+
// ── Root ────────────────────────────────────────────────────
|
|
6
|
+
|
|
7
|
+
// The bottom padding is the room the layers peek into: 6px per layer, matching Figma.
|
|
8
|
+
export const insightStackRootVariants = cva(['relative'], {
|
|
9
|
+
variants: {
|
|
10
|
+
layers: {
|
|
11
|
+
0: '',
|
|
12
|
+
1: 'pb-1.5',
|
|
13
|
+
2: 'pb-3'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
layers: 0
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// ── Front ───────────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
// Keeps the front Insight painted above the layers on Android.
|
|
24
|
+
export const insightStackFrontVariants = cva(['relative z-10']);
|
|
25
|
+
|
|
26
|
+
// ── Layer ───────────────────────────────────────────────────
|
|
27
|
+
|
|
28
|
+
// Each layer is anchored to the root's bottom, so it peeks 6px per depth below the front card
|
|
29
|
+
// whatever that card's height. Both start at `top-5`, below where any front card begins: a detail
|
|
30
|
+
// Insight's frame sits 11px down (its tag reserve), and the layer's 6px glow needs room above
|
|
31
|
+
// that, so the layer tops stay hidden behind the opaque front card (at least 60px tall). The insets
|
|
32
|
+
// are symmetric, so RTL needs no mirroring.
|
|
33
|
+
export const insightStackLayerVariants = cva(['absolute', 'bg-surface-primary', 'border-2 border-stroke-secondary', 'rounded-[var(--border-radius-default)]', 'shadow-[0_0_6px_var(--color-surface-neutral-subtle)]'], {
|
|
34
|
+
variants: {
|
|
35
|
+
depth: {
|
|
36
|
+
1: 'inset-x-1 top-5',
|
|
37
|
+
2: 'inset-x-2 top-5 bottom-0'
|
|
38
|
+
},
|
|
39
|
+
layers: {
|
|
40
|
+
1: '',
|
|
41
|
+
2: ''
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
compoundVariants: [{
|
|
45
|
+
depth: 1,
|
|
46
|
+
layers: 1,
|
|
47
|
+
className: 'bottom-0'
|
|
48
|
+
}, {
|
|
49
|
+
depth: 1,
|
|
50
|
+
layers: 2,
|
|
51
|
+
className: 'bottom-1.5'
|
|
52
|
+
}],
|
|
53
|
+
defaultVariants: {
|
|
54
|
+
depth: 1,
|
|
55
|
+
layers: 1
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cva","insightStackRootVariants","variants","layers","defaultVariants","insightStackFrontVariants","insightStackLayerVariants","depth","compoundVariants","className"],"sourceRoot":"../../../../src","sources":["components/InsightStack/styles.ts"],"mappings":";;AAAA,SAASA,GAAG,QAA2B,eAAe;;AAEtD;;AAEA;AACA,OAAO,MAAMC,wBAAwB,GAAGD,GAAG,CAAC,CAAC,UAAU,CAAC,EAAE;EACxDE,QAAQ,EAAE;IACRC,MAAM,EAAE;MACN,CAAC,EAAE,EAAE;MACL,CAAC,EAAE,QAAQ;MACX,CAAC,EAAE;IACL;EACF,CAAC;EACDC,eAAe,EAAE;IACfD,MAAM,EAAE;EACV;AACF,CAAC,CAAC;;AAEF;;AAEA;AACA,OAAO,MAAME,yBAAyB,GAAGL,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC;;AAE/D;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,yBAAyB,GAAGN,GAAG,CAC1C,CACE,UAAU,EACV,oBAAoB,EACpB,kCAAkC,EAClC,wCAAwC,EACxC,sDAAsD,CACvD,EACD;EACEE,QAAQ,EAAE;IACRK,KAAK,EAAE;MACL,CAAC,EAAE,iBAAiB;MACpB,CAAC,EAAE;IACL,CAAC;IACDJ,MAAM,EAAE;MACN,CAAC,EAAE,EAAE;MACL,CAAC,EAAE;IACL;EACF,CAAC;EACDK,gBAAgB,EAAE,CAChB;IAAED,KAAK,EAAE,CAAC;IAAEJ,MAAM,EAAE,CAAC;IAAEM,SAAS,EAAE;EAAW,CAAC,EAC9C;IAAEF,KAAK,EAAE,CAAC;IAAEJ,MAAM,EAAE,CAAC;IAAEM,SAAS,EAAE;EAAa,CAAC,CACjD;EACDL,eAAe,EAAE;IACfG,KAAK,EAAE,CAAC;IACRJ,MAAM,EAAE;EACV;AACF,CACF,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useMemo","View","OtpCellIndexProvider","OtpInputField","OtpInputProvider","dataAttributes","mergeDataAttributes","useInputContext","useOtpInput","ParentContext","cn","useParentContext","useStyleContext","Input","inputFieldVariants","otpCellVariants","otpFieldVariants","otpRootVariants","jsx","_jsx","SCOPE","useOtpInputStyleContext","OtpStyledCell","className","children","variant","variantProp","size","sizeProp","props","ref","context","displayName","OtpStyledField","setIsFocused","onFocus","e","onBlur","OtpInputRoot","fullWidth","style","cellCount","value","onChangeText","onComplete","isDisabled","isInvalid","isReadOnly","smsOtpAutofill","filterInput","allowedCharacters","characterPattern","getCellProps","cellTestIdPrefix","accessibilityLabel","rest","otpContext","rootClassName","parent","ctx","fieldClassName","resolvedDisabled","resolvedInvalid","resolvedReadOnly","cells","i","push","cellIndex","Provider","slot","OtpInput","Object","assign","Cell","Field"],"sourceRoot":"../../../../src","sources":["components/OtpInput/index.tsx"],"mappings":";;AACA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,SAASC,IAAI,QAAwC,cAAc;AACnE,SACEC,oBAAoB,EACpBC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,EACdC,mBAAmB,EACnBC,eAAe,EACfC,WAAW,QAGN,oBAAoB;AAC3B,SAASC,aAAa,EAAEC,EAAE,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,eAAe;AACpF,SAASC,KAAK,QAAyB,UAAU;AACjD,SAAiCC,kBAAkB,QAAQ,iBAAiB;AAC5E,SACEC,eAAe,EACfC,gBAAgB,EAChBC,eAAe,QAEV,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElB,MAAMC,KAAK,GAAG,WAAW;AAEzB,MAAMC,uBAAuB,GAAGA,CAAA,KAAMT,eAAe,CAACQ,KAAK,CAA+B;
|
|
1
|
+
{"version":3,"names":["forwardRef","useMemo","View","OtpCellIndexProvider","OtpInputField","OtpInputProvider","dataAttributes","mergeDataAttributes","useInputContext","useOtpInput","ParentContext","cn","useParentContext","useStyleContext","Input","inputFieldVariants","otpCellVariants","otpFieldVariants","otpRootVariants","jsx","_jsx","SCOPE","useOtpInputStyleContext","OtpStyledCell","className","children","variant","variantProp","size","sizeProp","props","ref","context","displayName","OtpStyledField","setIsFocused","onFocus","e","onBlur","OtpInputRoot","fullWidth","style","cellCount","value","onChangeText","onComplete","isDisabled","isInvalid","isReadOnly","smsOtpAutofill","filterInput","allowedCharacters","characterPattern","getCellProps","cellTestIdPrefix","accessibilityLabel","rest","otpContext","rootClassName","parent","ctx","fieldClassName","resolvedDisabled","resolvedInvalid","resolvedReadOnly","cells","i","push","cellIndex","Provider","slot","OtpInput","Object","assign","Cell","Field"],"sourceRoot":"../../../../src","sources":["components/OtpInput/index.tsx"],"mappings":";;AACA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,SAASC,IAAI,QAAwC,cAAc;AACnE,SACEC,oBAAoB,EACpBC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,EACdC,mBAAmB,EACnBC,eAAe,EACfC,WAAW,QAGN,oBAAoB;AAC3B,SAASC,aAAa,EAAEC,EAAE,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,eAAe;AACpF,SAASC,KAAK,QAAyB,UAAU;AACjD,SAAiCC,kBAAkB,QAAQ,iBAAiB;AAC5E,SACEC,eAAe,EACfC,gBAAgB,EAChBC,eAAe,QAEV,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElB,MAAMC,KAAK,GAAG,WAAW;AAEzB,MAAMC,uBAAuB,GAAGA,CAAA,KAAMT,eAAe,CAACQ,KAAK,CAA+B;AAW1F,MAAME,aAAa,gBAAGvB,UAAU,CAC9B,CACE;EAAEwB,SAAS;EAAEC,QAAQ;EAAEC,OAAO,EAAEC,WAAW;EAAEC,IAAI,EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EACvEC,GAAuB,KACpB;EACH,MAAMC,OAAO,GAAGV,uBAAuB,CAAC,CAAC;EACzC,MAAMI,OAAO,GAAGC,WAAW,IAAIK,OAAO,CAACN,OAAO,IAAI,SAAS;EAC3D,MAAME,IAAI,GAAGC,QAAQ,IAAIG,OAAO,CAACJ,IAAI,IAAI,SAAS;EAClD,oBACER,IAAA,CAACN,KAAK;IACJiB,GAAG,EAAEA,GAAI;IACTL,OAAO,EAAEA,OAAQ;IACjBE,IAAI,EAAEA,IAAK;IACX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,CAAC2D,QAAQ;IAAC1B,KAAK,EAAEiB,GAAI;IAAAnC,QAAA,eACjCL,IAAA,CAACf,gBAAgB;MAACsC,KAAK,EAAEc,UAAW;MAAAhC,QAAA,eAClCL,IAAA,CAAClB,IAAI;QACH6B,GAAG,EAAEA,GAAI;QACTP,SAAS,EAAEkC,aAAc;QACzBjB,KAAK,EAAEA,KAAM;QAAA,GACTe,IAAI;QAAA,GACJjD,mBAAmB,CAACiD,IAAI,EAAElD,cAAc,CAAC;UAAEgE,IAAI,EAAE;QAAY,CAAC,CAAC,CAAC;QAAA7C,QAAA,EAEnEwC;MAAK,CACF;IAAC,CACS;EAAC,CACG,CAAC;AAE7B,CACF,CAAC;AAED1B,YAAY,CAACN,WAAW,GAAG,UAAU;AAOrC,OAAO,MAAMsC,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAAClC,YAAY,EAAE;EAClDmC,IAAI,EAAEnD,aAAa;EACnBoD,KAAK,EAAEzC;AACT,CAAC,CAA8B","ignoreList":[]}
|
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { cloneElement, forwardRef, isValidElement, useMemo } from 'react';
|
|
4
|
-
import { Text } from 'react-native';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { Children, cloneElement, createContext, forwardRef, isValidElement, useContext, useMemo } from 'react';
|
|
4
|
+
import { Platform, Text, View } from 'react-native';
|
|
5
|
+
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
|
6
|
+
import { Check, KeyboardArrowDown, KeyboardArrowUp, Search } from '@cdx-ui/icons';
|
|
7
|
+
import { SelectContent as SelectContentPrimitive, SelectEmpty as SelectEmptyPrimitive, SelectItem as SelectItemPrimitive, SelectListbox as SelectListboxPrimitive, SelectRoot as SelectRootPrimitive, SelectProvider, SelectSearch as SelectSearchPrimitive, SelectSheetContent as SelectSheetContentPrimitive, SelectTrigger as SelectTriggerPrimitive, Slot, dataAttributes, mergeDataAttributes, useSelectContext, useSelectItemContext } from '@cdx-ui/primitives';
|
|
8
|
+
import { cn, FormControlContext, ParentContext, useParentContext, useStyleContext } from '@cdx-ui/utils';
|
|
9
|
+
import { BottomSheet } from '../BottomSheet';
|
|
10
|
+
import { checkboxIconVariants, checkboxIndicatorVariants } from '../Checkbox/styles';
|
|
8
11
|
import { Icon } from '../Icon';
|
|
12
|
+
import { Input } from '../Input';
|
|
9
13
|
import { Menu } from '../Menu';
|
|
10
|
-
import { menuItemVariants } from '../Menu/styles';
|
|
14
|
+
import { menuItemControlVariants, menuItemVariants } from '../Menu/styles';
|
|
15
|
+
import { PickerBottomSheetSurface, PickerSheetTextInput } from '../picker/surfaces';
|
|
11
16
|
import { positionToDataIcon } from '../../utils/positionToDataIcon';
|
|
12
|
-
import { selectIconVariants, selectTriggerVariants, selectValueVariants } from './styles';
|
|
17
|
+
import { selectBottomSheetListboxVariants, selectBottomSheetVariants, selectEmptyTextVariants, selectEmptyVariants, selectIconVariants, selectItemVariants, selectSearchListboxVariants, selectSearchVariants, selectTriggerVariants, selectValueVariants } from './styles';
|
|
13
18
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
19
|
const SCOPE = 'SELECT';
|
|
15
20
|
const useSelectStyleContext = () => useStyleContext(SCOPE);
|
|
21
|
+
const IS_WEB = Platform.OS === 'web';
|
|
22
|
+
|
|
23
|
+
/** `true` inside the native `Select.BottomSheet`, where `Select.Search` uses the sheet's input. */
|
|
24
|
+
const SelectSheetContext = /*#__PURE__*/createContext(false);
|
|
16
25
|
|
|
17
26
|
// =============================================================================
|
|
18
27
|
// STYLED ROOT
|
|
19
28
|
// =============================================================================
|
|
20
29
|
|
|
30
|
+
/**
|
|
31
|
+
* `type` narrows `value` / `defaultValue` / `onValueChange` to `string` (single, the default)
|
|
32
|
+
* or `string[]` (multiple).
|
|
33
|
+
*/
|
|
34
|
+
|
|
21
35
|
const SelectRoot = /*#__PURE__*/forwardRef(({
|
|
22
36
|
variant = 'outline',
|
|
23
37
|
size = 'default',
|
|
@@ -97,6 +111,11 @@ SelectTrigger.displayName = 'Select.Trigger';
|
|
|
97
111
|
// STYLED VALUE (styled-only)
|
|
98
112
|
// =============================================================================
|
|
99
113
|
|
|
114
|
+
/**
|
|
115
|
+
* `Intl.ListFormat` is not available on Hermes, so labels are joined with a fixed separator
|
|
116
|
+
* to keep the summary identical on iOS, Android, and web.
|
|
117
|
+
*/
|
|
118
|
+
const SELECTED_TEXT_SEPARATOR = ', ';
|
|
100
119
|
const SelectValue = /*#__PURE__*/forwardRef(({
|
|
101
120
|
asChild,
|
|
102
121
|
className,
|
|
@@ -109,13 +128,21 @@ const SelectValue = /*#__PURE__*/forwardRef(({
|
|
|
109
128
|
size
|
|
110
129
|
} = useSelectStyleContext();
|
|
111
130
|
const {
|
|
112
|
-
|
|
131
|
+
type,
|
|
113
132
|
items,
|
|
133
|
+
selectedValues,
|
|
114
134
|
invalid
|
|
115
135
|
} = useSelectContext();
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
const
|
|
136
|
+
const selectedItems = useMemo(() => items.filter(item => selectedValues.includes(item.value)), [items, selectedValues]);
|
|
137
|
+
const isPlaceholder = !selectedValues.some(selected => selected !== '');
|
|
138
|
+
const selectedText = selectedItems.map(item => item.label).join(SELECTED_TEXT_SEPARATOR);
|
|
139
|
+
const renderState = {
|
|
140
|
+
isPlaceholder,
|
|
141
|
+
selectedItems,
|
|
142
|
+
selectedText
|
|
143
|
+
};
|
|
144
|
+
const customDisplay = typeof children === 'function' ? children(renderState) : children;
|
|
145
|
+
const displayText = isPlaceholder ? placeholder : selectedText;
|
|
119
146
|
const computedClassName = cn(selectValueVariants({
|
|
120
147
|
size
|
|
121
148
|
}), className);
|
|
@@ -124,13 +151,14 @@ const SelectValue = /*#__PURE__*/forwardRef(({
|
|
|
124
151
|
ref: ref,
|
|
125
152
|
className: computedClassName,
|
|
126
153
|
style: style,
|
|
154
|
+
numberOfLines: type === 'multiple' ? 1 : undefined,
|
|
127
155
|
...props,
|
|
128
156
|
...mergeDataAttributes(props, dataAttributes({
|
|
129
157
|
slot: 'select-value',
|
|
130
|
-
placeholder:
|
|
158
|
+
placeholder: isPlaceholder,
|
|
131
159
|
invalid
|
|
132
160
|
})),
|
|
133
|
-
children:
|
|
161
|
+
children: customDisplay ?? displayText
|
|
134
162
|
});
|
|
135
163
|
});
|
|
136
164
|
SelectValue.displayName = 'Select.Value';
|
|
@@ -181,10 +209,125 @@ const SelectIcon = ({
|
|
|
181
209
|
};
|
|
182
210
|
SelectIcon.displayName = 'Select.Icon';
|
|
183
211
|
|
|
212
|
+
// =============================================================================
|
|
213
|
+
// STYLED SEARCH — composes Input inside the popup
|
|
214
|
+
// =============================================================================
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The search input sits inside the select's `Field` in the React tree but is not the field's
|
|
218
|
+
* control, so it must not pick up the field's id, label, validation, or label-press focus.
|
|
219
|
+
*/
|
|
220
|
+
const ISOLATED_FIELD = {};
|
|
221
|
+
const SelectSearch = /*#__PURE__*/forwardRef(({
|
|
222
|
+
asChild,
|
|
223
|
+
className,
|
|
224
|
+
style,
|
|
225
|
+
variant = 'subtle',
|
|
226
|
+
children,
|
|
227
|
+
...props
|
|
228
|
+
}, ref) => {
|
|
229
|
+
const {
|
|
230
|
+
size
|
|
231
|
+
} = useSelectStyleContext();
|
|
232
|
+
const inSheet = useContext(SelectSheetContext);
|
|
233
|
+
const slotData = dataAttributes({
|
|
234
|
+
slot: 'select-search'
|
|
235
|
+
});
|
|
236
|
+
if (asChild) {
|
|
237
|
+
return /*#__PURE__*/_jsx(FormControlContext.Provider, {
|
|
238
|
+
value: ISOLATED_FIELD,
|
|
239
|
+
children: /*#__PURE__*/_jsx(SelectSearchPrimitive, {
|
|
240
|
+
ref: ref,
|
|
241
|
+
asChild: true,
|
|
242
|
+
className: className,
|
|
243
|
+
style: style,
|
|
244
|
+
...props,
|
|
245
|
+
...mergeDataAttributes(props, slotData),
|
|
246
|
+
children: children
|
|
247
|
+
})
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
return /*#__PURE__*/_jsx(FormControlContext.Provider, {
|
|
251
|
+
value: ISOLATED_FIELD,
|
|
252
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
253
|
+
className: cn(selectSearchVariants(), className),
|
|
254
|
+
style: style,
|
|
255
|
+
...slotData,
|
|
256
|
+
children: /*#__PURE__*/_jsxs(Input, {
|
|
257
|
+
variant: variant,
|
|
258
|
+
size: size ?? 'default',
|
|
259
|
+
children: [/*#__PURE__*/_jsx(Input.Icon, {
|
|
260
|
+
as: Search
|
|
261
|
+
}), /*#__PURE__*/_jsx(SelectSearchPrimitive, {
|
|
262
|
+
ref: ref,
|
|
263
|
+
asChild: true,
|
|
264
|
+
...props,
|
|
265
|
+
children: inSheet ? /*#__PURE__*/_jsx(Input.Field, {
|
|
266
|
+
asChild: true,
|
|
267
|
+
children: /*#__PURE__*/_jsx(PickerSheetTextInput, {})
|
|
268
|
+
}) : /*#__PURE__*/_jsx(Input.Field, {})
|
|
269
|
+
})]
|
|
270
|
+
})
|
|
271
|
+
})
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
SelectSearch.displayName = 'Select.Search';
|
|
275
|
+
|
|
276
|
+
// =============================================================================
|
|
277
|
+
// STYLED EMPTY — shown when no option matches the search
|
|
278
|
+
// =============================================================================
|
|
279
|
+
|
|
280
|
+
const SelectEmpty = /*#__PURE__*/forwardRef(({
|
|
281
|
+
asChild,
|
|
282
|
+
className,
|
|
283
|
+
style,
|
|
284
|
+
children,
|
|
285
|
+
...props
|
|
286
|
+
}, ref) => {
|
|
287
|
+
const {
|
|
288
|
+
size
|
|
289
|
+
} = useSelectStyleContext();
|
|
290
|
+
return /*#__PURE__*/_jsx(SelectEmptyPrimitive, {
|
|
291
|
+
ref: ref,
|
|
292
|
+
asChild: asChild,
|
|
293
|
+
className: cn(selectEmptyVariants(), className),
|
|
294
|
+
style: style,
|
|
295
|
+
...props,
|
|
296
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
297
|
+
slot: 'select-empty'
|
|
298
|
+
})),
|
|
299
|
+
children: !asChild && typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
300
|
+
className: selectEmptyTextVariants({
|
|
301
|
+
size
|
|
302
|
+
}),
|
|
303
|
+
children: children
|
|
304
|
+
}) : children
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
SelectEmpty.displayName = 'Select.Empty';
|
|
308
|
+
|
|
184
309
|
// =============================================================================
|
|
185
310
|
// STYLED CONTENT — composes Menu surface (listbox semantics stay on primitive)
|
|
186
311
|
// =============================================================================
|
|
187
312
|
|
|
313
|
+
const isSlot = (child, slot) => /*#__PURE__*/isValidElement(child) && child.type === slot;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Sorts direct children into regions: `Select.Search` above a scrollable listbox of the
|
|
317
|
+
* remaining children, and `Select.Empty` below it. `Select.Search` and `Select.Empty` must be
|
|
318
|
+
* direct children: a `memo()`, HOC, or custom wrapper is not recognized and renders among the
|
|
319
|
+
* options. A second `Select.Search` or `Select.Empty` is dropped.
|
|
320
|
+
*/
|
|
321
|
+
function partitionPopupChildren(children) {
|
|
322
|
+
const childArray = Children.toArray(children);
|
|
323
|
+
return {
|
|
324
|
+
search: childArray.find(child => isSlot(child, SelectSearch)),
|
|
325
|
+
empty: childArray.find(child => isSlot(child, SelectEmpty)),
|
|
326
|
+
options: childArray.filter(child => !isSlot(child, SelectSearch) && !isSlot(child, SelectEmpty))
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** Without `asChild`, direct children are sorted into regions (see `partitionPopupChildren`). */
|
|
188
331
|
const SelectContent = /*#__PURE__*/forwardRef(({
|
|
189
332
|
asChild,
|
|
190
333
|
className,
|
|
@@ -192,6 +335,9 @@ const SelectContent = /*#__PURE__*/forwardRef(({
|
|
|
192
335
|
children,
|
|
193
336
|
...props
|
|
194
337
|
}, ref) => {
|
|
338
|
+
const slotData = mergeDataAttributes(props, dataAttributes({
|
|
339
|
+
slot: 'select-content'
|
|
340
|
+
}));
|
|
195
341
|
if (asChild) {
|
|
196
342
|
return /*#__PURE__*/_jsx(SelectContentPrimitive, {
|
|
197
343
|
ref: ref,
|
|
@@ -199,30 +345,182 @@ const SelectContent = /*#__PURE__*/forwardRef(({
|
|
|
199
345
|
className: className,
|
|
200
346
|
style: style,
|
|
201
347
|
...props,
|
|
202
|
-
...
|
|
203
|
-
slot: 'select-content'
|
|
204
|
-
})),
|
|
348
|
+
...slotData,
|
|
205
349
|
children: children
|
|
206
350
|
});
|
|
207
351
|
}
|
|
352
|
+
const {
|
|
353
|
+
search,
|
|
354
|
+
empty,
|
|
355
|
+
options
|
|
356
|
+
} = partitionPopupChildren(children);
|
|
208
357
|
return /*#__PURE__*/_jsx(SelectContentPrimitive, {
|
|
209
358
|
ref: ref,
|
|
210
359
|
asChild: true,
|
|
211
360
|
style: style,
|
|
212
361
|
...props,
|
|
213
|
-
...
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
362
|
+
...slotData,
|
|
363
|
+
children: search ? /*#__PURE__*/_jsxs(Menu.Content, {
|
|
364
|
+
asSurface: true,
|
|
365
|
+
className: className,
|
|
366
|
+
children: [search, /*#__PURE__*/_jsx(SelectListboxPrimitive, {
|
|
367
|
+
asChild: true,
|
|
368
|
+
children: /*#__PURE__*/_jsx(Menu.Content, {
|
|
369
|
+
asSurface: true,
|
|
370
|
+
scrollable: true,
|
|
371
|
+
className: selectSearchListboxVariants(),
|
|
372
|
+
children: options
|
|
373
|
+
})
|
|
374
|
+
}), empty]
|
|
375
|
+
}) : /*#__PURE__*/_jsxs(Menu.Content, {
|
|
217
376
|
asSurface: true,
|
|
218
377
|
scrollable: true,
|
|
219
378
|
className: className,
|
|
220
|
-
children:
|
|
379
|
+
children: [options, empty]
|
|
221
380
|
})
|
|
222
381
|
});
|
|
223
382
|
});
|
|
224
383
|
SelectContent.displayName = 'Select.Content';
|
|
225
384
|
|
|
385
|
+
// =============================================================================
|
|
386
|
+
// STYLED BOTTOM SHEET — native surface in place of Select.Content
|
|
387
|
+
// =============================================================================
|
|
388
|
+
|
|
389
|
+
const SAFE_AREA_FALLBACK = {
|
|
390
|
+
bottom: 0
|
|
391
|
+
};
|
|
392
|
+
const SelectNativeBottomSheet = /*#__PURE__*/forwardRef(({
|
|
393
|
+
asChild,
|
|
394
|
+
className,
|
|
395
|
+
children,
|
|
396
|
+
dismissAccessibilityLabel: _dismissAccessibilityLabel,
|
|
397
|
+
...props
|
|
398
|
+
}, ref) => {
|
|
399
|
+
const ctx = useSelectContext();
|
|
400
|
+
const insets = useContext(SafeAreaInsetsContext) ?? SAFE_AREA_FALLBACK;
|
|
401
|
+
const slotData = mergeDataAttributes(props, dataAttributes({
|
|
402
|
+
slot: 'select-bottom-sheet'
|
|
403
|
+
}));
|
|
404
|
+
const {
|
|
405
|
+
search,
|
|
406
|
+
empty,
|
|
407
|
+
options
|
|
408
|
+
} = partitionPopupChildren(children);
|
|
409
|
+
|
|
410
|
+
// The sheet renders in the BottomSheet.Provider portal, outside this tree, so the select
|
|
411
|
+
// context is provided again inside it.
|
|
412
|
+
return /*#__PURE__*/_jsx(PickerBottomSheetSurface, {
|
|
413
|
+
open: ctx.open && !ctx.native,
|
|
414
|
+
setOpen: ctx.setOpen,
|
|
415
|
+
fill: true
|
|
416
|
+
// gorhom makes the sheet one accessibility element by default, which hides the rows
|
|
417
|
+
// from VoiceOver.
|
|
418
|
+
,
|
|
419
|
+
accessible: false,
|
|
420
|
+
keyboardBehavior: "extend",
|
|
421
|
+
keyboardBlurBehavior: "restore",
|
|
422
|
+
children: /*#__PURE__*/_jsx(SelectProvider, {
|
|
423
|
+
value: ctx,
|
|
424
|
+
children: /*#__PURE__*/_jsx(SelectSheetContext.Provider, {
|
|
425
|
+
value: true,
|
|
426
|
+
children: asChild ? /*#__PURE__*/_jsx(SelectSheetContentPrimitive, {
|
|
427
|
+
ref: ref,
|
|
428
|
+
asChild: true,
|
|
429
|
+
...props,
|
|
430
|
+
...slotData,
|
|
431
|
+
children: children
|
|
432
|
+
}) : /*#__PURE__*/_jsxs(SelectSheetContentPrimitive, {
|
|
433
|
+
ref: ref,
|
|
434
|
+
className: cn(selectBottomSheetVariants(), className),
|
|
435
|
+
...props,
|
|
436
|
+
...slotData,
|
|
437
|
+
children: [search, /*#__PURE__*/_jsxs(BottomSheet.ScrollView, {
|
|
438
|
+
keyboardShouldPersistTaps: "handled",
|
|
439
|
+
keyboardDismissMode: "on-drag",
|
|
440
|
+
automaticallyAdjustKeyboardInsets: true,
|
|
441
|
+
contentContainerStyle: {
|
|
442
|
+
paddingBottom: insets.bottom
|
|
443
|
+
},
|
|
444
|
+
children: [/*#__PURE__*/_jsx(SelectListboxPrimitive, {
|
|
445
|
+
className: selectBottomSheetListboxVariants(),
|
|
446
|
+
children: options
|
|
447
|
+
}), empty]
|
|
448
|
+
})]
|
|
449
|
+
})
|
|
450
|
+
})
|
|
451
|
+
})
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Presents the options in a bottom sheet on iOS and Android, in place of `Select.Content`. The
|
|
457
|
+
* sheet keeps `Select.Search` and the results above the soft keyboard, and closes on swipe
|
|
458
|
+
* down, backdrop press, Android back, and the VoiceOver escape gesture without changing the
|
|
459
|
+
* value. On web it renders the `Select.Content` dropdown. Requires `BottomSheet.Provider`.
|
|
460
|
+
*/
|
|
461
|
+
const SelectBottomSheet = /*#__PURE__*/forwardRef((props, ref) => IS_WEB ? /*#__PURE__*/_jsx(SelectContent, {
|
|
462
|
+
ref: ref,
|
|
463
|
+
...props
|
|
464
|
+
}) : /*#__PURE__*/_jsx(SelectNativeBottomSheet, {
|
|
465
|
+
ref: ref,
|
|
466
|
+
...props
|
|
467
|
+
}));
|
|
468
|
+
SelectBottomSheet.displayName = 'Select.BottomSheet';
|
|
469
|
+
|
|
470
|
+
// =============================================================================
|
|
471
|
+
// STYLED ITEM CONTROL — Menu checkbox chrome driven by item selection
|
|
472
|
+
// =============================================================================
|
|
473
|
+
|
|
474
|
+
const SelectItemControl = ({
|
|
475
|
+
asChild,
|
|
476
|
+
className,
|
|
477
|
+
style,
|
|
478
|
+
children,
|
|
479
|
+
...props
|
|
480
|
+
}) => {
|
|
481
|
+
const {
|
|
482
|
+
checked
|
|
483
|
+
} = useSelectItemContext();
|
|
484
|
+
const fieldState = checked ? 'checked' : 'idle';
|
|
485
|
+
const hiddenProps = {
|
|
486
|
+
className: cn(menuItemControlVariants(), 'pointer-events-none', className),
|
|
487
|
+
style,
|
|
488
|
+
accessible: false,
|
|
489
|
+
accessibilityElementsHidden: true,
|
|
490
|
+
importantForAccessibility: 'no-hide-descendants',
|
|
491
|
+
'aria-hidden': true,
|
|
492
|
+
...props,
|
|
493
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
494
|
+
slot: 'select-item-control',
|
|
495
|
+
checked
|
|
496
|
+
}))
|
|
497
|
+
};
|
|
498
|
+
if (asChild) {
|
|
499
|
+
return /*#__PURE__*/_jsx(Slot, {
|
|
500
|
+
...hiddenProps,
|
|
501
|
+
children: children
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
return /*#__PURE__*/_jsx(View, {
|
|
505
|
+
...hiddenProps,
|
|
506
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
507
|
+
className: checkboxIndicatorVariants(),
|
|
508
|
+
...dataAttributes({
|
|
509
|
+
checked,
|
|
510
|
+
fieldState
|
|
511
|
+
}),
|
|
512
|
+
children: checked ? /*#__PURE__*/_jsx(Icon, {
|
|
513
|
+
as: Check,
|
|
514
|
+
className: checkboxIconVariants(),
|
|
515
|
+
accessibilityElementsHidden: true,
|
|
516
|
+
"aria-hidden": true
|
|
517
|
+
}) : null
|
|
518
|
+
})
|
|
519
|
+
});
|
|
520
|
+
};
|
|
521
|
+
SelectItemControl.displayName = 'Select.ItemControl';
|
|
522
|
+
const hasItemControl = children => Children.toArray(children).some(child => /*#__PURE__*/isValidElement(child) && child.type === SelectItemControl);
|
|
523
|
+
|
|
226
524
|
// =============================================================================
|
|
227
525
|
// STYLED ITEM — composes Menu item visuals (option semantics stay on primitive)
|
|
228
526
|
// =============================================================================
|
|
@@ -240,11 +538,11 @@ const SelectItem = /*#__PURE__*/forwardRef(({
|
|
|
240
538
|
size
|
|
241
539
|
} = useSelectStyleContext();
|
|
242
540
|
const {
|
|
243
|
-
|
|
541
|
+
isSelected
|
|
244
542
|
} = useSelectContext();
|
|
245
|
-
const checked =
|
|
246
|
-
const computedClassName = cn(menuItemVariants(), size === 'small' ? 'px-2.5 py-1.5' : undefined, className);
|
|
247
|
-
const selectedIndicator = indicator === undefined ? /*#__PURE__*/_jsx(Menu.ItemIndicator, {
|
|
543
|
+
const checked = isSelected(itemValue);
|
|
544
|
+
const computedClassName = cn(menuItemVariants(), selectItemVariants(), size === 'small' ? 'px-2.5 py-1.5' : undefined, className);
|
|
545
|
+
const selectedIndicator = indicator === undefined ? hasItemControl(children) ? null : /*#__PURE__*/_jsx(Menu.ItemIndicator, {
|
|
248
546
|
isChecked: checked
|
|
249
547
|
}) : checked ? indicator : null;
|
|
250
548
|
const itemChildren = asChild ? /*#__PURE__*/isValidElement(children) ? (/*#__PURE__*/cloneElement(children, undefined, children.props.children, selectedIndicator)) : children : /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -307,7 +605,11 @@ export const Select = Object.assign(SelectRoot, {
|
|
|
307
605
|
Value: SelectValue,
|
|
308
606
|
Icon: SelectIcon,
|
|
309
607
|
Content: SelectContent,
|
|
608
|
+
BottomSheet: SelectBottomSheet,
|
|
609
|
+
Search: SelectSearch,
|
|
610
|
+
Empty: SelectEmpty,
|
|
310
611
|
Item: SelectItem,
|
|
311
|
-
ItemLabel: SelectItemLabel
|
|
612
|
+
ItemLabel: SelectItemLabel,
|
|
613
|
+
ItemControl: SelectItemControl
|
|
312
614
|
});
|
|
313
615
|
//# sourceMappingURL=index.js.map
|