@cypress-design/react-checkbox 0.2.2 → 0.3.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.
@@ -0,0 +1,6 @@
1
+ $ yarn build:module && yarn build:types
2
+ $ rollup -c ./rollup.config.mjs
3
+ 
4
+ ./index.ts → ./dist/index.umd.js, ./dist/index.es.mjs...
5
+ created ./dist/index.umd.js, ./dist/index.es.mjs in 19.6s
6
+ $ tsc --project ./tsconfig.build.json
package/CHANGELOG.md CHANGED
@@ -1,5 +1,119 @@
1
1
  # @cypress-design/react-checkbox
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`63ea78a`](https://github.com/cypress-io/cypress-design/commit/63ea78af2062fd5e3fb8c61fa4bcf85fd95e803b) Thanks [@elevatebart](https://github.com/elevatebart)! - add constants package to dependencies
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#196](https://github.com/cypress-io/cypress-design/pull/196) [`fc6d9e4`](https://github.com/cypress-io/cypress-design/commit/fc6d9e4fedcc01fa8e01b868b0fa66d8895c37d0) Thanks [@elevatebart](https://github.com/elevatebart)! - refactor: avoid constants relative imports
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [[`fc6d9e4`](https://github.com/cypress-io/cypress-design/commit/fc6d9e4fedcc01fa8e01b868b0fa66d8895c37d0)]:
18
+ - @cypress-design/react-icon@0.20.0
19
+
20
+ ## 0.2.0
21
+
22
+ ### Minor Changes
23
+
24
+ - [#178](https://github.com/cypress-io/cypress-design/pull/178) [`d0de778`](https://github.com/cypress-io/cypress-design/commit/d0de77843adb87d8f4804219c6dca8f45b15c650) Thanks [@elevatebart](https://github.com/elevatebart)! - deliver new docs and improved components
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [[`18399c7`](https://github.com/cypress-io/cypress-design/commit/18399c72a52288c67af0935384430d4e4cd24251), [`d0de778`](https://github.com/cypress-io/cypress-design/commit/d0de77843adb87d8f4804219c6dca8f45b15c650)]:
29
+ - @cypress-design/react-icon@0.19.0
30
+
31
+ ## 0.1.1
32
+
33
+ ### Patch Changes
34
+
35
+ - [#164](https://github.com/cypress-io/cypress-design/pull/164) [`4fd951a`](https://github.com/cypress-io/cypress-design/commit/4fd951a39335900da2508beef9b3565a6f8f9518) Thanks [@elevatebart](https://github.com/elevatebart)! - fix: update active buttons borders
36
+
37
+ ## 0.1.0
38
+
39
+ ### Minor Changes
40
+
41
+ - [#162](https://github.com/cypress-io/cypress-design/pull/162) [`76d4e60`](https://github.com/cypress-io/cypress-design/commit/76d4e601687d28578cdee0ddc67cd04b286ae2c3) Thanks [@elevatebart](https://github.com/elevatebart)! - refactor: functionalize classes used
42
+
43
+ ## 0.5.0
44
+
45
+ ### Minor Changes
46
+
47
+ - [#151](https://github.com/cypress-io/cypress-design/pull/151) [`8b0e735`](https://github.com/cypress-io/cypress-design/commit/8b0e7356eb64a6b3583d3486dda8ecbb11c34cca) Thanks [@elevatebart](https://github.com/elevatebart)! - refactor: use clases compatible with both windi and tailwind
48
+
49
+ ### Patch Changes
50
+
51
+ - Updated dependencies [[`106b61a`](https://github.com/cypress-io/cypress-design/commit/106b61a97888f956a4c9d235fde5efb4243e1445), [`7b4f416`](https://github.com/cypress-io/cypress-design/commit/7b4f4162a0d150aa8cab7ec239faebb58c39464d)]:
52
+ - @cypress-design/react-icon@0.17.0
53
+
54
+ ## 0.4.6
55
+
56
+ ### Patch Changes
57
+
58
+ - [#112](https://github.com/cypress-io/cypress-design/pull/112) [`d229b48`](https://github.com/cypress-io/cypress-design/commit/d229b48a3806a882abe83c9ebf9c32ed18d2c47f) Thanks [@elevatebart](https://github.com/elevatebart)! - fix: when label is too big avoid checkbox shrinking
59
+
60
+ ## 0.4.5
61
+
62
+ ### Patch Changes
63
+
64
+ - [#105](https://github.com/cypress-io/cypress-design/pull/105) [`2f54f5b`](https://github.com/cypress-io/cypress-design/commit/2f54f5b867b60ba5ce2e40fd38870bd65187ba30) Thanks [@elevatebart](https://github.com/elevatebart)! - checkbox should not contain a div to be added inside an inline only tag (<p>)
65
+
66
+ - Updated dependencies [[`2f54f5b`](https://github.com/cypress-io/cypress-design/commit/2f54f5b867b60ba5ce2e40fd38870bd65187ba30), [`e82d8cb`](https://github.com/cypress-io/cypress-design/commit/e82d8cb60882a379d89f86d1ff7b8f1d5b56ce66)]:
67
+ - @cypress-design/react-icon@0.11.0
68
+
69
+ ## 0.4.4
70
+
71
+ ### Patch Changes
72
+
73
+ - [#101](https://github.com/cypress-io/cypress-design/pull/101) [`1630e4c`](https://github.com/cypress-io/cypress-design/commit/1630e4c4200944cf6414cee9e92dcce6b4d8a576) Thanks [@mapsandapps](https://github.com/mapsandapps)! - Fix styles for Checkbox
74
+
75
+ ## 0.4.3
76
+
77
+ ### Patch Changes
78
+
79
+ - [#71](https://github.com/cypress-io/cypress-design/pull/71) [`379079e`](https://github.com/cypress-io/cypress-design/commit/379079e08802b6c3fae243925e3b9e8881e8ef54) Thanks [@elevatebart](https://github.com/elevatebart)! - allow users to click the checkbox instead of the label
80
+
81
+ ## 0.4.2
82
+
83
+ ### Patch Changes
84
+
85
+ - [#68](https://github.com/cypress-io/cypress-design/pull/68) [`8c577fb`](https://github.com/cypress-io/cypress-design/commit/8c577fb0c6a0411cf8218dfe78281834df3d6f13) Thanks [@elevatebart](https://github.com/elevatebart)! - feat: publish `.mjs` files for esm intead of `.js`
86
+
87
+ - Updated dependencies [[`8c577fb`](https://github.com/cypress-io/cypress-design/commit/8c577fb0c6a0411cf8218dfe78281834df3d6f13)]:
88
+ - @cypress-design/react-icon@0.4.2
89
+
90
+ ## 0.4.1
91
+
92
+ ### Patch Changes
93
+
94
+ - [`2afa4d5`](https://github.com/cypress-io/cypress-design/commit/2afa4d54a2373692f82bee35ae40446bc9bb3f91) Thanks [@elevatebart](https://github.com/elevatebart)! - avoid duplicate ids in checkboxes
95
+
96
+ ## 0.4.0
97
+
98
+ ### Minor Changes
99
+
100
+ - [#51](https://github.com/cypress-io/cypress-design/pull/51) [`ccd8f9a`](https://github.com/cypress-io/cypress-design/commit/ccd8f9a8feb624c0a52deaa9754c76969f43fc1e) Thanks [@elevatebart](https://github.com/elevatebart)! - in the build asset, add a comment containing all used windicss classes in the component
101
+
102
+ ### Patch Changes
103
+
104
+ - [#57](https://github.com/cypress-io/cypress-design/pull/57) [`6fa7d52`](https://github.com/cypress-io/cypress-design/commit/6fa7d52e409762bd1b32a8b04edaf78765830754) Thanks [@elevatebart](https://github.com/elevatebart)! - fix: move the input for checkboxes outside of label for accessibility
105
+
106
+ Source: https://www.a11ymatters.com/pattern/checkbox/
107
+
108
+ - Updated dependencies [[`ccd8f9a`](https://github.com/cypress-io/cypress-design/commit/ccd8f9a8feb624c0a52deaa9754c76969f43fc1e), [`0866c65`](https://github.com/cypress-io/cypress-design/commit/0866c654f24c36951c98468d789462748606b428), [`43b53eb`](https://github.com/cypress-io/cypress-design/commit/43b53eb6bd10111629239a87374cfcc894eda0e3)]:
109
+ - @cypress-design/react-icon@0.4.0
110
+
111
+ ## 0.3.0
112
+
113
+ ### Minor Changes
114
+
115
+ - [#44](https://github.com/cypress-io/cypress-design/pull/44) [`2fdaf6b`](https://github.com/cypress-io/cypress-design/commit/2fdaf6be6f81a2a851761258347ed213577c5b26) Thanks [@elevatebart](https://github.com/elevatebart)! - Add missing descriptions of props in button, tooltip, checkbox
116
+
3
117
  ## 0.2.2
4
118
 
5
119
  ### Patch Changes
@@ -0,0 +1,17 @@
1
+ import * as React from 'react'
2
+ import Checkbox from './Checkbox'
3
+
4
+ export default (options: {
5
+ color?: 'jade' | 'indigo' | 'red'
6
+ checked?: boolean
7
+ }) => {
8
+ const { checked = true, color } = options
9
+ return (
10
+ <Checkbox
11
+ checked={checked}
12
+ label="Checked"
13
+ color={color}
14
+ onChange={() => {}}
15
+ />
16
+ )
17
+ }
package/Checkbox.tsx CHANGED
@@ -2,25 +2,55 @@ import clsx from 'clsx'
2
2
  import * as React from 'react'
3
3
  import type { FunctionComponent, HTMLProps, ReactNode } from 'react'
4
4
  import { IconCheckmarkSmall } from '@cypress-design/react-icon'
5
+ import { CheckboxColors, Classes } from '@cypress-design/constants-checkbox'
5
6
 
6
7
  export interface CheckboxProps
7
- extends Omit<HTMLProps<HTMLLabelElement>, 'label' | 'onChange'> {
8
+ extends Omit<HTMLProps<HTMLDivElement>, 'label' | 'onChange' | 'name'> {
9
+ /**
10
+ * A unique identifier for the checkbox on the whole page.
11
+ * It will be used to give match label with input for a11y.
12
+ */
8
13
  id?: string
9
- checked: boolean
10
- onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
11
- color?: 'indigo' | 'red' | 'jade'
12
- label?: ReactNode
14
+ /**
15
+ * Name attribute of the <input type="checkbox"/>.
16
+ */
17
+ name?: string
18
+ /**
19
+ * Is the checkbox checked when it is first rendered.
20
+ */
21
+ checked?: boolean
22
+ /**
23
+ * The color of the background in the checkbox.
24
+ * The checkmark will always be white.
25
+ */
26
+ color?: 'red' | 'indigo' | 'jade'
27
+ /**
28
+ * If the checkbox is disabled, it will not be clickable.
29
+ */
13
30
  disabled?: boolean
31
+ /**
32
+ * Label for the checkbox.
33
+ * It is very important to set this to make the checkbox accessible.
34
+ */
35
+ label?: ReactNode
36
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
14
37
  }
15
38
 
39
+ const uid = () =>
40
+ String(Date.now().toString(32) + Math.random().toString(16)).replace(
41
+ /\./g,
42
+ ''
43
+ )
44
+
16
45
  export const Checkbox: FunctionComponent<CheckboxProps> = ({
17
- // @ts-ignore
18
- id = crypto.randomUUID(),
46
+ id = uid(),
19
47
  checked = false,
20
48
  onChange,
21
49
  color = 'indigo',
22
50
  label,
23
51
  disabled,
52
+ className,
53
+ name,
24
54
  ...rest
25
55
  }) => {
26
56
  const [localChecked, setChecked] = React.useState(checked)
@@ -31,48 +61,44 @@ export const Checkbox: FunctionComponent<CheckboxProps> = ({
31
61
  }
32
62
 
33
63
  return (
34
- <label
35
- {...rest}
36
- className={clsx(rest.className, 'relative flex items-center')}
37
- >
64
+ <span className={clsx(className, Classes.wrapper)} {...rest}>
38
65
  <input
39
66
  id={id}
40
- className="absolute inset-0 w-0 h-0 opacity-0"
67
+ className={Classes.hiddenInput}
41
68
  aria-describedby={`${id}-description`}
42
- name={id}
69
+ name={name || id}
43
70
  type="checkbox"
44
71
  onChange={onChangeInput}
45
72
  disabled={disabled}
46
73
  checked={localChecked}
47
74
  />
48
- {localChecked && (
49
- <IconCheckmarkSmall strokeColor="white" className="absolute" />
50
- )}
51
- <span
52
- className={clsx([
53
- `block border-1 rounded h-16px w-16px flex items-center text-white`,
54
- disabled
55
- ? 'border-gray-200 bg-gray-100'
56
- : localChecked
57
- ? {
58
- 'border-indigo-500 bg-indigo-400': color === 'indigo',
59
- 'border-jade-500 bg-jade-400': color === 'jade',
60
- 'border-red-500 bg-red-400': color === 'red',
61
- }
62
- : 'border-gray-200 bg-white',
63
- ])}
64
- />
65
- {label && (
75
+ <label className={Classes.labelTag} htmlFor={id}>
76
+ {localChecked && (
77
+ // <tw-keep strokeColor="white"/>
78
+ <IconCheckmarkSmall strokeColor="white" className="absolute" />
79
+ )}
66
80
  <span
67
81
  className={clsx([
68
- disabled ? 'text-gray-500' : 'text-gray-800',
69
- 'block ml-2 text-16px leading-normal font-light select-none',
82
+ Classes.visibleCheckbox,
83
+ disabled
84
+ ? CheckboxColors.disabled
85
+ : localChecked
86
+ ? CheckboxColors[color]
87
+ : CheckboxColors.empty,
70
88
  ])}
71
- >
72
- {label}
73
- </span>
74
- )}
75
- </label>
89
+ />
90
+ {label && (
91
+ <span
92
+ className={clsx([
93
+ disabled ? 'text-gray-500' : 'text-gray-800 dark:text-gray-200',
94
+ Classes.trueLabel,
95
+ ])}
96
+ >
97
+ {label}
98
+ </span>
99
+ )}
100
+ </label>
101
+ </span>
76
102
  )
77
103
  }
78
104
 
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react'
2
- import { mount } from 'cypress/react'
2
+ import { mount } from 'cypress/react18'
3
3
  import { Checkbox } from './Checkbox'
4
4
 
5
5
  describe('Checkbox', () => {
6
- it('renders', () => {
6
+ it('changes when the label is clicked', () => {
7
7
  let isChecked = true
8
8
 
9
9
  mount(
@@ -12,12 +12,53 @@ describe('Checkbox', () => {
12
12
  id="welcome-opt-out"
13
13
  checked={isChecked}
14
14
  onChange={() => (isChecked = !isChecked)}
15
- className="m-2 px-2 py-1 border-1 border-gray-300 rounded"
15
+ className="px-2 py-1 m-2 border border-gray-300 rounded"
16
16
  />
17
17
  )
18
18
 
19
19
  cy.get('input[type="checkbox"]').should('be.checked')
20
+ cy.percySnapshot()
20
21
  cy.contains('Welcome guide settings').click()
21
22
  cy.get('input[type="checkbox"]').should('not.be.checked')
23
+ cy.percySnapshot()
24
+ })
25
+
26
+ it('changes when checkbox is clicked', () => {
27
+ let isChecked = true
28
+
29
+ mount(
30
+ <Checkbox
31
+ label="Welcome guide settings"
32
+ id="welcome-opt-out"
33
+ checked={isChecked}
34
+ onChange={() => (isChecked = !isChecked)}
35
+ className="px-2 py-1 m-2 border border-gray-300 rounded"
36
+ />
37
+ )
38
+
39
+ cy.get('input[type="checkbox"]').should('be.checked')
40
+ cy.get('svg').click()
41
+ cy.get('input[type="checkbox"]').should('not.be.checked')
42
+ })
43
+
44
+ it('keeps its width when label is long', () => {
45
+ mount(
46
+ <Checkbox
47
+ label={[
48
+ 'lorem ipsum dolor sit amet, consectetur adipiscing elit,',
49
+ 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
50
+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip',
51
+ 'ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse',
52
+ 'cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,',
53
+ 'sunt in culpa qui officia deserunt mollit anim id est laborum.',
54
+ ].join(' ')}
55
+ id="lorem-checkbox"
56
+ onChange={() => {}}
57
+ />
58
+ )
59
+
60
+ cy.percySnapshot()
61
+
62
+ cy.get('label span:first-child').invoke('outerWidth').should('equal', 16)
22
63
  })
23
64
  })
package/ReadMe.md ADDED
@@ -0,0 +1,13 @@
1
+ # Checkbox
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ npm install @cypress-design/react-checkbox
7
+ ```
8
+
9
+ or with yarn
10
+
11
+ ```bash
12
+ yarn add @cypress-design/react-checkbox
13
+ ```
@@ -1,12 +1,34 @@
1
1
  import * as React from 'react';
2
2
  import type { FunctionComponent, HTMLProps, ReactNode } from 'react';
3
- export interface CheckboxProps extends Omit<HTMLProps<HTMLLabelElement>, 'label' | 'onChange'> {
3
+ export interface CheckboxProps extends Omit<HTMLProps<HTMLDivElement>, 'label' | 'onChange' | 'name'> {
4
+ /**
5
+ * A unique identifier for the checkbox on the whole page.
6
+ * It will be used to give match label with input for a11y.
7
+ */
4
8
  id?: string;
5
- checked: boolean;
6
- onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
7
- color?: 'indigo' | 'red' | 'jade';
8
- label?: ReactNode;
9
+ /**
10
+ * Name attribute of the <input type="checkbox"/>.
11
+ */
12
+ name?: string;
13
+ /**
14
+ * Is the checkbox checked when it is first rendered.
15
+ */
16
+ checked?: boolean;
17
+ /**
18
+ * The color of the background in the checkbox.
19
+ * The checkmark will always be white.
20
+ */
21
+ color?: 'red' | 'indigo' | 'jade';
22
+ /**
23
+ * If the checkbox is disabled, it will not be clickable.
24
+ */
9
25
  disabled?: boolean;
26
+ /**
27
+ * Label for the checkbox.
28
+ * It is very important to set this to make the checkbox accessible.
29
+ */
30
+ label?: ReactNode;
31
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
10
32
  }
11
33
  export declare const Checkbox: FunctionComponent<CheckboxProps>;
12
34
  export default Checkbox;
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../Checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGpE,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/D,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IAC9D,KAAK,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAA;IACjC,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,CA6DrD,CAAA;AAED,eAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"Checkbox.d.ts","sourceRoot":"./","sources":["Checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAIpE,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;IACtE;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;IACjC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;CAC/D;AAQD,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,CA0DrD,CAAA;AAED,eAAe,QAAQ,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"./","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import clsx from 'clsx';
2
2
  import * as React from 'react';
3
3
  import * as iconsRegistry from '@cypress-design/icon-registry';
4
+ import { ICON_COLOR_PROP_NAMES } from '@cypress-design/icon-registry';
4
5
 
5
6
  /******************************************************************************
6
7
  Copyright (c) Microsoft Corporation.
@@ -79,10 +80,17 @@ function __rest(s, e) {
79
80
  }
80
81
 
81
82
  var compileReactIconProperties = function (_a) {
82
- var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size; _a.strokeColor; _a.fillColor; _a.secondaryStrokeColor; _a.secondaryFillColor; var attributes = __rest(_a, ["body", "compiledClasses", "size", "strokeColor", "fillColor", "secondaryStrokeColor", "secondaryFillColor"]);
83
- var componentProps = __assign({ width: size, height: size, fill: 'none', dangerouslySetInnerHTML: {
84
- __html: body
85
- } }, attributes);
83
+ var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size, attributes = __rest(_a, ["body", "compiledClasses", "size"]);
84
+ var filteredAttributes = Object.keys(attributes).reduce(function (newAttributes, attrName) {
85
+ if (!ICON_COLOR_PROP_NAMES.includes(attrName) && attrName !== 'name') {
86
+ newAttributes[attrName] =
87
+ attributes[attrName];
88
+ }
89
+ return newAttributes;
90
+ }, {});
91
+ var componentProps = __assign({ width: size, height: size, viewBox: "0 0 ".concat(size, " ").concat(size), fill: 'none', dangerouslySetInnerHTML: {
92
+ __html: body,
93
+ } }, filteredAttributes);
86
94
  if (attributes.className) {
87
95
  compiledClasses.push(attributes.className);
88
96
  }
@@ -94,46 +102,64 @@ var compileReactIconProperties = function (_a) {
94
102
  var IconCheckmarkSmall = function (props) {
95
103
  var _a = iconsRegistry.getComponentAttributes(__assign(__assign({}, props), { availableSizes: ["16"] })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
96
104
  var iconBodies = {
97
- "16": "<path d=\"M5 8.5 7.5 11 11 5\" stroke=\"currentColor\" class=\"icon-dark\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"
105
+ "16": "<path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 8.5 7.5 11 11 5\" class=\"icon-dark\"/>"
98
106
  };
99
107
  var body = iconBodies[size];
100
108
  if (!body) {
101
- throw Error("Icon \"checkmark-small\" is not available in size " + size);
109
+ throw Error("Icon \"checkmark-small\" is not available in size ".concat(size));
102
110
  }
103
111
  return React.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
104
112
  };
105
113
 
114
+
115
+ /* <windicss-keep class=""> */
116
+
117
+ const Classes = {
118
+ wrapper: 'relative flex items-center',
119
+ hiddenInput: 'absolute inset-0 w-0 h-0 opacity-0',
120
+ labelTag: 'flex items-center',
121
+ visibleCheckbox: 'border border-solid rounded h-[16px] w-[16px] flex flex-shrink-0 items-center text-white',
122
+ trueLabel: 'block ml-[8px] text-[16px] leading-[24px] font-light select-none',
123
+ };
124
+ const CheckboxColors = {
125
+ indigo: 'border-indigo-500 bg-indigo-400',
126
+ jade: 'border-jade-500 bg-jade-400',
127
+ red: 'border-red-500 bg-red-400',
128
+ disabled: 'border-gray-200 bg-gray-100',
129
+ empty: 'border-gray-200 bg-white',
130
+ };
131
+
132
+ var uid = function () {
133
+ return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, '');
134
+ };
106
135
  var Checkbox = function (_a) {
107
- var
108
- // @ts-ignore
109
- _b = _a.id,
110
- // @ts-ignore
111
- id = _b === void 0 ? crypto.randomUUID() : _b, _c = _a.checked, checked = _c === void 0 ? false : _c, onChange = _a.onChange, _d = _a.color, color = _d === void 0 ? 'indigo' : _d, label = _a.label, disabled = _a.disabled, rest = __rest$1(_a, ["id", "checked", "onChange", "color", "label", "disabled"]);
136
+ var _b = _a.id, id = _b === void 0 ? uid() : _b, _c = _a.checked, checked = _c === void 0 ? false : _c, onChange = _a.onChange, _d = _a.color, color = _d === void 0 ? 'indigo' : _d, label = _a.label, disabled = _a.disabled, className = _a.className, name = _a.name, rest = __rest$1(_a, ["id", "checked", "onChange", "color", "label", "disabled", "className", "name"]);
112
137
  var _e = React.useState(checked), localChecked = _e[0], setChecked = _e[1];
113
138
  function onChangeInput(event) {
114
139
  setChecked(!localChecked);
115
140
  onChange(event);
116
141
  }
117
- return (React.createElement("label", __assign$1({}, rest, { className: clsx(rest.className, 'relative flex items-center') }),
118
- React.createElement("input", { id: id, className: "absolute inset-0 w-0 h-0 opacity-0", "aria-describedby": id + "-description", name: id, type: "checkbox", onChange: onChangeInput, disabled: disabled, checked: localChecked }),
119
- localChecked && (React.createElement(IconCheckmarkSmall, { strokeColor: "white", className: "absolute" })),
120
- React.createElement("span", { className: clsx([
121
- "block border-1 rounded h-16px w-16px flex items-center text-white",
122
- disabled
123
- ? 'border-gray-200 bg-gray-100'
124
- : localChecked
125
- ? {
126
- 'border-indigo-500 bg-indigo-400': color === 'indigo',
127
- 'border-jade-500 bg-jade-400': color === 'jade',
128
- 'border-red-500 bg-red-400': color === 'red'
129
- }
130
- : 'border-gray-200 bg-white',
131
- ]) }),
132
- label && (React.createElement("span", { className: clsx([
133
- disabled ? 'text-gray-500' : 'text-gray-800',
134
- 'block ml-2 text-16px leading-normal font-light select-none',
135
- ]) }, label))));
142
+ return (React.createElement("span", __assign$1({ className: clsx(className, Classes.wrapper) }, rest),
143
+ React.createElement("input", { id: id, className: Classes.hiddenInput, "aria-describedby": "".concat(id, "-description"), name: name || id, type: "checkbox", onChange: onChangeInput, disabled: disabled, checked: localChecked }),
144
+ React.createElement("label", { className: Classes.labelTag, htmlFor: id },
145
+ localChecked && (
146
+ // <tw-keep strokeColor="white"/>
147
+ React.createElement(IconCheckmarkSmall, { strokeColor: "white", className: "absolute" })),
148
+ React.createElement("span", { className: clsx([
149
+ Classes.visibleCheckbox,
150
+ disabled
151
+ ? CheckboxColors.disabled
152
+ : localChecked
153
+ ? CheckboxColors[color]
154
+ : CheckboxColors.empty,
155
+ ]) }),
156
+ label && (React.createElement("span", { className: clsx([
157
+ disabled ? 'text-gray-500' : 'text-gray-800 dark:text-gray-200',
158
+ Classes.trueLabel,
159
+ ]) }, label)))));
136
160
  };
137
161
 
138
162
  export { Checkbox as default };
139
- //# sourceMappingURL=index.es.js.map
163
+ //# sourceMappingURL=index.es.mjs.map
164
+
165
+ /* <windicss-keep class="absolute text-gray-500 text-gray-800 dark:text-gray-200 icon-dark-white"> */