@iziui/react 0.0.79-rc → 0.0.80-rc

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../../src/fields/Switch/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAgC,MAAM,OAAO,CAAC;AAI1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAShD,OAAO,sCAAsC,CAAC;AAE9C,MAAM,WAAW,WAAY,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;;AAyDD,wBAAuC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.stories.d.ts","sourceRoot":"","sources":["../../../../src/fields/Switch/Switch.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AASlD,OAAO,MAAuB,MAAM,UAAU,CAAC;AAM/C,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,OAAO,MAAM,CAa1C,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,OAAO,MAAM,CAQzC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,MAAM,CAQ9C,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,MAAM,CA+B9C,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,MAAM,CAE9C,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CA8E7B,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/Switch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC"}
@@ -4,4 +4,5 @@ export * from './ColorPicker';
4
4
  export * from './Input';
5
5
  export * from './InputFile';
6
6
  export * from './Select';
7
+ export * from './Switch';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/fields/Switchs/Switch.tsx"],"sourcesContent":["import { InputHTMLAttributes, useEffect, useMemo, useState } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport type { Colors } from '@iziui/core/theme';\nimport { joinClass } from '@iziui/core/utils/joinClass';\n\nimport { uuid } from '@iziui/toolkit/uuid';\n\nimport Stack from '@/layout/Stack';\n\nimport createComponent from '../../core/createComponent';\n\nimport '@iziui/styles/components/Switch.scss';\n\nexport interface SwitchProps extends InputHTMLAttributes<HTMLInputElement> {\n label?: string;\n error?: boolean;\n helperText?: string;\n color?: Colors;\n auto?: boolean;\n}\n\nfunction Switch({ label, error, helperText, color = 'primary', ...props }: SwitchProps) {\n const [checked, setChecked] = useState(Boolean(props.checked));\n\n const classNameCheckbox = joinClass(\n `${prefix}-switch__checkbox`,\n `${prefix}-switch__checkbox--${color}`,\n );\n\n const classNameLabel = joinClass(\n `${prefix}-switch__label`,\n error && `${prefix}-switch__label--error`,\n );\n\n const helperTextClss = joinClass(\n `${prefix}-switch__helper-text`,\n error && `${prefix}-switch__helper-text--error`,\n helperText && `${prefix}-switch__helper-text--visible`,\n );\n\n const id = useMemo(() => `${prefix}-switch-${uuid()}`, []);\n\n useEffect(() => { setChecked(Boolean(props.checked)); }, [props.checked]);\n\n const handleToggle = () => {\n if (!props.onChange) { return; }\n\n props.onChange({\n type: 'checkbox',\n target: { checked: !checked }\n } as React.ChangeEvent<HTMLInputElement>);\n };\n\n return (\n <Stack gap={2}>\n <label htmlFor={id} className={classNameLabel}>\n {label}\n </label>\n <div className={`${prefix}-switch`}>\n <input\n {...props}\n type=\"checkbox\"\n id={id}\n className={classNameCheckbox}\n onChange={handleToggle}\n checked={checked}\n />\n <label className={`${prefix}-switch__box`} htmlFor={id}>\n <span className={`${prefix}-switch__button`} />\n </label>\n </div>\n <span className={helperTextClss}>{helperText}</span>\n </Stack>\n );\n}\n\nexport default createComponent(Switch);"],"names":["Switch","label","error","helperText","color","props","checked","setChecked","useState","classNameCheckbox","joinClass","prefix","classNameLabel","helperTextClss","id","useMemo","uuid","useEffect","handleToggle","jsxs","Stack","jsx","Switch_default","createComponent"],"mappings":"4dAuBA,SAASA,EAAO,CAAE,MAAAC,EAAO,MAAAC,EAAO,WAAAC,EAAY,MAAAC,EAAQ,UAAW,GAAGC,GAAsB,CACtF,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAS,EAAQH,EAAM,OAAQ,EAEvDI,EAAoBC,EACxB,GAAGC,CAAM,oBACT,GAAGA,CAAM,sBAAsBP,CAAK,EAAA,EAGhCQ,EAAiBF,EACrB,GAAGC,CAAM,iBACTT,GAAS,GAAGS,CAAM,uBAAA,EAGdE,EAAiBH,EACrB,GAAGC,CAAM,uBACTT,GAAS,GAAGS,CAAM,8BAClBR,GAAc,GAAGQ,CAAM,+BAAA,EAGnBG,EAAKC,EAAQ,IAAM,GAAGJ,CAAM,WAAWK,EAAA,CAAM,GAAI,EAAE,EAEzDC,EAAU,IAAM,CAAEV,EAAW,EAAQF,EAAM,OAAQ,CAAG,EAAG,CAACA,EAAM,OAAO,CAAC,EAExE,MAAMa,EAAe,IAAM,CACpBb,EAAM,UAEXA,EAAM,SAAS,CACb,KAAM,WACN,OAAQ,CAAE,QAAS,CAACC,CAAA,CAAQ,CACU,CAC1C,EAEA,OACEa,EAACC,EAAA,CAAM,IAAK,EACV,SAAA,CAAAC,EAAC,QAAA,CAAM,QAASP,EAAI,UAAWF,EAC5B,SAAAX,EACH,EACAkB,EAAC,MAAA,CAAI,UAAW,GAAGR,CAAM,UACvB,SAAA,CAAAU,EAAC,QAAA,CACE,GAAGhB,EACJ,KAAK,WACL,GAAAS,EACA,UAAWL,EACX,SAAUS,EACV,QAAAZ,CAAA,CAAA,EAEFe,EAAC,QAAA,CAAM,UAAW,GAAGV,CAAM,eAAgB,QAASG,EAClD,SAAAO,EAAC,OAAA,CAAK,UAAW,GAAGV,CAAM,kBAAmB,CAAA,CAC/C,CAAA,EACF,EACAU,EAAC,OAAA,CAAK,UAAWR,EAAiB,SAAAV,CAAA,CAAW,CAAA,EAC/C,CAEJ,CAEA,MAAAmB,EAAeC,EAAgBvB,CAAM"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/fields/Switch/Switch.tsx"],"sourcesContent":["import { InputHTMLAttributes, useEffect, useMemo, useState } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport type { Colors } from '@iziui/core/theme';\nimport { joinClass } from '@iziui/core/utils/joinClass';\n\nimport { uuid } from '@iziui/toolkit/uuid';\n\nimport Stack from '@/layout/Stack';\n\nimport createComponent from '../../core/createComponent';\n\nimport '@iziui/styles/components/Switch.scss';\n\nexport interface SwitchProps extends InputHTMLAttributes<HTMLInputElement> {\n label?: string;\n error?: boolean;\n helperText?: string;\n color?: Colors;\n auto?: boolean;\n}\n\nfunction Switch({ label, error, helperText, color = 'primary', ...props }: SwitchProps) {\n const [checked, setChecked] = useState(Boolean(props.checked));\n\n const classNameCheckbox = joinClass(\n `${prefix}-switch__checkbox`,\n `${prefix}-switch__checkbox--${color}`,\n );\n\n const classNameLabel = joinClass(\n `${prefix}-switch__label`,\n error && `${prefix}-switch__label--error`,\n );\n\n const helperTextClss = joinClass(\n `${prefix}-switch__helper-text`,\n error && `${prefix}-switch__helper-text--error`,\n helperText && `${prefix}-switch__helper-text--visible`,\n );\n\n const id = useMemo(() => `${prefix}-switch-${uuid()}`, []);\n\n useEffect(() => { setChecked(Boolean(props.checked)); }, [props.checked]);\n\n const handleToggle = () => {\n if (!props.onChange) { return; }\n\n props.onChange({\n type: 'checkbox',\n target: { checked: !checked }\n } as React.ChangeEvent<HTMLInputElement>);\n };\n\n return (\n <Stack gap={2}>\n <label htmlFor={id} className={classNameLabel}>\n {label}\n </label>\n <div className={`${prefix}-switch`}>\n <input\n {...props}\n type=\"checkbox\"\n id={id}\n className={classNameCheckbox}\n onChange={handleToggle}\n checked={checked}\n />\n <label className={`${prefix}-switch__box`} htmlFor={id}>\n <span className={`${prefix}-switch__button`} />\n </label>\n </div>\n <span className={helperTextClss}>{helperText}</span>\n </Stack>\n );\n}\n\nexport default createComponent(Switch);"],"names":["Switch","label","error","helperText","color","props","checked","setChecked","useState","classNameCheckbox","joinClass","prefix","classNameLabel","helperTextClss","id","useMemo","uuid","useEffect","handleToggle","jsxs","Stack","jsx","Switch_default","createComponent"],"mappings":"2fAuBA,SAASA,EAAO,CAAE,MAAAC,EAAO,MAAAC,EAAO,WAAAC,EAAY,MAAAC,EAAQ,UAAW,GAAGC,GAAsB,CACtF,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAAA,SAAS,EAAQH,EAAM,OAAQ,EAEvDI,EAAoBC,EAAAA,UACxB,GAAGC,EAAAA,MAAM,oBACT,GAAGA,EAAAA,MAAM,sBAAsBP,CAAK,EAAA,EAGhCQ,EAAiBF,EAAAA,UACrB,GAAGC,EAAAA,MAAM,iBACTT,GAAS,GAAGS,EAAAA,MAAM,uBAAA,EAGdE,EAAiBH,EAAAA,UACrB,GAAGC,EAAAA,MAAM,uBACTT,GAAS,GAAGS,EAAAA,MAAM,8BAClBR,GAAc,GAAGQ,EAAAA,MAAM,+BAAA,EAGnBG,EAAKC,UAAQ,IAAM,GAAGJ,EAAAA,MAAM,WAAWK,EAAAA,KAAA,CAAM,GAAI,EAAE,EAEzDC,EAAAA,UAAU,IAAM,CAAEV,EAAW,EAAQF,EAAM,OAAQ,CAAG,EAAG,CAACA,EAAM,OAAO,CAAC,EAExE,MAAMa,EAAe,IAAM,CACpBb,EAAM,UAEXA,EAAM,SAAS,CACb,KAAM,WACN,OAAQ,CAAE,QAAS,CAACC,CAAA,CAAQ,CACU,CAC1C,EAEA,OACEa,EAAAA,KAACC,EAAAA,MAAA,CAAM,IAAK,EACV,SAAA,CAAAC,MAAC,QAAA,CAAM,QAASP,EAAI,UAAWF,EAC5B,SAAAX,EACH,EACAkB,EAAAA,KAAC,MAAA,CAAI,UAAW,GAAGR,QAAM,UACvB,SAAA,CAAAU,EAAAA,IAAC,QAAA,CACE,GAAGhB,EACJ,KAAK,WACL,GAAAS,EACA,UAAWL,EACX,SAAUS,EACV,QAAAZ,CAAA,CAAA,EAEFe,EAAAA,IAAC,QAAA,CAAM,UAAW,GAAGV,QAAM,eAAgB,QAASG,EAClD,SAAAO,EAAAA,IAAC,OAAA,CAAK,UAAW,GAAGV,QAAM,kBAAmB,CAAA,CAC/C,CAAA,EACF,EACAU,EAAAA,IAAC,OAAA,CAAK,UAAWR,EAAiB,SAAAV,CAAA,CAAW,CAAA,EAC/C,CAEJ,CAEA,MAAAmB,EAAeC,EAAAA,gBAAgBvB,CAAM"}
@@ -0,0 +1,2 @@
1
+ export { default } from '../../.types/fields/Switch';
2
+ export * from '../../.types/fields/Switch';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/fields/Switch/Switch.tsx"],"sourcesContent":["import { InputHTMLAttributes, useEffect, useMemo, useState } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport type { Colors } from '@iziui/core/theme';\nimport { joinClass } from '@iziui/core/utils/joinClass';\n\nimport { uuid } from '@iziui/toolkit/uuid';\n\nimport Stack from '@/layout/Stack';\n\nimport createComponent from '../../core/createComponent';\n\nimport '@iziui/styles/components/Switch.scss';\n\nexport interface SwitchProps extends InputHTMLAttributes<HTMLInputElement> {\n label?: string;\n error?: boolean;\n helperText?: string;\n color?: Colors;\n auto?: boolean;\n}\n\nfunction Switch({ label, error, helperText, color = 'primary', ...props }: SwitchProps) {\n const [checked, setChecked] = useState(Boolean(props.checked));\n\n const classNameCheckbox = joinClass(\n `${prefix}-switch__checkbox`,\n `${prefix}-switch__checkbox--${color}`,\n );\n\n const classNameLabel = joinClass(\n `${prefix}-switch__label`,\n error && `${prefix}-switch__label--error`,\n );\n\n const helperTextClss = joinClass(\n `${prefix}-switch__helper-text`,\n error && `${prefix}-switch__helper-text--error`,\n helperText && `${prefix}-switch__helper-text--visible`,\n );\n\n const id = useMemo(() => `${prefix}-switch-${uuid()}`, []);\n\n useEffect(() => { setChecked(Boolean(props.checked)); }, [props.checked]);\n\n const handleToggle = () => {\n if (!props.onChange) { return; }\n\n props.onChange({\n type: 'checkbox',\n target: { checked: !checked }\n } as React.ChangeEvent<HTMLInputElement>);\n };\n\n return (\n <Stack gap={2}>\n <label htmlFor={id} className={classNameLabel}>\n {label}\n </label>\n <div className={`${prefix}-switch`}>\n <input\n {...props}\n type=\"checkbox\"\n id={id}\n className={classNameCheckbox}\n onChange={handleToggle}\n checked={checked}\n />\n <label className={`${prefix}-switch__box`} htmlFor={id}>\n <span className={`${prefix}-switch__button`} />\n </label>\n </div>\n <span className={helperTextClss}>{helperText}</span>\n </Stack>\n );\n}\n\nexport default createComponent(Switch);"],"names":["Switch","label","error","helperText","color","props","checked","setChecked","useState","classNameCheckbox","joinClass","prefix","classNameLabel","helperTextClss","id","useMemo","uuid","useEffect","handleToggle","jsxs","Stack","jsx","Switch_default","createComponent"],"mappings":"4dAuBA,SAASA,EAAO,CAAE,MAAAC,EAAO,MAAAC,EAAO,WAAAC,EAAY,MAAAC,EAAQ,UAAW,GAAGC,GAAsB,CACtF,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAS,EAAQH,EAAM,OAAQ,EAEvDI,EAAoBC,EACxB,GAAGC,CAAM,oBACT,GAAGA,CAAM,sBAAsBP,CAAK,EAAA,EAGhCQ,EAAiBF,EACrB,GAAGC,CAAM,iBACTT,GAAS,GAAGS,CAAM,uBAAA,EAGdE,EAAiBH,EACrB,GAAGC,CAAM,uBACTT,GAAS,GAAGS,CAAM,8BAClBR,GAAc,GAAGQ,CAAM,+BAAA,EAGnBG,EAAKC,EAAQ,IAAM,GAAGJ,CAAM,WAAWK,EAAA,CAAM,GAAI,EAAE,EAEzDC,EAAU,IAAM,CAAEV,EAAW,EAAQF,EAAM,OAAQ,CAAG,EAAG,CAACA,EAAM,OAAO,CAAC,EAExE,MAAMa,EAAe,IAAM,CACpBb,EAAM,UAEXA,EAAM,SAAS,CACb,KAAM,WACN,OAAQ,CAAE,QAAS,CAACC,CAAA,CAAQ,CACU,CAC1C,EAEA,OACEa,EAACC,EAAA,CAAM,IAAK,EACV,SAAA,CAAAC,EAAC,QAAA,CAAM,QAASP,EAAI,UAAWF,EAC5B,SAAAX,EACH,EACAkB,EAAC,MAAA,CAAI,UAAW,GAAGR,CAAM,UACvB,SAAA,CAAAU,EAAC,QAAA,CACE,GAAGhB,EACJ,KAAK,WACL,GAAAS,EACA,UAAWL,EACX,SAAUS,EACV,QAAAZ,CAAA,CAAA,EAEFe,EAAC,QAAA,CAAM,UAAW,GAAGV,CAAM,eAAgB,QAASG,EAClD,SAAAO,EAAC,OAAA,CAAK,UAAW,GAAGV,CAAM,kBAAmB,CAAA,CAC/C,CAAA,EACF,EACAU,EAAC,OAAA,CAAK,UAAWR,EAAiB,SAAAV,CAAA,CAAW,CAAA,EAC/C,CAEJ,CAEA,MAAAmB,EAAeC,EAAgBvB,CAAM"}
@@ -0,0 +1,2 @@
1
+ @forward "variables";
2
+ @forward "mixins";
@@ -0,0 +1,61 @@
1
+ /* Auto-generated by Style Dictionary. Do not edit directly. */
2
+ @use "sass:string";
3
+
4
+
5
+ /* GRID */
6
+ @mixin grid($gap: 0, $grid-columns: 12, $grid-rows: 1) {
7
+ width: 100%;
8
+ display: grid;
9
+ gap: $gap;
10
+ position: relative;
11
+ grid-template-rows: $grid-rows;
12
+ grid-template-columns: repeat($grid-columns, 1fr);
13
+ -ms-grid-columns: string.unquote(repeater("1fr ", $grid-columns));
14
+ }
15
+
16
+ @mixin grid-column-start($cols) {
17
+ -ms-grid-column: $cols;
18
+ grid-column-start: $cols;
19
+ }
20
+
21
+ @mixin grid-column-span($cols: $grid-columns) {
22
+ grid-column-end: span $cols;
23
+ -ms-grid-column-span: $cols;
24
+ }
25
+
26
+ @mixin grid-row-start($rows) {
27
+ -ms-grid-row: $rows;
28
+ grid-row-start: $rows;
29
+ }
30
+
31
+
32
+ /* MEDRIA QUERY */
33
+ @mixin for-xl {
34
+ @media only screen and (min-width: 1536px) {
35
+ @content;
36
+ }
37
+ }
38
+
39
+ @mixin for-lg {
40
+ @media only screen and (max-width: 1535px) {
41
+ @content;
42
+ }
43
+ }
44
+
45
+ @mixin for-md {
46
+ @media only screen and (max-width: 1199px) {
47
+ @content;
48
+ }
49
+ }
50
+
51
+ @mixin for-sm {
52
+ @media only screen and (max-width: 899px) {
53
+ @content;
54
+ }
55
+ }
56
+
57
+ @mixin for-xs {
58
+ @media only screen and (max-width: 599px) {
59
+ @content;
60
+ }
61
+ }
@@ -0,0 +1,47 @@
1
+ $colors: (
2
+ 'primary',
3
+ 'secondary',
4
+ 'info',
5
+ 'error',
6
+ 'warning',
7
+ 'success',
8
+ );
9
+
10
+ $sizes: (
11
+ 'xl',
12
+ 'lg',
13
+ 'md',
14
+ 'sm',
15
+ 'xs',
16
+ );
17
+
18
+ $prefix: 'iziui';
19
+
20
+ $font_sizes: (
21
+ small: 12px,
22
+ medium: 16px,
23
+ large: 22px
24
+ );
25
+
26
+ $icon_sizes: (
27
+ small: 16px,
28
+ medium: 24px,
29
+ large: 32px
30
+ );
31
+
32
+ $box-shadow-small: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
33
+ $box-shadow-regular: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
34
+ $box-shadow-large: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
35
+ $proportion-base: 10.8px 14.4px;
36
+ $proportion-small: 10.8px 14.4px;
37
+ $animation: .3s cubic-bezier(0.4, 0.0, 0.2, 1);
38
+ $gap: 0;
39
+ $columns: 12;
40
+ $rows: 1;
41
+ $xl: 1536;
42
+ $lg: 1535;
43
+ $md: 1199;
44
+ $sm: 899;
45
+ $xs: 599;
46
+ $radius: 8px;
47
+ $spacing: 8px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iziui/react",
3
- "version": "0.0.79-rc",
3
+ "version": "0.0.80-rc",
4
4
  "main": "./dist/index.cjs",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -47,7 +47,8 @@
47
47
  "import": "./dist/core/index.js",
48
48
  "require": "./dist/core/index.cjs"
49
49
  },
