@seed-design/lynx-react 0.0.0-alpha-20260622094810
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/_virtual/_rolldown/runtime.js +13 -0
- package/lib/components/ActionButton/ActionButton.d.ts +49 -0
- package/lib/components/ActionButton/ActionButton.d.ts.map +1 -0
- package/lib/components/ActionButton/ActionButton.jsx +158 -0
- package/lib/components/ActionButton/index.d.ts +2 -0
- package/lib/components/ActionButton/index.d.ts.map +1 -0
- package/lib/components/AppBar/AppBar.d.ts +35 -0
- package/lib/components/AppBar/AppBar.d.ts.map +1 -0
- package/lib/components/AppBar/AppBar.jsx +132 -0
- package/lib/components/AppBar/AppBar.namespace.d.ts +2 -0
- package/lib/components/AppBar/AppBar.namespace.d.ts.map +1 -0
- package/lib/components/AppBar/AppBar.namespace.js +15 -0
- package/lib/components/AppBar/context.d.ts +13 -0
- package/lib/components/AppBar/context.d.ts.map +1 -0
- package/lib/components/AppBar/context.js +12 -0
- package/lib/components/AppBar/index.d.ts +3 -0
- package/lib/components/AppBar/index.d.ts.map +1 -0
- package/lib/components/AppBar/useAppBar.d.ts +15 -0
- package/lib/components/AppBar/useAppBar.d.ts.map +1 -0
- package/lib/components/AppBar/useAppBar.js +72 -0
- package/lib/components/Badge/Badge.d.ts +14 -0
- package/lib/components/Badge/Badge.d.ts.map +1 -0
- package/lib/components/Badge/Badge.jsx +15 -0
- package/lib/components/Badge/index.d.ts +2 -0
- package/lib/components/Badge/index.d.ts.map +1 -0
- package/lib/components/BottomSheet/BottomSheet.d.ts +87 -0
- package/lib/components/BottomSheet/BottomSheet.d.ts.map +1 -0
- package/lib/components/BottomSheet/BottomSheet.jsx +163 -0
- package/lib/components/BottomSheet/BottomSheet.namespace.d.ts +2 -0
- package/lib/components/BottomSheet/BottomSheet.namespace.d.ts.map +1 -0
- package/lib/components/BottomSheet/BottomSheet.namespace.js +18 -0
- package/lib/components/BottomSheet/index.d.ts +3 -0
- package/lib/components/BottomSheet/index.d.ts.map +1 -0
- package/lib/components/Box/Box.d.ts +20 -0
- package/lib/components/Box/Box.d.ts.map +1 -0
- package/lib/components/Box/Box.jsx +14 -0
- package/lib/components/Box/index.d.ts +2 -0
- package/lib/components/Box/index.d.ts.map +1 -0
- package/lib/components/Checkbox/Checkbox.d.ts +35 -0
- package/lib/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/lib/components/Checkbox/Checkbox.jsx +130 -0
- package/lib/components/Checkbox/Checkbox.namespace.d.ts +2 -0
- package/lib/components/Checkbox/Checkbox.namespace.d.ts.map +1 -0
- package/lib/components/Checkbox/Checkbox.namespace.js +12 -0
- package/lib/components/Checkbox/index.d.ts +3 -0
- package/lib/components/Checkbox/index.d.ts.map +1 -0
- package/lib/components/Icon/Icon.d.ts +37 -0
- package/lib/components/Icon/Icon.d.ts.map +1 -0
- package/lib/components/Icon/Icon.jsx +143 -0
- package/lib/components/Icon/index.d.ts +2 -0
- package/lib/components/Icon/index.d.ts.map +1 -0
- package/lib/components/ProgressCircle/ProgressCircle.d.ts +25 -0
- package/lib/components/ProgressCircle/ProgressCircle.d.ts.map +1 -0
- package/lib/components/ProgressCircle/ProgressCircle.jsx +281 -0
- package/lib/components/ProgressCircle/ProgressCircle.namespace.d.ts +2 -0
- package/lib/components/ProgressCircle/ProgressCircle.namespace.d.ts.map +1 -0
- package/lib/components/ProgressCircle/ProgressCircle.namespace.js +9 -0
- package/lib/components/ProgressCircle/index.d.ts +3 -0
- package/lib/components/ProgressCircle/index.d.ts.map +1 -0
- package/lib/components/RadioGroup/RadioGroup.d.ts +34 -0
- package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -0
- package/lib/components/RadioGroup/RadioGroup.jsx +160 -0
- package/lib/components/RadioGroup/RadioGroup.namespace.d.ts +2 -0
- package/lib/components/RadioGroup/RadioGroup.namespace.d.ts.map +1 -0
- package/lib/components/RadioGroup/RadioGroup.namespace.js +12 -0
- package/lib/components/RadioGroup/index.d.ts +3 -0
- package/lib/components/RadioGroup/index.d.ts.map +1 -0
- package/lib/components/Stack/Stack.d.ts +33 -0
- package/lib/components/Stack/Stack.d.ts.map +1 -0
- package/lib/components/Stack/Stack.jsx +39 -0
- package/lib/components/Stack/index.d.ts +2 -0
- package/lib/components/Stack/index.d.ts.map +1 -0
- package/lib/components/Switch/Switch.d.ts +21 -0
- package/lib/components/Switch/Switch.d.ts.map +1 -0
- package/lib/components/Switch/Switch.jsx +101 -0
- package/lib/components/Switch/Switch.namespace.d.ts +2 -0
- package/lib/components/Switch/Switch.namespace.d.ts.map +1 -0
- package/lib/components/Switch/Switch.namespace.js +11 -0
- package/lib/components/Switch/index.d.ts +3 -0
- package/lib/components/Switch/index.d.ts.map +1 -0
- package/lib/components/TagGroup/TagGroup.d.ts +34 -0
- package/lib/components/TagGroup/TagGroup.d.ts.map +1 -0
- package/lib/components/TagGroup/TagGroup.jsx +57 -0
- package/lib/components/TagGroup/TagGroup.namespace.d.ts +2 -0
- package/lib/components/TagGroup/TagGroup.namespace.d.ts.map +1 -0
- package/lib/components/TagGroup/TagGroup.namespace.js +10 -0
- package/lib/components/TagGroup/index.d.ts +3 -0
- package/lib/components/TagGroup/index.d.ts.map +1 -0
- package/lib/components/Text/Text.d.ts +7 -0
- package/lib/components/Text/Text.d.ts.map +1 -0
- package/lib/components/Text/Text.jsx +28 -0
- package/lib/components/Text/index.d.ts +2 -0
- package/lib/components/Text/index.d.ts.map +1 -0
- package/lib/components/index.d.ts +14 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/hooks/index.d.ts +5 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/useControllableState.d.ts +15 -0
- package/lib/hooks/useControllableState.d.ts.map +1 -0
- package/lib/hooks/useControllableState.js +27 -0
- package/lib/hooks/useIconColor.d.ts +19 -0
- package/lib/hooks/useIconColor.d.ts.map +1 -0
- package/lib/hooks/useIconColor.js +38 -0
- package/lib/hooks/usePressTap.d.ts +27 -0
- package/lib/hooks/usePressTap.d.ts.map +1 -0
- package/lib/hooks/usePressTap.js +35 -0
- package/lib/hooks/useSafeArea.d.ts +19 -0
- package/lib/hooks/useSafeArea.d.ts.map +1 -0
- package/lib/hooks/useSafeArea.js +33 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +29 -0
- package/lib/types.d.ts +51 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/utils/children.d.ts +3 -0
- package/lib/utils/children.d.ts.map +1 -0
- package/lib/utils/children.js +8 -0
- package/lib/utils/create-slot-recipe-context.d.ts +27 -0
- package/lib/utils/create-slot-recipe-context.d.ts.map +1 -0
- package/lib/utils/create-slot-recipe-context.jsx +94 -0
- package/lib/utils/get-seed-class-name.d.ts +22 -0
- package/lib/utils/get-seed-class-name.d.ts.map +1 -0
- package/lib/utils/get-seed-class-name.js +28 -0
- package/lib/utils/index.d.ts +5 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/resolve-recipe-token.d.ts +38 -0
- package/lib/utils/resolve-recipe-token.d.ts.map +1 -0
- package/lib/utils/resolve-recipe-token.js +49 -0
- package/lib/utils/split-multiple-variants-props.d.ts +29 -0
- package/lib/utils/split-multiple-variants-props.d.ts.map +1 -0
- package/lib/utils/split-multiple-variants-props.js +34 -0
- package/lib/utils/styled.d.ts +83 -0
- package/lib/utils/styled.d.ts.map +1 -0
- package/lib/utils/styled.js +144 -0
- package/package.json +54 -0
- package/src/components/ActionButton/ActionButton.test.tsx +167 -0
- package/src/components/ActionButton/ActionButton.tsx +363 -0
- package/src/components/ActionButton/index.ts +1 -0
- package/src/components/AppBar/AppBar.namespace.ts +18 -0
- package/src/components/AppBar/AppBar.test.tsx +270 -0
- package/src/components/AppBar/AppBar.tsx +288 -0
- package/src/components/AppBar/context.ts +27 -0
- package/src/components/AppBar/index.ts +21 -0
- package/src/components/AppBar/useAppBar.ts +100 -0
- package/src/components/Badge/Badge.test.tsx +54 -0
- package/src/components/Badge/Badge.tsx +32 -0
- package/src/components/Badge/index.ts +1 -0
- package/src/components/BottomSheet/BottomSheet.namespace.ts +24 -0
- package/src/components/BottomSheet/BottomSheet.test.tsx +219 -0
- package/src/components/BottomSheet/BottomSheet.tsx +423 -0
- package/src/components/BottomSheet/index.ts +27 -0
- package/src/components/Box/Box.test.tsx +85 -0
- package/src/components/Box/Box.tsx +39 -0
- package/src/components/Box/index.ts +1 -0
- package/src/components/Checkbox/Checkbox.namespace.ts +12 -0
- package/src/components/Checkbox/Checkbox.tsx +282 -0
- package/src/components/Checkbox/index.ts +14 -0
- package/src/components/Icon/Icon.tsx +265 -0
- package/src/components/Icon/index.ts +8 -0
- package/src/components/ProgressCircle/ProgressCircle.namespace.ts +5 -0
- package/src/components/ProgressCircle/ProgressCircle.tsx +424 -0
- package/src/components/ProgressCircle/index.ts +9 -0
- package/src/components/RadioGroup/RadioGroup.namespace.ts +12 -0
- package/src/components/RadioGroup/RadioGroup.tsx +320 -0
- package/src/components/RadioGroup/index.ts +14 -0
- package/src/components/Stack/Stack.tsx +97 -0
- package/src/components/Stack/index.ts +1 -0
- package/src/components/Switch/Switch.namespace.ts +10 -0
- package/src/components/Switch/Switch.tsx +200 -0
- package/src/components/Switch/index.ts +12 -0
- package/src/components/TagGroup/TagGroup.namespace.ts +8 -0
- package/src/components/TagGroup/TagGroup.tsx +127 -0
- package/src/components/TagGroup/index.ts +10 -0
- package/src/components/Text/Text.tsx +64 -0
- package/src/components/Text/index.ts +1 -0
- package/src/components/index.ts +13 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useControllableState.test.ts +120 -0
- package/src/hooks/useControllableState.ts +38 -0
- package/src/hooks/useIconColor.test.ts +13 -0
- package/src/hooks/useIconColor.ts +67 -0
- package/src/hooks/usePressTap.test.ts +129 -0
- package/src/hooks/usePressTap.ts +58 -0
- package/src/hooks/useSafeArea.test.ts +83 -0
- package/src/hooks/useSafeArea.ts +56 -0
- package/src/index.ts +4 -0
- package/src/types.ts +76 -0
- package/src/utils/children.ts +13 -0
- package/src/utils/create-slot-recipe-context.test.tsx +96 -0
- package/src/utils/create-slot-recipe-context.tsx +187 -0
- package/src/utils/get-seed-class-name.ts +47 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/resolve-recipe-token.ts +47 -0
- package/src/utils/split-multiple-variants-props.test.ts +61 -0
- package/src/utils/split-multiple-variants-props.ts +59 -0
- package/src/utils/styled.ts +442 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type RecipeLike = {
|
|
2
|
+
splitVariantProps: (props: Record<string, unknown>) => [Record<string, unknown>, unknown];
|
|
3
|
+
};
|
|
4
|
+
type ExtractVariantProps<T> = T extends {
|
|
5
|
+
splitVariantProps: (...args: never[]) => [infer V, unknown];
|
|
6
|
+
} ? V : never;
|
|
7
|
+
type ExtractAllVariantKeys<R> = {
|
|
8
|
+
[K in keyof R]: ExtractVariantProps<R[K]> extends infer V ? V extends Record<string, unknown> ? keyof V : never : never;
|
|
9
|
+
}[keyof R];
|
|
10
|
+
/**
|
|
11
|
+
* Split `props` across multiple recipes' variant extractors in one pass.
|
|
12
|
+
*
|
|
13
|
+
* Given `recipesMap` of `{ [recipeKey]: recipe }`, returns:
|
|
14
|
+
* - A bucket per recipe key with that recipe's variant-only props.
|
|
15
|
+
* - `remainingProps` with every recipe variant key stripped out.
|
|
16
|
+
*
|
|
17
|
+
* Keys that appear in more than one recipe (e.g. shared `size`) are copied
|
|
18
|
+
* into each corresponding bucket. `remainingProps` never includes any key
|
|
19
|
+
* that any recipe claimed as a variant.
|
|
20
|
+
*
|
|
21
|
+
* Mirror of `packages/react/src/utils/splitMultipleVariantsProps` adapted
|
|
22
|
+
* to TypeScript for Lynx. Use when a single compound component composes two
|
|
23
|
+
* or more recipes (e.g. Switch's `switch` + `switchmark`).
|
|
24
|
+
*/
|
|
25
|
+
export declare function splitMultipleVariantsProps<R extends Record<string, RecipeLike>, P>(props: P, recipesMap: R): [{
|
|
26
|
+
[K in keyof R]: ExtractVariantProps<R[K]>;
|
|
27
|
+
}, Omit<P, ExtractAllVariantKeys<R>>];
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=split-multiple-variants-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-multiple-variants-props.d.ts","sourceRoot":"","sources":["../../src/utils/split-multiple-variants-props.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG;IAChB,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;CAC3F,CAAC;AAEF,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS;IACtC,iBAAiB,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;CAC7D,GACG,CAAC,GACD,KAAK,CAAC;AAEV,KAAK,qBAAqB,CAAC,CAAC,IAAI;KAC7B,CAAC,IAAI,MAAM,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,GACrD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,GACP,KAAK,GACP,KAAK;CACV,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,EAChF,KAAK,EAAE,CAAC,EACR,UAAU,EAAE,CAAC,GACZ,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,EAAE,IAAI,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAsBpF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/utils/split-multiple-variants-props.ts
|
|
2
|
+
/**
|
|
3
|
+
* Split `props` across multiple recipes' variant extractors in one pass.
|
|
4
|
+
*
|
|
5
|
+
* Given `recipesMap` of `{ [recipeKey]: recipe }`, returns:
|
|
6
|
+
* - A bucket per recipe key with that recipe's variant-only props.
|
|
7
|
+
* - `remainingProps` with every recipe variant key stripped out.
|
|
8
|
+
*
|
|
9
|
+
* Keys that appear in more than one recipe (e.g. shared `size`) are copied
|
|
10
|
+
* into each corresponding bucket. `remainingProps` never includes any key
|
|
11
|
+
* that any recipe claimed as a variant.
|
|
12
|
+
*
|
|
13
|
+
* Mirror of `packages/react/src/utils/splitMultipleVariantsProps` adapted
|
|
14
|
+
* to TypeScript for Lynx. Use when a single compound component composes two
|
|
15
|
+
* or more recipes (e.g. Switch's `switch` + `switchmark`).
|
|
16
|
+
*/
|
|
17
|
+
function splitMultipleVariantsProps(props, recipesMap) {
|
|
18
|
+
const multipleVariantsProps = {};
|
|
19
|
+
const extractedKeys = /* @__PURE__ */ new Set();
|
|
20
|
+
const propsRecord = props;
|
|
21
|
+
for (const recipeKey in recipesMap) {
|
|
22
|
+
const [variantProps] = recipesMap[recipeKey].splitVariantProps(propsRecord);
|
|
23
|
+
multipleVariantsProps[recipeKey] = variantProps;
|
|
24
|
+
for (const variantPropKey in variantProps) extractedKeys.add(variantPropKey);
|
|
25
|
+
}
|
|
26
|
+
const remainingProps = {};
|
|
27
|
+
for (const propKey in propsRecord) {
|
|
28
|
+
if (extractedKeys.has(propKey)) continue;
|
|
29
|
+
remainingProps[propKey] = propsRecord[propKey];
|
|
30
|
+
}
|
|
31
|
+
return [multipleVariantsProps, remainingProps];
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { splitMultipleVariantsProps };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { CSSProperties } from '@lynx-js/types';
|
|
2
|
+
import { Dimension, FontSize, FontWeight, LineHeight, Radius, ScopedColorBanner, ScopedColorBg, ScopedColorFg, ScopedColorPalette, ScopedColorStroke, SpacingX, SpacingY } from '@seed-design/lynx-css/vars';
|
|
3
|
+
export declare function handleColor(color: string | undefined): any;
|
|
4
|
+
export declare function handleDimension(dimension: number | string | undefined): string | undefined;
|
|
5
|
+
export declare function resolveFlexValue(value: number | string | boolean | undefined): number | string | undefined;
|
|
6
|
+
export declare function handlePaddingWithSafeArea(padding: string | 0 | undefined, safeAreaInset: string): string | undefined;
|
|
7
|
+
export declare function handleRadius(radius: string | 0 | undefined): any;
|
|
8
|
+
export declare function handleFontWeight(fontWeight: string | undefined): any;
|
|
9
|
+
export declare function handleFontSize(size: string | undefined): any;
|
|
10
|
+
export declare function handleLineHeight(lineHeight: string | undefined): any;
|
|
11
|
+
export interface StyleProps {
|
|
12
|
+
bg?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
|
|
13
|
+
background?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
|
|
14
|
+
color?: ScopedColorFg | ScopedColorPalette | (string & {});
|
|
15
|
+
borderColor?: ScopedColorStroke | ScopedColorPalette | (string & {});
|
|
16
|
+
borderWidth?: 0 | 1 | (string & {});
|
|
17
|
+
borderTopWidth?: 0 | 1 | (string & {});
|
|
18
|
+
borderRightWidth?: 0 | 1 | (string & {});
|
|
19
|
+
borderBottomWidth?: 0 | 1 | (string & {});
|
|
20
|
+
borderLeftWidth?: 0 | 1 | (string & {});
|
|
21
|
+
borderRadius?: Radius | 0 | (string & {});
|
|
22
|
+
borderTopLeftRadius?: Radius | 0 | (string & {});
|
|
23
|
+
borderTopRightRadius?: Radius | 0 | (string & {});
|
|
24
|
+
borderBottomRightRadius?: Radius | 0 | (string & {});
|
|
25
|
+
borderBottomLeftRadius?: Radius | 0 | (string & {});
|
|
26
|
+
width?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
27
|
+
minWidth?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
28
|
+
maxWidth?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
29
|
+
height?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
30
|
+
minHeight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
31
|
+
maxHeight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
32
|
+
top?: 0 | (string & {});
|
|
33
|
+
left?: 0 | (string & {});
|
|
34
|
+
right?: 0 | (string & {});
|
|
35
|
+
bottom?: 0 | (string & {});
|
|
36
|
+
padding?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
37
|
+
p?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
38
|
+
paddingX?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
39
|
+
px?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
40
|
+
paddingY?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
41
|
+
py?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
42
|
+
paddingTop?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
|
|
43
|
+
pt?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
|
|
44
|
+
paddingRight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
45
|
+
pr?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
46
|
+
paddingBottom?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
|
|
47
|
+
pb?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
|
|
48
|
+
paddingLeft?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
49
|
+
pl?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
50
|
+
display?: "flex" | "none" | (string & {});
|
|
51
|
+
position?: "relative" | "absolute" | "fixed" | (string & {});
|
|
52
|
+
overflowX?: "visible" | "hidden" | (string & {});
|
|
53
|
+
overflowY?: "visible" | "hidden" | (string & {});
|
|
54
|
+
zIndex?: CSSProperties["zIndex"];
|
|
55
|
+
flexGrow?: CSSProperties["flexGrow"] | boolean;
|
|
56
|
+
flexShrink?: CSSProperties["flexShrink"] | boolean;
|
|
57
|
+
flexDirection?: "row" | "column" | "rowReverse" | "columnReverse" | (string & {});
|
|
58
|
+
flexWrap?: "nowrap" | "wrap" | boolean;
|
|
59
|
+
justifyContent?: "flexStart" | "flexEnd" | "center" | "spaceBetween" | "spaceAround" | (string & {});
|
|
60
|
+
justifySelf?: CSSProperties["justifySelf"];
|
|
61
|
+
alignItems?: "flexStart" | "flexEnd" | "center" | "stretch" | (string & {});
|
|
62
|
+
alignContent?: "flexStart" | "flexEnd" | "center" | "stretch" | (string & {});
|
|
63
|
+
alignSelf?: "flexStart" | "flexEnd" | "center" | "stretch" | (string & {});
|
|
64
|
+
gap?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
65
|
+
}
|
|
66
|
+
interface UseStyleProps extends StyleProps {
|
|
67
|
+
style?: CSSProperties;
|
|
68
|
+
}
|
|
69
|
+
export declare function useStyleProps<T extends UseStyleProps>(props: T): {
|
|
70
|
+
style: CSSProperties;
|
|
71
|
+
restProps: Omit<T, keyof UseStyleProps>;
|
|
72
|
+
};
|
|
73
|
+
export type TextStyle = "screenTitle" | "articleBody" | "articleNote" | "t1Regular" | "t1Medium" | "t1Bold" | "t2Regular" | "t2Medium" | "t2Bold" | "t3Regular" | "t3Medium" | "t3Bold" | "t4Regular" | "t4Medium" | "t4Bold" | "t5Regular" | "t5Medium" | "t5Bold" | "t6Regular" | "t6Medium" | "t6Bold" | "t7Regular" | "t7Medium" | "t7Bold" | "t8Bold" | "t9Bold" | "t10Bold" | "t1StaticRegular" | "t1StaticMedium" | "t1StaticBold" | "t2StaticRegular" | "t2StaticMedium" | "t2StaticBold" | "t3StaticRegular" | "t3StaticMedium" | "t3StaticBold" | "t4StaticRegular" | "t4StaticMedium" | "t4StaticBold" | "t5StaticRegular" | "t5StaticMedium" | "t5StaticBold" | "t6StaticRegular" | "t6StaticMedium" | "t6StaticBold" | "t7StaticRegular" | "t7StaticMedium" | "t7StaticBold" | "t8StaticBold" | "t9StaticBold" | "t10StaticBold";
|
|
74
|
+
export interface TextStyleProps {
|
|
75
|
+
color?: ScopedColorFg | ScopedColorPalette | (string & {});
|
|
76
|
+
fontSize?: FontSize | (string & {});
|
|
77
|
+
lineHeight?: LineHeight | (string & {});
|
|
78
|
+
fontWeight?: FontWeight;
|
|
79
|
+
textStyle?: TextStyle;
|
|
80
|
+
align?: "left" | "center" | "right";
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=styled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../src/utils/styled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,UAAU,EACV,UAAU,EACV,MAAM,EACN,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACT,MAAM,4BAA4B,CAAC;AAKpC,wBAAgB,WAAW,CAAC,KAAK,EAAE,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C;IACpC,UAAU,CAAC,EAAE,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { useSafeArea } from "../hooks/useSafeArea.js";
|
|
2
|
+
import { vars } from "@seed-design/lynx-css/vars";
|
|
3
|
+
//#region src/utils/styled.ts
|
|
4
|
+
function handleColor(color) {
|
|
5
|
+
if (!color) return;
|
|
6
|
+
const [type, value] = color.split(".");
|
|
7
|
+
return vars.$color[type]?.[value] ?? color;
|
|
8
|
+
}
|
|
9
|
+
function handleDimension(dimension) {
|
|
10
|
+
if (dimension == null) return;
|
|
11
|
+
if (typeof dimension === "number") return `${dimension}px`;
|
|
12
|
+
if (dimension === "full") return "100%";
|
|
13
|
+
const [type, value] = dimension.split(".");
|
|
14
|
+
return vars.$dimension[dimension] ?? vars.$dimension[type]?.[value] ?? dimension;
|
|
15
|
+
}
|
|
16
|
+
function resolveFlexValue(value) {
|
|
17
|
+
if (value === true) return 1;
|
|
18
|
+
if (value === false) return 0;
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function handleBorderWidth(width) {
|
|
22
|
+
if (width == null) return;
|
|
23
|
+
if (typeof width === "number") return `${width}px`;
|
|
24
|
+
return width;
|
|
25
|
+
}
|
|
26
|
+
function handlePaddingWithSafeArea(padding, safeAreaInset) {
|
|
27
|
+
if (padding === "safeArea") return safeAreaInset;
|
|
28
|
+
return handleDimension(padding);
|
|
29
|
+
}
|
|
30
|
+
function handleRadius(radius) {
|
|
31
|
+
if (radius == null) return;
|
|
32
|
+
return vars.$radius[radius] ?? radius;
|
|
33
|
+
}
|
|
34
|
+
function handleDisplay(display) {
|
|
35
|
+
if (!display) return;
|
|
36
|
+
return {
|
|
37
|
+
flex: "flex",
|
|
38
|
+
none: "none"
|
|
39
|
+
}[display] ?? display;
|
|
40
|
+
}
|
|
41
|
+
function handleFlexDirection(flexDirection) {
|
|
42
|
+
if (!flexDirection) return;
|
|
43
|
+
return {
|
|
44
|
+
row: "row",
|
|
45
|
+
column: "column",
|
|
46
|
+
rowReverse: "row-reverse",
|
|
47
|
+
columnReverse: "column-reverse"
|
|
48
|
+
}[flexDirection] ?? flexDirection;
|
|
49
|
+
}
|
|
50
|
+
function handleJustifyContent(justifyContent) {
|
|
51
|
+
if (!justifyContent) return;
|
|
52
|
+
return {
|
|
53
|
+
flexStart: "flex-start",
|
|
54
|
+
flexEnd: "flex-end",
|
|
55
|
+
center: "center",
|
|
56
|
+
spaceBetween: "space-between",
|
|
57
|
+
spaceAround: "space-around"
|
|
58
|
+
}[justifyContent] ?? justifyContent;
|
|
59
|
+
}
|
|
60
|
+
function handleAlignItems(alignItems) {
|
|
61
|
+
if (!alignItems) return;
|
|
62
|
+
return {
|
|
63
|
+
flexStart: "flex-start",
|
|
64
|
+
flexEnd: "flex-end",
|
|
65
|
+
center: "center",
|
|
66
|
+
stretch: "stretch"
|
|
67
|
+
}[alignItems] ?? alignItems;
|
|
68
|
+
}
|
|
69
|
+
function handleFontWeight(fontWeight) {
|
|
70
|
+
if (!fontWeight) return;
|
|
71
|
+
return vars.$fontWeight[fontWeight] ?? fontWeight;
|
|
72
|
+
}
|
|
73
|
+
function handleFontSize(size) {
|
|
74
|
+
if (!size) return;
|
|
75
|
+
return vars.$fontSize[size] ?? size;
|
|
76
|
+
}
|
|
77
|
+
function handleLineHeight(lineHeight) {
|
|
78
|
+
if (!lineHeight) return;
|
|
79
|
+
return vars.$lineHeight[lineHeight] ?? lineHeight;
|
|
80
|
+
}
|
|
81
|
+
function useStyleProps(props) {
|
|
82
|
+
const { background, bg, color, borderColor, borderWidth, borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidth, borderRadius, borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius, width, minWidth, maxWidth, height, minHeight, maxHeight, padding, paddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft, p, px, py, pt, pr, pb, pl, bottom, left, right, top, display, position, overflowX, overflowY, zIndex, flexGrow, flexShrink, flexDirection, flexWrap, justifyContent, justifySelf, alignItems, alignContent, alignSelf, gap, style, ...restProps } = props;
|
|
83
|
+
const { safeAreaInsetTop, safeAreaInsetBottom } = useSafeArea();
|
|
84
|
+
const backgroundValue = handleColor(background ?? bg);
|
|
85
|
+
const paddingValue = handleDimension(padding ?? p);
|
|
86
|
+
const paddingXValue = handleDimension(paddingX ?? px) ?? paddingValue;
|
|
87
|
+
const paddingYValue = handleDimension(paddingY ?? py) ?? paddingValue;
|
|
88
|
+
const paddingTopValue = handlePaddingWithSafeArea(paddingTop ?? pt, safeAreaInsetTop) ?? paddingYValue;
|
|
89
|
+
const paddingRightValue = handleDimension(paddingRight ?? pr) ?? paddingXValue;
|
|
90
|
+
const paddingBottomValue = handlePaddingWithSafeArea(paddingBottom ?? pb, safeAreaInsetBottom) ?? paddingYValue;
|
|
91
|
+
const paddingLeftValue = handleDimension(paddingLeft ?? pl) ?? paddingXValue;
|
|
92
|
+
const hasBorderStyle = borderColor != null || borderWidth != null || borderTopWidth != null || borderRightWidth != null || borderBottomWidth != null || borderLeftWidth != null;
|
|
93
|
+
return {
|
|
94
|
+
style: {
|
|
95
|
+
background: backgroundValue,
|
|
96
|
+
color: handleColor(color),
|
|
97
|
+
borderStyle: hasBorderStyle ? "solid" : void 0,
|
|
98
|
+
borderColor: handleColor(borderColor),
|
|
99
|
+
borderWidth: handleBorderWidth(borderWidth),
|
|
100
|
+
borderTopWidth: handleBorderWidth(borderTopWidth),
|
|
101
|
+
borderRightWidth: handleBorderWidth(borderRightWidth),
|
|
102
|
+
borderBottomWidth: handleBorderWidth(borderBottomWidth),
|
|
103
|
+
borderLeftWidth: handleBorderWidth(borderLeftWidth),
|
|
104
|
+
borderRadius: handleRadius(borderRadius),
|
|
105
|
+
borderTopLeftRadius: handleRadius(borderTopLeftRadius),
|
|
106
|
+
borderTopRightRadius: handleRadius(borderTopRightRadius),
|
|
107
|
+
borderBottomRightRadius: handleRadius(borderBottomRightRadius),
|
|
108
|
+
borderBottomLeftRadius: handleRadius(borderBottomLeftRadius),
|
|
109
|
+
width: handleDimension(width),
|
|
110
|
+
minWidth: handleDimension(minWidth),
|
|
111
|
+
maxWidth: handleDimension(maxWidth),
|
|
112
|
+
height: handleDimension(height),
|
|
113
|
+
minHeight: handleDimension(minHeight),
|
|
114
|
+
maxHeight: handleDimension(maxHeight),
|
|
115
|
+
paddingTop: paddingTopValue,
|
|
116
|
+
paddingRight: paddingRightValue,
|
|
117
|
+
paddingBottom: paddingBottomValue,
|
|
118
|
+
paddingLeft: paddingLeftValue,
|
|
119
|
+
top: handleDimension(top),
|
|
120
|
+
left: handleDimension(left),
|
|
121
|
+
right: handleDimension(right),
|
|
122
|
+
bottom: handleDimension(bottom),
|
|
123
|
+
gap: handleDimension(gap),
|
|
124
|
+
display: handleDisplay(display),
|
|
125
|
+
position,
|
|
126
|
+
overflowX,
|
|
127
|
+
overflowY,
|
|
128
|
+
zIndex,
|
|
129
|
+
flexGrow: resolveFlexValue(flexGrow),
|
|
130
|
+
flexShrink: resolveFlexValue(flexShrink),
|
|
131
|
+
flexDirection: handleFlexDirection(flexDirection),
|
|
132
|
+
flexWrap: flexWrap === true ? "wrap" : flexWrap === false ? "nowrap" : flexWrap,
|
|
133
|
+
justifyContent: handleJustifyContent(justifyContent),
|
|
134
|
+
justifySelf,
|
|
135
|
+
alignItems: handleAlignItems(alignItems),
|
|
136
|
+
alignContent: handleAlignItems(alignContent),
|
|
137
|
+
alignSelf: handleAlignItems(alignSelf),
|
|
138
|
+
...style
|
|
139
|
+
},
|
|
140
|
+
restProps
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { handleColor, handleDimension, handleFontSize, handleFontWeight, handleLineHeight, resolveFlexValue, useStyleProps };
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@seed-design/lynx-react",
|
|
3
|
+
"version": "0.0.0-alpha-20260622094810",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/daangn/seed-design.git",
|
|
7
|
+
"directory": "packages/lynx-react"
|
|
8
|
+
},
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"*.css"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./lib/index.d.ts",
|
|
16
|
+
"import": "./lib/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"lib",
|
|
22
|
+
"src"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"clean": "rm -rf lib",
|
|
26
|
+
"build": "vite build",
|
|
27
|
+
"lint:publish": "bun publint",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@lynx-js/react": ">=0.100.0",
|
|
33
|
+
"@lynx-js/types": ">=3.7.0",
|
|
34
|
+
"@seed-design/lynx-css": "0.0.0-alpha-20260622094810"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@lynx-js/react": "^0.116.3",
|
|
38
|
+
"@lynx-js/types": "^3.7.0",
|
|
39
|
+
"@seed-design/lynx-css": "0.0.0-alpha-20260622094810",
|
|
40
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
41
|
+
"jsdom": "^29.0.2",
|
|
42
|
+
"vite": "^8.0.0",
|
|
43
|
+
"vite-plugin-dts": "^4.5.4",
|
|
44
|
+
"vitest": "^3.2.4"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@lynx-js/lynx-ui-sheet": "^3.130.1",
|
|
51
|
+
"@lynx-js/lynx-ui-common": "^3.130.0",
|
|
52
|
+
"clsx": "^2.1.1"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
2
|
+
import { getQueriesForElement, render } from "@lynx-js/react/testing-library";
|
|
3
|
+
import type { MainThread } from "@lynx-js/types";
|
|
4
|
+
import * as React from "@lynx-js/react";
|
|
5
|
+
import { describe, expect, it, vi } from "vitest";
|
|
6
|
+
|
|
7
|
+
import type { LynxIconElementProps } from "../../types";
|
|
8
|
+
import { Icon, PrefixIcon, SuffixIcon } from "../Icon";
|
|
9
|
+
import { ActionButton } from "./ActionButton";
|
|
10
|
+
|
|
11
|
+
vi.mock("@lynx-js/react", async (importOriginal) => {
|
|
12
|
+
const actual = await importOriginal<typeof import("@lynx-js/react")>();
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
...actual,
|
|
16
|
+
runOnMainThread: () => () => undefined,
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function getRenderedQueries() {
|
|
21
|
+
return getQueriesForElement(getRenderedRoot());
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getRenderedRoot() {
|
|
25
|
+
const root = elementTree.root;
|
|
26
|
+
|
|
27
|
+
if (!root) {
|
|
28
|
+
throw new Error("Expected Lynx render root to exist.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return root;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getActionButtonRoot() {
|
|
35
|
+
const root = getRenderedRoot();
|
|
36
|
+
|
|
37
|
+
if (root.classList.contains("seed-action-button__root")) {
|
|
38
|
+
return root;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const actionButtonRoot = root.querySelector<HTMLElement>(".seed-action-button__root");
|
|
42
|
+
|
|
43
|
+
if (!actionButtonRoot) {
|
|
44
|
+
throw new Error("Expected ActionButton root to exist.");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return actionButtonRoot;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const MockIcon = React.forwardRef<MainThread.Element, LynxIconElementProps>((props, ref) => {
|
|
51
|
+
const { className, style, ...rest } = props;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<image
|
|
55
|
+
{...rest}
|
|
56
|
+
{...(ref ? { "main-thread:ref": ref as React.Ref<MainThread.Element> } : {})}
|
|
57
|
+
className={className}
|
|
58
|
+
style={style}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
MockIcon.displayName = "MockIcon";
|
|
63
|
+
|
|
64
|
+
describe("ActionButton", () => {
|
|
65
|
+
it("keeps the original label in the text slot while loading", () => {
|
|
66
|
+
render(<ActionButton loading>Submit</ActionButton>);
|
|
67
|
+
|
|
68
|
+
const { getByText } = getRenderedQueries();
|
|
69
|
+
const label = getByText("Submit");
|
|
70
|
+
const root = getRenderedRoot();
|
|
71
|
+
|
|
72
|
+
expect(label).toHaveClass("seed-action-button__text");
|
|
73
|
+
expect(label).toHaveClass("seed-action-button__text--size_medium-layout_withText");
|
|
74
|
+
expect(root.querySelector(".seed-action-button__content")).toBeInTheDocument();
|
|
75
|
+
expect(root.querySelector(".seed-action-button__loadingIndicator")).toBeInTheDocument();
|
|
76
|
+
expect(root.querySelector(".seed-progress-circle__root")).toBeInTheDocument();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("applies action button slot classes to child icon slots", () => {
|
|
80
|
+
render(
|
|
81
|
+
<ActionButton variant="brandSolid">
|
|
82
|
+
<PrefixIcon icon={<MockIcon />} />
|
|
83
|
+
Submit
|
|
84
|
+
<SuffixIcon icon={<MockIcon />} />
|
|
85
|
+
</ActionButton>,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const { getByText } = getRenderedQueries();
|
|
89
|
+
const root = getRenderedRoot();
|
|
90
|
+
|
|
91
|
+
expect(root.querySelector(".seed-prefix-icon")).toHaveClass("seed-action-button__prefixIcon");
|
|
92
|
+
expect(root.querySelector(".seed-suffix-icon")).toHaveClass("seed-action-button__suffixIcon");
|
|
93
|
+
expect(root.querySelector(".seed-prefix-icon image")).toHaveStyle({
|
|
94
|
+
width: "100%",
|
|
95
|
+
height: "100%",
|
|
96
|
+
});
|
|
97
|
+
expect(getByText("Submit")).toHaveClass("seed-action-button__text");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("keeps existing icon props compatible with the new slot wrapper", () => {
|
|
101
|
+
render(
|
|
102
|
+
<ActionButton prefixIcon={<MockIcon />} suffixIcon={<MockIcon />}>
|
|
103
|
+
Submit
|
|
104
|
+
</ActionButton>,
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const root = getRenderedRoot();
|
|
108
|
+
|
|
109
|
+
expect(root.querySelector(".seed-prefix-icon")).toHaveClass("seed-action-button__prefixIcon");
|
|
110
|
+
expect(root.querySelector(".seed-suffix-icon")).toHaveClass("seed-action-button__suffixIcon");
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("supports icon-only child slot", () => {
|
|
114
|
+
render(
|
|
115
|
+
<ActionButton layout="iconOnly" accessibility-label="Add">
|
|
116
|
+
<Icon icon={<MockIcon />} />
|
|
117
|
+
</ActionButton>,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const root = getRenderedRoot();
|
|
121
|
+
|
|
122
|
+
expect(root.querySelector(".seed-icon")).toHaveClass("seed-action-button__icon");
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("maps accessibility props to the root view", () => {
|
|
126
|
+
render(
|
|
127
|
+
<ActionButton layout="iconOnly" accessibility-label="Add">
|
|
128
|
+
<Icon icon={<MockIcon />} />
|
|
129
|
+
</ActionButton>,
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const root = getActionButtonRoot();
|
|
133
|
+
|
|
134
|
+
expect(root).toHaveAttribute("accessibility-label", "Add");
|
|
135
|
+
expect(root).toHaveAttribute("accessibility-element", "true");
|
|
136
|
+
expect(root).toHaveAttribute("accessibility-traits", "button");
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("keeps existing icon prop compatible with icon-only validation", () => {
|
|
140
|
+
render(<ActionButton layout="iconOnly" accessibility-label="Add" icon={<MockIcon />} />);
|
|
141
|
+
|
|
142
|
+
const root = getRenderedRoot();
|
|
143
|
+
|
|
144
|
+
expect(root.querySelector(".seed-icon")).toHaveClass("seed-action-button__icon");
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("throws in development when icon-only layout has no Icon child", () => {
|
|
148
|
+
expect(() => {
|
|
149
|
+
render(
|
|
150
|
+
<ActionButton layout="iconOnly" accessibility-label="Add">
|
|
151
|
+
Add
|
|
152
|
+
</ActionButton>,
|
|
153
|
+
);
|
|
154
|
+
}).toThrow(/must render <Icon \/> as a child/);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("throws in development when icon-only layout has multiple Icon children", () => {
|
|
158
|
+
expect(() => {
|
|
159
|
+
render(
|
|
160
|
+
<ActionButton layout="iconOnly" accessibility-label="Add">
|
|
161
|
+
<Icon icon={<MockIcon />} />
|
|
162
|
+
<Icon icon={<MockIcon />} />
|
|
163
|
+
</ActionButton>,
|
|
164
|
+
);
|
|
165
|
+
}).toThrow(/must render only one <Icon \/>/);
|
|
166
|
+
});
|
|
167
|
+
});
|