@tosui/react 0.1.3 → 0.1.5
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 +106 -60
- package/dist/components/Alert/Alert.d.ts.map +1 -1
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/Badge/Badge.d.ts.map +1 -1
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Box/Box.d.ts +2 -7
- package/dist/components/Box/Box.d.ts.map +1 -1
- package/dist/components/Box/Box.js +1 -1
- package/dist/components/Box/Box.js.map +1 -1
- package/dist/components/Box/borders/borders.d.ts +11 -13
- package/dist/components/Box/borders/borders.d.ts.map +1 -1
- package/dist/components/Box/borders/borders.js +29 -62
- package/dist/components/Box/borders/borders.js.map +1 -1
- package/dist/components/Box/borders/borders.module.css +936 -40
- package/dist/components/Box/borders/borders.module.css.js +600 -40
- package/dist/components/Box/borders/borders.module.css.js.map +1 -1
- package/dist/components/Box/colors/colors.d.ts +6 -8
- package/dist/components/Box/colors/colors.d.ts.map +1 -1
- package/dist/components/Box/colors/colors.js +20 -30
- package/dist/components/Box/colors/colors.js.map +1 -1
- package/dist/components/Box/colors/colors.module.css +2537 -108
- package/dist/components/Box/colors/colors.module.css.js +1620 -108
- package/dist/components/Box/colors/colors.module.css.js.map +1 -1
- package/dist/components/Box/display/display.d.ts +2 -8
- package/dist/components/Box/display/display.d.ts.map +1 -1
- package/dist/components/Box/display/display.js +10 -33
- package/dist/components/Box/display/display.js.map +1 -1
- package/dist/components/Box/flexbox/flexbox.d.ts +12 -14
- package/dist/components/Box/flexbox/flexbox.d.ts.map +1 -1
- package/dist/components/Box/flexbox/flexbox.js +39 -102
- package/dist/components/Box/flexbox/flexbox.js.map +1 -1
- package/dist/components/Box/flexbox/flexbox.module.css +1210 -56
- package/dist/components/Box/flexbox/flexbox.module.css.js +727 -55
- package/dist/components/Box/flexbox/flexbox.module.css.js.map +1 -1
- package/dist/components/Box/grid/grid.d.ts +3 -2
- package/dist/components/Box/grid/grid.d.ts.map +1 -1
- package/dist/components/Box/grid/grid.js +24 -15
- package/dist/components/Box/grid/grid.js.map +1 -1
- package/dist/components/Box/grid/grid.module.css +68 -18
- package/dist/components/Box/grid/grid.module.css.js +14 -14
- package/dist/components/Box/inset/inset.d.ts.map +1 -1
- package/dist/components/Box/inset/inset.js +8 -52
- package/dist/components/Box/inset/inset.js.map +1 -1
- package/dist/components/Box/inset/inset.module.css +120 -120
- package/dist/components/Box/inset/inset.module.css.js +21 -161
- package/dist/components/Box/inset/inset.module.css.js.map +1 -1
- package/dist/components/Box/interactions/interactions.d.ts +6 -8
- package/dist/components/Box/interactions/interactions.d.ts.map +1 -1
- package/dist/components/Box/interactions/interactions.js +20 -30
- package/dist/components/Box/interactions/interactions.js.map +1 -1
- package/dist/components/Box/interactions/interactions.module.css +891 -38
- package/dist/components/Box/interactions/interactions.module.css.js +570 -38
- package/dist/components/Box/interactions/interactions.module.css.js.map +1 -1
- package/dist/components/Box/margin/margin.d.ts.map +1 -1
- package/dist/components/Box/margin/margin.js +8 -52
- package/dist/components/Box/margin/margin.js.map +1 -1
- package/dist/components/Box/margin/margin.module.css +120 -120
- package/dist/components/Box/margin/margin.module.css.js +21 -161
- package/dist/components/Box/margin/margin.module.css.js.map +1 -1
- package/dist/components/Box/opacity/opacity.d.ts +2 -8
- package/dist/components/Box/opacity/opacity.d.ts.map +1 -1
- package/dist/components/Box/opacity/opacity.js +10 -33
- package/dist/components/Box/opacity/opacity.js.map +1 -1
- package/dist/components/Box/overflow/overflow.d.ts +2 -8
- package/dist/components/Box/overflow/overflow.d.ts.map +1 -1
- package/dist/components/Box/overflow/overflow.js +24 -29
- package/dist/components/Box/overflow/overflow.js.map +1 -1
- package/dist/components/Box/padding/padding.d.ts.map +1 -1
- package/dist/components/Box/padding/padding.js +8 -52
- package/dist/components/Box/padding/padding.js.map +1 -1
- package/dist/components/Box/padding/padding.module.css +120 -120
- package/dist/components/Box/padding/padding.module.css.js +21 -161
- package/dist/components/Box/padding/padding.module.css.js.map +1 -1
- package/dist/components/Box/position/position.d.ts +2 -8
- package/dist/components/Box/position/position.d.ts.map +1 -1
- package/dist/components/Box/position/position.js +10 -33
- package/dist/components/Box/position/position.js.map +1 -1
- package/dist/components/Box/roundness/roundness.d.ts +12 -14
- package/dist/components/Box/roundness/roundness.d.ts.map +1 -1
- package/dist/components/Box/roundness/roundness.js +26 -62
- package/dist/components/Box/roundness/roundness.js.map +1 -1
- package/dist/components/Box/roundness/roundness.module.css +937 -40
- package/dist/components/Box/roundness/roundness.module.css.js +600 -40
- package/dist/components/Box/roundness/roundness.module.css.js.map +1 -1
- package/dist/components/Box/shadows/shadows.d.ts +2 -8
- package/dist/components/Box/shadows/shadows.d.ts.map +1 -1
- package/dist/components/Box/shadows/shadows.js +10 -33
- package/dist/components/Box/shadows/shadows.js.map +1 -1
- package/dist/components/Box/shared/index.d.ts +1 -0
- package/dist/components/Box/shared/index.d.ts.map +1 -1
- package/dist/components/Box/shared/responsive.d.ts +36 -0
- package/dist/components/Box/shared/responsive.d.ts.map +1 -0
- package/dist/components/Box/shared/responsive.js +65 -0
- package/dist/components/Box/shared/responsive.js.map +1 -0
- package/dist/components/Box/shared/types.d.ts +6 -0
- package/dist/components/Box/shared/types.d.ts.map +1 -1
- package/dist/components/Box/sizing/sizing.d.ts.map +1 -1
- package/dist/components/Box/sizing/sizing.js +5 -37
- package/dist/components/Box/sizing/sizing.js.map +1 -1
- package/dist/components/Box/sizing/sizing.module.css +175 -183
- package/dist/components/Box/sizing/sizing.module.css.js +31 -241
- package/dist/components/Box/sizing/sizing.module.css.js.map +1 -1
- package/dist/components/Box/text/text.d.ts +6 -8
- package/dist/components/Box/text/text.d.ts.map +1 -1
- package/dist/components/Box/text/text.js +24 -30
- package/dist/components/Box/text/text.js.map +1 -1
- package/dist/components/Box/text/text.module.css +562 -24
- package/dist/components/Box/text/text.module.css.js +360 -24
- package/dist/components/Box/text/text.module.css.js.map +1 -1
- package/dist/components/Box/typography/typography.d.ts +7 -9
- package/dist/components/Box/typography/typography.d.ts.map +1 -1
- package/dist/components/Box/typography/typography.js +33 -19
- package/dist/components/Box/typography/typography.js.map +1 -1
- package/dist/components/Box/typography/typography.module.css +890 -19
- package/dist/components/Box/typography/typography.module.css.js +570 -19
- package/dist/components/Box/typography/typography.module.css.js.map +1 -1
- package/dist/components/Box/zIndex/zIndex.d.ts +2 -8
- package/dist/components/Box/zIndex/zIndex.d.ts.map +1 -1
- package/dist/components/Box/zIndex/zIndex.js +10 -33
- package/dist/components/Box/zIndex/zIndex.js.map +1 -1
- package/dist/components/Flex/Flex.d.ts +5 -6
- package/dist/components/Flex/Flex.d.ts.map +1 -1
- package/dist/components/Flex/Flex.js +0 -1
- package/dist/components/Flex/Flex.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +8 -7
- package/dist/components/Grid/Grid.d.ts.map +1 -1
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/IconButton/IconButton.d.ts.map +1 -1
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/Menu/Menu.d.ts.map +1 -1
- package/dist/components/Menu/Menu.js +5 -5
- package/dist/components/Menu/Menu.js.map +1 -1
- package/dist/components/Popover/Popover.d.ts.map +1 -1
- package/dist/components/Popover/Popover.js +9 -9
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/Progress/Progress.d.ts.map +1 -1
- package/dist/components/Progress/Progress.js.map +1 -1
- package/dist/components/Stack/Stack.d.ts +2 -1
- package/dist/components/Stack/Stack.d.ts.map +1 -1
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +5 -5
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/index.css +9313 -1632
- package/dist/styles/styles.css +7 -0
- package/package.json +1 -1
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { ResponsiveValue } from '../../../utils/breakpoints';
|
|
2
|
-
import { StyleResult } from '../shared';
|
|
2
|
+
import { StateProps, StyleResult } from '../shared';
|
|
3
3
|
export type OpacityValue = "invisible" | "faint" | "semi" | "full";
|
|
4
4
|
export type OpacityProps = {
|
|
5
5
|
opacity?: ResponsiveValue<OpacityValue>;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
_hover?: OpacityProps;
|
|
9
|
-
_focus?: OpacityProps;
|
|
10
|
-
_active?: OpacityProps;
|
|
11
|
-
_disabled?: OpacityProps;
|
|
12
|
-
};
|
|
13
|
-
export declare function getOpacityStyles(props: OpacityProps & OpacityStateProps): StyleResult;
|
|
7
|
+
export declare function getOpacityStyles(props: OpacityProps & StateProps<OpacityProps>): StyleResult;
|
|
14
8
|
//# sourceMappingURL=opacity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opacity.d.ts","sourceRoot":"","sources":["../../../../src/components/Box/opacity/opacity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"opacity.d.ts","sourceRoot":"","sources":["../../../../src/components/Box/opacity/opacity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,WAAW,EAEjB,MAAM,WAAW,CAAC;AAInB,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;CACzC,CAAC;AAWF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,GAC7C,WAAW,CAmBb"}
|
|
@@ -1,40 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getEnumResponsiveStyles } from "../shared/responsive.js";
|
|
2
2
|
import styles from "./opacity.module.css.js";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return stateClassSuffix ? styles[`${value}${stateClassSuffix}`] : styles[value];
|
|
8
|
-
}
|
|
9
|
-
return stateClassSuffix ? styles[`${value}_${responsiveKey}${stateClassSuffix}`] : styles[`${value}_${responsiveKey}`];
|
|
10
|
-
}
|
|
11
|
-
function getOpacityStylesForValue(value, state) {
|
|
12
|
-
const result = { className: "", style: {} };
|
|
13
|
-
if (value === void 0) return result;
|
|
14
|
-
if (typeof value === "string") {
|
|
15
|
-
const className = getOpacityClass(value, "base", state);
|
|
16
|
-
if (className) {
|
|
17
|
-
result.className = className;
|
|
18
|
-
}
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
for (const responsiveKey of RESPONSIVE_KEYS) {
|
|
22
|
-
const opacityValue = value[responsiveKey];
|
|
23
|
-
if (opacityValue === void 0) continue;
|
|
24
|
-
const className = getOpacityClass(opacityValue, responsiveKey, state);
|
|
25
|
-
if (className) {
|
|
26
|
-
result.className = clsx(result.className, className);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
4
|
+
function getOpacityStylesForState(props, state) {
|
|
5
|
+
if (!props) return { className: "", style: {} };
|
|
6
|
+
return getEnumResponsiveStyles(styles, "", props.opacity, state);
|
|
30
7
|
}
|
|
31
8
|
function getOpacityStyles(props) {
|
|
32
|
-
const {
|
|
33
|
-
const baseStyles =
|
|
34
|
-
const hoverStyles =
|
|
35
|
-
const focusStyles =
|
|
36
|
-
const activeStyles =
|
|
37
|
-
const disabledStyles =
|
|
9
|
+
const { _hover, _focus, _active, _disabled, ...baseProps } = props;
|
|
10
|
+
const baseStyles = getOpacityStylesForState(baseProps, "base");
|
|
11
|
+
const hoverStyles = getOpacityStylesForState(_hover, "hover");
|
|
12
|
+
const focusStyles = getOpacityStylesForState(_focus, "focus");
|
|
13
|
+
const activeStyles = getOpacityStylesForState(_active, "active");
|
|
14
|
+
const disabledStyles = getOpacityStylesForState(_disabled, "disabled");
|
|
38
15
|
return {
|
|
39
16
|
className: clsx(
|
|
40
17
|
baseStyles.className,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opacity.js","sources":["../../../../src/components/Box/opacity/opacity.ts"],"sourcesContent":["import type { ResponsiveValue } from \"@/utils/breakpoints\";\nimport {\n
|
|
1
|
+
{"version":3,"file":"opacity.js","sources":["../../../../src/components/Box/opacity/opacity.ts"],"sourcesContent":["import type { ResponsiveValue } from \"@/utils/breakpoints\";\nimport {\n type StateKey,\n type StateProps,\n type StyleResult,\n getEnumResponsiveStyles,\n} from \"../shared\";\nimport styles from \"./opacity.module.css\";\nimport clsx from \"clsx\";\n\nexport type OpacityValue = \"invisible\" | \"faint\" | \"semi\" | \"full\";\n\nexport type OpacityProps = {\n opacity?: ResponsiveValue<OpacityValue>;\n};\n\nfunction getOpacityStylesForState(\n props: OpacityProps | undefined,\n state: StateKey\n): StyleResult {\n if (!props) return { className: \"\", style: {} };\n\n return getEnumResponsiveStyles(styles, \"\", props.opacity, state);\n}\n\nexport function getOpacityStyles(\n props: OpacityProps & StateProps<OpacityProps>\n): StyleResult {\n const { _hover, _focus, _active, _disabled, ...baseProps } = props;\n\n const baseStyles = getOpacityStylesForState(baseProps, \"base\");\n const hoverStyles = getOpacityStylesForState(_hover, \"hover\");\n const focusStyles = getOpacityStylesForState(_focus, \"focus\");\n const activeStyles = getOpacityStylesForState(_active, \"active\");\n const disabledStyles = getOpacityStylesForState(_disabled, \"disabled\");\n\n return {\n className: clsx(\n baseStyles.className,\n hoverStyles.className,\n focusStyles.className,\n activeStyles.className,\n disabledStyles.className\n ),\n style: {},\n };\n}\n"],"names":[],"mappings":";;;AAgBA,SAAS,yBACP,OACA,OACa;AACb,MAAI,CAAC,MAAO,QAAO,EAAE,WAAW,IAAI,OAAO,GAAC;AAE5C,SAAO,wBAAwB,QAAQ,IAAI,MAAM,SAAS,KAAK;AACjE;AAEO,SAAS,iBACd,OACa;AACb,QAAM,EAAE,QAAQ,QAAQ,SAAS,WAAW,GAAG,cAAc;AAE7D,QAAM,aAAa,yBAAyB,WAAW,MAAM;AAC7D,QAAM,cAAc,yBAAyB,QAAQ,OAAO;AAC5D,QAAM,cAAc,yBAAyB,QAAQ,OAAO;AAC5D,QAAM,eAAe,yBAAyB,SAAS,QAAQ;AAC/D,QAAM,iBAAiB,yBAAyB,WAAW,UAAU;AAErE,SAAO;AAAA,IACL,WAAW;AAAA,MACT,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,eAAe;AAAA,IAAA;AAAA,IAEjB,OAAO,CAAA;AAAA,EAAC;AAEZ;"}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { ResponsiveValue } from '../../../utils/breakpoints';
|
|
2
|
-
import { StyleResult } from '../shared';
|
|
2
|
+
import { StateProps, StyleResult } from '../shared';
|
|
3
3
|
export type OverflowValue = "auto" | "hidden" | "scroll" | "visible";
|
|
4
4
|
export type OverflowProps = {
|
|
5
5
|
overflow?: ResponsiveValue<OverflowValue>;
|
|
6
6
|
overflowX?: ResponsiveValue<OverflowValue>;
|
|
7
7
|
overflowY?: ResponsiveValue<OverflowValue>;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
10
|
-
_hover?: OverflowProps;
|
|
11
|
-
_focus?: OverflowProps;
|
|
12
|
-
_active?: OverflowProps;
|
|
13
|
-
_disabled?: OverflowProps;
|
|
14
|
-
};
|
|
15
|
-
export declare function getOverflowStyles(props: OverflowProps & OverflowStateProps): StyleResult;
|
|
9
|
+
export declare function getOverflowStyles(props: OverflowProps & StateProps<OverflowProps>): StyleResult;
|
|
16
10
|
//# sourceMappingURL=overflow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overflow.d.ts","sourceRoot":"","sources":["../../../../src/components/Box/overflow/overflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"overflow.d.ts","sourceRoot":"","sources":["../../../../src/components/Box/overflow/overflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,WAAW,CAAC;AAInB,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAErE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;CAC5C,CAAC;AAmEF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC,GAC/C,WAAW,CAmBb"}
|
|
@@ -1,53 +1,48 @@
|
|
|
1
1
|
import { RESPONSIVE_KEYS, STATE_CLASS_SUFFIXES } from "../shared/constants.js";
|
|
2
2
|
import styles from "./overflow.module.css.js";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
-
|
|
5
|
-
overflow: "",
|
|
6
|
-
overflowX: "X",
|
|
7
|
-
overflowY: "Y"
|
|
8
|
-
};
|
|
9
|
-
function getOverflowClass(value, type, responsiveKey, state) {
|
|
4
|
+
function getOverflowClassForProp(value, suffix, bp, state) {
|
|
10
5
|
const stateClassSuffix = STATE_CLASS_SUFFIXES[state];
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return stateClassSuffix ? styles[`${baseClassName}${stateClassSuffix}`] : styles[baseClassName];
|
|
6
|
+
const baseKey = `${value}${suffix}`;
|
|
7
|
+
if (bp === "base") {
|
|
8
|
+
return stateClassSuffix ? styles[`${baseKey}${stateClassSuffix}`] : styles[baseKey];
|
|
15
9
|
}
|
|
16
|
-
return stateClassSuffix ? styles[`${
|
|
10
|
+
return stateClassSuffix ? styles[`${baseKey}_${bp}${stateClassSuffix}`] : styles[`${baseKey}_${bp}`];
|
|
17
11
|
}
|
|
18
|
-
function
|
|
12
|
+
function resolveOverflowProp(value, suffix, state) {
|
|
19
13
|
const result = { className: "", style: {} };
|
|
20
14
|
if (value === void 0) return result;
|
|
21
15
|
if (typeof value === "string") {
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
result.className = className;
|
|
25
|
-
}
|
|
16
|
+
const cls = getOverflowClassForProp(value, suffix, "base", state);
|
|
17
|
+
if (cls) result.className = cls;
|
|
26
18
|
return result;
|
|
27
19
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
const responsive = value;
|
|
21
|
+
const classes = [];
|
|
22
|
+
for (const key of RESPONSIVE_KEYS) {
|
|
23
|
+
const v = responsive[key];
|
|
24
|
+
if (v === void 0) continue;
|
|
25
|
+
const cls = getOverflowClassForProp(v, suffix, key, state);
|
|
26
|
+
if (cls) classes.push(cls);
|
|
27
|
+
}
|
|
28
|
+
if (classes.length > 0) {
|
|
29
|
+
result.className = classes.join(" ");
|
|
35
30
|
}
|
|
36
31
|
return result;
|
|
37
32
|
}
|
|
38
33
|
function getOverflowStylesForState(props, state) {
|
|
39
34
|
if (!props) return { className: "", style: {} };
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
35
|
+
const overflowResult = resolveOverflowProp(props.overflow, "", state);
|
|
36
|
+
const overflowXResult = resolveOverflowProp(props.overflowX, "X", state);
|
|
37
|
+
const overflowYResult = resolveOverflowProp(props.overflowY, "Y", state);
|
|
43
38
|
return {
|
|
44
|
-
className: clsx(
|
|
39
|
+
className: clsx(overflowResult.className, overflowXResult.className, overflowYResult.className),
|
|
45
40
|
style: {}
|
|
46
41
|
};
|
|
47
42
|
}
|
|
48
43
|
function getOverflowStyles(props) {
|
|
49
|
-
const {
|
|
50
|
-
const baseStyles = getOverflowStylesForState(
|
|
44
|
+
const { _hover, _focus, _active, _disabled, ...baseProps } = props;
|
|
45
|
+
const baseStyles = getOverflowStylesForState(baseProps, "base");
|
|
51
46
|
const hoverStyles = getOverflowStylesForState(_hover, "hover");
|
|
52
47
|
const focusStyles = getOverflowStylesForState(_focus, "focus");
|
|
53
48
|
const activeStyles = getOverflowStylesForState(_active, "active");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overflow.js","sources":["../../../../src/components/Box/overflow/overflow.ts"],"sourcesContent":["import type { ResponsiveValue } from \"@/utils/breakpoints\";\nimport {\n RESPONSIVE_KEYS,\n STATE_CLASS_SUFFIXES,\n type StateKey,\n type StyleResult,\n} from \"../shared\";\nimport styles from \"./overflow.module.css\";\nimport clsx from \"clsx\";\n\nexport type OverflowValue = \"auto\" | \"hidden\" | \"scroll\" | \"visible\";\n\nexport type OverflowProps = {\n overflow?: ResponsiveValue<OverflowValue>;\n overflowX?: ResponsiveValue<OverflowValue>;\n overflowY?: ResponsiveValue<OverflowValue>;\n};\n\
|
|
1
|
+
{"version":3,"file":"overflow.js","sources":["../../../../src/components/Box/overflow/overflow.ts"],"sourcesContent":["import type { ResponsiveValue, ResponsiveObject } from \"@/utils/breakpoints\";\nimport {\n RESPONSIVE_KEYS,\n STATE_CLASS_SUFFIXES,\n type StateKey,\n type StateProps,\n type StyleResult,\n} from \"../shared\";\nimport styles from \"./overflow.module.css\";\nimport clsx from \"clsx\";\n\nexport type OverflowValue = \"auto\" | \"hidden\" | \"scroll\" | \"visible\";\n\nexport type OverflowProps = {\n overflow?: ResponsiveValue<OverflowValue>;\n overflowX?: ResponsiveValue<OverflowValue>;\n overflowY?: ResponsiveValue<OverflowValue>;\n};\n\n/**\n * Overflow uses suffixed class names (e.g., \"autoX\", \"hiddenY\") rather than\n * prefixed ones, so we use a small custom lookup instead of getEnumResponsiveStyles.\n */\nfunction getOverflowClassForProp(\n value: OverflowValue,\n suffix: string,\n bp: string,\n state: StateKey\n): string | undefined {\n const stateClassSuffix = STATE_CLASS_SUFFIXES[state];\n const baseKey = `${value}${suffix}`;\n\n if (bp === \"base\") {\n return stateClassSuffix ? styles[`${baseKey}${stateClassSuffix}`] : styles[baseKey];\n }\n return stateClassSuffix\n ? styles[`${baseKey}_${bp}${stateClassSuffix}`]\n : styles[`${baseKey}_${bp}`];\n}\n\nfunction resolveOverflowProp(\n value: ResponsiveValue<OverflowValue> | undefined,\n suffix: string,\n state: StateKey\n): StyleResult {\n const result: StyleResult = { className: \"\", style: {} };\n if (value === undefined) return result;\n\n if (typeof value === \"string\") {\n const cls = getOverflowClassForProp(value, suffix, \"base\", state);\n if (cls) result.className = cls;\n return result;\n }\n\n const responsive = value as ResponsiveObject<OverflowValue>;\n const classes: string[] = [];\n for (const key of RESPONSIVE_KEYS) {\n const v = responsive[key];\n if (v === undefined) continue;\n const cls = getOverflowClassForProp(v, suffix, key, state);\n if (cls) classes.push(cls);\n }\n if (classes.length > 0) {\n result.className = classes.join(\" \");\n }\n return result;\n}\n\nfunction getOverflowStylesForState(\n props: OverflowProps | undefined,\n state: StateKey\n): StyleResult {\n if (!props) return { className: \"\", style: {} };\n\n const overflowResult = resolveOverflowProp(props.overflow, \"\", state);\n const overflowXResult = resolveOverflowProp(props.overflowX, \"X\", state);\n const overflowYResult = resolveOverflowProp(props.overflowY, \"Y\", state);\n\n return {\n className: clsx(overflowResult.className, overflowXResult.className, overflowYResult.className),\n style: {},\n };\n}\n\nexport function getOverflowStyles(\n props: OverflowProps & StateProps<OverflowProps>\n): StyleResult {\n const { _hover, _focus, _active, _disabled, ...baseProps } = props;\n\n const baseStyles = getOverflowStylesForState(baseProps, \"base\");\n const hoverStyles = getOverflowStylesForState(_hover, \"hover\");\n const focusStyles = getOverflowStylesForState(_focus, \"focus\");\n const activeStyles = getOverflowStylesForState(_active, \"active\");\n const disabledStyles = getOverflowStylesForState(_disabled, \"disabled\");\n\n return {\n className: clsx(\n baseStyles.className,\n hoverStyles.className,\n focusStyles.className,\n activeStyles.className,\n disabledStyles.className\n ),\n style: {},\n };\n}\n"],"names":[],"mappings":";;;AAuBA,SAAS,wBACP,OACA,QACA,IACA,OACoB;AACpB,QAAM,mBAAmB,qBAAqB,KAAK;AACnD,QAAM,UAAU,GAAG,KAAK,GAAG,MAAM;AAEjC,MAAI,OAAO,QAAQ;AACjB,WAAO,mBAAmB,OAAO,GAAG,OAAO,GAAG,gBAAgB,EAAE,IAAI,OAAO,OAAO;AAAA,EACpF;AACA,SAAO,mBACH,OAAO,GAAG,OAAO,IAAI,EAAE,GAAG,gBAAgB,EAAE,IAC5C,OAAO,GAAG,OAAO,IAAI,EAAE,EAAE;AAC/B;AAEA,SAAS,oBACP,OACA,QACA,OACa;AACb,QAAM,SAAsB,EAAE,WAAW,IAAI,OAAO,CAAA,EAAC;AACrD,MAAI,UAAU,OAAW,QAAO;AAEhC,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,MAAM,wBAAwB,OAAO,QAAQ,QAAQ,KAAK;AAChE,QAAI,YAAY,YAAY;AAC5B,WAAO;AAAA,EACT;AAEA,QAAM,aAAa;AACnB,QAAM,UAAoB,CAAA;AAC1B,aAAW,OAAO,iBAAiB;AACjC,UAAM,IAAI,WAAW,GAAG;AACxB,QAAI,MAAM,OAAW;AACrB,UAAM,MAAM,wBAAwB,GAAG,QAAQ,KAAK,KAAK;AACzD,QAAI,IAAK,SAAQ,KAAK,GAAG;AAAA,EAC3B;AACA,MAAI,QAAQ,SAAS,GAAG;AACtB,WAAO,YAAY,QAAQ,KAAK,GAAG;AAAA,EACrC;AACA,SAAO;AACT;AAEA,SAAS,0BACP,OACA,OACa;AACb,MAAI,CAAC,MAAO,QAAO,EAAE,WAAW,IAAI,OAAO,GAAC;AAE5C,QAAM,iBAAiB,oBAAoB,MAAM,UAAU,IAAI,KAAK;AACpE,QAAM,kBAAkB,oBAAoB,MAAM,WAAW,KAAK,KAAK;AACvE,QAAM,kBAAkB,oBAAoB,MAAM,WAAW,KAAK,KAAK;AAEvE,SAAO;AAAA,IACL,WAAW,KAAK,eAAe,WAAW,gBAAgB,WAAW,gBAAgB,SAAS;AAAA,IAC9F,OAAO,CAAA;AAAA,EAAC;AAEZ;AAEO,SAAS,kBACd,OACa;AACb,QAAM,EAAE,QAAQ,QAAQ,SAAS,WAAW,GAAG,cAAc;AAE7D,QAAM,aAAa,0BAA0B,WAAW,MAAM;AAC9D,QAAM,cAAc,0BAA0B,QAAQ,OAAO;AAC7D,QAAM,cAAc,0BAA0B,QAAQ,OAAO;AAC7D,QAAM,eAAe,0BAA0B,SAAS,QAAQ;AAChE,QAAM,iBAAiB,0BAA0B,WAAW,UAAU;AAEtE,SAAO;AAAA,IACL,WAAW;AAAA,MACT,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,eAAe;AAAA,IAAA;AAAA,IAEjB,OAAO,CAAA;AAAA,EAAC;AAEZ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"padding.d.ts","sourceRoot":"","sources":["../../../../src/components/Box/padding/padding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"padding.d.ts","sourceRoot":"","sources":["../../../../src/components/Box/padding/padding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAEL,KAAK,WAAW,EAGjB,MAAM,WAAW,CAAC;AAInB,KAAK,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAIpC,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAClC,EAAE,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACnC,EAAE,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACnC,EAAE,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACnC,EAAE,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACnC,EAAE,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACnC,EAAE,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,SAAS,CAAC,EAAE,YAAY,CAAC;CAC1B,CAAC;AAgCF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,YAAY,GAAG,iBAAiB,GACtC,WAAW,CAyBb"}
|
|
@@ -1,40 +1,7 @@
|
|
|
1
|
-
import { STATE_SUFFIXES, STATE_CLASS_SUFFIXES, RESPONSIVE_KEYS } from "../shared/constants.js";
|
|
2
1
|
import { getRawValue } from "../shared/spacing.js";
|
|
2
|
+
import { getResponsiveVarStyles } from "../shared/responsive.js";
|
|
3
3
|
import styles from "./padding.module.css.js";
|
|
4
4
|
import clsx from "clsx";
|
|
5
|
-
function getSpacingProps(key, value, state = "base") {
|
|
6
|
-
const result = { className: "", style: {} };
|
|
7
|
-
if (value === void 0) return result;
|
|
8
|
-
const stateSuffix = STATE_SUFFIXES[state];
|
|
9
|
-
const stateClassSuffix = STATE_CLASS_SUFFIXES[state];
|
|
10
|
-
if (typeof value !== "object") {
|
|
11
|
-
const rawValue = getRawValue(value);
|
|
12
|
-
if (rawValue !== void 0) {
|
|
13
|
-
const className = stateClassSuffix ? styles[`${key}${stateClassSuffix}`] : styles[key];
|
|
14
|
-
result.className = className || "";
|
|
15
|
-
result.style[`--t-${key}${stateSuffix}`] = rawValue;
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
for (const responsiveKey of RESPONSIVE_KEYS) {
|
|
20
|
-
const rawValue = getRawValue(value[responsiveKey]);
|
|
21
|
-
if (rawValue === void 0) continue;
|
|
22
|
-
let className;
|
|
23
|
-
let varName;
|
|
24
|
-
if (responsiveKey === "base") {
|
|
25
|
-
className = stateClassSuffix ? styles[`${key}${stateClassSuffix}`] : styles[key];
|
|
26
|
-
varName = `--t-${key}${stateSuffix}`;
|
|
27
|
-
} else {
|
|
28
|
-
className = stateClassSuffix ? styles[`${key}_${responsiveKey}${stateClassSuffix}`] : styles[`${key}_${responsiveKey}`];
|
|
29
|
-
varName = `--t-${key}_${responsiveKey}${stateSuffix}`;
|
|
30
|
-
}
|
|
31
|
-
if (className) {
|
|
32
|
-
result.className = clsx(result.className, className);
|
|
33
|
-
}
|
|
34
|
-
result.style[varName] = rawValue;
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
5
|
function resolvePaddingValue(key, props) {
|
|
39
6
|
const shorthandMap = {
|
|
40
7
|
pt: "py",
|
|
@@ -45,25 +12,14 @@ function resolvePaddingValue(key, props) {
|
|
|
45
12
|
return props[key] ?? props[shorthandMap[key]] ?? props.p;
|
|
46
13
|
}
|
|
47
14
|
function getPaddingStylesForState(props, state) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const paddingLeft = getSpacingProps("pl", resolvePaddingValue("pl", props), state);
|
|
15
|
+
if (!props) return { className: "", style: {} };
|
|
16
|
+
const keys = ["pt", "pr", "pb", "pl"];
|
|
17
|
+
const results = keys.map(
|
|
18
|
+
(key) => getResponsiveVarStyles(styles, key, key, resolvePaddingValue(key, props), state, getRawValue)
|
|
19
|
+
);
|
|
54
20
|
return {
|
|
55
|
-
className: clsx(
|
|
56
|
-
|
|
57
|
-
paddingRight.className,
|
|
58
|
-
paddingBottom.className,
|
|
59
|
-
paddingLeft.className
|
|
60
|
-
),
|
|
61
|
-
style: {
|
|
62
|
-
...paddingTop.style,
|
|
63
|
-
...paddingRight.style,
|
|
64
|
-
...paddingBottom.style,
|
|
65
|
-
...paddingLeft.style
|
|
66
|
-
}
|
|
21
|
+
className: clsx(...results.map((r) => r.className)),
|
|
22
|
+
style: Object.assign({}, ...results.map((r) => r.style))
|
|
67
23
|
};
|
|
68
24
|
}
|
|
69
25
|
function getPaddingStyles(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"padding.js","sources":["../../../../src/components/Box/padding/padding.ts"],"sourcesContent":["import type { ResponsiveValue } from \"@/utils/breakpoints\";\nimport {\n
|
|
1
|
+
{"version":3,"file":"padding.js","sources":["../../../../src/components/Box/padding/padding.ts"],"sourcesContent":["import type { ResponsiveValue } from \"@/utils/breakpoints\";\nimport {\n type StateKey,\n type StyleResult,\n getRawValue,\n getResponsiveVarStyles,\n} from \"../shared\";\nimport styles from \"./padding.module.css\";\nimport clsx from \"clsx\";\n\ntype SpacingValue = string | number;\ntype PaddingKey = \"pt\" | \"pr\" | \"pb\" | \"pl\";\ntype PaddingShorthandKey = \"p\" | \"px\" | \"py\";\n\nexport type PaddingProps = {\n p?: ResponsiveValue<SpacingValue>;\n pt?: ResponsiveValue<SpacingValue>;\n pr?: ResponsiveValue<SpacingValue>;\n pb?: ResponsiveValue<SpacingValue>;\n pl?: ResponsiveValue<SpacingValue>;\n px?: ResponsiveValue<SpacingValue>;\n py?: ResponsiveValue<SpacingValue>;\n};\n\nexport type PaddingStateProps = {\n _hover?: PaddingProps;\n _focus?: PaddingProps;\n _active?: PaddingProps;\n _disabled?: PaddingProps;\n};\n\nfunction resolvePaddingValue(\n key: PaddingKey,\n props: PaddingProps\n): ResponsiveValue<SpacingValue> | undefined {\n const shorthandMap: Record<PaddingKey, PaddingShorthandKey> = {\n pt: \"py\",\n pb: \"py\",\n pr: \"px\",\n pl: \"px\",\n };\n return props[key] ?? props[shorthandMap[key]] ?? props.p;\n}\n\nfunction getPaddingStylesForState(\n props: PaddingProps | undefined,\n state: StateKey\n): StyleResult {\n if (!props) return { className: \"\", style: {} };\n\n const keys: PaddingKey[] = [\"pt\", \"pr\", \"pb\", \"pl\"];\n const results = keys.map((key) =>\n getResponsiveVarStyles(styles, key, key, resolvePaddingValue(key, props), state, getRawValue)\n );\n\n return {\n className: clsx(...results.map((r) => r.className)),\n style: Object.assign({}, ...results.map((r) => r.style)),\n };\n}\n\nexport function getPaddingStyles(\n props: PaddingProps & PaddingStateProps\n): StyleResult {\n const { _hover, _focus, _active, _disabled, ...baseProps } = props;\n\n const baseStyles = getPaddingStylesForState(baseProps, \"base\");\n const hoverStyles = getPaddingStylesForState(_hover, \"hover\");\n const focusStyles = getPaddingStylesForState(_focus, \"focus\");\n const activeStyles = getPaddingStylesForState(_active, \"active\");\n const disabledStyles = getPaddingStylesForState(_disabled, \"disabled\");\n\n return {\n className: clsx(\n baseStyles.className,\n hoverStyles.className,\n focusStyles.className,\n activeStyles.className,\n disabledStyles.className\n ),\n style: {\n ...baseStyles.style,\n ...hoverStyles.style,\n ...focusStyles.style,\n ...activeStyles.style,\n ...disabledStyles.style,\n },\n };\n}\n"],"names":[],"mappings":";;;;AA+BA,SAAS,oBACP,KACA,OAC2C;AAC3C,QAAM,eAAwD;AAAA,IAC5D,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,EAAA;AAEN,SAAO,MAAM,GAAG,KAAK,MAAM,aAAa,GAAG,CAAC,KAAK,MAAM;AACzD;AAEA,SAAS,yBACP,OACA,OACa;AACb,MAAI,CAAC,MAAO,QAAO,EAAE,WAAW,IAAI,OAAO,GAAC;AAE5C,QAAM,OAAqB,CAAC,MAAM,MAAM,MAAM,IAAI;AAClD,QAAM,UAAU,KAAK;AAAA,IAAI,CAAC,QACxB,uBAAuB,QAAQ,KAAK,KAAK,oBAAoB,KAAK,KAAK,GAAG,OAAO,WAAW;AAAA,EAAA;AAG9F,SAAO;AAAA,IACL,WAAW,KAAK,GAAG,QAAQ,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC;AAAA,IAClD,OAAO,OAAO,OAAO,IAAI,GAAG,QAAQ,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;AAAA,EAAA;AAE3D;AAEO,SAAS,iBACd,OACa;AACb,QAAM,EAAE,QAAQ,QAAQ,SAAS,WAAW,GAAG,cAAc;AAE7D,QAAM,aAAa,yBAAyB,WAAW,MAAM;AAC7D,QAAM,cAAc,yBAAyB,QAAQ,OAAO;AAC5D,QAAM,cAAc,yBAAyB,QAAQ,OAAO;AAC5D,QAAM,eAAe,yBAAyB,SAAS,QAAQ;AAC/D,QAAM,iBAAiB,yBAAyB,WAAW,UAAU;AAErE,SAAO;AAAA,IACL,WAAW;AAAA,MACT,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,eAAe;AAAA,IAAA;AAAA,IAEjB,OAAO;AAAA,MACL,GAAG,WAAW;AAAA,MACd,GAAG,YAAY;AAAA,MACf,GAAG,YAAY;AAAA,MACf,GAAG,aAAa;AAAA,MAChB,GAAG,eAAe;AAAA,IAAA;AAAA,EACpB;AAEJ;"}
|