@solibo/solibo-ui 0.3.40 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index33.css');const r=require("react/jsx-runtime"),u=require("../../classix-5H4IWnMA.cjs"),l=require("react"),d=require("../icon/index.cjs"),_="_button_1cw1v_1",g="_danger_1cw1v_19",p="_minimal_1cw1v_32",y="_primary_1cw1v_39",t={button:_,danger:g,minimal:p,primary:y},b={danger:t.danger,default:t.default,minimal:t.minimal,primary:t.primary},f=l.forwardRef(({children:a,className:i,disabled:s=!1,icon:n,onClick:o,variant:e="default",...c},m)=>r.jsxs("button",{className:u.t(t.button,b[e],i),disabled:s,onClick:o,ref:m,type:"button",...c,children:[n&&r.jsx(d.Icon,{gap:"right",name:n,size:"small",variant:e==="minimal"?"default":"white"}),a]}));exports.Button=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index33.css');const a=require("react/jsx-runtime"),u=require("../../classix-5H4IWnMA.cjs"),l=require("react"),d=require("../icon/index.cjs"),_="_button_1cw1v_1",p="_danger_1cw1v_19",b="_minimal_1cw1v_32",g="_primary_1cw1v_39",t={button:_,danger:p,minimal:b,primary:g},y={danger:t.danger,default:t.default,minimal:t.minimal,primary:t.primary},f=l.forwardRef(({children:r,className:i,disabled:o=!1,icon:n,onClick:s,variant:e="default",...c},m)=>a.jsxs("button",{className:u.t(t.button,y[e],i),disabled:o,onClick:s,ref:m,type:"button",...c,"data-component":"button",children:[n&&a.jsx(d.Icon,{gap:"right",name:n,size:"small",variant:e==="minimal"?"default":"white"}),r]}));exports.Button=f;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { forwardRef } from 'react';\n\nimport { Icon } from '../icon';\nimport { IconName } from '../icon/icons';\nimport styles from './styles.module.css';\n\nconst variants = {\n danger: styles.danger,\n default: styles.default,\n minimal: styles.minimal,\n primary: styles.primary,\n};\n\nexport type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n children: React.ReactNode;\n className?: string;\n disabled?: boolean;\n icon?: IconName;\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n variant?: keyof typeof variants;\n};\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n children,\n className,\n disabled = false,\n icon,\n onClick,\n variant = 'default',\n ...props\n },\n ref\n ) => {\n return (\n <button\n className={cx(styles.button, variants[variant], className)}\n disabled={disabled}\n onClick={onClick}\n ref={ref}\n type='button'\n {...props}\n >\n {icon && (\n <Icon\n gap='right'\n name={icon}\n size='small'\n variant={variant === 'minimal' ? 'default' : 'white'}\n />\n )}\n {children}\n </button>\n );\n }\n);\n"],"names":["variants","danger","styles","default","minimal","primary","Button","forwardRef","children","className","disabled","icon","onClick","variant","props","ref","cx","button","jsx","Icon"],"mappings":"8UAOMA,EAAW,CACfC,OAAQC,EAAOD,OACfE,QAASD,EAAOC,QAChBC,QAASF,EAAOE,QAChBC,QAASH,EAAOG,OAClB,EAWaC,EAASC,EAAAA,WACpB,CACE,CACEC,SAAAA,EACAC,UAAAA,EACAC,SAAAA,EAAW,GACXC,KAAAA,EACAC,QAAAA,EACAC,QAAAA,EAAU,UACV,GAAGC,CACL,EACAC,WAGG,SAAA,CACC,UAAWC,EAAAA,EAAGd,EAAOe,OAAQjB,EAASa,CAAO,EAAGJ,CAAS,EACzD,SAAAC,EACA,QAAAE,EACA,IAAAG,EACA,KAAK,SACL,GAAID,EAEHH,SAAAA,CAAAA,GACCO,EAAAA,IAACC,EAAAA,KAAA,CACC,IAAI,QACJ,KAAMR,EACN,KAAK,QACL,QAASE,IAAY,UAAY,UAAY,QAAQ,EAGxDL,CAAAA,EACH,CAGN"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { forwardRef } from 'react';\n\nimport { Icon } from '../icon';\nimport { IconName } from '../icon/icons';\nimport styles from './styles.module.css';\n\nconst variants = {\n danger: styles.danger,\n default: styles.default,\n minimal: styles.minimal,\n primary: styles.primary,\n};\n\nexport type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n children: React.ReactNode;\n className?: string;\n disabled?: boolean;\n icon?: IconName;\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n variant?: keyof typeof variants;\n};\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n { children, className, disabled = false, icon, onClick, variant = 'default', ...props },\n ref\n ) => {\n return (\n <button\n className={cx(styles.button, variants[variant], className)}\n disabled={disabled}\n onClick={onClick}\n ref={ref}\n type='button'\n {...props}\n >\n {icon && (\n <Icon\n gap='right'\n name={icon}\n size='small'\n variant={variant === 'minimal' ? 'default' : 'white'}\n />\n )}\n {children}\n </button>\n );\n }\n);\n"],"names":["variants","danger","styles","default","minimal","primary","Button","forwardRef","children","className","disabled","icon","onClick","variant","props","ref","cx","button","jsx","Icon"],"mappings":"8UAOMA,EAAW,CACfC,OAAQC,EAAOD,OACfE,QAASD,EAAOC,QAChBC,QAASF,EAAOE,QAChBC,QAASH,EAAOG,OAClB,EAWaC,EAASC,EAAAA,WACpB,CACE,CAAEC,SAAAA,EAAUC,UAAAA,EAAWC,SAAAA,EAAW,GAAOC,KAAAA,EAAMC,QAAAA,EAASC,QAAAA,EAAU,UAAW,GAAGC,CAAM,EACtFC,WAGG,SAAA,CACC,UAAWC,EAAAA,EAAGd,EAAOe,OAAQjB,EAASa,CAAO,EAAGJ,CAAS,EACzD,SAAAC,EACA,QAAAE,EACA,IAAAG,EACA,KAAK,SACL,GAAID,EAAM,iBAAA,SAETH,SAAAA,CAAAA,GACCO,EAAAA,IAACC,EAAAA,KAAA,CACC,IAAI,QACJ,KAAMR,EACN,KAAK,QACL,QAASE,IAAY,UAAY,UAAY,QAAQ,EAGxDL,CAAAA,EACH,CAGN"}
@@ -1,28 +1,28 @@
1
1
  import { jsxs as l, jsx as c } from "react/jsx-runtime";
2
2
  import { t as p } from "../../classix-DG18itHa.js";
3
3
  import { forwardRef as u } from "react";
