softable-pixels-web 1.0.7 → 1.1.0
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/dist/{Button-B9tDbn4Q.js → Button-nrM-Dn6T.js} +20 -12
- package/dist/Button-nrM-Dn6T.js.map +1 -0
- package/dist/{CheckItem-CBzbinCc.js → CheckItem-Cr8YZFKe.js} +6 -5
- package/dist/CheckItem-Cr8YZFKe.js.map +1 -0
- package/dist/{Checkbox-l_SA4qUE.js → Checkbox-BRAE-Kg-.js} +8 -7
- package/dist/Checkbox-BRAE-Kg-.js.map +1 -0
- package/dist/{Icon-BrLGgg0w.js → Icon-7fQw74zg.js} +4 -4
- package/dist/{Icon-BrLGgg0w.js.map → Icon-7fQw74zg.js.map} +1 -1
- package/dist/IconButton-B7-l2DTb.js +81 -0
- package/dist/IconButton-B7-l2DTb.js.map +1 -0
- package/dist/{InfoSummary-CHRfCc3v.js → InfoSummary-D2ER39sF.js} +13 -12
- package/dist/InfoSummary-D2ER39sF.js.map +1 -0
- package/dist/{Input-CUZNjGoG.js → Input-BR3ZaetX.js} +8 -7
- package/dist/Input-BR3ZaetX.js.map +1 -0
- package/dist/{Label-BVteAeiK.js → Label-1Gh2DlKl.js} +5 -4
- package/dist/Label-1Gh2DlKl.js.map +1 -0
- package/dist/{TabSwitch-DRs6-76U.js → TabSwitch-Ce-uQvRp.js} +8 -11
- package/dist/TabSwitch-Ce-uQvRp.js.map +1 -0
- package/dist/{TextArea-ZKDCCx4I.js → TextArea-BsErpaMx.js} +7 -6
- package/dist/TextArea-BsErpaMx.js.map +1 -0
- package/dist/{ThemeContext-BQQnMo5F.js → ThemeContext-BsU2ZyE5.js} +52 -90
- package/dist/ThemeContext-BsU2ZyE5.js.map +1 -0
- package/dist/Typography-CKXLkfw7.js +148 -0
- package/dist/Typography-CKXLkfw7.js.map +1 -0
- package/dist/button.d.ts +2 -2
- package/dist/button.js +3 -2
- package/dist/check-item.d.ts +1 -1
- package/dist/check-item.js +4 -3
- package/dist/checkbox.d.ts +2 -2
- package/dist/checkbox.js +4 -3
- package/dist/icon-button.d.ts +2 -0
- package/dist/icon-button.js +4 -0
- package/dist/index-BYZm15m2.d.ts +26 -0
- package/dist/{index-CXR_rnK-.d.ts → index-BrVPSHH2.d.ts} +11 -11
- package/dist/{index-Cbt7nYQB.d.ts → index-C181qAfZ.d.ts} +3 -2
- package/dist/{index-H8VYQre4.d.ts → index-CIxyqe-m.d.ts} +4 -13
- package/dist/{index-CqAWI5LI.d.ts → index-Da42fqu3.d.ts} +2 -2
- package/dist/{index-x_PYKZgv.d.ts → index-R-Kb8ovB.d.ts} +48 -3
- package/dist/{index-CADs9cEh.d.ts → index-akSk71wZ.d.ts} +1 -1
- package/dist/{index-BvkboQOE.d.ts → index-v4w-T_f6.d.ts} +14 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +14 -12
- package/dist/info-summary.js +3 -2
- package/dist/input.d.ts +2 -2
- package/dist/input.js +5 -4
- package/dist/styleProps-7WdaXgmQ.d.ts +39 -0
- package/dist/tab-switch.d.ts +1 -1
- package/dist/tab-switch.js +3 -2
- package/dist/text-area.d.ts +2 -2
- package/dist/text-area.js +5 -4
- package/dist/theme-context.d.ts +1 -1
- package/dist/theme-context.js +3 -1
- package/dist/{types-_ZbgGCjb.d.ts → types-CdA3IIV2.d.ts} +4 -3
- package/dist/typography.d.ts +1 -1
- package/dist/typography.js +2 -1
- package/dist/{Typography-BaE9Y1O8.js → useThemedStyles-68D71Lua.js} +30 -159
- package/dist/useThemedStyles-68D71Lua.js.map +1 -0
- package/dist/{useThemedStyles-_SsqjB7Q.d.ts → useThemedStyles-CXoofBTv.d.ts} +10 -39
- package/package.json +8 -1
- package/dist/Button-B9tDbn4Q.js.map +0 -1
- package/dist/CheckItem-CBzbinCc.js.map +0 -1
- package/dist/Checkbox-l_SA4qUE.js.map +0 -1
- package/dist/InfoSummary-CHRfCc3v.js.map +0 -1
- package/dist/Input-CUZNjGoG.js.map +0 -1
- package/dist/Label-BVteAeiK.js.map +0 -1
- package/dist/TabSwitch-DRs6-76U.js.map +0 -1
- package/dist/TextArea-ZKDCCx4I.js.map +0 -1
- package/dist/ThemeContext-BQQnMo5F.js.map +0 -1
- package/dist/Typography-BaE9Y1O8.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input-BR3ZaetX.js","names":["Input: React.FC<InputProps>"],"sources":["../src/components/commons/inputs/Input/hooks/useInput/index.ts","../src/components/commons/inputs/Input/styles.ts","../src/components/commons/inputs/Input/index.tsx"],"sourcesContent":["// External Libraries\nimport { useState, useRef, useCallback } from 'react'\n\n// Types\nimport type { InputProps } from '../../types'\n\nexport const useInput = ({\n value: controlledValue,\n defaultValue = '',\n onChange,\n}: Partial<InputProps>) => {\n // Refs\n const inputRef = useRef<HTMLInputElement>(null)\n\n // States\n const [internalValue, setInternalValue] = useState(defaultValue)\n const [showPassword, setShowPassword] = useState(false)\n\n // Constants\n const isControlled = controlledValue !== undefined\n const currentValue = isControlled ? controlledValue : internalValue\n\n // Functions\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value\n\n if (!isControlled) setInternalValue(value)\n onChange?.(value)\n },\n [isControlled, onChange],\n )\n\n const togglePasswordVisibility = useCallback(() => {\n setShowPassword(prev => !prev)\n }, [])\n\n const focusInput = useCallback(() => {\n inputRef.current?.focus()\n }, [])\n\n return {\n inputRef,\n focusInput,\n isControlled,\n currentValue,\n showPassword,\n handleChange,\n togglePasswordVisibility,\n }\n}\n","// External libraries\nimport type { CSSProperties } from 'react'\n\n// Types\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\nimport type { InputProps } from './types'\n\nexport const INPUT_STYLES = {\n width: {\n auto: { width: 'auto' },\n full: { width: '100%' },\n md: { width: '12rem' },\n lg: { width: '16rem' },\n xl: { width: '20rem' },\n '2xl': { width: '24rem' }\n } as Record<string, CSSProperties>,\n radius: {\n none: { borderRadius: '0px' },\n sm: { borderRadius: '0.125rem' },\n md: { borderRadius: '0.375rem' },\n lg: { borderRadius: '0.5rem' },\n full: { borderRadius: '9999px' }\n } as Record<string, CSSProperties>,\n size: {\n sm: {\n wrapper: { minHeight: '2rem' },\n input: {\n padding: '0.5rem 0.75rem',\n lineHeight: '1rem',\n fontSize: '0.75rem'\n },\n label: {\n fontSize: '0.75rem',\n lineHeight: '1rem',\n marginBottom: '0.25rem'\n },\n description: {\n fontSize: '0.75rem',\n lineHeight: '1rem',\n marginTop: '0.25rem'\n },\n error: {\n fontSize: '0.75rem',\n lineHeight: '1rem',\n marginTop: '0.25rem'\n }\n } as Record<string, CSSProperties>,\n md: {\n wrapper: { minHeight: '2.5rem' },\n input: {\n padding: '0.5rem 0.75rem',\n lineHeight: '1.25rem',\n fontSize: '0.875rem'\n },\n label: {\n fontSize: '0.875rem',\n lineHeight: '1.25rem',\n marginBottom: '0.375rem'\n },\n description: {\n fontSize: '0.75rem',\n lineHeight: '1rem',\n marginTop: '0.375rem'\n },\n error: {\n fontSize: '0.75rem',\n lineHeight: '1rem',\n marginTop: '0.375rem'\n }\n } as Record<string, CSSProperties>,\n lg: {\n wrapper: { minHeight: '3rem' },\n input: {\n padding: '0.75rem 1rem',\n lineHeight: '1.5rem',\n fontSize: '1rem',\n width: '16rem'\n },\n label: {\n fontSize: '0.875rem',\n lineHeight: '1.25rem',\n marginBottom: '0.5rem'\n },\n description: {\n fontSize: '0.875rem',\n lineHeight: '1.25rem',\n marginTop: '0.5rem'\n },\n error: {\n fontSize: '0.875rem',\n lineHeight: '1.25rem',\n marginTop: '0.5rem'\n }\n } as Record<string, CSSProperties>\n },\n variant: {\n bordered: {\n wrapper: { border: '1px solid var(--px-border-primary)' },\n input: {\n backgroundColor: 'transparent',\n color: 'var(--px-text-primary)',\n '::placeholder': {\n color: 'var(--px-text-secondary)'\n }\n },\n label: { color: 'var(--px-text-primary)' },\n button: {\n color: 'var(--px-text-secondary)',\n ':hover': { color: 'var(--px-text-primary)' }\n }\n } as Record<string, CSSProperties>\n },\n state: {\n default: {\n input: {},\n ring: {\n boxShadow: '0 0 0 2px var(--px-color-info)'\n }\n },\n invalid: {\n wrapper: {\n borderColor: 'var(--px-color-invalid)',\n __rules: {\n '&:focus-within': {\n boxShadow:\n '0 0 0 1px var(--px-background), 0 0 0 3px var(--px-color-invalid)'\n }\n }\n },\n input: {\n color: 'var(--px-color-invalid)'\n },\n error: {\n color: 'var(--px-color-invalid)'\n }\n },\n\n disabled: {\n wrapper: {\n opacity: 0.6,\n cursor: 'not-allowed',\n backgroundColor: '#f9fafb'\n },\n input: {\n cursor: 'not-allowed'\n },\n label: {\n cursor: 'not-allowed'\n }\n }\n } as Record<string, Partial<StyleMap>>\n}\n\nexport function createInputStyles(props: InputProps): StyleMap {\n const {\n size = 'md',\n variant = 'bordered',\n radius = 'md',\n isDisabled = false,\n isInvalid = false,\n focusedRingColor\n } = props\n\n const focusRingColor = focusedRingColor || 'var(--px-color-info)'\n\n return styled({\n wrapper: {\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n\n ...(INPUT_STYLES.size[size]?.wrapper ?? {}),\n ...(INPUT_STYLES.variant[variant]?.wrapper ?? {}),\n ...(INPUT_STYLES.radius[radius] ?? {}),\n\n __rules: {\n '&:focus-within': {\n boxShadow: `0 0 0 1px var(--px-background), 0 0 0 3px ${focusRingColor}`\n }\n },\n\n ...(isDisabled ? INPUT_STYLES.state.disabled.wrapper : {}),\n ...(isInvalid ? INPUT_STYLES.state.invalid.wrapper : {})\n },\n\n input: {\n flex: 1,\n backgroundColor: 'transparent',\n outline: 'none',\n width: '100%',\n\n ...(INPUT_STYLES.size[size]?.input ?? {}),\n\n ...(INPUT_STYLES.variant[variant]?.input ?? {}),\n ...(INPUT_STYLES.state.default.input ?? {}),\n\n ...(isDisabled ? INPUT_STYLES.state.disabled.input : {}),\n ...(isInvalid ? INPUT_STYLES.state.invalid.input : {})\n },\n\n label: {\n ...(INPUT_STYLES.size[size]?.label ?? {}),\n ...(INPUT_STYLES.variant[variant]?.label ?? {}),\n\n ...(isDisabled ? INPUT_STYLES.state.disabled.label : {})\n },\n\n error: {\n display: 'block',\n\n ...(INPUT_STYLES.size[size]?.error ?? {}),\n ...(INPUT_STYLES.state.invalid.error ?? {})\n },\n\n button: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n padding: '0.25rem',\n cursor: 'pointer',\n\n ...(INPUT_STYLES.variant[variant]?.button ?? {}),\n ...(INPUT_STYLES.radius[radius] ?? {}),\n\n ...(isDisabled ? { cursor: 'not-allowed', opacity: 0.5 } : {})\n },\n\n startContent: {\n display: 'flex',\n alignItems: 'center',\n padding: '0.25rem'\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\nimport { useId, useMemo } from 'react'\n\n// Components\nimport { Label } from '../../Label'\nimport { Icon } from '@components/toolkit/Icon'\n\n// Types\nimport type { InputProps } from './types'\n\n// Hooks\nimport { useInput } from './hooks/useInput'\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Styles\nimport { createInputStyles, INPUT_STYLES } from './styles'\n\nexport const Input: React.FC<InputProps> = props => {\n // Hooks\n const {\n id,\n type,\n label,\n width,\n fullWidth,\n required,\n isDisabled,\n minLength,\n maxLength,\n placeholder,\n requiredColor,\n labelColor,\n labelWeight,\n labelVariant,\n startContent,\n endContent,\n errorMessage,\n onChange,\n value,\n defaultValue,\n size,\n radius,\n variant,\n isInvalid,\n ...nativeInputProps\n } = props\n\n const {\n inputRef,\n currentValue,\n showPassword,\n handleChange,\n togglePasswordVisibility\n } = useInput({\n size,\n value,\n radius,\n variant,\n isInvalid,\n fullWidth,\n isDisabled,\n defaultValue,\n onChange\n })\n\n // Constants\n const reactId = useId()\n const inputId = useMemo(() => {\n return id || `input-${reactId}`\n }, [id, reactId])\n const containerWidth = getWidth()\n\n // Hooks\n const { styles, classes } = useThemedStyles(props, createInputStyles, {\n pick: p => [\n p.size,\n p.variant,\n p.radius,\n p.isDisabled,\n p.isInvalid,\n p.focusedRingColor\n ],\n override: props.styles,\n applyCommonProps: true,\n commonSlot: 'input'\n })\n\n // Functions\n function getType() {\n if (type === 'password' && showPassword) return 'text'\n return type\n }\n\n function getWidth() {\n if (fullWidth) return { width: '100%' }\n if (width) return INPUT_STYLES.width[width] || { width: 'auto' }\n return { width: 'auto' }\n }\n\n function renderLabel() {\n if (!label) return null\n\n return (\n <div className=\"flex items-center gap-3\">\n <Label\n htmlFor={inputId}\n label={label}\n required={required}\n styles={{ label: styles.label }}\n requiredColor={requiredColor}\n labelColor={labelColor}\n labelWeight={labelWeight}\n labelVariant={labelVariant}\n />\n </div>\n )\n }\n\n function renderEndContent() {\n return (\n <>\n {type === 'password' ? (\n <button\n type=\"button\"\n style={styles.button}\n onClick={togglePasswordVisibility}\n >\n {showPassword ? (\n <Icon name={'general-eye-off'} />\n ) : (\n <Icon name={'general-eye'} />\n )}\n </button>\n ) : (\n endContent\n )}\n </>\n )\n }\n\n return (\n <div style={containerWidth}>\n {renderLabel()}\n <div style={styles.wrapper} className={classes.wrapper}>\n {startContent && <div style={styles.startContent}>{startContent}</div>}\n <div style={{ flex: 1 }}>\n <input\n ref={inputRef}\n id={inputId}\n type={getType()}\n value={currentValue}\n style={styles.input}\n className={classes.input}\n disabled={isDisabled}\n minLength={minLength}\n maxLength={maxLength}\n placeholder={placeholder ?? 'Digite aqui...'}\n onChange={handleChange}\n {...nativeInputProps}\n />\n </div>\n {renderEndContent() && <div>{renderEndContent()}</div>}\n </div>\n\n {errorMessage ? <div style={styles.error}>{errorMessage}</div> : null}\n </div>\n )\n}\n"],"mappings":";;;;;;;AAMA,MAAa,YAAY,EACvB,OAAO,iBACP,eAAe,IACf,eACyB;CAEzB,MAAM,WAAW,OAAyB,KAAK;CAG/C,MAAM,CAAC,eAAe,oBAAoB,SAAS,aAAa;CAChE,MAAM,CAAC,cAAc,mBAAmB,SAAS,MAAM;CAGvD,MAAM,eAAe,oBAAoB;CACzC,MAAM,eAAe,eAAe,kB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ACC;OACA;OACX,aAAa,eAAe;OAC5B,UAAU;OACV,GAAI;QACJ;OACE;KACL,kBAAkB,IAAI,oBAAC,mBAAK,kBAAkB,GAAO;;KAClD;GAEL,eAAe,oBAAC;IAAI,OAAO,OAAO;cAAQ;KAAmB,GAAG;;GAC7D"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { n as useThemedStyles, t as
|
|
1
|
+
import { n as useThemedStyles, t as styled } from "./useThemedStyles-68D71Lua.js";
|
|
2
|
+
import { t as Typography } from "./Typography-CKXLkfw7.js";
|
|
2
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
4
|
|
|
4
5
|
//#region src/components/commons/Label/style.ts
|
|
@@ -18,7 +19,7 @@ const LABEL_VARIANTS = {
|
|
|
18
19
|
};
|
|
19
20
|
function createLabelStyles(props) {
|
|
20
21
|
const { labelColor, labelWeight, labelVariant = "b2", requiredColor } = props;
|
|
21
|
-
return {
|
|
22
|
+
return styled({
|
|
22
23
|
label: {
|
|
23
24
|
display: "inline-flex",
|
|
24
25
|
alignItems: "center",
|
|
@@ -33,7 +34,7 @@ function createLabelStyles(props) {
|
|
|
33
34
|
fontSize: "inherit",
|
|
34
35
|
fontWeight: "inherit"
|
|
35
36
|
}
|
|
36
|
-
};
|
|
37
|
+
});
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
//#endregion
|
|
@@ -75,4 +76,4 @@ const Label = (props) => {
|
|
|
75
76
|
|
|
76
77
|
//#endregion
|
|
77
78
|
export { Label as t };
|
|
78
|
-
//# sourceMappingURL=Label-
|
|
79
|
+
//# sourceMappingURL=Label-1Gh2DlKl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Label-1Gh2DlKl.js","names":["LABEL_VARIANTS: Record<string, CSSProperties>"],"sources":["../src/components/commons/Label/style.ts","../src/components/commons/Label/index.tsx"],"sourcesContent":["// External libraries\nimport type { CSSProperties } from 'react'\n\n// Types\nimport type { LabelProps } from './types'\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\n\nconst LABEL_VARIANTS: Record<string, CSSProperties> = {\n b1: {\n fontSize: '1rem',\n lineHeight: '1.5rem'\n },\n b2: {\n fontSize: '0.875rem',\n lineHeight: '1.25rem'\n },\n b3: {\n fontSize: '0.75rem',\n lineHeight: '1rem'\n }\n}\n\nexport function createLabelStyles(props: LabelProps): StyleMap {\n const { labelColor, labelWeight, labelVariant = 'b2', requiredColor } = props\n\n return styled({\n label: {\n display: 'inline-flex',\n alignItems: 'center',\n gap: '0.25rem',\n fontWeight: labelWeight,\n\n ...(LABEL_VARIANTS[labelVariant] ?? {}),\n\n ...(labelColor ? { color: labelColor } : {})\n },\n\n required: {\n color: requiredColor,\n lineHeight: 'inherit',\n fontSize: 'inherit',\n fontWeight: 'inherit'\n }\n })\n}\n","// Components\nimport { Typography } from '@components/toolkit/Typography'\n\n// Types\nimport type { LabelProps } from './types'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Styles\nimport { createLabelStyles } from './style'\n\nexport const Label = (props: LabelProps) => {\n const {\n htmlFor,\n label,\n required,\n requiredColor,\n labelColor,\n labelWeight,\n labelVariant = 'b2',\n } = props\n\n const { styles } = useThemedStyles(props, createLabelStyles, {\n pick: p => [p.labelColor, p.labelWeight, p.labelVariant, p.requiredColor],\n override: props.styles,\n applyCommonProps: true,\n })\n\n return (\n <label htmlFor={htmlFor} style={styles.label}>\n <Typography\n variant={labelVariant}\n styles={{\n text: {\n minWidth: 'fit-content',\n color: labelColor,\n fontWeight: labelWeight,\n },\n }}\n >\n {label}\n\n {required ? (\n <Typography\n as=\"span\"\n variant=\"b2\"\n styles={{ text: { color: requiredColor, marginLeft: '0.125rem' } }}\n >\n *\n </Typography>\n ) : null}\n </Typography>\n </label>\n )\n}\n"],"mappings":";;;;;AAOA,MAAMA,iBAAgD;CACpD,IAAI;EACF,UAAU;EACV,YAAY;EACb;CACD,IAAI;EACF,UAAU;EACV,YAAY;EACb;CACD,IAAI;EACF,UAAU;EACV,YAAY;EACb;CACF;AAED,SAAgB,kBAAkB,OAA6B;CAC7D,MAAM,EAAE,YAAY,aAAa,eAAe,MAAM,kBAAkB;AAExE,QAAO,OAAO;EACZ,OAAO;GACL,SAAS;GACT,YAAY;GACZ,KAAK;GACL,YAAY;GAEZ,GAAI,eAAe,iBAAiB,EAAE;GAEtC,GAAI,aAAa,EAAE,OAAO,YAAY,GAAG,EAAE;GAC5C;EAED,UAAU;GACR,OAAO;GACP,YAAY;GACZ,UAAU;GACV,YAAY;GACb;EACF,CAAC;;;;;AC/BJ,MAAa,SAAS,UAAsB;CAC1C,MAAM,EACJ,SACA,OACA,UACA,eACA,YACA,aACA,eAAe,SACb;CAEJ,MAAM,EAAE,WAAW,gBAAgB,OAAO,mBAAmB;EAC3D,OAAM,MAAK;GAAC,EAAE;GAAY,EAAE;GAAa,EAAE;GAAc,EAAE;GAAc;EACzE,UAAU,MAAM;EAChB,kBAAkB;EACnB,CAAC;AAEF,QACE,oBAAC;EAAe;EAAS,OAAO,OAAO;YACrC,qBAAC;GACC,SAAS;GACT,QAAQ,EACN,MAAM;IACJ,UAAU;IACV,OAAO;IACP,YAAY;IACb,EACF;cAEA,OAEA,WACC,oBAAC;IACC,IAAG;IACH,SAAQ;IACR,QAAQ,EAAE,MAAM;KAAE,OAAO;KAAe,YAAY;KAAY,EAAE;cACnE;KAEY,GACX;IACO;GACP"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { n as useThemedStyles, t as
|
|
1
|
+
import { n as useThemedStyles, t as styled } from "./useThemedStyles-68D71Lua.js";
|
|
2
|
+
import { t as Typography } from "./Typography-CKXLkfw7.js";
|
|
2
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
4
|
import { motion } from "framer-motion";
|
|
4
5
|
|
|
5
6
|
//#region src/components/toolkit/TabSwitch/components/TabSwitchItem/styles.ts
|
|
6
7
|
function createTabSwitchItemStyles({ variant, disabled, selected, selectedColor }) {
|
|
7
8
|
const accent = selectedColor ?? "var(--px-color-primary)";
|
|
8
|
-
return {
|
|
9
|
+
return styled({
|
|
9
10
|
item: {
|
|
10
11
|
minHeight: "1.25rem",
|
|
11
12
|
position: "relative",
|
|
@@ -36,7 +37,7 @@ function createTabSwitchItemStyles({ variant, disabled, selected, selectedColor
|
|
|
36
37
|
height: 2,
|
|
37
38
|
background: selected ? accent : "transparent"
|
|
38
39
|
}
|
|
39
|
-
};
|
|
40
|
+
});
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
//#endregion
|
|
@@ -78,7 +79,7 @@ const SwitchItem = (props) => {
|
|
|
78
79
|
//#region src/components/toolkit/TabSwitch/styles.ts
|
|
79
80
|
function createTabSwitchStyles(props) {
|
|
80
81
|
const { fitContent } = props;
|
|
81
|
-
return { container: {
|
|
82
|
+
return styled({ container: {
|
|
82
83
|
display: "flex",
|
|
83
84
|
flexDirection: "row",
|
|
84
85
|
alignItems: "center",
|
|
@@ -87,7 +88,7 @@ function createTabSwitchStyles(props) {
|
|
|
87
88
|
borderBottom: "1px solid var(--px-border-primaryder, #e5e7eb)",
|
|
88
89
|
gap: 0,
|
|
89
90
|
__rules: { "& svg": { zIndex: 1 } }
|
|
90
|
-
} };
|
|
91
|
+
} });
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
//#endregion
|
|
@@ -96,11 +97,7 @@ const TabSwitch = (props) => {
|
|
|
96
97
|
{
|
|
97
98
|
const { options, disabled, layoutId, currentValue, variant = "default", onChange } = props;
|
|
98
99
|
const { styles, classes } = useThemedStyles(props, createTabSwitchStyles, {
|
|
99
|
-
pick: (p) => [
|
|
100
|
-
p.fitContent,
|
|
101
|
-
p.selectedLabelColor,
|
|
102
|
-
p.variant
|
|
103
|
-
],
|
|
100
|
+
pick: (p) => [p.disabled, p.currentValue],
|
|
104
101
|
override: props.styles,
|
|
105
102
|
applyCommonProps: true
|
|
106
103
|
});
|
|
@@ -123,4 +120,4 @@ const TabSwitch = (props) => {
|
|
|
123
120
|
|
|
124
121
|
//#endregion
|
|
125
122
|
export { TabSwitch as t };
|
|
126
|
-
//# sourceMappingURL=TabSwitch-
|
|
123
|
+
//# sourceMappingURL=TabSwitch-Ce-uQvRp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabSwitch-Ce-uQvRp.js","names":[],"sources":["../src/components/toolkit/TabSwitch/components/TabSwitchItem/styles.ts","../src/components/toolkit/TabSwitch/components/TabSwitchItem/index.tsx","../src/components/toolkit/TabSwitch/styles.ts","../src/components/toolkit/TabSwitch/index.tsx"],"sourcesContent":["// External Libraries\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\n\ninterface Params {\n disabled?: boolean\n selected?: boolean\n selectedColor?: string\n variant: 'default' | 'underline'\n}\n\nexport function createTabSwitchItemStyles({\n variant,\n disabled,\n selected,\n selectedColor\n}: Params): StyleMap {\n const accent = selectedColor ?? 'var(--px-color-primary)'\n\n return styled({\n item: {\n minHeight: '1.25rem',\n position: 'relative',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n background: 'transparent',\n border: 0,\n padding: '8px 10px',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.5 : 1,\n userSelect: 'none',\n whiteSpace: 'nowrap',\n __rules: { '& > p': { zIndex: 1 } }\n },\n\n selectedBg:\n variant === 'default'\n ? {\n position: 'absolute',\n inset: 0,\n borderRadius: 6,\n border: '1px solid var(--px-border-primary)',\n background: selected ? accent : 'transparent'\n }\n : {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: -2,\n height: 2,\n background: selected ? accent : 'transparent'\n }\n })\n}\n","// External Libraries\nimport { motion } from 'framer-motion'\n\n// Components\nimport { Typography } from '@components/toolkit/Typography'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { SwitchOption } from '../../types'\n\n// Styles\nimport { createTabSwitchItemStyles } from './styles'\n\ntype Props<T> = {\n option: SwitchOption<T>\n selected: boolean\n layoutId?: string\n disabled?: boolean\n selectedColor?: string\n selectedLabelColor?: string\n variant: 'default' | 'underline'\n onClick: (value: T) => void\n}\n\nexport const SwitchItem = <T,>(props: Props<T>) => {\n const { option, disabled, selected, layoutId, onClick } = props\n\n const { styles, classes } = useThemedStyles(\n props,\n createTabSwitchItemStyles,\n {\n pick: p => [p.variant, p.selectedColor, p.selectedLabelColor, p.selected]\n }\n )\n\n const isDisabled = disabled || option.disabled\n\n return (\n <button\n type=\"button\"\n style={styles.item}\n className={classes.item}\n tabIndex={isDisabled ? -1 : 0}\n onClick={() => !isDisabled && onClick(option.value)}\n >\n {selected ? (\n <motion.div\n layoutId={layoutId || 'pixel-tabswitch-selected'}\n style={styles.selectedBg}\n />\n ) : null}\n\n {option.icon ? (\n <span style={{ display: 'inline-flex' }}>{option.icon}</span>\n ) : null}\n\n <Typography variant=\"b1\" fontWeight=\"bold\">\n {option.label}\n </Typography>\n </button>\n )\n}\n","// Types\nimport type { TabSwitchProps } from './types'\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\n\nexport function createTabSwitchStyles<T>(props: TabSwitchProps<T>): StyleMap {\n const { fitContent } = props\n\n return styled({\n container: {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n color: 'var(--px-text-primary, #4b5563)',\n width: fitContent ? 'fit-content' : '100%',\n borderBottom: '1px solid var(--px-border-primaryder, #e5e7eb)',\n gap: 0,\n __rules: { '& svg': { zIndex: 1 } }\n }\n })\n}\n","// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Components\nimport { SwitchItem } from './components/TabSwitchItem'\n\n// Types\nimport type { TabSwitchProps } from './types'\n\n// Styles\nimport { createTabSwitchStyles } from './styles'\n\nexport * from './types'\n\nexport const TabSwitch = <T,>(props: TabSwitchProps<T>) => {\n {\n const {\n options,\n disabled,\n layoutId,\n currentValue,\n variant = 'default',\n onChange\n } = props\n\n const { styles, classes } = useThemedStyles(props, createTabSwitchStyles, {\n pick: p => [p.disabled, p.currentValue],\n override: props.styles,\n applyCommonProps: true\n })\n\n return (\n <div style={styles.container} className={classes.container}>\n {options.map(opt => (\n <SwitchItem\n key={String(opt.value)}\n option={opt}\n variant={variant}\n layoutId={layoutId}\n disabled={disabled}\n selectedColor={props.selectedColor}\n selected={currentValue === opt.value}\n selectedLabelColor={props.selectedLabelColor}\n onClick={onChange}\n />\n ))}\n </div>\n )\n }\n}\n"],"mappings":";;;;;;AAUA,SAAgB,0BAA0B,EACxC,SACA,UACA,UACA,iBACmB;CACnB,MAAM,SAAS,iBAAiB;AAEhC,QAAO,OAAO;EACZ,MAAM;GACJ,WAAW;GACX,UAAU;GACV,SAAS;GACT,YAAY;GACZ,gBAAgB;GAChB,KAAK;GACL,YAAY;GACZ,QAAQ;GACR,SAAS;GACT,QAAQ,WAAW,gBAAgB;GACnC,SAAS,WAAW,KAAM;GAC1B,YAAY;GACZ,YAAY;GACZ,SAAS,EAAE,SAAS,EAAE,QAAQ,GAAG,EAAE;GACpC;EAED,YACE,YAAY,YACR;GACE,UAAU;GACV,OAAO;GACP,cAAc;GACd,QAAQ;GACR,YAAY,WAAW,SAAS;GACjC,GACD;GACE,UAAU;GACV,MAAM;GACN,OAAO;GACP,QAAQ;GACR,QAAQ;GACR,YAAY,WAAW,SAAS;GACjC;EACR,CAAC;;;;;AC3BJ,MAAa,cAAkB,UAAoB;CACjD,MAAM,EAAE,QAAQ,UAAU,UAAU,UAAU,YAAY;CAE1D,MAAM,EAAE,QAAQ,YAAY,gBAC1B,OACA,2BACA,EACE,OAAM,MAAK;EAAC,EAAE;EAAS,EAAE;EAAe,EAAE;EAAoB,EAAE;EAAS,EAC1E,CACF;CAED,MAAM,aAAa,YAAY,OAAO;AAEtC,QACE,qBAAC;EACC,MAAK;EACL,OAAO,OAAO;EACd,WAAW,QAAQ;EACnB,UAAU,aAAa,KAAK;EAC5B,eAAe,CAAC,cAAc,QAAQ,OAAO,MAAM;;GAElD,WACC,oBAAC,OAAO;IACN,UAAU,YAAY;IACtB,OAAO,OAAO;KACd,GACA;GAEH,OAAO,OACN,oBAAC;IAAK,OAAO,EAAE,SAAS,eAAe;cAAG,OAAO;KAAY,GAC3D;GAEJ,oBAAC;IAAW,SAAQ;IAAK,YAAW;cACjC,OAAO;KACG;;GACN;;;;;ACzDb,SAAgB,sBAAyB,OAAoC;CAC3E,MAAM,EAAE,eAAe;AAEvB,QAAO,OAAO,EACZ,WAAW;EACT,SAAS;EACT,eAAe;EACf,YAAY;EACZ,OAAO;EACP,OAAO,aAAa,gBAAgB;EACpC,cAAc;EACd,KAAK;EACL,SAAS,EAAE,SAAS,EAAE,QAAQ,GAAG,EAAE;EACpC,EACF,CAAC;;;;;ACJJ,MAAa,aAAiB,UAA6B;CACzD;EACE,MAAM,EACJ,SACA,UACA,UACA,cACA,UAAU,WACV,aACE;EAEJ,MAAM,EAAE,QAAQ,YAAY,gBAAgB,OAAO,uBAAuB;GACxE,OAAM,MAAK,CAAC,EAAE,UAAU,EAAE,aAAa;GACvC,UAAU,MAAM;GAChB,kBAAkB;GACnB,CAAC;AAEF,SACE,oBAAC;GAAI,OAAO,OAAO;GAAW,WAAW,QAAQ;aAC9C,QAAQ,KAAI,QACX,oBAAC;IAEC,QAAQ;IACC;IACC;IACA;IACV,eAAe,MAAM;IACrB,UAAU,iBAAiB,IAAI;IAC/B,oBAAoB,MAAM;IAC1B,SAAS;MARJ,OAAO,IAAI,MAAM,CAStB,CACF;IACE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { t as Icon } from "./Icon-
|
|
2
|
-
import { n as useThemedStyles, t as
|
|
3
|
-
import { t as
|
|
1
|
+
import { t as Icon } from "./Icon-7fQw74zg.js";
|
|
2
|
+
import { n as useThemedStyles, t as styled } from "./useThemedStyles-68D71Lua.js";
|
|
3
|
+
import { t as Typography } from "./Typography-CKXLkfw7.js";
|
|
4
|
+
import { t as Label } from "./Label-1Gh2DlKl.js";
|
|
4
5
|
import { useId } from "react";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
|
|
@@ -9,7 +10,7 @@ function createTextAreaStyles(props) {
|
|
|
9
10
|
const { height = "8rem", readOnly, startIcon } = props;
|
|
10
11
|
const focusRingColor = props.focusedRingColor || "var(--px-color-info)";
|
|
11
12
|
const placeHolderColor = props.placeholderColor || "var(--px-text-placeholder)";
|
|
12
|
-
return {
|
|
13
|
+
return styled({
|
|
13
14
|
iconContainer: {
|
|
14
15
|
position: "absolute",
|
|
15
16
|
left: "0.75rem",
|
|
@@ -35,7 +36,7 @@ function createTextAreaStyles(props) {
|
|
|
35
36
|
"&:focus": readOnly ? { outline: "none" } : { outline: `2px solid ${focusRingColor}` }
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
};
|
|
39
|
+
});
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
//#endregion
|
|
@@ -110,4 +111,4 @@ const TextArea = (props) => {
|
|
|
110
111
|
|
|
111
112
|
//#endregion
|
|
112
113
|
export { TextArea as t };
|
|
113
|
-
//# sourceMappingURL=TextArea-
|
|
114
|
+
//# sourceMappingURL=TextArea-BsErpaMx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextArea-BsErpaMx.js","names":[],"sources":["../src/components/commons/inputs/TextArea/styles.ts","../src/components/commons/inputs/TextArea/index.tsx"],"sourcesContent":["// Types\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\nimport type { TextAreaProps } from './types'\n\nexport function createTextAreaStyles(props: TextAreaProps): StyleMap {\n const { height = '8rem', readOnly, startIcon } = props\n\n const focusRingColor = props.focusedRingColor || 'var(--px-color-info)'\n const placeHolderColor =\n props.placeholderColor || 'var(--px-text-placeholder)'\n\n return styled({\n iconContainer: {\n position: 'absolute',\n left: '0.75rem',\n top: '1.375rem',\n transform: 'translateY(-50%)'\n },\n textArea: {\n height,\n width: '100%',\n paddingBlock: '0.75rem',\n paddingInline: '0.875rem',\n borderRadius: '0.5rem',\n resize: 'none',\n\n fontWeight: '400',\n fontSize: '1rem',\n color: 'var(--px-text-primary)',\n\n border: '1px solid red',\n outlineOffset: '-1px',\n\n cursor: readOnly ? 'default' : undefined,\n paddingLeft: startIcon ? '2.5rem' : undefined,\n\n __rules: {\n '&::placeholder': {\n color: `${placeHolderColor}`\n },\n '&:focus': readOnly\n ? { outline: 'none' }\n : { outline: `2px solid ${focusRingColor}` }\n }\n }\n })\n}\n","// External Libraries\nimport { useId } from 'react'\n\n// Types\nimport type { TextAreaProps } from './types'\n\n// Components\nimport { Label } from '@components/commons/Label'\nimport { Icon } from '@components/toolkit/Icon'\nimport { Typography } from '@components/toolkit/Typography'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Styles\nimport { createTextAreaStyles } from './styles'\n\nexport const TextArea = (props: TextAreaProps) => {\n const {\n value,\n disabled,\n readOnly,\n maxLength,\n hideMaxLength,\n textMaxLength,\n placeholder,\n\n label,\n required,\n requiredColor,\n labelColor,\n labelWeight,\n labelVariant,\n\n startIcon,\n iconColor\n } = props\n\n // Hooks\n const inputId = useId()\n\n const { styles, classes } = useThemedStyles(props, createTextAreaStyles, {\n pick: p => [\n p.height,\n p.readOnly,\n p.startIcon,\n p.placeholderColor,\n p.focusedRingColor\n ],\n override: props.styles,\n applyCommonProps: true\n })\n\n // Functions\n function handleChange(e: React.ChangeEvent<HTMLTextAreaElement>) {\n if (disabled || readOnly) return\n props.onChange?.(e.target.value)\n }\n\n function renderLabel() {\n if (!label) return null\n\n return (\n <div className=\"flex items-center gap-3\">\n <Label\n htmlFor={inputId}\n label={label}\n required={required}\n requiredColor={requiredColor}\n labelColor={labelColor}\n labelWeight={labelWeight}\n labelVariant={labelVariant}\n />\n </div>\n )\n }\n\n return (\n <div>\n {renderLabel()}\n\n <div style={{ position: 'relative' }}>\n {startIcon && (\n <div style={styles.iconContainer}>\n <Icon\n name={startIcon}\n color={iconColor ? iconColor : 'var(--px-text-primary)'}\n />\n </div>\n )}\n\n <textarea\n value={value}\n disabled={disabled}\n readOnly={readOnly}\n maxLength={maxLength}\n placeholder={placeholder}\n style={styles.textArea}\n className={classes.textArea}\n onChange={handleChange}\n />\n </div>\n\n {maxLength && !hideMaxLength ? (\n <Typography variant=\"b2\" styles={{ text: { marginLeft: 'auto' } }}>\n {value.length}/{maxLength} {textMaxLength}\n </Typography>\n ) : null}\n </div>\n )\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,qBAAqB,OAAgC;CACnE,MAAM,EAAE,SAAS,QAAQ,UAAU,cAAc;CAEjD,MAAM,iBAAiB,MAAM,oBAAoB;CACjD,MAAM,mBACJ,MAAM,oBAAoB;AAE5B,QAAO,OAAO;EACZ,eAAe;GACb,UAAU;GACV,MAAM;GACN,KAAK;GACL,WAAW;GACZ;EACD,UAAU;GACR;GACA,OAAO;GACP,cAAc;GACd,eAAe;GACf,cAAc;GACd,QAAQ;GAER,YAAY;GACZ,UAAU;GACV,OAAO;GAEP,QAAQ;GACR,eAAe;GAEf,QAAQ,WAAW,YAAY;GAC/B,aAAa,YAAY,WAAW;GAEpC,SAAS;IACP,kBAAkB,EAChB,OAAO,GAAG,oBACX;IACD,WAAW,WACP,EAAE,SAAS,QAAQ,GACnB,EAAE,SAAS,aAAa,kBAAkB;IAC/C;GACF;EACF,CAAC;;;;;AC5BJ,MAAa,YAAY,UAAyB;CAChD,MAAM,EACJ,OACA,UACA,UACA,WACA,eACA,eACA,aAEA,OACA,UACA,eACA,YACA,aACA,cAEA,WACA,cACE;CAGJ,MAAM,UAAU,OAAO;CAEvB,MAAM,EAAE,QAAQ,YAAY,gBAAgB,OAAO,sBAAsB;EACvE,OAAM,MAAK;GACT,EAAE;GACF,EAAE;GACF,EAAE;GACF,EAAE;GACF,EAAE;GACH;EACD,UAAU,MAAM;EAChB,kBAAkB;EACnB,CAAC;CAGF,SAAS,aAAa,GAA2C;AAC/D,MAAI,YAAY,SAAU;AAC1B,QAAM,WAAW,EAAE,OAAO,MAAM;;CAGlC,SAAS,cAAc;AACrB,MAAI,CAAC,MAAO,QAAO;AAEnB,SACE,oBAAC;GAAI,WAAU;aACb,oBAAC;IACC,SAAS;IACF;IACG;IACK;IACH;IACC;IACC;KACd;IACE;;AAIV,QACE,qBAAC;EACE,aAAa;EAEd,qBAAC;GAAI,OAAO,EAAE,UAAU,YAAY;cACjC,aACC,oBAAC;IAAI,OAAO,OAAO;cACjB,oBAAC;KACC,MAAM;KACN,OAAO,YAAY,YAAY;MAC/B;KACE,EAGR,oBAAC;IACQ;IACG;IACA;IACC;IACE;IACb,OAAO,OAAO;IACd,WAAW,QAAQ;IACnB,UAAU;KACV;IACE;EAEL,aAAa,CAAC,gBACb,qBAAC;GAAW,SAAQ;GAAK,QAAQ,EAAE,MAAM,EAAE,YAAY,QAAQ,EAAE;;IAC9D,MAAM;IAAO;IAAE;IAAU;IAAE;;IACjB,GACX;KACA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
|
1
|
+
import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useState } from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/functions/deepMerge.ts
|
|
@@ -75,6 +75,7 @@ const defaultThemes = {
|
|
|
75
75
|
light: {
|
|
76
76
|
colors: {
|
|
77
77
|
scrollbar: "#0000001a",
|
|
78
|
+
disabled: "#D5D7DA",
|
|
78
79
|
primary: "#0EB24C",
|
|
79
80
|
secondary: "#6C6C6C",
|
|
80
81
|
success: "#0EB24C",
|
|
@@ -123,6 +124,7 @@ const defaultThemes = {
|
|
|
123
124
|
dark: {
|
|
124
125
|
colors: {
|
|
125
126
|
scrollbar: "#858585",
|
|
127
|
+
disabled: "#D5D7DA",
|
|
126
128
|
primary: "#0EB24C",
|
|
127
129
|
secondary: "#C7CFD8",
|
|
128
130
|
success: "#0EB24C",
|
|
@@ -361,7 +363,7 @@ function themeToCssVars(theme) {
|
|
|
361
363
|
"--px-color-error": theme.colors.error,
|
|
362
364
|
"--px-color-invalid": theme.colors.invalid,
|
|
363
365
|
"--px-color-info": theme.colors.info,
|
|
364
|
-
"--px-color-disabled": theme.colors.
|
|
366
|
+
"--px-color-disabled": theme.colors.disabled,
|
|
365
367
|
"--px-scrollbar": theme.colors.scrollbar,
|
|
366
368
|
"--px-bg": theme.colors.background.primary,
|
|
367
369
|
"--px-surface": theme.colors.surface,
|
|
@@ -409,84 +411,62 @@ function themeToCssVars(theme) {
|
|
|
409
411
|
//#endregion
|
|
410
412
|
//#region src/contexts/ThemeContext/index.tsx
|
|
411
413
|
/** biome-ignore-all lint/suspicious/noExplicitAny: <Not needed> */
|
|
412
|
-
/**
|
|
413
|
-
* Theme Context
|
|
414
|
-
* -------------
|
|
415
|
-
* Internal context used by `ThemeProvider` and consumed by `useTheme()`.
|
|
416
|
-
*
|
|
417
|
-
* The value is always non-null inside a `<ThemeProvider />`.
|
|
418
|
-
*/
|
|
419
414
|
const ThemeContext = createContext(null);
|
|
420
415
|
/**
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
416
|
+
* useIsomorphicLayoutEffect
|
|
417
|
+
* - On client: runs before paint (layout effect)
|
|
418
|
+
* - On server: falls back to useEffect (no warnings)
|
|
424
419
|
*/
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
* Registry of user patches (stable unless `themes` changes).
|
|
428
|
-
*/
|
|
420
|
+
const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
421
|
+
const ThemeProvider = ({ themes, children, override, persistence, persist = false, defaultMode = "system", storageKey = "px-theme", fallback = null }) => {
|
|
429
422
|
const registry = useMemo(() => buildRegistry(themes), [themes]);
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
423
|
+
function makeInitialMode() {
|
|
424
|
+
if (persistence) try {
|
|
425
|
+
return persistence.get() ?? defaultMode;
|
|
426
|
+
} catch {
|
|
427
|
+
return defaultMode;
|
|
428
|
+
}
|
|
429
|
+
if (persist) {
|
|
430
|
+
const ls = getLocalStorageSafe();
|
|
431
|
+
if (!ls) return defaultMode;
|
|
432
|
+
const raw = ls.getItem(storageKey);
|
|
433
|
+
return isThemeMode(raw) ? raw : defaultMode;
|
|
434
|
+
}
|
|
435
|
+
return defaultMode;
|
|
436
|
+
}
|
|
438
437
|
const [mode, setMode] = useState(makeInitialMode);
|
|
439
438
|
/**
|
|
440
|
-
*
|
|
441
|
-
|
|
442
|
-
const [isLoading, setLoading] = useState(true);
|
|
443
|
-
useEffect(() => {
|
|
444
|
-
setLoading(false);
|
|
445
|
-
}, []);
|
|
446
|
-
/**
|
|
447
|
-
* Keep in sync with OS when mode === "system".
|
|
448
|
-
*/
|
|
449
|
-
useEffect(() => {
|
|
450
|
-
if (typeof window === "undefined") return;
|
|
451
|
-
if (mode !== "system") return;
|
|
452
|
-
return watchSystemTheme(() => {
|
|
453
|
-
setMode("system");
|
|
454
|
-
});
|
|
455
|
-
}, [mode]);
|
|
456
|
-
/**
|
|
457
|
-
* Resolved name is the actual currently applied theme name.
|
|
458
|
-
* If `mode === "system"`, it becomes "light" or "dark".
|
|
439
|
+
* Gate: only render children after we applied class + vars at least once.
|
|
440
|
+
* This prevents "unstyled flash" for your components.
|
|
459
441
|
*/
|
|
442
|
+
const [isReady, setReady] = useState(false);
|
|
460
443
|
const resolvedName = useMemo(() => {
|
|
461
444
|
if (typeof window === "undefined") return mode === "system" ? "light" : mode;
|
|
462
445
|
return resolveName(mode);
|
|
463
446
|
}, [mode]);
|
|
464
|
-
/**
|
|
465
|
-
* Build final resolved theme tokens (always complete).
|
|
466
|
-
*/
|
|
467
447
|
const theme = useMemo(() => buildTheme(registry, resolvedName, override), [
|
|
468
448
|
registry,
|
|
469
449
|
resolvedName,
|
|
470
450
|
override
|
|
471
451
|
]);
|
|
452
|
+
useEffect(() => {
|
|
453
|
+
if (typeof window === "undefined") return;
|
|
454
|
+
if (mode !== "system") return;
|
|
455
|
+
return watchSystemTheme(() => {
|
|
456
|
+
setMode("system");
|
|
457
|
+
});
|
|
458
|
+
}, [mode]);
|
|
472
459
|
/**
|
|
473
|
-
* Apply theme
|
|
474
|
-
* - toggles `.dark` class on <html> (Tailwind)
|
|
475
|
-
* - injects --px-* variables on <html>
|
|
460
|
+
* Apply theme BEFORE paint (client) and then unlock rendering.
|
|
476
461
|
*/
|
|
477
|
-
|
|
462
|
+
useIsomorphicLayoutEffect(() => {
|
|
478
463
|
if (typeof window === "undefined") return;
|
|
479
464
|
applyThemeClass(resolvedName === "dark" ? "dark" : "light");
|
|
480
465
|
applyCssVars(themeToCssVars(theme));
|
|
466
|
+
setReady(true);
|
|
481
467
|
}, [resolvedName, theme]);
|
|
482
468
|
/**
|
|
483
469
|
* Persist mode changes (optional).
|
|
484
|
-
*
|
|
485
|
-
* We persist the selected `mode` (including "system"), not the resolvedName.
|
|
486
|
-
*
|
|
487
|
-
* Priority:
|
|
488
|
-
* - If `persistence` exists, use it.
|
|
489
|
-
* - Else if `persist === true`, use localStorage.
|
|
490
470
|
*/
|
|
491
471
|
useEffect(() => {
|
|
492
472
|
if (persistence) {
|
|
@@ -507,48 +487,30 @@ const ThemeProvider = ({ themes, children, override, persistence, persist = fals
|
|
|
507
487
|
storageKey,
|
|
508
488
|
persistence
|
|
509
489
|
]);
|
|
510
|
-
function makeInitialMode() {
|
|
511
|
-
if (persistence) try {
|
|
512
|
-
return persistence.get() ?? defaultMode;
|
|
513
|
-
} catch {
|
|
514
|
-
return defaultMode;
|
|
515
|
-
}
|
|
516
|
-
const ls = getLocalStorageSafe();
|
|
517
|
-
if (!ls) return defaultMode;
|
|
518
|
-
const raw = ls.getItem(storageKey);
|
|
519
|
-
return isThemeMode(raw) ? raw : defaultMode;
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* Sets the selected theme mode.
|
|
523
|
-
*/
|
|
524
490
|
function setTheme(next) {
|
|
525
491
|
setMode(next);
|
|
526
492
|
}
|
|
527
|
-
/**
|
|
528
|
-
* Toggles between two theme names (defaults to "light" and "dark").
|
|
529
|
-
*/
|
|
530
493
|
function toggleTheme(a = "light", b = "dark") {
|
|
531
494
|
setMode(resolvedName === a ? b : a);
|
|
532
495
|
}
|
|
496
|
+
const ctxValue = useMemo(() => ({
|
|
497
|
+
mode,
|
|
498
|
+
resolvedName,
|
|
499
|
+
theme,
|
|
500
|
+
isLoading: !isReady,
|
|
501
|
+
setTheme,
|
|
502
|
+
toggleTheme
|
|
503
|
+
}), [
|
|
504
|
+
mode,
|
|
505
|
+
resolvedName,
|
|
506
|
+
theme,
|
|
507
|
+
isReady
|
|
508
|
+
]);
|
|
533
509
|
return /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
534
|
-
value:
|
|
535
|
-
|
|
536
|
-
resolvedName,
|
|
537
|
-
theme,
|
|
538
|
-
isLoading,
|
|
539
|
-
setTheme,
|
|
540
|
-
toggleTheme
|
|
541
|
-
},
|
|
542
|
-
children
|
|
510
|
+
value: ctxValue,
|
|
511
|
+
children: isReady ? children : fallback
|
|
543
512
|
});
|
|
544
513
|
};
|
|
545
|
-
/**
|
|
546
|
-
* useTheme()
|
|
547
|
-
*
|
|
548
|
-
* Returns the current theme context.
|
|
549
|
-
*
|
|
550
|
-
* @throws If called outside of `<ThemeProvider />`.
|
|
551
|
-
*/
|
|
552
514
|
function useTheme() {
|
|
553
515
|
const ctx = useContext(ThemeContext);
|
|
554
516
|
if (!ctx) throw new Error("useTheme must be used within a ThemeProvider");
|
|
@@ -557,4 +519,4 @@ function useTheme() {
|
|
|
557
519
|
|
|
558
520
|
//#endregion
|
|
559
521
|
export { useTheme as n, ThemeProvider as t };
|
|
560
|
-
//# sourceMappingURL=ThemeContext-
|
|
522
|
+
//# sourceMappingURL=ThemeContext-BsU2ZyE5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeContext-BsU2ZyE5.js","names":["result: any","out: any","defaultThemes: ThemeRegistry","ThemeProvider: React.FC<ThemeProviderProps>"],"sources":["../src/utils/functions/deepMerge.ts","../src/contexts/ThemeContext/constants.ts","../src/contexts/ThemeContext/utils/general.ts","../src/contexts/ThemeContext/utils/themeToCSSVars.ts","../src/contexts/ThemeContext/index.tsx"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noExplicitAny: <Not needed> */\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends Array<infer U>\n ? Array<DeepPartial<U>>\n : T[P] extends object\n ? DeepPartial<T[P]>\n : T[P]\n}\n\nexport function deepMerge<T>(base: T, override?: DeepPartial<T>): T {\n if (override === undefined) return clone(base)\n\n if (!isPlainObject(base) || !isPlainObject(override)) {\n return clone(override as T)\n }\n\n const result: any = Array.isArray(base) ? [] : {}\n\n const baseKeys = Object.keys(base as any) as (keyof T)[]\n const overrideKeys = Object.keys(override as any) as (keyof T)[]\n\n const allKeys = Array.from(new Set([...baseKeys, ...overrideKeys]))\n\n for (const k of allKeys) {\n const baseVal = (base as any)[k]\n const overrideVal = (override as any)[k]\n\n if (overrideVal === undefined) {\n result[k] = clone(baseVal)\n continue\n }\n\n if (isPlainObject(baseVal) && isPlainObject(overrideVal)) {\n result[k] = deepMerge(baseVal, overrideVal)\n continue\n }\n\n result[k] = clone(overrideVal)\n }\n\n return result as T\n}\n\nfunction isPlainObject(x: any): x is Record<string, any> {\n return !!x && typeof x === 'object' && !Array.isArray(x)\n}\n\nfunction clone<T>(v: T): T {\n if (v === undefined || v === null) return v\n if (Array.isArray(v)) return v.map(item => clone(item)) as unknown as T\n if (isPlainObject(v)) {\n const out: any = {}\n for (const k of Object.keys(v)) out[k] = clone((v as any)[k])\n return out\n }\n return v\n}\n","// theme/defaultThemes.ts\nimport type { ThemeRegistry } from './types'\n\nconst COMMON_MAP = {\n spacing: {\n xs: '0.25rem', // 4px\n sm: '0.5rem', // 8px\n md: '1rem', // 16px\n lg: '1.5rem', // 24px\n xl: '2rem', // 32px\n '2xl': '3rem' // 48px\n },\n borderRadius: {\n none: '0rem', // 0px\n sm: '0.25rem', // 4px\n md: '0.375rem', // 6px\n lg: '0.5rem', // 8px\n full: '9999rem' // \"infinite\" radius equivalent\n },\n fontSize: {\n xs: '0.75rem', // 12px\n sm: '0.875rem', // 14px\n md: '1rem', // 16px\n lg: '1.125rem', // 18px\n xl: '1.25rem', // 20px\n '2xl': '1.5rem' // 24px\n },\n fontWeight: { normal: 400, medium: 500, semibold: 600, bold: 700 }\n} as const\n\nexport const defaultThemes: ThemeRegistry = {\n light: {\n colors: {\n scrollbar: '#0000001a',\n disabled: '#D5D7DA',\n\n primary: '#0EB24C',\n secondary: '#6C6C6C',\n success: '#0EB24C',\n warning: '#f59e0b',\n error: '#ef4444',\n invalid: '#f87171',\n info: '#06b6d4',\n\n background: {\n primary: '#FFFFFF',\n card: {\n primary: '#F4F4F4',\n secondary: '#F3F6F9'\n }\n },\n button: {\n filled: {\n label: '#FFFFFF',\n background: '#0EB24C'\n },\n\n outlined: {\n label: '#0EB24C',\n borderColor: '#0EB24C'\n },\n\n ghost: {\n label: '#6C6C6C'\n }\n },\n\n surface: '#FBFBFB',\n border: {\n primary: '#E8E8E9',\n secondary: '#E8E8E9'\n },\n\n text: {\n primary: '#222222',\n secondary: '#6C6C6C',\n disabled: '#A0A0A0',\n inverse: '#FFFFFF'\n }\n },\n\n ...COMMON_MAP,\n\n shadows: {\n sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',\n md: '0 4px 6px -1px rgba(0, 0, 0, 0.10)',\n lg: '0 10px 15px -3px rgba(0, 0, 0, 0.10)',\n xl: '0 20px 25px -5px rgba(0, 0, 0, 0.10)'\n }\n },\n\n dark: {\n colors: {\n scrollbar: '#858585',\n disabled: '#D5D7DA',\n\n primary: '#0EB24C', // brand se mantém (ou pode clarear depois)\n secondary: '#C7CFD8',\n success: '#0EB24C',\n warning: '#f59e0b',\n error: '#ef4444',\n invalid: '#f87171',\n info: '#06b6d4',\n\n background: {\n primary: '#090909',\n card: {\n primary: '#F4F4F4',\n secondary: '#202020'\n }\n },\n button: {\n filled: {\n label: '#FFFFFF',\n background: '#0EB24C'\n },\n\n outlined: {\n label: '#0EB24C',\n borderColor: '#0EB24C'\n },\n\n ghost: {\n label: '#6C6C6C'\n }\n },\n\n surface: '#090909',\n\n border: {\n primary: '#27282D',\n secondary: '#27282D'\n },\n\n text: {\n primary: '#ECECEC',\n secondary: '#C7CFD8',\n disabled: '#8B93A0',\n inverse: '#090909'\n }\n },\n\n ...COMMON_MAP,\n\n shadows: {\n sm: '0 1px 2px 0 rgba(0, 0, 0, 0.35)',\n md: '0 4px 6px -1px rgba(0, 0, 0, 0.45)',\n lg: '0 10px 15px -3px rgba(0, 0, 0, 0.50)',\n xl: '0 20px 25px -5px rgba(0, 0, 0, 0.55)'\n }\n }\n}\n","// Utils\n/** biome-ignore-all lint/suspicious/noExplicitAny: <Not needed> */\nimport { deepMerge } from '@utils/functions'\nimport { defaultThemes } from '../constants'\n\n// Types\nimport type { ThemeMode, ThemeRegistry, ThemeTokens } from '../types'\n\n/**\n * Theme Utilities\n * ===============\n * Small DOM utilities used by the ThemeProvider to:\n * - toggle dark mode class for Tailwind compatibility\n * - inject CSS variables (`--px-*`) into the document root\n * - read/watch the OS/browser theme preference (`prefers-color-scheme`)\n *\n * These helpers are:\n * - **client-safe** (guarded for SSR)\n * - **framework-agnostic** (only touch `documentElement`)\n * - **tiny** (no dependencies)\n */\n\n/**\n * CSSVarMap\n * ---------\n * A map of CSS custom properties to be applied on the document root.\n *\n * Notes:\n * - Keys must be valid CSS variable names (e.g. `\"--px-bg\"`, `\"--px-text-primary\"`).\n * - Values can be strings or numbers.\n * - If you store numbers (e.g. 16), you decide at consumption time whether it means px.\n *\n * You can keep it generic:\n * Record<`--${string}`, string | number>\n *\n * Or restrict to your library prefix:\n * Record<`--px-${string}`, string | number>\n */\nexport type CSSVarMap = Partial<Record<`--${string}`, string | number>>\n\n/**\n * applyThemeClass(themeName)\n * -------------------------\n * Applies the light/dark mode class to the `<html>` element.\n *\n * Tailwind’s dark mode (in the common \"class\" strategy) typically relies on a\n * `.dark` class. This function toggles ONLY the `dark` class:\n *\n * - themeName `\"dark\"` => adds `.dark`\n * - themeName `\"light\"` => removes `.dark`\n *\n * SSR:\n * - No-op on the server (when `document` is undefined).\n */\nexport function applyThemeClass(themeName: 'light' | 'dark') {\n if (typeof document === 'undefined') return\n const root = document.documentElement\n root.classList.toggle('dark', themeName === 'dark')\n}\n\n/**\n * applyCssVars(vars)\n * ------------------\n * Injects CSS variables into the document root (`<html>`).\n *\n * This is how the library exposes theme tokens as CSS variables.\n * Components can then use `var(--px-...)` in styles.\n *\n * Example:\n * ```ts\n * applyCssVars({ '--px-bg': '#fff', '--px-text-primary': '#111' })\n * ```\n *\n * Behavior:\n * - Ignores `null` / `undefined` values.\n * - Converts all values to string before applying.\n *\n * SSR:\n * - No-op on the server (when `document` is undefined).\n */\nexport function applyCssVars(vars: CSSVarMap) {\n if (typeof document === 'undefined') return\n const root = document.documentElement\n\n for (const [key, value] of Object.entries(vars)) {\n if (value == null) continue\n root.style.setProperty(key, String(value))\n }\n}\n\n/**\n * getSystemThemeName()\n * --------------------\n * Returns the current OS/browser color scheme preference.\n *\n * It reads `prefers-color-scheme: dark` using `window.matchMedia`.\n *\n * Returns:\n * - `\"dark\"` if the user prefers dark mode\n * - `\"light\"` otherwise\n *\n * SSR:\n * - Returns `\"light\"` on the server (safe default).\n */\nexport function getSystemThemeName(): 'light' | 'dark' {\n if (typeof window === 'undefined') return 'light'\n const prefersDark =\n window.matchMedia?.('(prefers-color-scheme: dark)').matches ?? false\n return prefersDark ? 'dark' : 'light'\n}\n\n/**\n * watchSystemTheme(onChange)\n * --------------------------\n * Subscribes to changes in OS/browser theme preference.\n *\n * Use this when your selected mode is `\"system\"` so the app immediately reacts\n * when the user changes their OS theme.\n *\n * - Calls `onChange('light' | 'dark')` whenever the preference changes.\n * - Returns an `unsubscribe()` function.\n *\n * Implementation details:\n * - Uses `matchMedia('(prefers-color-scheme: dark)')`.\n * - Supports both modern `addEventListener('change', ...)` and legacy Safari\n * `addListener(...)` APIs.\n *\n * SSR:\n * - Returns a no-op unsubscribe function on the server.\n */\nexport function watchSystemTheme(onChange: (name: 'light' | 'dark') => void) {\n if (typeof window === 'undefined') return () => {}\n\n const mq = window.matchMedia('(prefers-color-scheme: dark)')\n\n const handler = () => onChange(mq.matches ? 'dark' : 'light')\n\n // Optional: sync immediately on subscribe\n handler()\n\n // Modern browsers\n if (mq.addEventListener) {\n mq.addEventListener('change', handler)\n return () => mq.removeEventListener('change', handler)\n }\n\n // Legacy Safari\n mq.addListener(handler as any)\n return () => mq.removeListener(handler as any)\n}\n\n/**\n * Resolves an effective theme name from a mode.\n */\nexport function resolveName(mode: ThemeMode): string {\n if (mode !== 'system') return mode\n return getSystemThemeName()\n}\n\n/**\n * Builds a registry of user theme patches.\n */\nexport function buildRegistry(\n userThemes?: Partial<ThemeRegistry>\n): ThemeRegistry {\n return {\n light: {},\n dark: {},\n ...(userThemes ?? {})\n } as ThemeRegistry\n}\n\n/**\n * Builds the final resolved theme tokens.\n */\nexport function buildTheme(\n registry: ThemeRegistry,\n resolvedName: string,\n override?: Partial<ThemeTokens>\n): ThemeTokens {\n const base: ThemeTokens =\n resolvedName === 'dark'\n ? (defaultThemes.dark as ThemeTokens)\n : (defaultThemes.light as ThemeTokens)\n\n const selectedPatch = (registry[resolvedName] ?? registry.light) as any\n\n const merged = deepMerge(base, selectedPatch)\n return deepMerge(merged, override)\n}\n\nexport function isThemeMode(value: unknown): value is ThemeMode {\n return typeof value === 'string' && value.length > 0\n}\n\nexport function getLocalStorageSafe(): Storage | null {\n if (typeof window === 'undefined') return null\n try {\n return window.localStorage\n } catch {\n return null\n }\n}\n","// Types\nimport type { CSSVarMap } from './general'\nimport type { ThemeTokens } from '../types'\n\n/**\n * themeToCssVars(theme)\n * ---------------------\n * Converts a resolved `ThemeTokens` object into a CSS variable map (`CSSVarMap`).\n *\n * The ThemeProvider uses this function to inject `--px-*` variables into the\n * document root (`<html>`). Components can then rely on stable CSS variables,\n * making them framework-agnostic and compatible with Tailwind (via `.dark`).\n *\n * Why CSS variables?\n * - They are fast (native to the browser)\n * - They work across any styling strategy (inline styles, CSS modules, Tailwind, etc.)\n * - They enable dynamic theme switching without rerendering every component\n *\n * Requirements / Assumptions:\n * - The input `theme` must be **fully resolved** (i.e. complete `ThemeTokens`).\n * The ThemeProvider is responsible for merging partial theme patches on top\n * of a complete base theme (light/dark defaults).\n *\n * Variable naming:\n * - All variables are prefixed with `--px-` to avoid collisions.\n * - Tokens are grouped by category (colors, surfaces, borders, text, spacing, radius, typography, shadows).\n *\n * Notes:\n * - Spacing/radius/fontSize tokens are stored as numbers (e.g. `16`), which is valid\n * for CSS variables. When consuming them, you can:\n * - append `px` in JS (`${var}px`), or\n * - store them as strings here (e.g. `\"16px\"`) if you prefer.\n *\n * Example usage (component styles):\n * ```ts\n * const styles = {\n * background: 'var(--px-bg)',\n * color: 'var(--px-text-primary)',\n * borderColor: 'var(--px-border-primary)',\n * }\n * ```\n *\n * Example usage (Tailwind config / CSS):\n * ```css\n * .card {\n * background: var(--px-surface);\n * color: var(--px-text-primary);\n * border: 1px solid var(--px-border-primary);\n * }\n * ```\n */\nexport function themeToCssVars(theme: ThemeTokens): CSSVarMap {\n return {\n /**\n * Brand & intent colors\n */\n '--px-color-primary': theme.colors.primary,\n '--px-color-secondary': theme.colors.secondary,\n '--px-color-success': theme.colors.success,\n '--px-color-warning': theme.colors.warning,\n '--px-color-error': theme.colors.error,\n '--px-color-invalid': theme.colors.invalid,\n '--px-color-info': theme.colors.info,\n '--px-color-disabled': theme.colors.disabled,\n\n /**\n * Scrollbar\n */\n '--px-scrollbar': theme.colors.scrollbar,\n\n /**\n * Surfaces / backgrounds\n */\n '--px-bg': theme.colors.background.primary,\n '--px-surface': theme.colors.surface,\n '--px-background-card-primary': theme.colors.background.card.primary,\n '--px-background-card-secondary': theme.colors.background.card.secondary,\n\n /**\n * Borders\n * -------\n * Divider and outline colors.\n */\n '--px-border-primary': theme.colors.border.primary,\n '--px-border-secondary': theme.colors.border.secondary,\n\n /**\n * Text\n * ----\n * Text colors for different emphasis levels.\n */\n '--px-text-primary': theme.colors.text.primary,\n '--px-text-secondary': theme.colors.text.secondary,\n '--px-text-disabled': theme.colors.text.disabled,\n '--px-text-inverse': theme.colors.text.inverse,\n\n /**\n * Buttons – Filled\n * ----------------\n * Filled button colors\n */\n '--px-btn-filled-bg': theme.colors.button.filled.background,\n '--px-btn-filled-label': theme.colors.button.filled.label,\n\n /**\n * Buttons – Outlined\n * ------------------\n * Outlined button colors\n */\n '--px-btn-outlined-border': theme.colors.button.outlined.borderColor,\n '--px-btn-outlined-label': theme.colors.button.outlined.label,\n\n /**\n * Buttons – Ghost\n * --------------\n * Ghost button colors\n */\n '--px-btn-ghost-label': theme.colors.button.ghost.label,\n /**\n * Spacing\n * -------------\n * Numeric spacing tokens (commonly used as px).\n */\n '--px-space-xs': theme.spacing.xs,\n '--px-space-sm': theme.spacing.sm,\n '--px-space-md': theme.spacing.md,\n '--px-space-lg': theme.spacing.lg,\n '--px-space-xl': theme.spacing.xl,\n '--px-space-2xl': theme.spacing['2xl'],\n\n /**\n * Border radius scale\n * -------------------\n * Numeric radius tokens (commonly used as px).\n */\n '--px-radius-none': theme.borderRadius.none,\n '--px-radius-sm': theme.borderRadius.sm,\n '--px-radius-md': theme.borderRadius.md,\n '--px-radius-lg': theme.borderRadius.lg,\n '--px-radius-full': theme.borderRadius.full,\n\n /**\n * Typography scale\n * ----------------\n * Font sizes and font weights.\n */\n '--px-fs-xs': theme.fontSize.xs,\n '--px-fs-sm': theme.fontSize.sm,\n '--px-fs-md': theme.fontSize.md,\n '--px-fs-lg': theme.fontSize.lg,\n '--px-fs-xl': theme.fontSize.xl,\n '--px-fs-2xl': theme.fontSize['2xl'],\n\n '--px-fw-normal': theme.fontWeight.normal,\n '--px-fw-medium': theme.fontWeight.medium,\n '--px-fw-semibold': theme.fontWeight.semibold,\n '--px-fw-bold': theme.fontWeight.bold,\n\n /**\n * Shadows\n * -------\n * CSS shadow strings for elevation.\n */\n '--px-shadow-sm': theme.shadows.sm,\n '--px-shadow-md': theme.shadows.md,\n '--px-shadow-lg': theme.shadows.lg,\n '--px-shadow-xl': theme.shadows.xl\n }\n}\n","/** biome-ignore-all lint/suspicious/noExplicitAny: <Not needed> */\n\n'use client'\n\n// External Libraries\nimport {\n useMemo,\n useState,\n useEffect,\n useContext,\n createContext,\n useLayoutEffect\n} from 'react'\n\n// Utils\nimport {\n buildTheme,\n isThemeMode,\n resolveName,\n applyCssVars,\n buildRegistry,\n themeToCssVars,\n applyThemeClass,\n watchSystemTheme,\n getLocalStorageSafe\n} from './utils'\n\n// Types\nimport type { ThemeMode, ThemeContextData, ThemeProviderProps } from './types'\n\nexport * from './types'\n\nconst ThemeContext = createContext<ThemeContextData | null>(null)\n\n/**\n * useIsomorphicLayoutEffect\n * - On client: runs before paint (layout effect)\n * - On server: falls back to useEffect (no warnings)\n */\nconst useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nexport const ThemeProvider: React.FC<ThemeProviderProps> = ({\n themes,\n children,\n override,\n persistence,\n persist = false,\n defaultMode = 'system',\n storageKey = 'px-theme',\n fallback = null\n}) => {\n const registry = useMemo(() => buildRegistry(themes), [themes])\n\n function makeInitialMode(): ThemeMode {\n // 1) advanced adapter\n if (persistence) {\n try {\n const saved = persistence.get()\n return (saved ?? defaultMode) as ThemeMode\n } catch {\n return defaultMode\n }\n }\n\n // 2) quick localStorage mode\n if (persist) {\n const ls = getLocalStorageSafe()\n if (!ls) return defaultMode\n const raw = ls.getItem(storageKey)\n return isThemeMode(raw) ? raw : defaultMode\n }\n\n // 3) fallback\n return defaultMode\n }\n\n const [mode, setMode] = useState<ThemeMode>(makeInitialMode)\n\n /**\n * Gate: only render children after we applied class + vars at least once.\n * This prevents \"unstyled flash\" for your components.\n */\n const [isReady, setReady] = useState(false)\n\n const resolvedName = useMemo(() => {\n if (typeof window === 'undefined') return mode === 'system' ? 'light' : mode\n return resolveName(mode)\n }, [mode])\n\n const theme = useMemo(\n () => buildTheme(registry, resolvedName, override),\n [registry, resolvedName, override]\n )\n\n // keep in sync with OS when mode === \"system\"\n useEffect(() => {\n if (typeof window === 'undefined') return\n if (mode !== 'system') return\n\n return watchSystemTheme(() => {\n setMode('system')\n })\n }, [mode])\n\n /**\n * Apply theme BEFORE paint (client) and then unlock rendering.\n */\n useIsomorphicLayoutEffect(() => {\n if (typeof window === 'undefined') return\n\n applyThemeClass(resolvedName === 'dark' ? 'dark' : 'light')\n applyCssVars(themeToCssVars(theme))\n\n // unlock after first successful application\n setReady(true)\n }, [resolvedName, theme])\n\n /**\n * Persist mode changes (optional).\n */\n useEffect(() => {\n if (persistence) {\n try {\n persistence.set(mode)\n } catch {}\n return\n }\n\n if (!persist) return\n const ls = getLocalStorageSafe()\n if (!ls) return\n\n try {\n ls.setItem(storageKey, mode)\n } catch {}\n }, [mode, persist, storageKey, persistence])\n\n function setTheme(next: ThemeMode) {\n setMode(next)\n }\n\n function toggleTheme(a: string = 'light', b: string = 'dark') {\n setMode(resolvedName === a ? b : a)\n }\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: <Not needed>\n const ctxValue = useMemo(\n () => ({\n mode,\n resolvedName,\n theme,\n isLoading: !isReady,\n setTheme,\n toggleTheme\n }),\n [mode, resolvedName, theme, isReady]\n )\n\n return (\n <ThemeContext.Provider value={ctxValue}>\n {isReady ? children : fallback}\n </ThemeContext.Provider>\n )\n}\n\nexport function useTheme(): ThemeContextData {\n const ctx = useContext(ThemeContext)\n if (!ctx) throw new Error('useTheme must be used within a ThemeProvider')\n return ctx\n}\n"],"mappings":";;;;AASA,SAAgB,UAAa,MAAS,UAA8B;AAClE,KAAI,aAAa,OAAW,QAAO,MAAM,KAAK;AAE9C,KAAI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I,SAAS,SAAU;AAEvB,SAAO,uBAAuB;AAC5B,WAAQ,SAAS;IACjB;IACD,CAAC,KAAK,CAAC;;;;AAKV,iCAAgC;AAC9B,MAAI,OAAO,WAAW,YAAa;AAEnC,kBAAgB,iBAAiB,SAAS,SAAS,QAAQ;AAC3D,eAAa,eAAe,MAAM,CAAC;AAGnC,WAAS,KAAK;IACb,CAAC,cAAc,MAAM,CAAC;;;;AAKzB,iBAAgB;AACd,MAAI,aAAa;AACf,OAAI;AACF,gBAAY,IAAI,KAAK;WACf;AACR;;AAGF,MAAI,CAAC,QAAS;EACd,MAAM,KAAK,qBAAqB;AAChC,MAAI,CAAC,GAAI;AAET,MAAI;AACF,MAAG,QAAQ,YAAY,KAAK;UACtB;IACP;EAAC;EAAM;EAAS;EAAY;EAAY,CAAC;CAE5C,SAAS,SAAS,MAAiB;AACjC,UAAQ,KAAK;;CAGf,SAAS,YAAY,IAAY,SAAS,IAAY,QAAQ;AAC5D,UAAQ,iBAAiB,IAAI,IAAI,EAAE;;CAIrC,MAAM,WAAW,eACR;EACL;EACA;EACA;EACA,WAAW,CAAC;EACZ;EACA;EACD,GACD;EAAC;EAAM;EAAc;EAAO;EAAQ,CACrC;AAED,QACE,oBAAC,aAAa;EAAS,OAAO;YAC3B,UAAU,WAAW;GACA;;AAI5B,SAAgB,WAA6B;CAC3C,MAAM,MAAM,WAAW,aAAa;AACpC,KAAI,CAAC,IAAK,OAAM,IAAI,MAAM,+CAA+C;AACzE,QAAO"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { n as useThemedStyles, t as styled } from "./useThemedStyles-68D71Lua.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/toolkit/Typography/config.ts
|
|
5
|
+
const primaryColor = "var(--px-text-primary)";
|
|
6
|
+
const secondaryColor = "var(--px-text-secondary)";
|
|
7
|
+
const typographyVariants = {
|
|
8
|
+
h1: {
|
|
9
|
+
fontSize: "3rem",
|
|
10
|
+
fontWeight: "700",
|
|
11
|
+
lineHeight: "1.25",
|
|
12
|
+
color: primaryColor
|
|
13
|
+
},
|
|
14
|
+
h2: {
|
|
15
|
+
fontSize: "2.25rem",
|
|
16
|
+
fontWeight: "600",
|
|
17
|
+
lineHeight: "1.35",
|
|
18
|
+
color: primaryColor
|
|
19
|
+
},
|
|
20
|
+
h3: {
|
|
21
|
+
fontSize: "1.875rem",
|
|
22
|
+
fontWeight: "600",
|
|
23
|
+
color: primaryColor
|
|
24
|
+
},
|
|
25
|
+
h4: {
|
|
26
|
+
fontSize: "1.5rem",
|
|
27
|
+
fontWeight: "500",
|
|
28
|
+
color: primaryColor
|
|
29
|
+
},
|
|
30
|
+
h5: {
|
|
31
|
+
fontSize: "1.25rem",
|
|
32
|
+
fontWeight: "500",
|
|
33
|
+
color: primaryColor
|
|
34
|
+
},
|
|
35
|
+
b1: {
|
|
36
|
+
fontSize: "1rem",
|
|
37
|
+
fontWeight: "500",
|
|
38
|
+
color: primaryColor
|
|
39
|
+
},
|
|
40
|
+
b2: {
|
|
41
|
+
fontSize: "0.875rem",
|
|
42
|
+
color: secondaryColor
|
|
43
|
+
},
|
|
44
|
+
b3: {
|
|
45
|
+
fontSize: "0.75rem",
|
|
46
|
+
color: secondaryColor
|
|
47
|
+
},
|
|
48
|
+
caption: {
|
|
49
|
+
fontSize: "0.75rem",
|
|
50
|
+
color: secondaryColor
|
|
51
|
+
},
|
|
52
|
+
legal: {
|
|
53
|
+
fontSize: "0.65rem",
|
|
54
|
+
textTransform: "uppercase",
|
|
55
|
+
letterSpacing: "0.025em",
|
|
56
|
+
color: secondaryColor
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const variantToElement = {
|
|
60
|
+
h1: "h1",
|
|
61
|
+
h2: "h2",
|
|
62
|
+
h3: "h3",
|
|
63
|
+
h4: "h4",
|
|
64
|
+
h5: "h5",
|
|
65
|
+
b1: "p",
|
|
66
|
+
b2: "p",
|
|
67
|
+
b3: "p",
|
|
68
|
+
caption: "span",
|
|
69
|
+
legal: "span"
|
|
70
|
+
};
|
|
71
|
+
const alignText = {
|
|
72
|
+
left: { textAlign: "left" },
|
|
73
|
+
center: { textAlign: "center" },
|
|
74
|
+
right: { textAlign: "right" },
|
|
75
|
+
justify: { textAlign: "justify" }
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/components/toolkit/Typography/style.ts
|
|
80
|
+
function createTypographyStyles(props) {
|
|
81
|
+
const { isLoading, variant, align = "left", color } = props;
|
|
82
|
+
return styled({
|
|
83
|
+
base: {
|
|
84
|
+
display: "flex",
|
|
85
|
+
flexDirection: "row",
|
|
86
|
+
alignItems: "center",
|
|
87
|
+
borderBottom: "1px solid var(--pixel-border, #e5e7eb)",
|
|
88
|
+
gap: 0,
|
|
89
|
+
animation: isLoading ? "animate-pulse 1.5s infinite" : void 0
|
|
90
|
+
},
|
|
91
|
+
loading: {
|
|
92
|
+
width: "50%",
|
|
93
|
+
height: "1em",
|
|
94
|
+
display: "inline-block",
|
|
95
|
+
backgroundColor: "var(--pixel-gray-300, #d1d5db)",
|
|
96
|
+
borderRadius: "0.25rem"
|
|
97
|
+
},
|
|
98
|
+
text: {
|
|
99
|
+
...alignText[align],
|
|
100
|
+
...typographyVariants[variant],
|
|
101
|
+
color: color ?? typographyVariants[variant].color
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/components/toolkit/Typography/index.tsx
|
|
108
|
+
function Typography(props) {
|
|
109
|
+
const { id, as, href, variant, children, placeholder, isLoading = false, styles: styleTypography } = props;
|
|
110
|
+
const { styles } = useThemedStyles(props, createTypographyStyles, {
|
|
111
|
+
pick: (p) => [
|
|
112
|
+
p.isLoading,
|
|
113
|
+
p.variant,
|
|
114
|
+
p.align
|
|
115
|
+
],
|
|
116
|
+
commonSlot: "text",
|
|
117
|
+
applyCommonProps: true,
|
|
118
|
+
override: styleTypography
|
|
119
|
+
});
|
|
120
|
+
const Component = as ?? variantToElement[variant];
|
|
121
|
+
if (isLoading) return /* @__PURE__ */ jsx("span", {
|
|
122
|
+
id,
|
|
123
|
+
"aria-hidden": "true",
|
|
124
|
+
role: "presentation",
|
|
125
|
+
style: {
|
|
126
|
+
...styles.text,
|
|
127
|
+
...styles.loading
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const sharedProps = {
|
|
131
|
+
id,
|
|
132
|
+
style: styles.text,
|
|
133
|
+
"aria-label": placeholder
|
|
134
|
+
};
|
|
135
|
+
if (href) return /* @__PURE__ */ jsx("a", {
|
|
136
|
+
href,
|
|
137
|
+
...sharedProps,
|
|
138
|
+
children
|
|
139
|
+
});
|
|
140
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
141
|
+
...sharedProps,
|
|
142
|
+
children
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
//#endregion
|
|
147
|
+
export { Typography as t };
|
|
148
|
+
//# sourceMappingURL=Typography-CKXLkfw7.js.map
|