@seed-design/lynx-react 0.5.2 → 0.6.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/lib/components/Checkbox/Checkbox.d.ts +26 -0
- package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/components/Checkbox/Checkbox.jsx +1 -1
- package/lib/components/Icon/Icon.d.ts +5 -0
- package/lib/components/Icon/Icon.d.ts.map +1 -1
- package/lib/components/Icon/Icon.jsx +14 -3
- package/lib/components/MannerTemp/MannerTemp.d.ts +19 -0
- package/lib/components/MannerTemp/MannerTemp.d.ts.map +1 -0
- package/lib/components/MannerTemp/MannerTemp.jsx +47 -0
- package/lib/components/MannerTemp/index.d.ts +2 -0
- package/lib/components/MannerTemp/index.d.ts.map +1 -0
- package/lib/components/MannerTempBadge/MannerTempBadge.d.ts +13 -0
- package/lib/components/MannerTempBadge/MannerTempBadge.d.ts.map +1 -0
- package/lib/components/MannerTempBadge/MannerTempBadge.jsx +15 -0
- package/lib/components/MannerTempBadge/index.d.ts +2 -0
- package/lib/components/MannerTempBadge/index.d.ts.map +1 -0
- package/lib/components/NotificationBadge/NotificationBadge.d.ts +18 -0
- package/lib/components/NotificationBadge/NotificationBadge.d.ts.map +1 -0
- package/lib/components/NotificationBadge/NotificationBadge.jsx +34 -0
- package/lib/components/NotificationBadge/index.d.ts +2 -0
- package/lib/components/NotificationBadge/index.d.ts.map +1 -0
- package/lib/components/PageBanner/PageBanner.d.ts +35 -0
- package/lib/components/PageBanner/PageBanner.d.ts.map +1 -0
- package/lib/components/PageBanner/PageBanner.jsx +150 -0
- package/lib/components/PageBanner/PageBanner.namespace.d.ts +2 -0
- package/lib/components/PageBanner/PageBanner.namespace.d.ts.map +1 -0
- package/lib/components/PageBanner/PageBanner.namespace.js +14 -0
- package/lib/components/PageBanner/index.d.ts +3 -0
- package/lib/components/PageBanner/index.d.ts.map +1 -0
- package/lib/components/RadioGroup/RadioGroup.d.ts +9 -0
- package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/lib/components/RadioGroup/RadioGroup.jsx +1 -1
- package/lib/components/SegmentedControl/SegmentedControl.d.ts +27 -0
- package/lib/components/SegmentedControl/SegmentedControl.d.ts.map +1 -0
- package/lib/components/SegmentedControl/SegmentedControl.jsx +120 -0
- package/lib/components/SegmentedControl/SegmentedControl.namespace.d.ts +2 -0
- package/lib/components/SegmentedControl/SegmentedControl.namespace.d.ts.map +1 -0
- package/lib/components/SegmentedControl/SegmentedControl.namespace.js +10 -0
- package/lib/components/SegmentedControl/index.d.ts +3 -0
- package/lib/components/SegmentedControl/index.d.ts.map +1 -0
- package/lib/components/SelectBox/CheckSelectBox.namespace.d.ts +2 -0
- package/lib/components/SelectBox/CheckSelectBox.namespace.d.ts.map +1 -0
- package/lib/components/SelectBox/CheckSelectBox.namespace.js +17 -0
- package/lib/components/SelectBox/RadioSelectBox.namespace.d.ts +2 -0
- package/lib/components/SelectBox/RadioSelectBox.namespace.d.ts.map +1 -0
- package/lib/components/SelectBox/RadioSelectBox.namespace.js +15 -0
- package/lib/components/SelectBox/SelectBox.d.ts +85 -0
- package/lib/components/SelectBox/SelectBox.d.ts.map +1 -0
- package/lib/components/SelectBox/SelectBox.jsx +237 -0
- package/lib/components/SelectBox/index.d.ts +4 -0
- package/lib/components/SelectBox/index.d.ts.map +1 -0
- package/lib/components/index.d.ts +6 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/hooks/useIconColor.d.ts +3 -2
- package/lib/hooks/useIconColor.d.ts.map +1 -1
- package/lib/hooks/useIconColor.js +12 -4
- package/lib/index.js +11 -1
- package/package.json +3 -3
- package/src/components/Checkbox/Checkbox.tsx +1 -1
- package/src/components/Icon/Icon.test.tsx +25 -1
- package/src/components/Icon/Icon.tsx +22 -1
- package/src/components/MannerTemp/MannerTemp.test.tsx +41 -0
- package/src/components/MannerTemp/MannerTemp.tsx +85 -0
- package/src/components/MannerTemp/index.ts +1 -0
- package/src/components/MannerTempBadge/MannerTempBadge.test.tsx +35 -0
- package/src/components/MannerTempBadge/MannerTempBadge.tsx +34 -0
- package/src/components/MannerTempBadge/index.ts +1 -0
- package/src/components/NotificationBadge/NotificationBadge.test.tsx +28 -0
- package/src/components/NotificationBadge/NotificationBadge.tsx +81 -0
- package/src/components/NotificationBadge/index.ts +1 -0
- package/src/components/PageBanner/PageBanner.namespace.ts +16 -0
- package/src/components/PageBanner/PageBanner.test.tsx +124 -0
- package/src/components/PageBanner/PageBanner.tsx +340 -0
- package/src/components/PageBanner/index.ts +18 -0
- package/src/components/RadioGroup/RadioGroup.tsx +1 -1
- package/src/components/SegmentedControl/SegmentedControl.namespace.ts +8 -0
- package/src/components/SegmentedControl/SegmentedControl.test.tsx +81 -0
- package/src/components/SegmentedControl/SegmentedControl.tsx +236 -0
- package/src/components/SegmentedControl/index.ts +10 -0
- package/src/components/SelectBox/CheckSelectBox.namespace.ts +22 -0
- package/src/components/SelectBox/RadioSelectBox.namespace.ts +18 -0
- package/src/components/SelectBox/SelectBox.test.tsx +169 -0
- package/src/components/SelectBox/SelectBox.tsx +533 -0
- package/src/components/SelectBox/index.ts +3 -0
- package/src/components/index.ts +6 -0
- package/src/hooks/useIconColor.test.ts +37 -1
- package/src/hooks/useIconColor.ts +10 -5
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useControllableState } from "../../hooks/useControllableState.js";
|
|
2
|
+
import { usePressTap } from "../../hooks/usePressTap.js";
|
|
3
|
+
import { createSlotRecipeContext } from "../../utils/create-slot-recipe-context.jsx";
|
|
4
|
+
import * as React from "@lynx-js/react";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { segmentedControl } from "@seed-design/lynx-css/recipes/segmented-control";
|
|
7
|
+
//#region src/components/SegmentedControl/SegmentedControl.tsx
|
|
8
|
+
var SegmentedControlContext = React.createContext(null);
|
|
9
|
+
var { ClassNamesProvider, useClassNames } = createSlotRecipeContext(segmentedControl);
|
|
10
|
+
function useSegmentedControlContext(consumer) {
|
|
11
|
+
const context = React.useContext(SegmentedControlContext);
|
|
12
|
+
if (!context) throw new Error(`<${consumer}/> must be rendered inside <SegmentedControlRoot/>.`);
|
|
13
|
+
return context;
|
|
14
|
+
}
|
|
15
|
+
var SegmentedControlRoot = React.forwardRef((props, ref) => {
|
|
16
|
+
const { children, className, style, value: valueProp, defaultValue, disabled = false, onValueChange, "accessibility-element": accessibilityElement = true, "accessibility-role-description": accessibilityRoleDescription = "radiogroup", ...nativeProps } = props;
|
|
17
|
+
const [value, setValue] = useControllableState({
|
|
18
|
+
value: valueProp,
|
|
19
|
+
defaultValue,
|
|
20
|
+
onChange(nextValue) {
|
|
21
|
+
"background only";
|
|
22
|
+
if (nextValue !== void 0) onValueChange?.(nextValue);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const [items, setItems] = React.useState([]);
|
|
26
|
+
const registerItem = React.useCallback((itemValue) => {
|
|
27
|
+
setItems((current) => {
|
|
28
|
+
if (current.includes(itemValue)) return current;
|
|
29
|
+
return [...current, itemValue];
|
|
30
|
+
});
|
|
31
|
+
return () => {
|
|
32
|
+
"background only";
|
|
33
|
+
setItems((current) => current.filter((item) => item !== itemValue));
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
const selectValue = React.useCallback((nextValue) => {
|
|
37
|
+
if (!disabled) setValue(nextValue);
|
|
38
|
+
}, [disabled, setValue]);
|
|
39
|
+
const selectedIndex = items.indexOf(value ?? "");
|
|
40
|
+
const classNames = segmentedControl({ hasSelection: selectedIndex >= 0 });
|
|
41
|
+
const contextValue = React.useMemo(() => ({
|
|
42
|
+
value,
|
|
43
|
+
disabled,
|
|
44
|
+
items,
|
|
45
|
+
selectValue,
|
|
46
|
+
registerItem
|
|
47
|
+
}), [
|
|
48
|
+
value,
|
|
49
|
+
disabled,
|
|
50
|
+
items,
|
|
51
|
+
selectValue,
|
|
52
|
+
registerItem
|
|
53
|
+
]);
|
|
54
|
+
return <SegmentedControlContext.Provider value={contextValue}>
|
|
55
|
+
<ClassNamesProvider value={classNames}>
|
|
56
|
+
<view {...ref ? { ref } : {}} {...nativeProps} accessibility-element={accessibilityElement} accessibility-role-description={accessibilityRoleDescription} className={clsx(classNames.root, className)} style={{
|
|
57
|
+
"--segment-count": Math.max(items.length, 1).toString(),
|
|
58
|
+
"--segment-index": Math.max(selectedIndex, 0).toString(),
|
|
59
|
+
...style
|
|
60
|
+
}}>
|
|
61
|
+
{children}
|
|
62
|
+
</view>
|
|
63
|
+
</ClassNamesProvider>
|
|
64
|
+
</SegmentedControlContext.Provider>;
|
|
65
|
+
});
|
|
66
|
+
SegmentedControlRoot.displayName = "SegmentedControlRoot";
|
|
67
|
+
var SegmentedControlItem = React.forwardRef((props, ref) => {
|
|
68
|
+
const { children, className, style, value: itemValue, disabled: itemDisabled = false, bindtap, "main-thread:bindtap": mainThreadBindtap, "accessibility-element": accessibilityElement = true, "accessibility-label": accessibilityLabel, "accessibility-role-description": accessibilityRoleDescription = "radio", "accessibility-traits": accessibilityTraits, ...nativeProps } = props;
|
|
69
|
+
const context = useSegmentedControlContext("SegmentedControlItem");
|
|
70
|
+
const disabled = context.disabled || itemDisabled;
|
|
71
|
+
const selected = context.value === itemValue;
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
"background only";
|
|
74
|
+
return context.registerItem(itemValue);
|
|
75
|
+
}, [context.registerItem, itemValue]);
|
|
76
|
+
const handleTap = React.useCallback((...args) => {
|
|
77
|
+
"background only";
|
|
78
|
+
if (!selected) context.selectValue(itemValue);
|
|
79
|
+
bindtap?.(...args);
|
|
80
|
+
}, [
|
|
81
|
+
bindtap,
|
|
82
|
+
context.selectValue,
|
|
83
|
+
itemValue,
|
|
84
|
+
selected
|
|
85
|
+
]);
|
|
86
|
+
const pressSelectionRef = React.useRef(selected);
|
|
87
|
+
const { pressed, bindtouchstart, ...pressHandlers } = usePressTap({
|
|
88
|
+
disabled,
|
|
89
|
+
onTap: handleTap,
|
|
90
|
+
mainThreadOnTap: mainThreadBindtap
|
|
91
|
+
});
|
|
92
|
+
const handleTouchStart = React.useCallback((...args) => {
|
|
93
|
+
pressSelectionRef.current = selected;
|
|
94
|
+
bindtouchstart(...args);
|
|
95
|
+
}, [bindtouchstart, selected]);
|
|
96
|
+
const classes = segmentedControl({
|
|
97
|
+
selected,
|
|
98
|
+
disabled,
|
|
99
|
+
pressed
|
|
100
|
+
});
|
|
101
|
+
const pressStartClasses = segmentedControl({
|
|
102
|
+
selected: pressSelectionRef.current,
|
|
103
|
+
disabled,
|
|
104
|
+
pressed
|
|
105
|
+
});
|
|
106
|
+
const label = typeof children === "string" || typeof children === "number" ? String(children) : void 0;
|
|
107
|
+
return <view {...ref ? { ref } : {}} {...nativeProps} bindtouchstart={handleTouchStart} {...pressHandlers} accessibility-element={accessibilityElement} accessibility-label={accessibilityLabel ?? label} accessibility-role-description={accessibilityRoleDescription} accessibility-value={selected ? "selected" : "not selected"} accessibility-traits={disabled ? "disabled" : selected ? "selected" : accessibilityTraits ?? "button"} className={clsx(classes.item, className)} style={style}>
|
|
108
|
+
<view accessibility-elements-hidden={true} className={pressStartClasses.itemBackground} />
|
|
109
|
+
<text className={classes.label}>{children}</text>
|
|
110
|
+
</view>;
|
|
111
|
+
});
|
|
112
|
+
SegmentedControlItem.displayName = "SegmentedControlItem";
|
|
113
|
+
var SegmentedControlIndicator = React.forwardRef((props, ref) => {
|
|
114
|
+
const { className, style, ...nativeProps } = props;
|
|
115
|
+
const classNames = useClassNames();
|
|
116
|
+
return <view {...ref ? { ref } : {}} {...nativeProps} accessibility-elements-hidden={true} className={clsx(classNames.indicator, className)} style={style} />;
|
|
117
|
+
});
|
|
118
|
+
SegmentedControlIndicator.displayName = "SegmentedControlIndicator";
|
|
119
|
+
//#endregion
|
|
120
|
+
export { SegmentedControlIndicator, SegmentedControlItem, SegmentedControlRoot };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { SegmentedControlIndicator as Indicator, SegmentedControlItem as Item, SegmentedControlRoot as Root, type SegmentedControlIndicatorProps as IndicatorProps, type SegmentedControlItemProps as ItemProps, type SegmentedControlRootProps as RootProps, } from './SegmentedControl';
|
|
2
|
+
//# sourceMappingURL=SegmentedControl.namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControl.namespace.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedControl/SegmentedControl.namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,IAAI,SAAS,EACtC,oBAAoB,IAAI,IAAI,EAC5B,oBAAoB,IAAI,IAAI,EAC5B,KAAK,8BAA8B,IAAI,cAAc,EACrD,KAAK,yBAAyB,IAAI,SAAS,EAC3C,KAAK,yBAAyB,IAAI,SAAS,GAC5C,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { SegmentedControlIndicator, SegmentedControlItem, SegmentedControlRoot } from "./SegmentedControl.jsx";
|
|
3
|
+
//#region src/components/SegmentedControl/SegmentedControl.namespace.ts
|
|
4
|
+
var SegmentedControl_namespace_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
Indicator: () => SegmentedControlIndicator,
|
|
6
|
+
Item: () => SegmentedControlItem,
|
|
7
|
+
Root: () => SegmentedControlRoot
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { SegmentedControl_namespace_exports };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { SegmentedControlIndicator, SegmentedControlItem, SegmentedControlRoot, type SegmentedControlIndicatorProps, type SegmentedControlItemProps, type SegmentedControlRootProps, } from './SegmentedControl';
|
|
2
|
+
export * as SegmentedControl from './SegmentedControl.namespace';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedControl/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,GAC/B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,gBAAgB,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { CheckSelectBoxBody as Body, CheckSelectBoxCheckmarkControl as CheckmarkControl, CheckSelectBoxCheckmarkIcon as CheckmarkIcon, CheckSelectBoxContent as Content, CheckSelectBoxDescription as Description, CheckSelectBoxFooter as Footer, CheckSelectBoxGroup as Group, CheckSelectBoxLabel as Label, CheckSelectBoxRoot as Root, CheckSelectBoxTrigger as Trigger, type CheckSelectBoxBodyProps as BodyProps, type CheckSelectBoxCheckmarkControlProps as CheckmarkControlProps, type CheckSelectBoxCheckmarkIconProps as CheckmarkIconProps, type CheckSelectBoxContentProps as ContentProps, type CheckSelectBoxDescriptionProps as DescriptionProps, type CheckSelectBoxFooterProps as FooterProps, type CheckSelectBoxGroupProps as GroupProps, type CheckSelectBoxLabelProps as LabelProps, type CheckSelectBoxRootProps as RootProps, type CheckSelectBoxTriggerProps as TriggerProps, } from './SelectBox';
|
|
2
|
+
//# sourceMappingURL=CheckSelectBox.namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckSelectBox.namespace.d.ts","sourceRoot":"","sources":["../../../src/components/SelectBox/CheckSelectBox.namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,IAAI,IAAI,EAC1B,8BAA8B,IAAI,gBAAgB,EAClD,2BAA2B,IAAI,aAAa,EAC5C,qBAAqB,IAAI,OAAO,EAChC,yBAAyB,IAAI,WAAW,EACxC,oBAAoB,IAAI,MAAM,EAC9B,mBAAmB,IAAI,KAAK,EAC5B,mBAAmB,IAAI,KAAK,EAC5B,kBAAkB,IAAI,IAAI,EAC1B,qBAAqB,IAAI,OAAO,EAChC,KAAK,uBAAuB,IAAI,SAAS,EACzC,KAAK,mCAAmC,IAAI,qBAAqB,EACjE,KAAK,gCAAgC,IAAI,kBAAkB,EAC3D,KAAK,0BAA0B,IAAI,YAAY,EAC/C,KAAK,8BAA8B,IAAI,gBAAgB,EACvD,KAAK,yBAAyB,IAAI,WAAW,EAC7C,KAAK,wBAAwB,IAAI,UAAU,EAC3C,KAAK,wBAAwB,IAAI,UAAU,EAC3C,KAAK,uBAAuB,IAAI,SAAS,EACzC,KAAK,0BAA0B,IAAI,YAAY,GAChD,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { CheckSelectBoxBody, CheckSelectBoxCheckmarkControl, CheckSelectBoxCheckmarkIcon, CheckSelectBoxContent, CheckSelectBoxDescription, CheckSelectBoxFooter, CheckSelectBoxGroup, CheckSelectBoxLabel, CheckSelectBoxRoot, CheckSelectBoxTrigger } from "./SelectBox.jsx";
|
|
3
|
+
//#region src/components/SelectBox/CheckSelectBox.namespace.ts
|
|
4
|
+
var CheckSelectBox_namespace_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
Body: () => CheckSelectBoxBody,
|
|
6
|
+
CheckmarkControl: () => CheckSelectBoxCheckmarkControl,
|
|
7
|
+
CheckmarkIcon: () => CheckSelectBoxCheckmarkIcon,
|
|
8
|
+
Content: () => CheckSelectBoxContent,
|
|
9
|
+
Description: () => CheckSelectBoxDescription,
|
|
10
|
+
Footer: () => CheckSelectBoxFooter,
|
|
11
|
+
Group: () => CheckSelectBoxGroup,
|
|
12
|
+
Label: () => CheckSelectBoxLabel,
|
|
13
|
+
Root: () => CheckSelectBoxRoot,
|
|
14
|
+
Trigger: () => CheckSelectBoxTrigger
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
export { CheckSelectBox_namespace_exports };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { RadioSelectBoxBody as Body, RadioSelectBoxContent as Content, RadioSelectBoxDescription as Description, RadioSelectBoxFooter as Footer, RadioSelectBoxGroup as Group, RadioSelectBoxItem as Item, RadioSelectBoxLabel as Label, RadioSelectBoxTrigger as Trigger, type RadioSelectBoxBodyProps as BodyProps, type RadioSelectBoxContentProps as ContentProps, type RadioSelectBoxDescriptionProps as DescriptionProps, type RadioSelectBoxFooterProps as FooterProps, type RadioSelectBoxGroupProps as GroupProps, type RadioSelectBoxItemProps as ItemProps, type RadioSelectBoxLabelProps as LabelProps, type RadioSelectBoxTriggerProps as TriggerProps, } from './SelectBox';
|
|
2
|
+
//# sourceMappingURL=RadioSelectBox.namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioSelectBox.namespace.d.ts","sourceRoot":"","sources":["../../../src/components/SelectBox/RadioSelectBox.namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,IAAI,IAAI,EAC1B,qBAAqB,IAAI,OAAO,EAChC,yBAAyB,IAAI,WAAW,EACxC,oBAAoB,IAAI,MAAM,EAC9B,mBAAmB,IAAI,KAAK,EAC5B,kBAAkB,IAAI,IAAI,EAC1B,mBAAmB,IAAI,KAAK,EAC5B,qBAAqB,IAAI,OAAO,EAChC,KAAK,uBAAuB,IAAI,SAAS,EACzC,KAAK,0BAA0B,IAAI,YAAY,EAC/C,KAAK,8BAA8B,IAAI,gBAAgB,EACvD,KAAK,yBAAyB,IAAI,WAAW,EAC7C,KAAK,wBAAwB,IAAI,UAAU,EAC3C,KAAK,uBAAuB,IAAI,SAAS,EACzC,KAAK,wBAAwB,IAAI,UAAU,EAC3C,KAAK,0BAA0B,IAAI,YAAY,GAChD,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { RadioSelectBoxBody, RadioSelectBoxContent, RadioSelectBoxDescription, RadioSelectBoxFooter, RadioSelectBoxGroup, RadioSelectBoxItem, RadioSelectBoxLabel, RadioSelectBoxTrigger } from "./SelectBox.jsx";
|
|
3
|
+
//#region src/components/SelectBox/RadioSelectBox.namespace.ts
|
|
4
|
+
var RadioSelectBox_namespace_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
Body: () => RadioSelectBoxBody,
|
|
6
|
+
Content: () => RadioSelectBoxContent,
|
|
7
|
+
Description: () => RadioSelectBoxDescription,
|
|
8
|
+
Footer: () => RadioSelectBoxFooter,
|
|
9
|
+
Group: () => RadioSelectBoxGroup,
|
|
10
|
+
Item: () => RadioSelectBoxItem,
|
|
11
|
+
Label: () => RadioSelectBoxLabel,
|
|
12
|
+
Trigger: () => RadioSelectBoxTrigger
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { RadioSelectBox_namespace_exports };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { SelectBoxVariantProps } from '@seed-design/lynx-css/recipes/select-box';
|
|
2
|
+
import { LynxAccessibilityProps, LynxStyledElementProps } from '../../types';
|
|
3
|
+
import { CheckboxRootProps } from '../Checkbox/Checkbox';
|
|
4
|
+
import { InternalIconProps } from '../Icon/Icon';
|
|
5
|
+
import { RadioGroupItemProps } from '../RadioGroup/RadioGroup';
|
|
6
|
+
import * as React from "@lynx-js/react";
|
|
7
|
+
/**
|
|
8
|
+
* @platform Lynx
|
|
9
|
+
*
|
|
10
|
+
* 웹 대비 미지원 기능:
|
|
11
|
+
* - HiddenInput / name / required / invalid: Lynx에 native form 제출 모델이 없음
|
|
12
|
+
* - focus / focusVisible: Lynx에 키보드 포커스 개념이 없음
|
|
13
|
+
* - DOM field wrapper: Lynx Registry는 label/error 연결용 wrapper를 제공하지 않음
|
|
14
|
+
*/
|
|
15
|
+
type FooterVisibility = "when-selected" | "when-not-selected" | "always";
|
|
16
|
+
type PublicSelectBoxVariantProps = Omit<SelectBoxVariantProps, "selected" | "pressed" | "disabled" | "footerOpen">;
|
|
17
|
+
export interface SelectBoxGroupProps extends LynxStyledElementProps {
|
|
18
|
+
/**
|
|
19
|
+
* 열 개수입니다. 2 이상이면 자식 Select Box의 기본 layout이 vertical이 됩니다.
|
|
20
|
+
* @default 1
|
|
21
|
+
*/
|
|
22
|
+
columns?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface CheckSelectBoxGroupProps extends SelectBoxGroupProps {
|
|
25
|
+
}
|
|
26
|
+
export declare const CheckSelectBoxGroup: React.ForwardRefExoticComponent<SelectBoxGroupProps & React.RefAttributes<unknown>>;
|
|
27
|
+
export interface RadioSelectBoxGroupProps extends SelectBoxGroupProps {
|
|
28
|
+
}
|
|
29
|
+
export declare const RadioSelectBoxGroup: React.ForwardRefExoticComponent<SelectBoxGroupProps & React.RefAttributes<unknown>>;
|
|
30
|
+
export interface CheckSelectBoxRootProps extends PublicSelectBoxVariantProps, LynxStyledElementProps, LynxAccessibilityProps, Pick<CheckboxRootProps, "checked" | "defaultChecked" | "indeterminate" | "disabled" | "onCheckedChange"> {
|
|
31
|
+
/** @default "when-selected" */
|
|
32
|
+
footerVisibility?: FooterVisibility;
|
|
33
|
+
}
|
|
34
|
+
export declare const CheckSelectBoxRoot: React.ForwardRefExoticComponent<CheckSelectBoxRootProps & React.RefAttributes<unknown>>;
|
|
35
|
+
export interface RadioSelectBoxItemProps extends PublicSelectBoxVariantProps, LynxStyledElementProps, LynxAccessibilityProps, Pick<RadioGroupItemProps, "value" | "disabled"> {
|
|
36
|
+
/** @default "when-selected" */
|
|
37
|
+
footerVisibility?: FooterVisibility;
|
|
38
|
+
}
|
|
39
|
+
export declare const RadioSelectBoxItem: React.ForwardRefExoticComponent<RadioSelectBoxItemProps & React.RefAttributes<unknown>>;
|
|
40
|
+
export interface CheckSelectBoxTriggerProps extends LynxStyledElementProps {
|
|
41
|
+
}
|
|
42
|
+
export declare const CheckSelectBoxTrigger: React.ForwardRefExoticComponent<LynxStyledElementProps & React.RefAttributes<unknown>>;
|
|
43
|
+
export interface CheckSelectBoxContentProps extends LynxStyledElementProps {
|
|
44
|
+
}
|
|
45
|
+
export declare const CheckSelectBoxContent: React.ForwardRefExoticComponent<LynxStyledElementProps & React.RefAttributes<unknown>>;
|
|
46
|
+
export interface CheckSelectBoxBodyProps extends LynxStyledElementProps {
|
|
47
|
+
}
|
|
48
|
+
export declare const CheckSelectBoxBody: React.ForwardRefExoticComponent<LynxStyledElementProps & React.RefAttributes<unknown>>;
|
|
49
|
+
export interface CheckSelectBoxLabelProps extends LynxStyledElementProps {
|
|
50
|
+
}
|
|
51
|
+
export declare const CheckSelectBoxLabel: React.ForwardRefExoticComponent<LynxStyledElementProps & React.RefAttributes<unknown>>;
|
|
52
|
+
export interface CheckSelectBoxDescriptionProps extends LynxStyledElementProps {
|
|
53
|
+
}
|
|
54
|
+
export declare const CheckSelectBoxDescription: React.ForwardRefExoticComponent<LynxStyledElementProps & React.RefAttributes<unknown>>;
|
|
55
|
+
export interface RadioSelectBoxTriggerProps extends LynxStyledElementProps {
|
|
56
|
+
}
|
|
57
|
+
export declare const RadioSelectBoxTrigger: React.ForwardRefExoticComponent<LynxStyledElementProps & React.RefAttributes<unknown>>;
|
|
58
|
+
export interface RadioSelectBoxContentProps extends LynxStyledElementProps {
|
|
59
|
+
}
|
|
60
|
+
export declare const RadioSelectBoxContent: React.ForwardRefExoticComponent<LynxStyledElementProps & React.RefAttributes<unknown>>;
|
|
61
|
+
export interface RadioSelectBoxBodyProps extends LynxStyledElementProps {
|
|
62
|
+
}
|
|
63
|
+
export declare const RadioSelectBoxBody: React.ForwardRefExoticComponent<LynxStyledElementProps & React.RefAttributes<unknown>>;
|
|
64
|
+
export interface RadioSelectBoxLabelProps extends LynxStyledElementProps {
|
|
65
|
+
}
|
|
66
|
+
export declare const RadioSelectBoxLabel: React.ForwardRefExoticComponent<LynxStyledElementProps & React.RefAttributes<unknown>>;
|
|
67
|
+
export interface RadioSelectBoxDescriptionProps extends LynxStyledElementProps {
|
|
68
|
+
}
|
|
69
|
+
export declare const RadioSelectBoxDescription: React.ForwardRefExoticComponent<LynxStyledElementProps & React.RefAttributes<unknown>>;
|
|
70
|
+
export interface SelectBoxFooterProps extends LynxStyledElementProps, LynxAccessibilityProps {
|
|
71
|
+
}
|
|
72
|
+
export interface CheckSelectBoxFooterProps extends SelectBoxFooterProps {
|
|
73
|
+
}
|
|
74
|
+
export declare const CheckSelectBoxFooter: React.ForwardRefExoticComponent<SelectBoxFooterProps & React.RefAttributes<unknown>>;
|
|
75
|
+
export interface RadioSelectBoxFooterProps extends SelectBoxFooterProps {
|
|
76
|
+
}
|
|
77
|
+
export declare const RadioSelectBoxFooter: React.ForwardRefExoticComponent<SelectBoxFooterProps & React.RefAttributes<unknown>>;
|
|
78
|
+
export interface CheckSelectBoxCheckmarkControlProps extends LynxStyledElementProps {
|
|
79
|
+
}
|
|
80
|
+
export declare const CheckSelectBoxCheckmarkControl: React.ForwardRefExoticComponent<CheckSelectBoxCheckmarkControlProps & React.RefAttributes<unknown>>;
|
|
81
|
+
export interface CheckSelectBoxCheckmarkIconProps extends Omit<InternalIconProps, "deps"> {
|
|
82
|
+
}
|
|
83
|
+
export declare const CheckSelectBoxCheckmarkIcon: React.ForwardRefExoticComponent<CheckSelectBoxCheckmarkIconProps & React.RefAttributes<unknown>>;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=SelectBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectBox.d.ts","sourceRoot":"","sources":["../../../src/components/SelectBox/SelectBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAa,KAAK,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAOjG,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EAIvB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAgB,KAAK,iBAAiB,EAAsB,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAkC,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,EAEL,KAAK,mBAAmB,EAEzB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;GAOG;AAEH,KAAK,gBAAgB,GAAG,eAAe,GAAG,mBAAmB,GAAG,QAAQ,CAAC;AACzE,KAAK,2BAA2B,GAAG,IAAI,CACrC,qBAAqB,EACrB,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CACnD,CAAC;AAwEF,MAAM,WAAW,mBAAoB,SAAQ,sBAAsB;IACjE;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAsBD,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;CAAG;AACxE,eAAO,MAAM,mBAAmB,qFAAiB,CAAC;AAElD,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;CAAG;AACxE,eAAO,MAAM,mBAAmB,qFAAiB,CAAC;AAIlD,MAAM,WAAW,uBACf,SAAQ,2BAA2B,EACjC,sBAAsB,EACtB,sBAAsB,EACtB,IAAI,CACF,iBAAiB,EACjB,SAAS,GAAG,gBAAgB,GAAG,eAAe,GAAG,UAAU,GAAG,iBAAiB,CAChF;IACH,+BAA+B;IAC/B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAkCD,eAAO,MAAM,kBAAkB,yFA6C9B,CAAC;AAKF,MAAM,WAAW,uBACf,SAAQ,2BAA2B,EACjC,sBAAsB,EACtB,sBAAsB,EACtB,IAAI,CAAC,mBAAmB,EAAE,OAAO,GAAG,UAAU,CAAC;IACjD,+BAA+B;IAC/B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AA4BD,eAAO,MAAM,kBAAkB,yFAuC9B,CAAC;AAoEF,MAAM,WAAW,0BAA2B,SAAQ,sBAAsB;CAAG;AAC7E,eAAO,MAAM,qBAAqB,wFAAqD,CAAC;AACxF,MAAM,WAAW,0BAA2B,SAAQ,sBAAsB;CAAG;AAC7E,eAAO,MAAM,qBAAqB,wFAAqD,CAAC;AACxF,MAAM,WAAW,uBAAwB,SAAQ,sBAAsB;CAAG;AAC1E,eAAO,MAAM,kBAAkB,wFAA+C,CAAC;AAC/E,MAAM,WAAW,wBAAyB,SAAQ,sBAAsB;CAAG;AAC3E,eAAO,MAAM,mBAAmB,wFAAyC,CAAC;AAC1E,MAAM,WAAW,8BAA+B,SAAQ,sBAAsB;CAAG;AACjF,eAAO,MAAM,yBAAyB,wFAA6D,CAAC;AAEpG,MAAM,WAAW,0BAA2B,SAAQ,sBAAsB;CAAG;AAC7E,eAAO,MAAM,qBAAqB,wFAAqD,CAAC;AACxF,MAAM,WAAW,0BAA2B,SAAQ,sBAAsB;CAAG;AAC7E,eAAO,MAAM,qBAAqB,wFAAqD,CAAC;AACxF,MAAM,WAAW,uBAAwB,SAAQ,sBAAsB;CAAG;AAC1E,eAAO,MAAM,kBAAkB,wFAA+C,CAAC;AAC/E,MAAM,WAAW,wBAAyB,SAAQ,sBAAsB;CAAG;AAC3E,eAAO,MAAM,mBAAmB,wFAAyC,CAAC;AAC1E,MAAM,WAAW,8BAA+B,SAAQ,sBAAsB;CAAG;AACjF,eAAO,MAAM,yBAAyB,wFAA6D,CAAC;AAIpG,MAAM,WAAW,oBAAqB,SAAQ,sBAAsB,EAAE,sBAAsB;CAAG;AAsD/F,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;CAAG;AAC1E,eAAO,MAAM,oBAAoB,sFAAkB,CAAC;AACpD,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;CAAG;AAC1E,eAAO,MAAM,oBAAoB,sFAAkB,CAAC;AAWpD,MAAM,WAAW,mCAAoC,SAAQ,sBAAsB;CAAG;AAEtF,eAAO,MAAM,8BAA8B,qGAyBzC,CAAC;AAGH,MAAM,WAAW,gCAAiC,SAAQ,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC;CAAG;AAE5F,eAAO,MAAM,2BAA2B,kGAwBtC,CAAC"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { createSlotRecipeContext } from "../../utils/create-slot-recipe-context.jsx";
|
|
2
|
+
import { IconSlotProvider, InternalIcon } from "../Icon/Icon.jsx";
|
|
3
|
+
import { CheckboxRoot, useCheckboxContext } from "../Checkbox/Checkbox.jsx";
|
|
4
|
+
import { RadioGroupItem, useRadioGroupItemContext } from "../RadioGroup/RadioGroup.jsx";
|
|
5
|
+
import * as React from "@lynx-js/react";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { selectBox } from "@seed-design/lynx-css/recipes/select-box";
|
|
8
|
+
import { selectBoxCheckmark } from "@seed-design/lynx-css/recipes/select-box-checkmark";
|
|
9
|
+
import { selectBoxGroup } from "@seed-design/lynx-css/recipes/select-box-group";
|
|
10
|
+
//#region src/components/SelectBox/SelectBox.tsx
|
|
11
|
+
var SelectBoxRuntimeContext = React.createContext(null);
|
|
12
|
+
var SelectBoxLayoutContext = React.createContext({});
|
|
13
|
+
var { ClassNamesProvider, useClassNames } = createSlotRecipeContext(selectBox);
|
|
14
|
+
function useSelectBoxRuntimeContext(consumer) {
|
|
15
|
+
const context = React.useContext(SelectBoxRuntimeContext);
|
|
16
|
+
if (!context) throw new Error(`<${consumer}/> must be rendered inside a SelectBox root or item.`);
|
|
17
|
+
return context;
|
|
18
|
+
}
|
|
19
|
+
function SelectBoxSurface({ children, className, style, accessibilityProps }) {
|
|
20
|
+
const context = useSelectBoxRuntimeContext("SelectBoxSurface");
|
|
21
|
+
const footerOpen = context.footerVisibility === "always" || (context.footerVisibility === "when-selected" ? context.selected : !context.selected);
|
|
22
|
+
const classes = selectBox({
|
|
23
|
+
...context.variantProps,
|
|
24
|
+
selected: context.selected,
|
|
25
|
+
pressed: context.pressed,
|
|
26
|
+
disabled: context.disabled,
|
|
27
|
+
footerOpen
|
|
28
|
+
});
|
|
29
|
+
return <ClassNamesProvider value={classes}>
|
|
30
|
+
<IconSlotProvider value={{
|
|
31
|
+
classNames: { prefixIcon: classes.prefixIcon },
|
|
32
|
+
deps: [
|
|
33
|
+
context.selected,
|
|
34
|
+
context.pressed,
|
|
35
|
+
context.disabled
|
|
36
|
+
]
|
|
37
|
+
}}>
|
|
38
|
+
<view className={clsx(classes.root, className)} style={style} accessibility-element={true} accessibility-role-description={context.accessibilityRole} accessibility-value={context.selected ? "selected" : "not selected"} accessibility-traits={context.disabled ? "disabled" : void 0} {...accessibilityProps}>
|
|
39
|
+
{children}
|
|
40
|
+
<view className={classes.selectedStroke} accessibility-elements-hidden={true} />
|
|
41
|
+
</view>
|
|
42
|
+
</IconSlotProvider>
|
|
43
|
+
</ClassNamesProvider>;
|
|
44
|
+
}
|
|
45
|
+
var SelectBoxGroup = React.forwardRef((props, ref) => {
|
|
46
|
+
const { children, columns = 1, className, style, ...nativeProps } = props;
|
|
47
|
+
const classes = selectBoxGroup({ multiColumn: columns > 1 });
|
|
48
|
+
const layout = columns > 1 ? "vertical" : "horizontal";
|
|
49
|
+
return <SelectBoxLayoutContext.Provider value={{ layout }}>
|
|
50
|
+
<view {...ref ? { ref } : {}} className={clsx(classes, className)} style={{
|
|
51
|
+
...style,
|
|
52
|
+
gridTemplateColumns: `repeat(${columns}, 1fr)`
|
|
53
|
+
}} {...nativeProps}>
|
|
54
|
+
{children}
|
|
55
|
+
</view>
|
|
56
|
+
</SelectBoxLayoutContext.Provider>;
|
|
57
|
+
});
|
|
58
|
+
SelectBoxGroup.displayName = "SelectBoxGroup";
|
|
59
|
+
var CheckSelectBoxGroup = SelectBoxGroup;
|
|
60
|
+
var RadioSelectBoxGroup = SelectBoxGroup;
|
|
61
|
+
function CheckSelectBoxSurface(props) {
|
|
62
|
+
const checkbox = useCheckboxContext("CheckSelectBoxRoot");
|
|
63
|
+
const contextValue = React.useMemo(() => ({
|
|
64
|
+
selected: checkbox.checked,
|
|
65
|
+
pressed: checkbox.pressed,
|
|
66
|
+
disabled: checkbox.disabled,
|
|
67
|
+
footerVisibility: props.footerVisibility,
|
|
68
|
+
variantProps: props.variantProps,
|
|
69
|
+
accessibilityRole: "checkbox"
|
|
70
|
+
}), [
|
|
71
|
+
checkbox.checked,
|
|
72
|
+
checkbox.disabled,
|
|
73
|
+
checkbox.pressed,
|
|
74
|
+
props.footerVisibility,
|
|
75
|
+
props.variantProps
|
|
76
|
+
]);
|
|
77
|
+
return <SelectBoxRuntimeContext.Provider value={contextValue}>
|
|
78
|
+
<SelectBoxSurface {...props} />
|
|
79
|
+
</SelectBoxRuntimeContext.Provider>;
|
|
80
|
+
}
|
|
81
|
+
var CheckSelectBoxRoot = React.forwardRef((props, ref) => {
|
|
82
|
+
const { children, className, style, checked, defaultChecked, indeterminate, disabled, onCheckedChange, footerVisibility = "when-selected", ...restProps } = props;
|
|
83
|
+
const inheritedVariantProps = React.useContext(SelectBoxLayoutContext);
|
|
84
|
+
const [variantProps, accessibilityProps] = selectBox.splitVariantProps(restProps);
|
|
85
|
+
const resolvedVariantProps = {
|
|
86
|
+
...variantProps,
|
|
87
|
+
layout: variantProps.layout ?? inheritedVariantProps.layout
|
|
88
|
+
};
|
|
89
|
+
const interactionRootClassName = selectBox(resolvedVariantProps).interactionRoot;
|
|
90
|
+
return <CheckboxRoot ref={ref} className={interactionRootClassName} checked={checked} defaultChecked={defaultChecked} indeterminate={indeterminate} disabled={disabled} onCheckedChange={onCheckedChange} accessibility-element={false}>
|
|
91
|
+
<CheckSelectBoxSurface className={className} style={style} footerVisibility={footerVisibility} variantProps={resolvedVariantProps} accessibilityProps={accessibilityProps}>
|
|
92
|
+
{children}
|
|
93
|
+
</CheckSelectBoxSurface>
|
|
94
|
+
</CheckboxRoot>;
|
|
95
|
+
});
|
|
96
|
+
CheckSelectBoxRoot.displayName = "CheckSelectBoxRoot";
|
|
97
|
+
function RadioSelectBoxSurface(props) {
|
|
98
|
+
const item = useRadioGroupItemContext("RadioSelectBoxItem");
|
|
99
|
+
const contextValue = React.useMemo(() => ({
|
|
100
|
+
selected: item.checked,
|
|
101
|
+
pressed: item.pressed,
|
|
102
|
+
disabled: item.disabled,
|
|
103
|
+
footerVisibility: props.footerVisibility,
|
|
104
|
+
variantProps: props.variantProps,
|
|
105
|
+
accessibilityRole: "radio"
|
|
106
|
+
}), [
|
|
107
|
+
item.checked,
|
|
108
|
+
item.disabled,
|
|
109
|
+
item.pressed,
|
|
110
|
+
props.footerVisibility,
|
|
111
|
+
props.variantProps
|
|
112
|
+
]);
|
|
113
|
+
return <SelectBoxRuntimeContext.Provider value={contextValue}>
|
|
114
|
+
<SelectBoxSurface {...props} />
|
|
115
|
+
</SelectBoxRuntimeContext.Provider>;
|
|
116
|
+
}
|
|
117
|
+
var RadioSelectBoxItem = React.forwardRef((props, ref) => {
|
|
118
|
+
const { children, className, style, value, disabled, footerVisibility = "when-selected", ...restProps } = props;
|
|
119
|
+
const inheritedVariantProps = React.useContext(SelectBoxLayoutContext);
|
|
120
|
+
const [variantProps, accessibilityProps] = selectBox.splitVariantProps(restProps);
|
|
121
|
+
const resolvedVariantProps = {
|
|
122
|
+
...variantProps,
|
|
123
|
+
layout: variantProps.layout ?? inheritedVariantProps.layout
|
|
124
|
+
};
|
|
125
|
+
const interactionRootClassName = selectBox(resolvedVariantProps).interactionRoot;
|
|
126
|
+
return <RadioGroupItem ref={ref} className={interactionRootClassName} value={value} disabled={disabled} accessibility-element={false}>
|
|
127
|
+
<RadioSelectBoxSurface className={className} style={style} footerVisibility={footerVisibility} variantProps={resolvedVariantProps} accessibilityProps={accessibilityProps}>
|
|
128
|
+
{children}
|
|
129
|
+
</RadioSelectBoxSurface>
|
|
130
|
+
</RadioGroupItem>;
|
|
131
|
+
});
|
|
132
|
+
RadioSelectBoxItem.displayName = "RadioSelectBoxItem";
|
|
133
|
+
function createViewSlot(displayName, slot) {
|
|
134
|
+
const Component = React.forwardRef((props, ref) => {
|
|
135
|
+
const { children, className, ...nativeProps } = props;
|
|
136
|
+
const classes = useClassNames();
|
|
137
|
+
return <view {...ref ? { ref } : {}} className={clsx(classes[slot], className)} {...nativeProps}>
|
|
138
|
+
{children}
|
|
139
|
+
</view>;
|
|
140
|
+
});
|
|
141
|
+
Component.displayName = displayName;
|
|
142
|
+
return Component;
|
|
143
|
+
}
|
|
144
|
+
function createTextSlot(displayName, slot) {
|
|
145
|
+
const Component = React.forwardRef((props, ref) => {
|
|
146
|
+
const { children, className, ...nativeProps } = props;
|
|
147
|
+
const classes = useClassNames();
|
|
148
|
+
return <text {...ref ? { ref } : {}} className={clsx(classes[slot], className)} {...nativeProps}>
|
|
149
|
+
{children}
|
|
150
|
+
</text>;
|
|
151
|
+
});
|
|
152
|
+
Component.displayName = displayName;
|
|
153
|
+
return Component;
|
|
154
|
+
}
|
|
155
|
+
function createLabelSlot(displayName) {
|
|
156
|
+
const Component = React.forwardRef((props, ref) => {
|
|
157
|
+
const { children, className, ...nativeProps } = props;
|
|
158
|
+
const classes = useClassNames();
|
|
159
|
+
const labelChildren = typeof children === "string" || typeof children === "number" ? <text>{children}</text> : children;
|
|
160
|
+
return <view {...ref ? { ref } : {}} className={clsx(classes.label, className)} {...nativeProps}>
|
|
161
|
+
{labelChildren}
|
|
162
|
+
</view>;
|
|
163
|
+
});
|
|
164
|
+
Component.displayName = displayName;
|
|
165
|
+
return Component;
|
|
166
|
+
}
|
|
167
|
+
var CheckSelectBoxTrigger = createViewSlot("CheckSelectBoxTrigger", "trigger");
|
|
168
|
+
var CheckSelectBoxContent = createViewSlot("CheckSelectBoxContent", "content");
|
|
169
|
+
var CheckSelectBoxBody = createViewSlot("CheckSelectBoxBody", "body");
|
|
170
|
+
var CheckSelectBoxLabel = createLabelSlot("CheckSelectBoxLabel");
|
|
171
|
+
var CheckSelectBoxDescription = createTextSlot("CheckSelectBoxDescription", "description");
|
|
172
|
+
var RadioSelectBoxTrigger = createViewSlot("RadioSelectBoxTrigger", "trigger");
|
|
173
|
+
var RadioSelectBoxContent = createViewSlot("RadioSelectBoxContent", "content");
|
|
174
|
+
var RadioSelectBoxBody = createViewSlot("RadioSelectBoxBody", "body");
|
|
175
|
+
var RadioSelectBoxLabel = createLabelSlot("RadioSelectBoxLabel");
|
|
176
|
+
var RadioSelectBoxDescription = createTextSlot("RadioSelectBoxDescription", "description");
|
|
177
|
+
function getFooterLayoutHeight(event) {
|
|
178
|
+
const eventWithHeight = event;
|
|
179
|
+
const height = event.detail?.height ?? event.params?.height ?? eventWithHeight.height;
|
|
180
|
+
if (typeof height !== "number" || !Number.isFinite(height)) return null;
|
|
181
|
+
return Math.max(0, height);
|
|
182
|
+
}
|
|
183
|
+
var SelectBoxFooter = React.forwardRef((props, ref) => {
|
|
184
|
+
const { children, className, style, "accessibility-elements-hidden": accessibilityElementsHidden = false, ...nativeProps } = props;
|
|
185
|
+
const context = useSelectBoxRuntimeContext("SelectBoxFooter");
|
|
186
|
+
const classes = useClassNames();
|
|
187
|
+
const [contentHeight, setContentHeight] = React.useState(0);
|
|
188
|
+
const open = context.footerVisibility === "always" || (context.footerVisibility === "when-selected" ? context.selected : !context.selected);
|
|
189
|
+
const handleLayoutChange = React.useCallback((event) => {
|
|
190
|
+
const height = getFooterLayoutHeight(event);
|
|
191
|
+
if (height !== null) setContentHeight((current) => current === height ? current : height);
|
|
192
|
+
}, []);
|
|
193
|
+
return <view {...ref ? { ref } : {}} className={clsx(classes.footer, className)} style={{
|
|
194
|
+
...style,
|
|
195
|
+
height: context.footerVisibility === "always" || open && contentHeight === 0 ? "auto" : open ? `${contentHeight}px` : "0px"
|
|
196
|
+
}} accessibility-elements-hidden={!open || accessibilityElementsHidden} {...nativeProps}>
|
|
197
|
+
<view className={classes.footerInner} bindlayoutchange={handleLayoutChange}>
|
|
198
|
+
{children}
|
|
199
|
+
</view>
|
|
200
|
+
</view>;
|
|
201
|
+
});
|
|
202
|
+
SelectBoxFooter.displayName = "SelectBoxFooter";
|
|
203
|
+
var CheckSelectBoxFooter = SelectBoxFooter;
|
|
204
|
+
var RadioSelectBoxFooter = SelectBoxFooter;
|
|
205
|
+
var SelectBoxCheckmarkContext = React.createContext(null);
|
|
206
|
+
var CheckSelectBoxCheckmarkControl = React.forwardRef((props, ref) => {
|
|
207
|
+
const { children, className, ...nativeProps } = props;
|
|
208
|
+
const context = useSelectBoxRuntimeContext("CheckSelectBoxCheckmarkControl");
|
|
209
|
+
const variantProps = {
|
|
210
|
+
selected: context.selected,
|
|
211
|
+
pressed: context.pressed,
|
|
212
|
+
disabled: context.disabled
|
|
213
|
+
};
|
|
214
|
+
const classes = selectBoxCheckmark(variantProps);
|
|
215
|
+
return <SelectBoxCheckmarkContext.Provider value={{
|
|
216
|
+
iconClassName: classes.icon,
|
|
217
|
+
variantProps
|
|
218
|
+
}}>
|
|
219
|
+
<view {...ref ? { ref } : {}} className={clsx(classes.root, className)} accessibility-elements-hidden={true} {...nativeProps}>
|
|
220
|
+
{children}
|
|
221
|
+
</view>
|
|
222
|
+
</SelectBoxCheckmarkContext.Provider>;
|
|
223
|
+
});
|
|
224
|
+
CheckSelectBoxCheckmarkControl.displayName = "CheckSelectBoxCheckmarkControl";
|
|
225
|
+
var CheckSelectBoxCheckmarkIcon = React.forwardRef((props, ref) => {
|
|
226
|
+
const { className, ...otherProps } = props;
|
|
227
|
+
const context = React.useContext(SelectBoxCheckmarkContext);
|
|
228
|
+
if (!context) throw new Error("<CheckSelectBoxCheckmarkIcon/> must be rendered inside <CheckSelectBoxCheckmarkControl/>.");
|
|
229
|
+
return <InternalIcon ref={ref} className={clsx(context.iconClassName, className)} deps={[
|
|
230
|
+
context.variantProps.selected,
|
|
231
|
+
context.variantProps.pressed,
|
|
232
|
+
context.variantProps.disabled
|
|
233
|
+
]} {...otherProps} />;
|
|
234
|
+
});
|
|
235
|
+
CheckSelectBoxCheckmarkIcon.displayName = "CheckSelectBoxCheckmarkIcon";
|
|
236
|
+
//#endregion
|
|
237
|
+
export { CheckSelectBoxBody, CheckSelectBoxCheckmarkControl, CheckSelectBoxCheckmarkIcon, CheckSelectBoxContent, CheckSelectBoxDescription, CheckSelectBoxFooter, CheckSelectBoxGroup, CheckSelectBoxLabel, CheckSelectBoxRoot, CheckSelectBoxTrigger, RadioSelectBoxBody, RadioSelectBoxContent, RadioSelectBoxDescription, RadioSelectBoxFooter, RadioSelectBoxGroup, RadioSelectBoxItem, RadioSelectBoxLabel, RadioSelectBoxTrigger };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SelectBox/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC"}
|
|
@@ -11,8 +11,14 @@ export * from './Divider';
|
|
|
11
11
|
export * from './Field';
|
|
12
12
|
export * from './Icon';
|
|
13
13
|
export * from './KeyboardAvoidingScrollView';
|
|
14
|
+
export * from './MannerTemp';
|
|
15
|
+
export * from './MannerTempBadge';
|
|
16
|
+
export * from './NotificationBadge';
|
|
17
|
+
export * from './PageBanner';
|
|
14
18
|
export * from './ProgressCircle';
|
|
15
19
|
export * from './RadioGroup';
|
|
20
|
+
export * from './SegmentedControl';
|
|
21
|
+
export * from './SelectBox';
|
|
16
22
|
export * from './Stack';
|
|
17
23
|
export * from './Switch';
|
|
18
24
|
export * from './Tabs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
|
@@ -2,11 +2,12 @@ import { MainThread } from '@lynx-js/types';
|
|
|
2
2
|
import { DependencyList, RefObject } from '@lynx-js/react';
|
|
3
3
|
export interface UseIconColorOptions {
|
|
4
4
|
sourceRef?: RefObject<MainThread.Element>;
|
|
5
|
+
enabled?: boolean;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* Lynx `<image>` 의 tint color 를 recipe 의 CSS `color` 로부터 main-thread 에서 읽어
|
|
8
|
-
* `tint-color` attribute 로 mirror. `deps`
|
|
9
|
-
* 다음 frame에 재동기화하고, UI 표시 이벤트에서는 즉시 동기화.
|
|
9
|
+
* `tint-color` attribute 로 mirror. `deps` 또는 시스템 테마가 바뀌면 native class
|
|
10
|
+
* patch가 반영된 다음 frame에 재동기화하고, UI 표시 이벤트에서는 즉시 동기화.
|
|
10
11
|
*
|
|
11
12
|
* ```tsx
|
|
12
13
|
* const iconColorProps = useIconColor([variant, disabled, loading]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIconColor.d.ts","sourceRoot":"","sources":["../../src/hooks/useIconColor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAOhE,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useIconColor.d.ts","sourceRoot":"","sources":["../../src/hooks/useIconColor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAOhE,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA0DD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,cAAc,EACpB,OAAO,CAAC,EAAE,mBAAmB,GAC5B;IACD,GAAG,EAAE,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACnC,0BAA0B,EAAE,MAAM,IAAI,CAAC;CACxC,CAuBA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { runOnMainThread, useEffect, useMainThreadRef } from "@lynx-js/react";
|
|
1
|
+
import { runOnMainThread, useEffect, useGlobalProps, useMainThreadRef } from "@lynx-js/react";
|
|
2
2
|
//#region src/hooks/useIconColor.ts
|
|
3
3
|
function syncTintColorOnce(targetRef, sourceRef) {
|
|
4
4
|
"main thread";
|
|
@@ -31,8 +31,8 @@ function cancelTintColorSync(frameRef) {
|
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Lynx `<image>` 의 tint color 를 recipe 의 CSS `color` 로부터 main-thread 에서 읽어
|
|
34
|
-
* `tint-color` attribute 로 mirror. `deps`
|
|
35
|
-
* 다음 frame에 재동기화하고, UI 표시 이벤트에서는 즉시 동기화.
|
|
34
|
+
* `tint-color` attribute 로 mirror. `deps` 또는 시스템 테마가 바뀌면 native class
|
|
35
|
+
* patch가 반영된 다음 frame에 재동기화하고, UI 표시 이벤트에서는 즉시 동기화.
|
|
36
36
|
*
|
|
37
37
|
* ```tsx
|
|
38
38
|
* const iconColorProps = useIconColor([variant, disabled, loading]);
|
|
@@ -42,17 +42,25 @@ function cancelTintColorSync(frameRef) {
|
|
|
42
42
|
function useIconColor(deps, options) {
|
|
43
43
|
const ref = useMainThreadRef(null);
|
|
44
44
|
const sourceRef = options?.sourceRef;
|
|
45
|
+
const enabled = options?.enabled ?? true;
|
|
45
46
|
const frameRef = useMainThreadRef(0);
|
|
47
|
+
const theme = useGlobalProps()?.theme;
|
|
46
48
|
function syncOnUiAppear() {
|
|
47
49
|
"main thread";
|
|
50
|
+
if (!enabled) return;
|
|
48
51
|
syncTintColorOnce(ref, sourceRef);
|
|
49
52
|
}
|
|
50
53
|
useEffect(() => {
|
|
54
|
+
if (!enabled) return;
|
|
51
55
|
runOnMainThread(scheduleTintColorSync)(ref, sourceRef, frameRef);
|
|
52
56
|
return () => {
|
|
53
57
|
runOnMainThread(cancelTintColorSync)(frameRef);
|
|
54
58
|
};
|
|
55
|
-
},
|
|
59
|
+
}, [
|
|
60
|
+
...deps,
|
|
61
|
+
enabled,
|
|
62
|
+
theme
|
|
63
|
+
]);
|
|
56
64
|
return {
|
|
57
65
|
ref,
|
|
58
66
|
"main-thread:binduiappear": syncOnUiAppear
|