4
- import { Icon as _ } from "../icon/index.js";
5
- import '../../assets/index33.css';const d = "_button_1cw1v_1", f = "_danger_1cw1v_19", g = "_minimal_1cw1v_32", y = "_primary_1cw1v_39", t = {
6
- button: d,
4
+ import { Icon as d } from "../icon/index.js";
5
+ import '../../assets/index33.css';const _ = "_button_1cw1v_1", f = "_danger_1cw1v_19", b = "_minimal_1cw1v_32", g = "_primary_1cw1v_39", t = {
6
+ button: _,
7
7
  danger: f,
8
- minimal: g,
9
- primary: y
10
- }, b = {
8
+ minimal: b,
9
+ primary: g
10
+ }, y = {
11
11
  danger: t.danger,
12
12
  default: t.default,
13
13
  minimal: t.minimal,
14
14
  primary: t.primary
15
15
  }, j = u(({
16
- children: n,
16
+ children: r,
17
17
  className: m,
18
- disabled: i = !1,
19
- icon: r,
20
- onClick: o,
18
+ disabled: o = !1,
19
+ icon: n,
20
+ onClick: i,
21
21
  variant: a = "default",
22
22
  ...e
23
- }, s) => /* @__PURE__ */ l("button", { className: p(t.button, b[a], m), disabled: i, onClick: o, ref: s, type: "button", ...e, children: [
24
- r && /* @__PURE__ */ c(_, { gap: "right", name: r, size: "small", variant: a === "minimal" ? "default" : "white" }),
25
- n
23
+ }, s) => /* @__PURE__ */ l("button", { className: p(t.button, y[a], m), disabled: o, onClick: i, ref: s, type: "button", ...e, "data-component": "button", children: [
24
+ n && /* @__PURE__ */ c(d, { gap: "right", name: n, size: "small", variant: a === "minimal" ? "default" : "white" }),
25
+ r
26
26
  ] }));
27
27
  export {
28
28
  j as Button
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { forwardRef } from 'react';\n\nimport { Icon } from '../icon';\nimport { IconName } from '../icon/icons';\nimport styles from './styles.module.css';\n\nconst variants = {\n danger: styles.danger,\n default: styles.default,\n minimal: styles.minimal,\n primary: styles.primary,\n};\n\nexport type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n children: React.ReactNode;\n className?: string;\n disabled?: boolean;\n icon?: IconName;\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n variant?: keyof typeof variants;\n};\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n children,\n className,\n disabled = false,\n icon,\n onClick,\n variant = 'default',\n ...props\n },\n ref\n ) => {\n return (\n <button\n className={cx(styles.button, variants[variant], className)}\n disabled={disabled}\n onClick={onClick}\n ref={ref}\n type='button'\n {...props}\n >\n {icon && (\n <Icon\n gap='right'\n name={icon}\n size='small'\n variant={variant === 'minimal' ? 'default' : 'white'}\n />\n )}\n {children}\n </button>\n );\n }\n);\n"],"names":["variants","danger","styles","default","minimal","primary","Button","forwardRef","children","className","disabled","icon","onClick","variant","props","ref","cx","button","jsx","Icon"],"mappings":";;;;;;;;;GAOMA,IAAW;AAAA,EACfC,QAAQC,EAAOD;AAAAA,EACfE,SAASD,EAAOC;AAAAA,EAChBC,SAASF,EAAOE;AAAAA,EAChBC,SAASH,EAAOG;AAClB,GAWaC,IAASC,EACpB,CACE;AAAA,EACEC,UAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,MAAAA;AAAAA,EACAC,SAAAA;AAAAA,EACAC,SAAAA,IAAU;AAAA,EACV,GAAGC;AACL,GACAC,wBAGG,UAAA,EACC,WAAWC,EAAGd,EAAOe,QAAQjB,EAASa,CAAO,GAAGJ,CAAS,GACzD,UAAAC,GACA,SAAAE,GACA,KAAAG,GACA,MAAK,UACL,GAAID,GAEHH,UAAAA;AAAAA,EAAAA,KACC,gBAAAO,EAACC,GAAA,EACC,KAAI,SACJ,MAAMR,GACN,MAAK,SACL,SAASE,MAAY,YAAY,YAAY,SAAQ;AAAA,EAGxDL;AAAAA,GACH,CAGN;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { forwardRef } from 'react';\n\nimport { Icon } from '../icon';\nimport { IconName } from '../icon/icons';\nimport styles from './styles.module.css';\n\nconst variants = {\n danger: styles.danger,\n default: styles.default,\n minimal: styles.minimal,\n primary: styles.primary,\n};\n\nexport type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n children: React.ReactNode;\n className?: string;\n disabled?: boolean;\n icon?: IconName;\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n variant?: keyof typeof variants;\n};\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n { children, className, disabled = false, icon, onClick, variant = 'default', ...props },\n ref\n ) => {\n return (\n <button\n className={cx(styles.button, variants[variant], className)}\n disabled={disabled}\n onClick={onClick}\n ref={ref}\n type='button'\n {...props}\n >\n {icon && (\n <Icon\n gap='right'\n name={icon}\n size='small'\n variant={variant === 'minimal' ? 'default' : 'white'}\n />\n )}\n {children}\n </button>\n );\n }\n);\n"],"names":["variants","danger","styles","default","minimal","primary","Button","forwardRef","children","className","disabled","icon","onClick","variant","props","ref","cx","button","jsx","Icon"],"mappings":";;;;;;;;;GAOMA,IAAW;AAAA,EACfC,QAAQC,EAAOD;AAAAA,EACfE,SAASD,EAAOC;AAAAA,EAChBC,SAASF,EAAOE;AAAAA,EAChBC,SAASH,EAAOG;AAClB,GAWaC,IAASC,EACpB,CACE;AAAA,EAAEC,UAAAA;AAAAA,EAAUC,WAAAA;AAAAA,EAAWC,UAAAA,IAAW;AAAA,EAAOC,MAAAA;AAAAA,EAAMC,SAAAA;AAAAA,EAASC,SAAAA,IAAU;AAAA,EAAW,GAAGC;AAAM,GACtFC,wBAGG,UAAA,EACC,WAAWC,EAAGd,EAAOe,QAAQjB,EAASa,CAAO,GAAGJ,CAAS,GACzD,UAAAC,GACA,SAAAE,GACA,KAAAG,GACA,MAAK,UACL,GAAID,GAAM,kBAAA,UAETH,UAAAA;AAAAA,EAAAA,KACC,gBAAAO,EAACC,GAAA,EACC,KAAI,SACJ,MAAMR,GACN,MAAK,SACL,SAASE,MAAY,YAAY,YAAY,SAAQ;AAAA,EAGxDL;AAAAA,GACH,CAGN;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),c=require("../../classix-5H4IWnMA.cjs"),s=require("react"),I=require("../../icons-C_cX1FYp.cjs"),P=require("../../utils-DqVa4K58.cjs"),a=require("../../styles.module-CwroCNAt.cjs"),R=s.forwardRef(({className:y,defaultCountryCode:d="+47",disabled:i=!1,icon:o,label:h,placeholder:m,type:t="text",...e},v)=>{const[l,g]=s.useState(""),[r,x]=s.useState(""),{onChange:N,value:j,...C}=e,{touched:f,onBlur:S}=P.useTouched(j===""),q=o&&t!=="radio"&&t!=="datetime-local"?{"--icon-svg":I.iconSVG(o,!0)}:void 0;s.useEffect(()=>{if(typeof e.onChange=="function"&&t==="tel"){const u={name:e.name,value:r?(l||d).split(" ").join("")+r.split(" ").join(""):void 0};e.onChange({target:u,currentTarget:u})}},[l,r]),s.useEffect(()=>{t==="tel"&&!e.value&&(x(""),g(""))},[e.value,t]);const p=n.jsxs(n.Fragment,{children:[n.jsx("input",{disabled:i,hidden:!0,onChange:N,pattern:void 0,placeholder:m,ref:v,type:t,value:j}),n.jsx("input",{type:"text",className:a.inputStyles.input,disabled:i,maxLength:5,onChange:u=>g(u.target.value),placeholder:d,value:l}),n.jsx("input",{type:"tel",className:c.t(a.inputStyles.input,f&&"touched"),"data-icon":o?"true":void 0,disabled:i,maxLength:14,name:void 0,onChange:u=>x(u.target.value),onBlur:S,pattern:e.pattern,style:q,value:r,...C})]});return n.jsxs("label",{className:a.inputStyles.label,children:[h&&n.jsx("span",{className:c.t(e.required&&a.inputStyles.required),children:h}),t==="tel"?p:n.jsx("input",{ref:v,className:c.t(a.inputStyles.input,y,f&&"touched"),"data-icon":o?"true":void 0,disabled:i,onBlur:S,placeholder:m,style:q,type:t,...e})]})});exports.Input=R;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),l=require("../../classix-5H4IWnMA.cjs"),s=require("react"),I=require("../../icons-C_cX1FYp.cjs"),P=require("../../utils-DqVa4K58.cjs"),a=require("../../styles.module-CwroCNAt.cjs"),R=s.forwardRef(({className:p,defaultCountryCode:d="+47",disabled:i=!1,icon:o,label:h,placeholder:m,type:t="text",...e},v)=>{const[c,g]=s.useState(""),[r,x]=s.useState(""),{onChange:y,value:j,...N}=e,{touched:f,onBlur:S}=P.useTouched(j===""),q=o&&t!=="radio"&&t!=="datetime-local"?{"--icon-svg":I.iconSVG(o,!0)}:void 0;s.useEffect(()=>{if(typeof e.onChange=="function"&&t==="tel"){const u={name:e.name,value:r?(c||d).split(" ").join("")+r.split(" ").join(""):void 0};e.onChange({target:u,currentTarget:u})}},[c,r]),s.useEffect(()=>{t==="tel"&&!e.value&&(x(""),g(""))},[e.value,t]);const C=n.jsxs(n.Fragment,{children:[n.jsx("input",{disabled:i,hidden:!0,onChange:y,pattern:void 0,placeholder:m,ref:v,type:t,value:j}),n.jsx("input",{type:"text",className:a.inputStyles.input,disabled:i,maxLength:5,onChange:u=>g(u.target.value),placeholder:d,value:c}),n.jsx("input",{type:"tel",className:l.t(a.inputStyles.input,f&&"touched"),"data-icon":o?"true":void 0,disabled:i,maxLength:14,name:void 0,onChange:u=>x(u.target.value),onBlur:S,pattern:e.pattern,style:q,value:r,...N})]});return n.jsxs("label",{className:a.inputStyles.label,"data-component":"input",children:[h&&n.jsx("span",{className:l.t(e.required&&a.inputStyles.required),children:h}),t==="tel"?C:n.jsx("input",{ref:v,className:l.t(a.inputStyles.input,p,f&&"touched"),"data-icon":o?"true":void 0,disabled:i,onBlur:S,placeholder:m,style:q,type:t,...e})]})});exports.Input=R;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/components/input/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { forwardRef, useEffect, useState } from 'react';\n\nimport { IconName, iconSVG } from '@/components/icon/icons.ts';\nimport { useTouched } from '@/utils.ts';\n\nimport styles from './styles.module.css';\n\nexport type InputProps = React.ComponentPropsWithoutRef<'input'> & {\n defaultCountryCode?: string;\n disabled?: boolean;\n icon?: IconName;\n label?: string;\n onClick?: React.MouseEventHandler<HTMLInputElement>;\n placeholder?: string;\n type?: 'datetime-local' | 'email' | 'number' | 'password' | 'radio' | 'search' | 'tel' | 'text';\n};\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n defaultCountryCode = '+47',\n disabled = false,\n icon,\n label,\n placeholder,\n type = 'text',\n ...props\n },\n ref\n ) => {\n const [countryCode, setCountryCode] = useState('');\n const [phoneNumber, setPhoneNumber] = useState('');\n const { onChange, value, ...restProps } = props;\n const { touched, onBlur } = useTouched(value === '');\n\n type withVars =\n | (React.CSSProperties & {\n '--icon-svg'?: string;\n })\n | undefined;\n\n const withVars: withVars =\n icon && type !== 'radio' && type !== 'datetime-local'\n ? {\n '--icon-svg': iconSVG(icon, true),\n }\n : undefined;\n\n useEffect(() => {\n if (typeof props.onChange === 'function' && type === 'tel') {\n const target = {\n name: props.name,\n value: phoneNumber\n ? (countryCode || defaultCountryCode).split(' ').join('') +\n phoneNumber.split(' ').join('')\n : undefined,\n } as unknown as HTMLInputElement;\n // eslint-disable-next-line\n (props.onChange as any)({ target, currentTarget: target });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [countryCode, phoneNumber]);\n\n useEffect(() => {\n if (type === 'tel' && !props.value) {\n setPhoneNumber('');\n setCountryCode('');\n }\n }, [props.value, type]);\n\n const telephoneInput = (\n <>\n <input\n disabled={disabled}\n hidden\n onChange={onChange}\n pattern={undefined}\n placeholder={placeholder}\n ref={ref}\n type={type}\n value={value}\n />\n <input\n type='text'\n className={styles.input}\n disabled={disabled}\n maxLength={5}\n onChange={(e) => setCountryCode(e.target.value)}\n placeholder={defaultCountryCode}\n value={countryCode}\n />\n <input\n type='tel'\n className={cx(styles.input, touched && 'touched')}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n maxLength={14}\n name={undefined}\n onChange={(e) => setPhoneNumber(e.target.value)}\n onBlur={onBlur}\n pattern={props.pattern}\n style={withVars}\n value={phoneNumber}\n {...restProps}\n />\n </>\n );\n\n return (\n <label className={styles.label}>\n {label && <span className={cx(props.required && styles.required)}>{label}</span>}\n {type === 'tel' ? (\n telephoneInput\n ) : (\n <input\n ref={ref}\n className={cx(styles.input, className, touched && 'touched')}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n onBlur={onBlur}\n placeholder={placeholder}\n style={withVars}\n type={type}\n {...props}\n />\n )}\n </label>\n );\n }\n);\n"],"names":["Input","forwardRef","className","defaultCountryCode","disabled","icon","label","placeholder","type","props","ref","countryCode","setCountryCode","useState","phoneNumber","setPhoneNumber","onChange","value","restProps","touched","onBlur","useTouched","withVars","iconSVG","undefined","useEffect","target","name","split","join","currentTarget","telephoneInput","jsxs","Fragment","jsx","styles","input","e","cx","pattern","required"],"mappings":"0SAkBaA,EAAQC,EAAAA,WACnB,CACE,CACEC,UAAAA,EACAC,mBAAAA,EAAqB,MACrBC,SAAAA,EAAW,GACXC,KAAAA,EACAC,MAAAA,EACAC,YAAAA,EACAC,KAAAA,EAAO,OACP,GAAGC,CACL,EACAC,IACG,CACH,KAAM,CAACC,EAAaC,CAAc,EAAIC,EAAAA,SAAS,EAAE,EAC3C,CAACC,EAAaC,CAAc,EAAIF,EAAAA,SAAS,EAAE,EAC3C,CAAEG,SAAAA,EAAUC,MAAAA,EAAO,GAAGC,CAAAA,EAAcT,EACpC,CAAEU,QAAAA,EAASC,OAAAA,CAAAA,EAAWC,EAAAA,WAAWJ,IAAU,EAAE,EAQ7CK,EACJjB,GAAQG,IAAS,SAAWA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ACEc,EAAAA,KAAC,QAAA,CAAM,UAAWG,EAAAA,YAAO7B,MACtBA,SAAAA,CAAAA,GAAS4B,EAAAA,IAAC,QAAK,UAAWI,EAAAA,EAAG7B,EAAM+B,UAAYL,EAAAA,YAAOK,QAAQ,EAAIlC,SAAAA,CAAAA,CAAM,EACxEE,IAAS,MACRuB,EAEAG,EAAAA,IAAC,QAAA,CACC,IAAAxB,EACA,UAAW4B,EAAAA,EAAGH,EAAAA,YAAOC,MAAOlC,EAAWiB,GAAW,SAAS,EAC3D,YAAWd,EAAO,OAASmB,OAC3B,SAAApB,EACA,OAAAgB,EACA,YAAAb,EACA,MAAOe,EACP,KAAAd,EACA,GAAIC,CAAAA,CAAM,CAAA,EAGhB,CAEJ,CACF"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/components/input/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { forwardRef, useEffect, useState } from 'react';\n\nimport { IconName, iconSVG } from '@/components/icon/icons.ts';\nimport { useTouched } from '@/utils.ts';\n\nimport styles from './styles.module.css';\n\nexport type InputProps = React.ComponentPropsWithoutRef<'input'> & {\n defaultCountryCode?: string;\n disabled?: boolean;\n icon?: IconName;\n label?: string;\n onClick?: React.MouseEventHandler<HTMLInputElement>;\n placeholder?: string;\n type?: 'datetime-local' | 'email' | 'number' | 'password' | 'radio' | 'search' | 'tel' | 'text';\n};\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n defaultCountryCode = '+47',\n disabled = false,\n icon,\n label,\n placeholder,\n type = 'text',\n ...props\n },\n ref\n ) => {\n const [countryCode, setCountryCode] = useState('');\n const [phoneNumber, setPhoneNumber] = useState('');\n const { onChange, value, ...restProps } = props;\n const { touched, onBlur } = useTouched(value === '');\n\n type withVars =\n | (React.CSSProperties & {\n '--icon-svg'?: string;\n })\n | undefined;\n\n const withVars: withVars =\n icon && type !== 'radio' && type !== 'datetime-local'\n ? {\n '--icon-svg': iconSVG(icon, true),\n }\n : undefined;\n\n useEffect(() => {\n if (typeof props.onChange === 'function' && type === 'tel') {\n const target = {\n name: props.name,\n value: phoneNumber\n ? (countryCode || defaultCountryCode).split(' ').join('') +\n phoneNumber.split(' ').join('')\n : undefined,\n } as unknown as HTMLInputElement;\n // eslint-disable-next-line\n (props.onChange as any)({ target, currentTarget: target });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [countryCode, phoneNumber]);\n\n useEffect(() => {\n if (type === 'tel' && !props.value) {\n setPhoneNumber('');\n setCountryCode('');\n }\n }, [props.value, type]);\n\n const telephoneInput = (\n <>\n <input\n disabled={disabled}\n hidden\n onChange={onChange}\n pattern={undefined}\n placeholder={placeholder}\n ref={ref}\n type={type}\n value={value}\n />\n <input\n type='text'\n className={styles.input}\n disabled={disabled}\n maxLength={5}\n onChange={(e) => setCountryCode(e.target.value)}\n placeholder={defaultCountryCode}\n value={countryCode}\n />\n <input\n type='tel'\n className={cx(styles.input, touched && 'touched')}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n maxLength={14}\n name={undefined}\n onChange={(e) => setPhoneNumber(e.target.value)}\n onBlur={onBlur}\n pattern={props.pattern}\n style={withVars}\n value={phoneNumber}\n {...restProps}\n />\n </>\n );\n\n return (\n <label className={styles.label}>\n {label && <span className={cx(props.required && styles.required)}>{label}</span>}\n {type === 'tel' ? (\n telephoneInput\n ) : (\n <input\n ref={ref}\n className={cx(styles.input, className, touched && 'touched')}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n onBlur={onBlur}\n placeholder={placeholder}\n style={withVars}\n type={type}\n {...props}\n />\n )}\n </label>\n );\n }\n);\n"],"names":["Input","forwardRef","className","defaultCountryCode","disabled","icon","label","placeholder","type","props","ref","countryCode","setCountryCode","useState","phoneNumber","setPhoneNumber","onChange","value","restProps","touched","onBlur","useTouched","withVars","iconSVG","undefined","useEffect","target","name","split","join","currentTarget","telephoneInput","jsxs","Fragment","jsx","styles","input","e","cx","pattern","required"],"mappings":"0SAkBaA,EAAQC,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C,KAAK,OACL,UAAWC,EAAAA,YAAOC,MAClB,SAAAhC,EACA,UAAW,EACX,SAAWiC,GAAMzB,EAAeyB,EAAEX,OAAOT,KAAK,EAC9C,YAAad,EACb,MAAOQ,EAAY,QAEpB,QAAA,CACC,KAAK,MACL,UAAW2B,EAAAA,EAAGH,EAAAA,YAAOC,MAAOjB,GAAW,SAAS,EAChD,YAAWd,EAAO,OAASmB,OAC3B,SAAApB,EACA,UAAW,GACX,KAAMoB,OACN,SAAWa,GAAMtB,EAAesB,EAAEX,OAAOT,KAAK,EAC9C,OAAAG,EACA,QAASX,EAAM8B,QACf,MAAOjB,EACP,MAAOR,EACP,GAAII,CAAAA,CAAU,CAAA,EAElB,EAGF,cACG,QAAA,CAAM,UAAWiB,EAAAA,YAAO7B,MAAM,iBAAA,QAC5BA,SAAAA,CAAAA,GAAS4B,EAAAA,IAAC,QAAK,UAAWI,EAAAA,EAAG7B,EAAM+B,UAAYL,EAAAA,YAAOK,QAAQ,EAAIlC,SAAAA,CAAAA,CAAM,EACxEE,IAAS,MACRuB,EAEAG,EAAAA,IAAC,QAAA,CACC,IAAAxB,EACA,UAAW4B,EAAAA,EAAGH,EAAAA,YAAOC,MAAOlC,EAAWiB,GAAW,SAAS,EAC3D,YAAWd,EAAO,OAASmB,OAC3B,SAAApB,EACA,OAAAgB,EACA,YAAAb,EACA,MAAOe,EACP,KAAAd,EACA,GAAIC,CAAAA,CAAM,CAAA,EAGhB,CAEJ,CACF"}
@@ -8,44 +8,44 @@ const y = T(({
8
8
  className: q,
9
9
  defaultCountryCode: c = "+47",
10
10
  disabled: u = !1,
11
- icon: r,
11
+ icon: i,
12
12
  label: m,
13
13
  placeholder: h,
14
14
  type: e = "text",
15
15
  ...t
16
16
  }, d) => {
17
- const [s, v] = j(""), [i, f] = j(""), {
17
+ const [s, v] = j(""), [r, f] = j(""), {
18
18
  onChange: w,
19
19
  value: g,
20
20
  ...I
21
21
  } = t, {
22
- touched: x,
23
- onBlur: N
24
- } = B(g === ""), p = r && e !== "radio" && e !== "datetime-local" ? {
25
- "--icon-svg": V(r, !0)
22
+ touched: p,
23
+ onBlur: x
24
+ } = B(g === ""), N = i && e !== "radio" && e !== "datetime-local" ? {
25
+ "--icon-svg": V(i, !0)
26
26
  } : void 0;
27
27
  S(() => {
28
28
  if (typeof t.onChange == "function" && e === "tel") {
29
29
  const n = {
30
30
  name: t.name,
31
- value: i ? (s || c).split(" ").join("") + i.split(" ").join("") : void 0
31
+ value: r ? (s || c).split(" ").join("") + r.split(" ").join("") : void 0
32
32
  };
33
33
  t.onChange({
34
34
  target: n,
35
35
  currentTarget: n
36
36
  });
37
37
  }
38
- }, [s, i]), S(() => {
38
+ }, [s, r]), S(() => {
39
39
  e === "tel" && !t.value && (f(""), v(""));
40
40
  }, [t.value, e]);
41
41
  const L = /* @__PURE__ */ C(P, { children: [
42
42
  /* @__PURE__ */ a("input", { disabled: u, hidden: !0, onChange: w, pattern: void 0, placeholder: h, ref: d, type: e, value: g }),
43
43
  /* @__PURE__ */ a("input", { type: "text", className: o.input, disabled: u, maxLength: 5, onChange: (n) => v(n.target.value), placeholder: c, value: s }),
44
- /* @__PURE__ */ a("input", { type: "tel", className: l(o.input, x && "touched"), "data-icon": r ? "true" : void 0, disabled: u, maxLength: 14, name: void 0, onChange: (n) => f(n.target.value), onBlur: N, pattern: t.pattern, style: p, value: i, ...I })
44
+ /* @__PURE__ */ a("input", { type: "tel", className: l(o.input, p && "touched"), "data-icon": i ? "true" : void 0, disabled: u, maxLength: 14, name: void 0, onChange: (n) => f(n.target.value), onBlur: x, pattern: t.pattern, style: N, value: r, ...I })
45
45
  ] });
46
- return /* @__PURE__ */ C("label", { className: o.label, children: [
46
+ return /* @__PURE__ */ C("label", { className: o.label, "data-component": "input", children: [
47
47
  m && /* @__PURE__ */ a("span", { className: l(t.required && o.required), children: m }),
48
- e === "tel" ? L : /* @__PURE__ */ a("input", { ref: d, className: l(o.input, q, x && "touched"), "data-icon": r ? "true" : void 0, disabled: u, onBlur: N, placeholder: h, style: p, type: e, ...t })
48
+ e === "tel" ? L : /* @__PURE__ */ a("input", { ref: d, className: l(o.input, q, p && "touched"), "data-icon": i ? "true" : void 0, disabled: u, onBlur: x, placeholder: h, style: N, type: e, ...t })
49
49
  ] });
50
50
  });
51
51
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/input/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { forwardRef, useEffect, useState } from 'react';\n\nimport { IconName, iconSVG } from '@/components/icon/icons.ts';\nimport { useTouched } from '@/utils.ts';\n\nimport styles from './styles.module.css';\n\nexport type InputProps = React.ComponentPropsWithoutRef<'input'> & {\n defaultCountryCode?: string;\n disabled?: boolean;\n icon?: IconName;\n label?: string;\n onClick?: React.MouseEventHandler<HTMLInputElement>;\n placeholder?: string;\n type?: 'datetime-local' | 'email' | 'number' | 'password' | 'radio' | 'search' | 'tel' | 'text';\n};\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n defaultCountryCode = '+47',\n disabled = false,\n icon,\n label,\n placeholder,\n type = 'text',\n ...props\n },\n ref\n ) => {\n const [countryCode, setCountryCode] = useState('');\n const [phoneNumber, setPhoneNumber] = useState('');\n const { onChange, value, ...restProps } = props;\n const { touched, onBlur } = useTouched(value === '');\n\n type withVars =\n | (React.CSSProperties & {\n '--icon-svg'?: string;\n })\n | undefined;\n\n const withVars: withVars =\n icon && type !== 'radio' && type !== 'datetime-local'\n ? {\n '--icon-svg': iconSVG(icon, true),\n }\n : undefined;\n\n useEffect(() => {\n if (typeof props.onChange === 'function' && type === 'tel') {\n const target = {\n name: props.name,\n value: phoneNumber\n ? (countryCode || defaultCountryCode).split(' ').join('') +\n phoneNumber.split(' ').join('')\n : undefined,\n } as unknown as HTMLInputElement;\n // eslint-disable-next-line\n (props.onChange as any)({ target, currentTarget: target });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [countryCode, phoneNumber]);\n\n useEffect(() => {\n if (type === 'tel' && !props.value) {\n setPhoneNumber('');\n setCountryCode('');\n }\n }, [props.value, type]);\n\n const telephoneInput = (\n <>\n <input\n disabled={disabled}\n hidden\n onChange={onChange}\n pattern={undefined}\n placeholder={placeholder}\n ref={ref}\n type={type}\n value={value}\n />\n <input\n type='text'\n className={styles.input}\n disabled={disabled}\n maxLength={5}\n onChange={(e) => setCountryCode(e.target.value)}\n placeholder={defaultCountryCode}\n value={countryCode}\n />\n <input\n type='tel'\n className={cx(styles.input, touched && 'touched')}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n maxLength={14}\n name={undefined}\n onChange={(e) => setPhoneNumber(e.target.value)}\n onBlur={onBlur}\n pattern={props.pattern}\n style={withVars}\n value={phoneNumber}\n {...restProps}\n />\n </>\n );\n\n return (\n <label className={styles.label}>\n {label && <span className={cx(props.required && styles.required)}>{label}</span>}\n {type === 'tel' ? (\n telephoneInput\n ) : (\n <input\n ref={ref}\n className={cx(styles.input, className, touched && 'touched')}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n onBlur={onBlur}\n placeholder={placeholder}\n style={withVars}\n type={type}\n {...props}\n />\n )}\n </label>\n );\n }\n);\n"],"names":["Input","forwardRef","className","defaultCountryCode","disabled","icon","label","placeholder","type","props","ref","countryCode","setCountryCode","useState","phoneNumber","setPhoneNumber","onChange","value","restProps","touched","onBlur","useTouched","withVars","iconSVG","undefined","useEffect","target","name","split","join","currentTarget","telephoneInput","jsxs","Fragment","jsx","styles","input","e","cx","pattern","required"],"mappings":";;;;;;AAkBO,MAAMA,IAAQC,EACnB,CACE;AAAA,EACEC,WAAAA;AAAAA,EACAC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,IAAW;AAAA,EACXC,MAAAA;AAAAA,EACAC,OAAAA;AAAAA,EACAC,aAAAA;AAAAA,EACAC,MAAAA,IAAO;AAAA,EACP,GAAGC;AACL,GACAC,MACG;AACH,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAS,EAAE,GAC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,KAAK,GAC9C,aAAad,GACb,OAAOQ,GAAY;AAAA,sBAEpB,SAAA,EACC,MAAK,OACL,WAAW2B,EAAGH,EAAOC,OAAOjB,KAAW,SAAS,GAChD,aAAWd,IAAO,SAASmB,QAC3B,UAAApB,GACA,WAAW,IACX,MAAMoB,QACN,UAAWa,CAAAA,MAAMtB,EAAesB,EAAEX,OAAOT,KAAK,GAC9C,QAAAG,GACA,SAASX,EAAM8B,SACf,OAAOjB,GACP,OAAOR,GACP,GAAII,EAAAA,CAAU;AAAA,EAAA,GAElB;AAGF,SACE,gBAAAc,EAAC,SAAA,EAAM,WAAWG,EAAO7B,OACtBA,UAAAA;AAAAA,IAAAA,KAAS,gBAAA4B,EAAC,UAAK,WAAWI,EAAG7B,EAAM+B,YAAYL,EAAOK,QAAQ,GAAIlC,UAAAA,EAAAA,CAAM;AAAA,IACxEE,MAAS,QACRuB,IAEA,gBAAAG,EAAC,SAAA,EACC,KAAAxB,GACA,WAAW4B,EAAGH,EAAOC,OAAOlC,GAAWiB,KAAW,SAAS,GAC3D,aAAWd,IAAO,SAASmB,QAC3B,UAAApB,GACA,QAAAgB,GACA,aAAAb,GACA,OAAOe,GACP,MAAAd,GACA,GAAIC,EAAAA,CAAM;AAAA,EAAA,GAGhB;AAEJ,CACF;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/input/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { forwardRef, useEffect, useState } from 'react';\n\nimport { IconName, iconSVG } from '@/components/icon/icons.ts';\nimport { useTouched } from '@/utils.ts';\n\nimport styles from './styles.module.css';\n\nexport type InputProps = React.ComponentPropsWithoutRef<'input'> & {\n defaultCountryCode?: string;\n disabled?: boolean;\n icon?: IconName;\n label?: string;\n onClick?: React.MouseEventHandler<HTMLInputElement>;\n placeholder?: string;\n type?: 'datetime-local' | 'email' | 'number' | 'password' | 'radio' | 'search' | 'tel' | 'text';\n};\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n defaultCountryCode = '+47',\n disabled = false,\n icon,\n label,\n placeholder,\n type = 'text',\n ...props\n },\n ref\n ) => {\n const [countryCode, setCountryCode] = useState('');\n const [phoneNumber, setPhoneNumber] = useState('');\n const { onChange, value, ...restProps } = props;\n const { touched, onBlur } = useTouched(value === '');\n\n type withVars =\n | (React.CSSProperties & {\n '--icon-svg'?: string;\n })\n | undefined;\n\n const withVars: withVars =\n icon && type !== 'radio' && type !== 'datetime-local'\n ? {\n '--icon-svg': iconSVG(icon, true),\n }\n : undefined;\n\n useEffect(() => {\n if (typeof props.onChange === 'function' && type === 'tel') {\n const target = {\n name: props.name,\n value: phoneNumber\n ? (countryCode || defaultCountryCode).split(' ').join('') +\n phoneNumber.split(' ').join('')\n : undefined,\n } as unknown as HTMLInputElement;\n // eslint-disable-next-line\n (props.onChange as any)({ target, currentTarget: target });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [countryCode, phoneNumber]);\n\n useEffect(() => {\n if (type === 'tel' && !props.value) {\n setPhoneNumber('');\n setCountryCode('');\n }\n }, [props.value, type]);\n\n const telephoneInput = (\n <>\n <input\n disabled={disabled}\n hidden\n onChange={onChange}\n pattern={undefined}\n placeholder={placeholder}\n ref={ref}\n type={type}\n value={value}\n />\n <input\n type='text'\n className={styles.input}\n disabled={disabled}\n maxLength={5}\n onChange={(e) => setCountryCode(e.target.value)}\n placeholder={defaultCountryCode}\n value={countryCode}\n />\n <input\n type='tel'\n className={cx(styles.input, touched && 'touched')}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n maxLength={14}\n name={undefined}\n onChange={(e) => setPhoneNumber(e.target.value)}\n onBlur={onBlur}\n pattern={props.pattern}\n style={withVars}\n value={phoneNumber}\n {...restProps}\n />\n </>\n );\n\n return (\n <label className={styles.label}>\n {label && <span className={cx(props.required && styles.required)}>{label}</span>}\n {type === 'tel' ? (\n telephoneInput\n ) : (\n <input\n ref={ref}\n className={cx(styles.input, className, touched && 'touched')}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n onBlur={onBlur}\n placeholder={placeholder}\n style={withVars}\n type={type}\n {...props}\n />\n )}\n </label>\n );\n }\n);\n"],"names":["Input","forwardRef","className","defaultCountryCode","disabled","icon","label","placeholder","type","props","ref","countryCode","setCountryCode","useState","phoneNumber","setPhoneNumber","onChange","value","restProps","touched","onBlur","useTouched","withVars","iconSVG","undefined","useEffect","target","name","split","join","currentTarget","telephoneInput","jsxs","Fragment","jsx","styles","input","e","cx","pattern","required"],"mappings":";;;;;;AAkBO,MAAMA,IAAQC,EACnB,CACE;AAAA,EACEC,WAAAA;AAAAA,EACAC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,IAAW;AAAA,EACXC,MAAAA;AAAAA,EACAC,OAAAA;AAAAA,EACAC,aAAAA;AAAAA,EACAC,MAAAA,IAAO;AAAA,EACP,GAAGC;AACL,GACAC,MACG;AACH,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAS,EAAE,GAC3C,CAACC,GAAaC,CAAc,IAAIF,EAAS,EAAE,GAC3C;AAAA,IAAEG,UAAAA;AAAAA,IAAUC,OAAAA;AAAAA,IAAO,GAAGC;AAAAA,EAAAA,IAAcT,GACpC;AAAA,IAAEU,SAAAA;AAAAA,IAASC,QAAAA;AAAAA,EAAAA,IAAWC,EAAWJ,MAAU,EAAE,GAQ7CK,IACJjB,KAAQG,MAAS,WAAWA,MAAS,mBACjC;AAAA,IACE,cAAce,EAAQlB,GAAM,EAAI;AAAA,EAAA,IAElCmB;AAENC,EAAAA,EAAU,MAAM;AACd,QAAI,OAAOhB,EAAMO,YAAa,cAAcR,MAAS,OAAO;AAC1D,YAAMkB,IAAS;AAAA,QACbC,MAAMlB,EAAMkB;AAAAA,QACZV,OAAOH,KACFH,KAAeR,GAAoByB,MAAM,GAAG,EAAEC,KAAK,EAAE,IACtDf,EAAYc,MAAM,GAAG,EAAEC,KAAK,EAAE,IAC9BL;AAAAA,MAAAA;AAGLf,MAAAA,EAAMO,SAAiB;AAA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WiB,KAAW,SAAS,GAC3D,aAAWd,IAAO,SAASmB,QAC3B,UAAApB,GACA,QAAAgB,GACA,aAAAb,GACA,OAAOe,GACP,MAAAd,GACA,GAAIC,EAAAA,CAAM;AAAA,EAAA,GAGhB;AAEJ,CACF;"}
@@ -0,0 +1,76 @@
1
+ /* generated by `pnpm tokens:build` 🥷 */
2
+
3
+ :root {
4
+ --border: var(--border-width) solid var(--color-border);
5
+ --border-radius: calc(var(--unit) / 1.5);
6
+ --border-radius-large: calc(var(--unit) * 1.5);
7
+ --border-width: 1px;
8
+ --border-width-heavy: 2px;
9
+ --color-background-light: var(--color-neutral-light);
10
+ --color-black: rgb(23 23 23);
11
+ --color-border: var(--color-timberwolf);
12
+ --color-border-primary: rgb(42 42 42 / 12%);
13
+ --color-cod-gray: rgb(11 11 11);
14
+ --color-dark: rgb(180 180 180);
15
+ --color-draft: rgb(255 255 200 / 80%);
16
+ --color-electric-violet: rgb(90 35 245);
17
+ --color-fallback: var(--color-silver);
18
+ --color-green: rgb(0 146 20);
19
+ --color-green-dark: rgb(33 69 45);
20
+ --color-green-light: rgb(209 250 229);
21
+ --color-highlight: rgb(235 235 235);
22
+ --color-icon: var(--color-outer-space);
23
+ --color-mahogany: rgb(136 4 2);
24
+ --color-neutral: var(--color-timberwolf);
25
+ --color-neutral-light: var(--color-wild-sand);
26
+ --color-outer-space: rgb(82 82 82);
27
+ --color-placeholder-text: var(--color-silver);
28
+ --color-primary: var(--color-electric-violet);
29
+ --color-primary-dark: var(--color-purple-heart);
30
+ --color-purple-heart: rgb(64 25 174);
31
+ --color-purple-light: rgb(239 233 254);
32
+ --color-red: rgb(191 6 3);
33
+ --color-red-light: rgb(235 178 177);
34
+ --color-silver: rgb(194 194 194);
35
+ --color-surface-active: rgb(123 79 247 / 20%);
36
+ --color-text: var(--color-text-primary);
37
+ --color-text-primary: var(--color-cod-gray);
38
+ --color-text-secondary: var(--color-outer-space);
39
+ --color-timberwolf: rgb(223 223 223);
40
+ --color-translucent: rgba(255 255 255 / 60%);
41
+ --color-warning: var(--color-red);
42
+ --color-white: rgb(255 255 255);
43
+ --color-wild-sand: rgb(245 245 245);
44
+ --font-family: 'Figtree', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
45
+ --font-size: var(--unit);
46
+ --font-size-h1: calc(var(--unit) * 2);
47
+ --font-size-h2: calc(var(--unit) * 1.25);
48
+ --font-size-h3: calc(var(--unit));
49
+ --font-size-small: calc(var(--unit) * 0.75);
50
+ --font-weight-bold: 700;
51
+ --font-weight-normal: 400;
52
+ --font-weight-semibold: 600;
53
+ --gradient: linear-gradient(180deg, rgb(255 255 255 / 100%), transparent 50%);
54
+ --icon-size: calc(var(--unit) * 1.5);
55
+ --negative-unit: calc(-1 * var(--unit));
56
+ --negative-unit-large: calc(var(--negative-unit) * 2);
57
+ --negative-unit-small: calc(var(--negative-unit) / 2);
58
+ --offset: calc(-2 * var(--unit));
59
+ --opacity-disabled: var(--opacity-minimal);
60
+ --opacity-minimal: 0.5;
61
+ --opacity-visited: var(--opacity-minimal);
62
+ --padding-box: 0.05px var(--unit);
63
+ --shadow: var(--shadow-color) var(--unit-micro) var(--unit-micro) var(--unit-tiny);
64
+ --shadow-big: var(--shadow-color) var(--unit-micro) var(--unit-micro) var(--unit-small);
65
+ --shadow-color: rgb(0 0 0 / 10%);
66
+ --transition-delay: 125ms;
67
+ --transition-duration: 250ms;
68
+ --transition-duration-long: calc(var(--transition-duration) * 2);
69
+ --transition-timing-function: ease-out;
70
+ --unit: 16px;
71
+ --unit-large: calc(var(--unit) * 2);
72
+ --unit-micro: calc(var(--unit) / 8);
73
+ --unit-small: calc(var(--unit) / 2);
74
+ --unit-tiny: calc(var(--unit) / 4);
75
+ --z-max: 2147483647;
76
+ }
@@ -0,0 +1,334 @@
1
+ {
2
+ "meta": {
3
+ "format": "solibo-design-tokens",
4
+ "packageName": "@solibo/solibo-ui",
5
+ "packageVersion": "0.4.1",
6
+ "schemaVersion": 1
7
+ },
8
+ "tokens": {
9
+ "border": {
10
+ "$type": "string",
11
+ "$value": "{border.width} solid {color.border}",
12
+ "radius": {
13
+ "$type": "dimension",
14
+ "$value": "calc({unit} / 1.5)",
15
+ "large": {
16
+ "$type": "dimension",
17
+ "$value": "calc({unit} * 1.5)"
18
+ }
19
+ },
20
+ "width": {
21
+ "$type": "dimension",
22
+ "$value": "1px",
23
+ "heavy": {
24
+ "$type": "dimension",
25
+ "$value": "2px"
26
+ }
27
+ }
28
+ },
29
+ "color": {
30
+ "background": {
31
+ "light": {
32
+ "$type": "color",
33
+ "$value": "{color.neutral.light}"
34
+ }
35
+ },
36
+ "black": {
37
+ "$type": "color",
38
+ "$value": "rgb(23 23 23)"
39
+ },
40
+ "border": {
41
+ "$type": "color",
42
+ "$value": "{color.timberwolf}",
43
+ "primary": {
44
+ "$type": "color",
45
+ "$value": "rgb(42 42 42 / 12%)"
46
+ }
47
+ },
48
+ "cod": {
49
+ "gray": {
50
+ "$type": "color",
51
+ "$value": "rgb(11 11 11)"
52
+ }
53
+ },
54
+ "dark": {
55
+ "$type": "color",
56
+ "$value": "rgb(180 180 180)"
57
+ },
58
+ "draft": {
59
+ "$type": "color",
60
+ "$value": "rgb(255 255 200 / 80%)"
61
+ },
62
+ "electric": {
63
+ "violet": {
64
+ "$type": "color",
65
+ "$value": "rgb(90 35 245)"
66
+ }
67
+ },
68
+ "fallback": {
69
+ "$type": "color",
70
+ "$value": "{color.silver}"
71
+ },
72
+ "green": {
73
+ "$type": "color",
74
+ "$value": "rgb(0 146 20)",
75
+ "dark": {
76
+ "$type": "color",
77
+ "$value": "rgb(33 69 45)"
78
+ },
79
+ "light": {
80
+ "$type": "color",
81
+ "$value": "rgb(209 250 229)"
82
+ }
83
+ },
84
+ "highlight": {
85
+ "$type": "color",
86
+ "$value": "rgb(235 235 235)"
87
+ },
88
+ "icon": {
89
+ "$type": "color",
90
+ "$value": "{color.outer.space}"
91
+ },
92
+ "mahogany": {
93
+ "$type": "color",
94
+ "$value": "rgb(136 4 2)"
95
+ },
96
+ "neutral": {
97
+ "$type": "color",
98
+ "$value": "{color.timberwolf}",
99
+ "light": {
100
+ "$type": "color",
101
+ "$value": "{color.wild.sand}"
102
+ }
103
+ },
104
+ "outer": {
105
+ "space": {
106
+ "$type": "color",
107
+ "$value": "rgb(82 82 82)"
108
+ }
109
+ },
110
+ "placeholder": {
111
+ "text": {
112
+ "$type": "color",
113
+ "$value": "{color.silver}"
114
+ }
115
+ },
116
+ "primary": {
117
+ "$type": "color",
118
+ "$value": "{color.electric.violet}",
119
+ "dark": {
120
+ "$type": "color",
121
+ "$value": "{color.purple.heart}"
122
+ }
123
+ },
124
+ "purple": {
125
+ "heart": {
126
+ "$type": "color",
127
+ "$value": "rgb(64 25 174)"
128
+ },
129
+ "light": {
130
+ "$type": "color",
131
+ "$value": "rgb(239 233 254)"
132
+ }
133
+ },
134
+ "red": {
135
+ "$type": "color",
136
+ "$value": "rgb(191 6 3)",
137
+ "light": {
138
+ "$type": "color",
139
+ "$value": "rgb(235 178 177)"
140
+ }
141
+ },
142
+ "silver": {
143
+ "$type": "color",
144
+ "$value": "rgb(194 194 194)"
145
+ },
146
+ "surface": {
147
+ "active": {
148
+ "$type": "color",
149
+ "$value": "rgb(123 79 247 / 20%)"
150
+ }
151
+ },
152
+ "text": {
153
+ "$type": "color",
154
+ "$value": "{color.text.primary}",
155
+ "primary": {
156
+ "$type": "color",
157
+ "$value": "{color.cod.gray}"
158
+ },
159
+ "secondary": {
160
+ "$type": "color",
161
+ "$value": "{color.outer.space}"
162
+ }
163
+ },
164
+ "timberwolf": {
165
+ "$type": "color",
166
+ "$value": "rgb(223 223 223)"
167
+ },
168
+ "translucent": {
169
+ "$type": "color",
170
+ "$value": "rgba(255 255 255 / 60%)"
171
+ },
172
+ "warning": {
173
+ "$type": "color",
174
+ "$value": "{color.red}"
175
+ },
176
+ "white": {
177
+ "$type": "color",
178
+ "$value": "rgb(255 255 255)"
179
+ },
180
+ "wild": {
181
+ "sand": {
182
+ "$type": "color",
183
+ "$value": "rgb(245 245 245)"
184
+ }
185
+ }
186
+ },
187
+ "font": {
188
+ "family": {
189
+ "$type": "fontFamily",
190
+ "$value": "'Figtree', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"
191
+ },
192
+ "size": {
193
+ "$type": "string",
194
+ "$value": "{unit}",
195
+ "h1": {
196
+ "$type": "dimension",
197
+ "$value": "calc({unit} * 2)"
198
+ },
199
+ "h2": {
200
+ "$type": "dimension",
201
+ "$value": "calc({unit} * 1.25)"
202
+ },
203
+ "h3": {
204
+ "$type": "dimension",
205
+ "$value": "calc({unit})"
206
+ },
207
+ "small": {
208
+ "$type": "dimension",
209
+ "$value": "calc({unit} * 0.75)"
210
+ }
211
+ },
212
+ "weight": {
213
+ "bold": {
214
+ "$type": "fontWeight",
215
+ "$value": "700"
216
+ },
217
+ "normal": {
218
+ "$type": "fontWeight",
219
+ "$value": "400"
220
+ },
221
+ "semibold": {
222
+ "$type": "fontWeight",
223
+ "$value": "600"
224
+ }
225
+ }
226
+ },
227
+ "gradient": {
228
+ "$type": "gradient",
229
+ "$value": "linear-gradient(180deg, rgb(255 255 255 / 100%), transparent 50%)"
230
+ },
231
+ "icon": {
232
+ "size": {
233
+ "$type": "dimension",
234
+ "$value": "calc({unit} * 1.5)"
235
+ }
236
+ },
237
+ "negative": {
238
+ "unit": {
239
+ "$type": "dimension",
240
+ "$value": "calc(-1 * {unit})",
241
+ "large": {
242
+ "$type": "dimension",
243
+ "$value": "calc({negative.unit} * 2)"
244
+ },
245
+ "small": {
246
+ "$type": "dimension",
247
+ "$value": "calc({negative.unit} / 2)"
248
+ }
249
+ }
250
+ },
251
+ "offset": {
252
+ "$type": "dimension",
253
+ "$value": "calc(-2 * {unit})"
254
+ },
255
+ "opacity": {
256
+ "disabled": {
257
+ "$type": "number",
258
+ "$value": "{opacity.minimal}"
259
+ },
260
+ "minimal": {
261
+ "$type": "number",
262
+ "$value": "0.5"
263
+ },
264
+ "visited": {
265
+ "$type": "number",
266
+ "$value": "{opacity.minimal}"
267
+ }
268
+ },
269
+ "padding": {
270
+ "box": {
271
+ "$type": "string",
272
+ "$value": "0.05px {unit}"
273
+ }
274
+ },
275
+ "shadow": {
276
+ "$type": "shadow",
277
+ "$value": "{shadow.color} {unit.micro} {unit.micro} {unit.tiny}",
278
+ "big": {
279
+ "$type": "shadow",
280
+ "$value": "{shadow.color} {unit.micro} {unit.micro} {unit.small}"
281
+ },
282
+ "color": {
283
+ "$type": "shadow",
284
+ "$value": "rgb(0 0 0 / 10%)"
285
+ }
286
+ },
287
+ "transition": {
288
+ "delay": {
289
+ "$type": "duration",
290
+ "$value": "125ms"
291
+ },
292
+ "duration": {
293
+ "$type": "duration",
294
+ "$value": "250ms",
295
+ "long": {
296
+ "$type": "duration",
297
+ "$value": "calc({transition.duration} * 2)"
298
+ }
299
+ },
300
+ "timing": {
301
+ "function": {
302
+ "$type": "string",
303
+ "$value": "ease-out"
304
+ }
305
+ }
306
+ },
307
+ "unit": {
308
+ "$type": "dimension",
309
+ "$value": "16px",
310
+ "large": {
311
+ "$type": "dimension",
312
+ "$value": "calc({unit} * 2)"
313
+ },
314
+ "micro": {
315
+ "$type": "dimension",
316
+ "$value": "calc({unit} / 8)"
317
+ },
318
+ "small": {
319
+ "$type": "dimension",
320
+ "$value": "calc({unit} / 2)"
321
+ },
322
+ "tiny": {
323
+ "$type": "dimension",
324
+ "$value": "calc({unit} / 4)"
325
+ }
326
+ },
327
+ "z": {
328
+ "max": {
329
+ "$type": "number",
330
+ "$value": "2147483647"
331
+ }
332
+ }
333
+ }
334
+ }