50
- "./style.css": "./dist/style.css"
50
+ "./style.css": "./dist/style.css",
51
+ "./scss/*": "./dist/scss/*"
51
52
  },
52
53
  "scripts": {
53
54
  "storybook": "storybook dev -p 6006",
@@ -1 +0,0 @@
1
- {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../../src/fields/Switchs/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAgC,MAAM,OAAO,CAAC;AAI1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAShD,OAAO,sCAAsC,CAAC;AAE9C,MAAM,WAAW,WAAY,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;;AAyDD,wBAAuC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Switch.stories.d.ts","sourceRoot":"","sources":["../../../../src/fields/Switchs/Switch.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AASlD,OAAO,MAAuB,MAAM,UAAU,CAAC;AAM/C,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,OAAO,MAAM,CAa1C,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,OAAO,MAAM,CAQzC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,MAAM,CAQ9C,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,MAAM,CA+B9C,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,MAAM,CAE9C,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CA8E7B,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/Switchs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/fields/Switchs/Switch.tsx"],"sourcesContent":["import { InputHTMLAttributes, useEffect, useMemo, useState } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport type { Colors } from '@iziui/core/theme';\nimport { joinClass } from '@iziui/core/utils/joinClass';\n\nimport { uuid } from '@iziui/toolkit/uuid';\n\nimport Stack from '@/layout/Stack';\n\nimport createComponent from '../../core/createComponent';\n\nimport '@iziui/styles/components/Switch.scss';\n\nexport interface SwitchProps extends InputHTMLAttributes<HTMLInputElement> {\n label?: string;\n error?: boolean;\n helperText?: string;\n color?: Colors;\n auto?: boolean;\n}\n\nfunction Switch({ label, error, helperText, color = 'primary', ...props }: SwitchProps) {\n const [checked, setChecked] = useState(Boolean(props.checked));\n\n const classNameCheckbox = joinClass(\n `${prefix}-switch__checkbox`,\n `${prefix}-switch__checkbox--${color}`,\n );\n\n const classNameLabel = joinClass(\n `${prefix}-switch__label`,\n error && `${prefix}-switch__label--error`,\n );\n\n const helperTextClss = joinClass(\n `${prefix}-switch__helper-text`,\n error && `${prefix}-switch__helper-text--error`,\n helperText && `${prefix}-switch__helper-text--visible`,\n );\n\n const id = useMemo(() => `${prefix}-switch-${uuid()}`, []);\n\n useEffect(() => { setChecked(Boolean(props.checked)); }, [props.checked]);\n\n const handleToggle = () => {\n if (!props.onChange) { return; }\n\n props.onChange({\n type: 'checkbox',\n target: { checked: !checked }\n } as React.ChangeEvent<HTMLInputElement>);\n };\n\n return (\n <Stack gap={2}>\n <label htmlFor={id} className={classNameLabel}>\n {label}\n </label>\n <div className={`${prefix}-switch`}>\n <input\n {...props}\n type=\"checkbox\"\n id={id}\n className={classNameCheckbox}\n onChange={handleToggle}\n checked={checked}\n />\n <label className={`${prefix}-switch__box`} htmlFor={id}>\n <span className={`${prefix}-switch__button`} />\n </label>\n </div>\n <span className={helperTextClss}>{helperText}</span>\n </Stack>\n );\n}\n\nexport default createComponent(Switch);"],"names":["Switch","label","error","helperText","color","props","checked","setChecked","useState","classNameCheckbox","joinClass","prefix","classNameLabel","helperTextClss","id","useMemo","uuid","useEffect","handleToggle","jsxs","Stack","jsx","Switch_default","createComponent"],"mappings":"2fAuBA,SAASA,EAAO,CAAE,MAAAC,EAAO,MAAAC,EAAO,WAAAC,EAAY,MAAAC,EAAQ,UAAW,GAAGC,GAAsB,CACtF,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAAA,SAAS,EAAQH,EAAM,OAAQ,EAEvDI,EAAoBC,EAAAA,UACxB,GAAGC,EAAAA,MAAM,oBACT,GAAGA,EAAAA,MAAM,sBAAsBP,CAAK,EAAA,EAGhCQ,EAAiBF,EAAAA,UACrB,GAAGC,EAAAA,MAAM,iBACTT,GAAS,GAAGS,EAAAA,MAAM,uBAAA,EAGdE,EAAiBH,EAAAA,UACrB,GAAGC,EAAAA,MAAM,uBACTT,GAAS,GAAGS,EAAAA,MAAM,8BAClBR,GAAc,GAAGQ,EAAAA,MAAM,+BAAA,EAGnBG,EAAKC,UAAQ,IAAM,GAAGJ,EAAAA,MAAM,WAAWK,EAAAA,KAAA,CAAM,GAAI,EAAE,EAEzDC,EAAAA,UAAU,IAAM,CAAEV,EAAW,EAAQF,EAAM,OAAQ,CAAG,EAAG,CAACA,EAAM,OAAO,CAAC,EAExE,MAAMa,EAAe,IAAM,CACpBb,EAAM,UAEXA,EAAM,SAAS,CACb,KAAM,WACN,OAAQ,CAAE,QAAS,CAACC,CAAA,CAAQ,CACU,CAC1C,EAEA,OACEa,EAAAA,KAACC,EAAAA,MAAA,CAAM,IAAK,EACV,SAAA,CAAAC,MAAC,QAAA,CAAM,QAASP,EAAI,UAAWF,EAC5B,SAAAX,EACH,EACAkB,EAAAA,KAAC,MAAA,CAAI,UAAW,GAAGR,QAAM,UACvB,SAAA,CAAAU,EAAAA,IAAC,QAAA,CACE,GAAGhB,EACJ,KAAK,WACL,GAAAS,EACA,UAAWL,EACX,SAAUS,EACV,QAAAZ,CAAA,CAAA,EAEFe,EAAAA,IAAC,QAAA,CAAM,UAAW,GAAGV,QAAM,eAAgB,QAASG,EAClD,SAAAO,EAAAA,IAAC,OAAA,CAAK,UAAW,GAAGV,QAAM,kBAAmB,CAAA,CAC/C,CAAA,EACF,EACAU,EAAAA,IAAC,OAAA,CAAK,UAAWR,EAAiB,SAAAV,CAAA,CAAW,CAAA,EAC/C,CAEJ,CAEA,MAAAmB,EAAeC,EAAAA,gBAAgBvB,CAAM"}
@@ -1,2 +0,0 @@
1
- export { default } from '../../.types/fields/Switchs';
2
- export * from '../../.types/fields/Switchs';
File without changes
File without changes