@cypress-design/react-checkbox 0.3.0 → 0.3.2
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/.turbo/turbo-build.log +6 -0
- package/CHANGELOG.md +117 -0
- package/Checkbox.rootstory.tsx +17 -0
- package/Checkbox.tsx +42 -34
- package/CheckboxReact.cy.tsx +44 -3
- package/ReadMe.md +19 -0
- package/dist/Checkbox.d.ts +5 -1
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/{index.es.js → index.es.mjs} +57 -31
- package/dist/index.es.mjs.map +1 -0
- package/dist/index.umd.js +59 -38
- package/dist/index.umd.js.map +1 -1
- package/package.json +10 -5
- package/rollup.config.mjs +3 -0
- package/tsconfig.build.json +1 -0
- package/tsconfig.json +4 -1
- package/Checkbox.stories.mdx +0 -67
- package/dist/index.es.js.map +0 -1
- package/rollup.config.js +0 -3
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
$ yarn build:module && yarn build:types
|
|
2
|
+
$ rollup -c ./rollup.config.mjs
|
|
3
|
+
[36m
|
|
4
|
+
[1m./index.ts[22m → [1m./dist/index.umd.js, ./dist/index.es.mjs[22m...[39m
|
|
5
|
+
[32mcreated [1m./dist/index.umd.js, ./dist/index.es.mjs[22m in [1m20.5s[22m[39m
|
|
6
|
+
$ tsc --project ./tsconfig.build.json
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,122 @@
|
|
|
1
1
|
# @cypress-design/react-checkbox
|
|
2
2
|
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`08ba16d`](https://github.com/cypress-io/cypress-design/commit/08ba16da4a8663676ee96ac4950938857bd0d9a3) Thanks [@elevatebart](https://github.com/elevatebart)! - fix wind-keep plugin
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`08ba16d`](https://github.com/cypress-io/cypress-design/commit/08ba16da4a8663676ee96ac4950938857bd0d9a3)]:
|
|
10
|
+
- @cypress-design/react-icon@0.21.1
|
|
11
|
+
|
|
12
|
+
## 0.3.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`63ea78a`](https://github.com/cypress-io/cypress-design/commit/63ea78af2062fd5e3fb8c61fa4bcf85fd95e803b) Thanks [@elevatebart](https://github.com/elevatebart)! - add constants package to dependencies
|
|
17
|
+
|
|
18
|
+
## 0.3.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- [#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
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [[`fc6d9e4`](https://github.com/cypress-io/cypress-design/commit/fc6d9e4fedcc01fa8e01b868b0fa66d8895c37d0)]:
|
|
27
|
+
- @cypress-design/react-icon@0.20.0
|
|
28
|
+
|
|
29
|
+
## 0.2.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- [#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
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [[`18399c7`](https://github.com/cypress-io/cypress-design/commit/18399c72a52288c67af0935384430d4e4cd24251), [`d0de778`](https://github.com/cypress-io/cypress-design/commit/d0de77843adb87d8f4804219c6dca8f45b15c650)]:
|
|
38
|
+
- @cypress-design/react-icon@0.19.0
|
|
39
|
+
|
|
40
|
+
## 0.1.1
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- [#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
|
|
45
|
+
|
|
46
|
+
## 0.1.0
|
|
47
|
+
|
|
48
|
+
### Minor Changes
|
|
49
|
+
|
|
50
|
+
- [#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
|
|
51
|
+
|
|
52
|
+
## 0.5.0
|
|
53
|
+
|
|
54
|
+
### Minor Changes
|
|
55
|
+
|
|
56
|
+
- [#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
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [[`106b61a`](https://github.com/cypress-io/cypress-design/commit/106b61a97888f956a4c9d235fde5efb4243e1445), [`7b4f416`](https://github.com/cypress-io/cypress-design/commit/7b4f4162a0d150aa8cab7ec239faebb58c39464d)]:
|
|
61
|
+
- @cypress-design/react-icon@0.17.0
|
|
62
|
+
|
|
63
|
+
## 0.4.6
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- [#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
|
|
68
|
+
|
|
69
|
+
## 0.4.5
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- [#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>)
|
|
74
|
+
|
|
75
|
+
- Updated dependencies [[`2f54f5b`](https://github.com/cypress-io/cypress-design/commit/2f54f5b867b60ba5ce2e40fd38870bd65187ba30), [`e82d8cb`](https://github.com/cypress-io/cypress-design/commit/e82d8cb60882a379d89f86d1ff7b8f1d5b56ce66)]:
|
|
76
|
+
- @cypress-design/react-icon@0.11.0
|
|
77
|
+
|
|
78
|
+
## 0.4.4
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- [#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
|
|
83
|
+
|
|
84
|
+
## 0.4.3
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- [#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
|
|
89
|
+
|
|
90
|
+
## 0.4.2
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- [#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`
|
|
95
|
+
|
|
96
|
+
- Updated dependencies [[`8c577fb`](https://github.com/cypress-io/cypress-design/commit/8c577fb0c6a0411cf8218dfe78281834df3d6f13)]:
|
|
97
|
+
- @cypress-design/react-icon@0.4.2
|
|
98
|
+
|
|
99
|
+
## 0.4.1
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- [`2afa4d5`](https://github.com/cypress-io/cypress-design/commit/2afa4d54a2373692f82bee35ae40446bc9bb3f91) Thanks [@elevatebart](https://github.com/elevatebart)! - avoid duplicate ids in checkboxes
|
|
104
|
+
|
|
105
|
+
## 0.4.0
|
|
106
|
+
|
|
107
|
+
### Minor Changes
|
|
108
|
+
|
|
109
|
+
- [#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
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- [#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
|
|
114
|
+
|
|
115
|
+
Source: https://www.a11ymatters.com/pattern/checkbox/
|
|
116
|
+
|
|
117
|
+
- 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)]:
|
|
118
|
+
- @cypress-design/react-icon@0.4.0
|
|
119
|
+
|
|
3
120
|
## 0.3.0
|
|
4
121
|
|
|
5
122
|
### Minor 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,14 +2,19 @@ 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<
|
|
8
|
+
extends Omit<HTMLProps<HTMLDivElement>, 'label' | 'onChange' | 'name'> {
|
|
8
9
|
/**
|
|
9
10
|
* A unique identifier for the checkbox on the whole page.
|
|
10
11
|
* It will be used to give match label with input for a11y.
|
|
11
12
|
*/
|
|
12
13
|
id?: string
|
|
14
|
+
/**
|
|
15
|
+
* Name attribute of the <input type="checkbox"/>.
|
|
16
|
+
*/
|
|
17
|
+
name?: string
|
|
13
18
|
/**
|
|
14
19
|
* Is the checkbox checked when it is first rendered.
|
|
15
20
|
*/
|
|
@@ -31,14 +36,21 @@ export interface CheckboxProps
|
|
|
31
36
|
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
|
|
32
37
|
}
|
|
33
38
|
|
|
39
|
+
const uid = () =>
|
|
40
|
+
String(Date.now().toString(32) + Math.random().toString(16)).replace(
|
|
41
|
+
/\./g,
|
|
42
|
+
''
|
|
43
|
+
)
|
|
44
|
+
|
|
34
45
|
export const Checkbox: FunctionComponent<CheckboxProps> = ({
|
|
35
|
-
|
|
36
|
-
id = crypto.randomUUID(),
|
|
46
|
+
id = uid(),
|
|
37
47
|
checked = false,
|
|
38
48
|
onChange,
|
|
39
49
|
color = 'indigo',
|
|
40
50
|
label,
|
|
41
51
|
disabled,
|
|
52
|
+
className,
|
|
53
|
+
name,
|
|
42
54
|
...rest
|
|
43
55
|
}) => {
|
|
44
56
|
const [localChecked, setChecked] = React.useState(checked)
|
|
@@ -49,48 +61,44 @@ export const Checkbox: FunctionComponent<CheckboxProps> = ({
|
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
return (
|
|
52
|
-
<
|
|
53
|
-
{...rest}
|
|
54
|
-
className={clsx(rest.className, 'relative flex items-center')}
|
|
55
|
-
>
|
|
64
|
+
<span className={clsx(className, Classes.wrapper)} {...rest}>
|
|
56
65
|
<input
|
|
57
66
|
id={id}
|
|
58
|
-
className=
|
|
67
|
+
className={Classes.hiddenInput}
|
|
59
68
|
aria-describedby={`${id}-description`}
|
|
60
|
-
name={id}
|
|
69
|
+
name={name || id}
|
|
61
70
|
type="checkbox"
|
|
62
71
|
onChange={onChangeInput}
|
|
63
72
|
disabled={disabled}
|
|
64
73
|
checked={localChecked}
|
|
65
74
|
/>
|
|
66
|
-
{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
`block border-1 rounded h-16px w-16px flex items-center text-white`,
|
|
72
|
-
disabled
|
|
73
|
-
? 'border-gray-200 bg-gray-100'
|
|
74
|
-
: localChecked
|
|
75
|
-
? {
|
|
76
|
-
'border-indigo-500 bg-indigo-400': color === 'indigo',
|
|
77
|
-
'border-jade-500 bg-jade-400': color === 'jade',
|
|
78
|
-
'border-red-500 bg-red-400': color === 'red',
|
|
79
|
-
}
|
|
80
|
-
: 'border-gray-200 bg-white',
|
|
81
|
-
])}
|
|
82
|
-
/>
|
|
83
|
-
{label && (
|
|
75
|
+
<label className={Classes.labelTag} htmlFor={id}>
|
|
76
|
+
{localChecked && (
|
|
77
|
+
// <tw-keep strokeColor="white"/>
|
|
78
|
+
<IconCheckmarkSmall strokeColor="white" className="absolute" />
|
|
79
|
+
)}
|
|
84
80
|
<span
|
|
85
81
|
className={clsx([
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
Classes.visibleCheckbox,
|
|
83
|
+
disabled
|
|
84
|
+
? CheckboxColors.disabled
|
|
85
|
+
: localChecked
|
|
86
|
+
? CheckboxColors[color]
|
|
87
|
+
: CheckboxColors.empty,
|
|
88
88
|
])}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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>
|
|
94
102
|
)
|
|
95
103
|
}
|
|
96
104
|
|
package/CheckboxReact.cy.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import { mount } from 'cypress/
|
|
2
|
+
import { mount } from 'cypress/react18'
|
|
3
3
|
import { Checkbox } from './Checkbox'
|
|
4
4
|
|
|
5
5
|
describe('Checkbox', () => {
|
|
6
|
-
it('
|
|
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="
|
|
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,19 @@
|
|
|
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
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import Checkbox from '@cypress-design/react-checkbox'
|
|
19
|
+
```
|
package/dist/Checkbox.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { FunctionComponent, HTMLProps, ReactNode } from 'react';
|
|
3
|
-
export interface CheckboxProps extends Omit<HTMLProps<
|
|
3
|
+
export interface CheckboxProps extends Omit<HTMLProps<HTMLDivElement>, 'label' | 'onChange' | 'name'> {
|
|
4
4
|
/**
|
|
5
5
|
* A unique identifier for the checkbox on the whole page.
|
|
6
6
|
* It will be used to give match label with input for a11y.
|
|
7
7
|
*/
|
|
8
8
|
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Name attribute of the <input type="checkbox"/>.
|
|
11
|
+
*/
|
|
12
|
+
name?: string;
|
|
9
13
|
/**
|
|
10
14
|
* Is the checkbox checked when it is first rendered.
|
|
11
15
|
*/
|
package/dist/Checkbox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["
|
|
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"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
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
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
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
|
|
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 "
|
|
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
|
+
/* <wind-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("
|
|
118
|
-
React.createElement("input", { id: id, className:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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.
|
|
163
|
+
//# sourceMappingURL=index.es.mjs.map
|
|
164
|
+
|
|
165
|
+
/* <wind-keep class="absolute text-gray-500 text-gray-800 dark:text-gray-200 icon-dark-white relative flex items-center inset-0 w-0 h-0 opacity-0 border border-solid rounded h-[16px] w-[16px] flex-shrink-0 text-white block ml-[8px] text-[16px] leading-[24px] font-light select-none border-indigo-500 bg-indigo-400 border-jade-500 bg-jade-400 border-red-500 bg-red-400 border-gray-200 bg-gray-100 bg-white"> */
|