@cypress-design/vue-checkbox 0.1.0 → 0.1.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.
- package/CHANGELOG.md +106 -0
- package/Checkbox.rootstory.tsx +9 -0
- package/Checkbox.stories.mdx +75 -0
- package/Checkbox.vue +89 -34
- package/CheckboxVue.cy.tsx +89 -0
- package/ReadMe.md +17 -0
- package/dist/constants.d.ts +15 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/index.es.mjs +107 -0
- package/dist/index.es.mjs.map +1 -0
- package/dist/index.umd.js +3 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/vue/Checkbox.vue.d.ts +212 -0
- package/dist/vue/Checkbox.vue.d.ts.map +1 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/index.ts +1 -1
- package/package.json +4 -4
- package/tsconfig.build.json +2 -2
- package/tsconfig.json +7 -1
- package/vite.config.ts +3 -3
- package/Checkbox.stories.tsx +0 -12
- package/dist/Checkbox.vue.d.ts +0 -40
- package/dist/Checkbox.vue.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.es.js +0 -51
- package/dist/index.es.js.map +0 -1
- /package/dist/{index.d.ts → vue/index.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,111 @@
|
|
|
1
1
|
# @cypress-design/vue-checkbox
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
15
|
+
## 0.5.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#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
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`106b61a`](https://github.com/cypress-io/cypress-design/commit/106b61a97888f956a4c9d235fde5efb4243e1445), [`7b4f416`](https://github.com/cypress-io/cypress-design/commit/7b4f4162a0d150aa8cab7ec239faebb58c39464d)]:
|
|
24
|
+
- @cypress-design/vue-icon@0.18.0
|
|
25
|
+
|
|
26
|
+
## 0.4.6
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- [#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
|
|
31
|
+
|
|
32
|
+
## 0.4.5
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- [#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>)
|
|
37
|
+
|
|
38
|
+
- Updated dependencies [[`2f54f5b`](https://github.com/cypress-io/cypress-design/commit/2f54f5b867b60ba5ce2e40fd38870bd65187ba30), [`e82d8cb`](https://github.com/cypress-io/cypress-design/commit/e82d8cb60882a379d89f86d1ff7b8f1d5b56ce66)]:
|
|
39
|
+
- @cypress-design/vue-icon@0.12.0
|
|
40
|
+
|
|
41
|
+
## 0.4.4
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- [#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
|
|
46
|
+
|
|
47
|
+
## 0.4.3
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- [#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
|
|
52
|
+
|
|
53
|
+
## 0.4.2
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- [#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`
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [[`8c577fb`](https://github.com/cypress-io/cypress-design/commit/8c577fb0c6a0411cf8218dfe78281834df3d6f13)]:
|
|
60
|
+
- @cypress-design/vue-icon@0.5.2
|
|
61
|
+
|
|
62
|
+
## 0.4.1
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- [`2afa4d5`](https://github.com/cypress-io/cypress-design/commit/2afa4d54a2373692f82bee35ae40446bc9bb3f91) Thanks [@elevatebart](https://github.com/elevatebart)! - avoid duplicate ids in checkboxes
|
|
67
|
+
|
|
68
|
+
## 0.4.0
|
|
69
|
+
|
|
70
|
+
### Minor Changes
|
|
71
|
+
|
|
72
|
+
- [#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
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- [#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
|
|
77
|
+
|
|
78
|
+
Source: https://www.a11ymatters.com/pattern/checkbox/
|
|
79
|
+
|
|
80
|
+
- 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)]:
|
|
81
|
+
- @cypress-design/vue-icon@0.5.0
|
|
82
|
+
|
|
83
|
+
## 0.3.0
|
|
84
|
+
|
|
85
|
+
### Minor Changes
|
|
86
|
+
|
|
87
|
+
- [#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
|
|
88
|
+
|
|
89
|
+
## 0.2.1
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- [`e3eb9c7`](https://github.com/cypress-io/cypress-design/commit/e3eb9c7fee2d7a6e0a773e85ed4b73be04d83587) Thanks [@elevatebart](https://github.com/elevatebart)! - downgrade typescript to 4.4 for compat with app
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [[`e3eb9c7`](https://github.com/cypress-io/cypress-design/commit/e3eb9c7fee2d7a6e0a773e85ed4b73be04d83587)]:
|
|
96
|
+
- @cypress-design/vue-icon@0.4.2
|
|
97
|
+
|
|
98
|
+
## 0.2.0
|
|
99
|
+
|
|
100
|
+
### Minor Changes
|
|
101
|
+
|
|
102
|
+
- [#33](https://github.com/cypress-io/cypress-design/pull/33) [`5f9cf10`](https://github.com/cypress-io/cypress-design/commit/5f9cf10ff4709fcd7d322c2dc5dbc676473b433e) Thanks [@elevatebart](https://github.com/elevatebart)! - fix design and api of checkboxes
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- Updated dependencies [[`5f9cf10`](https://github.com/cypress-io/cypress-design/commit/5f9cf10ff4709fcd7d322c2dc5dbc676473b433e)]:
|
|
107
|
+
- @cypress-design/vue-icon@0.3.0
|
|
108
|
+
|
|
3
109
|
## 0.1.0
|
|
4
110
|
|
|
5
111
|
### Minor Changes
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story, Description } from '@storybook/addon-docs'
|
|
2
|
+
import { version } from "./package.json"
|
|
3
|
+
import changelog from "./CHANGELOG.md?raw"
|
|
4
|
+
|
|
5
|
+
import Checkbox from './Checkbox.vue'
|
|
6
|
+
|
|
7
|
+
<h1>Checkbox<span className="text-lg font-normal"> - v{version}</span></h1>
|
|
8
|
+
|
|
9
|
+
<Meta title="Checkbox" component={Checkbox}
|
|
10
|
+
argTypes={{
|
|
11
|
+
color: {
|
|
12
|
+
options: ['indigo', 'red', 'jade'],
|
|
13
|
+
control: {
|
|
14
|
+
type: 'select',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}}
|
|
18
|
+
parameters={{
|
|
19
|
+
design: {
|
|
20
|
+
type: "figma",
|
|
21
|
+
url: 'https://www.figma.com/file/1WJ3GVQyMV5e7xVxPg3yID/Design-System?node-id=1027%3A9825',
|
|
22
|
+
}
|
|
23
|
+
}} />
|
|
24
|
+
|
|
25
|
+
<Canvas withSource="none">
|
|
26
|
+
<Story name="Checkbox">
|
|
27
|
+
{({ color }) => ({
|
|
28
|
+
template: `
|
|
29
|
+
<Checkbox checked label="Checked" :color="color"/>
|
|
30
|
+
<br />
|
|
31
|
+
<Checkbox label="Unchecked" :color="color"/>
|
|
32
|
+
<br />
|
|
33
|
+
<Checkbox checked disabled label="Disabled & checked" :color="color"/>
|
|
34
|
+
<br />
|
|
35
|
+
<Checkbox disabled label="Disabled & unchecked" :color="color"/>
|
|
36
|
+
`,
|
|
37
|
+
components: { Checkbox },
|
|
38
|
+
data: () => ({
|
|
39
|
+
color
|
|
40
|
+
})
|
|
41
|
+
})}
|
|
42
|
+
</Story>
|
|
43
|
+
</Canvas>
|
|
44
|
+
|
|
45
|
+
<ArgsTable />
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
Install the component
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
yarn add @cypress-design/vue-checkbox
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
In the script, import the component
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import Checkbox from '@cypress-design/vue-checkbox'
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
then in the template, use it
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
<Checkbox checked label="Checked" color="indigo"/>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
or with the v-model
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<Checkbox v-model="checked" label="Checked" color="indigo"/>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
<Description>
|
|
74
|
+
{changelog.replace(/^# .+/, '## Changelog')}
|
|
75
|
+
</Description>
|
package/Checkbox.vue
CHANGED
|
@@ -1,48 +1,103 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
'checked:border-jade-300 checked:bg-jade-600 checked:text-jade-600':
|
|
10
|
-
state === 'success',
|
|
11
|
-
'checked:border-red-300 checked:bg-red-600 checked:text-red-600':
|
|
12
|
-
state === 'danger',
|
|
13
|
-
}" @click="updated()" />
|
|
14
|
-
</div>
|
|
15
|
-
<div class="ml-2 text-16px leading-normal">
|
|
16
|
-
<slot name="label">
|
|
17
|
-
<label v-if="label" :for="id" class="disabled:text-gray-500 text-gray-800 font-light select-none">
|
|
18
|
-
{{ label }}
|
|
19
|
-
</label>
|
|
20
|
-
</slot>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</template>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
function uid() {
|
|
3
|
+
return String(Date.now().toString(32) + Math.random().toString(16)).replace(
|
|
4
|
+
/\./g,
|
|
5
|
+
''
|
|
6
|
+
)
|
|
7
|
+
}
|
|
8
|
+
</script>
|
|
24
9
|
|
|
25
10
|
<script lang="ts" setup>
|
|
26
|
-
|
|
11
|
+
import { ref, computed } from 'vue'
|
|
12
|
+
import { IconCheckmarkSmall } from '@cypress-design/vue-icon'
|
|
13
|
+
import { CheckboxColors, Classes } from '../constants'
|
|
27
14
|
|
|
28
15
|
const props = withDefaults(
|
|
29
16
|
defineProps<{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
/**
|
|
18
|
+
* A unique identifier for the checkbox on the whole page.
|
|
19
|
+
* It will be used to give match label with input for a11y.
|
|
20
|
+
*/
|
|
21
|
+
id?: string
|
|
22
|
+
/**
|
|
23
|
+
* Name attribute of the <input type="checkbox"/>.
|
|
24
|
+
*/
|
|
25
|
+
name?: string
|
|
26
|
+
/**
|
|
27
|
+
* Is the checkbox checked when it is first rendered.
|
|
28
|
+
*/
|
|
29
|
+
checked?: boolean
|
|
30
|
+
/**
|
|
31
|
+
* The color of the background in the checkbox.
|
|
32
|
+
* The checkmark will always be white.
|
|
33
|
+
*/
|
|
34
|
+
color?: 'red' | 'indigo' | 'jade'
|
|
35
|
+
/**
|
|
36
|
+
* If the checkbox is disabled, it will not be clickable.
|
|
37
|
+
*/
|
|
38
|
+
disabled?: boolean
|
|
39
|
+
modelValue?: boolean
|
|
40
|
+
/**
|
|
41
|
+
* Label for the checkbox.
|
|
42
|
+
* It is very important to set this to make the checkbox accessible.
|
|
43
|
+
*/
|
|
44
|
+
label?: string
|
|
34
45
|
}>(),
|
|
35
46
|
{
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
id: () => uid(),
|
|
48
|
+
color: 'indigo',
|
|
38
49
|
}
|
|
39
|
-
)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
const localChecked = ref(props.modelValue || props.checked)
|
|
40
53
|
|
|
41
54
|
const emit = defineEmits<{
|
|
42
|
-
(event: 'update:modelValue', value: boolean): void
|
|
43
|
-
}>()
|
|
55
|
+
(event: 'update:modelValue', value: boolean): void
|
|
56
|
+
}>()
|
|
44
57
|
|
|
45
58
|
function updated() {
|
|
46
|
-
|
|
59
|
+
localChecked.value = !localChecked.value
|
|
60
|
+
emit('update:modelValue', localChecked.value)
|
|
47
61
|
}
|
|
62
|
+
|
|
63
|
+
const checkboxClasses = computed(() =>
|
|
64
|
+
props.disabled
|
|
65
|
+
? CheckboxColors.disabled
|
|
66
|
+
: localChecked.value
|
|
67
|
+
? CheckboxColors[props.color]
|
|
68
|
+
: CheckboxColors.empty
|
|
69
|
+
)
|
|
48
70
|
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<span class="relative flex items-center">
|
|
74
|
+
<input
|
|
75
|
+
:id="id"
|
|
76
|
+
:class="Classes.hiddenInput"
|
|
77
|
+
:name="name || id"
|
|
78
|
+
type="checkbox"
|
|
79
|
+
@change="updated"
|
|
80
|
+
:disabled="props.disabled"
|
|
81
|
+
:checked="localChecked"
|
|
82
|
+
/>
|
|
83
|
+
<label :class="Classes.labelTag" :for="id">
|
|
84
|
+
<IconCheckmarkSmall
|
|
85
|
+
v-if="localChecked"
|
|
86
|
+
strokeColor="white"
|
|
87
|
+
class="absolute"
|
|
88
|
+
/>
|
|
89
|
+
<span :class="[checkboxClasses, Classes.visibleCheckbox]" />
|
|
90
|
+
<slot name="label">
|
|
91
|
+
<span
|
|
92
|
+
v-if="label"
|
|
93
|
+
:class="[
|
|
94
|
+
Classes.trueLabel,
|
|
95
|
+
disabled ? 'text-gray-500' : 'text-gray-800',
|
|
96
|
+
]"
|
|
97
|
+
>
|
|
98
|
+
{{ label }}
|
|
99
|
+
</span>
|
|
100
|
+
</slot>
|
|
101
|
+
</label>
|
|
102
|
+
</span>
|
|
103
|
+
</template>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
import { ref } from 'vue'
|
|
4
|
+
import { mount } from 'cypress/vue'
|
|
5
|
+
import Checkbox from './Checkbox.vue'
|
|
6
|
+
|
|
7
|
+
describe('<Checkbox />', () => {
|
|
8
|
+
it('changes when the label is clicked', () => {
|
|
9
|
+
mount(() => {
|
|
10
|
+
return (
|
|
11
|
+
<Checkbox
|
|
12
|
+
label="Welcome guide settings"
|
|
13
|
+
id="welcome-opt-out"
|
|
14
|
+
checked
|
|
15
|
+
class="px-2 py-1 m-2 border border-gray-300 rounded"
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
cy.get('input[type="checkbox"]').should('be.checked')
|
|
21
|
+
cy.percySnapshot()
|
|
22
|
+
cy.contains('Welcome guide settings').click()
|
|
23
|
+
cy.get('input[type="checkbox"]').should('not.be.checked')
|
|
24
|
+
cy.percySnapshot()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('changes when checkbox is clicked', () => {
|
|
28
|
+
mount(() => {
|
|
29
|
+
return (
|
|
30
|
+
<Checkbox
|
|
31
|
+
label="Welcome guide settings"
|
|
32
|
+
id="welcome-opt-out"
|
|
33
|
+
checked
|
|
34
|
+
class="px-2 py-1 m-2 border border-gray-300 rounded"
|
|
35
|
+
/>
|
|
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
|
+
return (
|
|
47
|
+
<Checkbox
|
|
48
|
+
label={[
|
|
49
|
+
'lorem ipsum dolor sit amet, consectetur adipiscing elit,',
|
|
50
|
+
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
|
51
|
+
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip',
|
|
52
|
+
'ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse',
|
|
53
|
+
'cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,',
|
|
54
|
+
'sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
|
55
|
+
].join(' ')}
|
|
56
|
+
id="lorem-checkbox"
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
cy.get('label span:first-child').invoke('outerWidth').should('equal', 16)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('renders vModel', () => {
|
|
65
|
+
const isChecked = ref(false)
|
|
66
|
+
mount(() => {
|
|
67
|
+
return (
|
|
68
|
+
<div>
|
|
69
|
+
<Checkbox
|
|
70
|
+
label="Welcome guide settings"
|
|
71
|
+
vModel={isChecked.value}
|
|
72
|
+
class="px-2 py-1 m-2 border border-gray-300 rounded"
|
|
73
|
+
/>
|
|
74
|
+
<div
|
|
75
|
+
class="px-2 py-1 m-2 border border-gray-300 rounded"
|
|
76
|
+
data-cy="result"
|
|
77
|
+
>
|
|
78
|
+
isChecked = {isChecked.value.toString()}
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
cy.get('[data-cy="result"]').should('contain', 'isChecked = false')
|
|
85
|
+
cy.contains('Welcome guide settings').click()
|
|
86
|
+
cy.get('input[type="checkbox"]').should('be.checked')
|
|
87
|
+
cy.get('[data-cy="result"]').should('contain', 'isChecked = true')
|
|
88
|
+
})
|
|
89
|
+
})
|
package/ReadMe.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const Classes: {
|
|
2
|
+
wrapper: string;
|
|
3
|
+
hiddenInput: string;
|
|
4
|
+
labelTag: string;
|
|
5
|
+
visibleCheckbox: string;
|
|
6
|
+
trueLabel: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const CheckboxColors: {
|
|
9
|
+
readonly indigo: "border-indigo-500 bg-indigo-400";
|
|
10
|
+
readonly jade: "border-jade-500 bg-jade-400";
|
|
11
|
+
readonly red: "border-red-500 bg-red-400";
|
|
12
|
+
readonly disabled: "border-gray-200 bg-gray-100";
|
|
13
|
+
readonly empty: "border-gray-200 bg-white";
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO;;;;;;CAOnB,CAAA;AAED,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAA"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { h as f, defineComponent as x, ref as C, computed as y, openBlock as u, createElementBlock as g, createElementVNode as b, normalizeClass as i, unref as a, createBlock as v, createCommentVNode as k, renderSlot as w, toDisplayString as B } from "vue";
|
|
2
|
+
import * as S from "@cypress-design/icon-registry";
|
|
3
|
+
import { ICON_COLOR_PROP_NAMES as j } from "@cypress-design/icon-registry";
|
|
4
|
+
const z = ({
|
|
5
|
+
body: e,
|
|
6
|
+
compiledClasses: o,
|
|
7
|
+
size: l,
|
|
8
|
+
class: t,
|
|
9
|
+
interactiveColorsOnGroup: h,
|
|
10
|
+
...n
|
|
11
|
+
}) => {
|
|
12
|
+
const d = Object.keys(n).reduce((p, s) => (!j.includes(s) && s !== "name" && (p[s] = n[s]), p), {}), c = {
|
|
13
|
+
width: l,
|
|
14
|
+
height: l,
|
|
15
|
+
viewBox: `0 0 ${l} ${l}`,
|
|
16
|
+
fill: "none",
|
|
17
|
+
innerHTML: e,
|
|
18
|
+
...d
|
|
19
|
+
};
|
|
20
|
+
return o.length && (c.class = o.join(" ")), c;
|
|
21
|
+
}, O = (e) => {
|
|
22
|
+
const { sizeWithDefault: o, compiledClasses: l } = S.getComponentAttributes({ ...e, availableSizes: ["16"] }), t = {
|
|
23
|
+
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"/>'
|
|
24
|
+
}[o];
|
|
25
|
+
if (!t)
|
|
26
|
+
throw Error(`Icon "checkmark-small" is not available in size ${o}`);
|
|
27
|
+
return f("svg", z({
|
|
28
|
+
...e,
|
|
29
|
+
size: o,
|
|
30
|
+
body: t,
|
|
31
|
+
compiledClasses: l
|
|
32
|
+
}));
|
|
33
|
+
}, r = {
|
|
34
|
+
wrapper: "relative flex items-center",
|
|
35
|
+
hiddenInput: "absolute inset-0 w-0 h-0 opacity-0",
|
|
36
|
+
labelTag: "flex items-center",
|
|
37
|
+
visibleCheckbox: "border border-solid rounded h-[16px] w-[16px] flex flex-shrink-0 items-center text-white",
|
|
38
|
+
trueLabel: "block ml-[8px] text-[16px] leading-[24px] font-light select-none"
|
|
39
|
+
}, m = {
|
|
40
|
+
indigo: "border-indigo-500 bg-indigo-400",
|
|
41
|
+
jade: "border-jade-500 bg-jade-400",
|
|
42
|
+
red: "border-red-500 bg-red-400",
|
|
43
|
+
disabled: "border-gray-200 bg-gray-100",
|
|
44
|
+
empty: "border-gray-200 bg-white"
|
|
45
|
+
}, V = { class: "relative flex items-center" }, E = ["id", "name", "disabled", "checked"], I = ["for"];
|
|
46
|
+
function L() {
|
|
47
|
+
return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, "");
|
|
48
|
+
}
|
|
49
|
+
const $ = /* @__PURE__ */ x({
|
|
50
|
+
__name: "Checkbox",
|
|
51
|
+
props: {
|
|
52
|
+
id: { default: () => L() },
|
|
53
|
+
name: null,
|
|
54
|
+
checked: { type: Boolean },
|
|
55
|
+
color: { default: "indigo" },
|
|
56
|
+
disabled: { type: Boolean },
|
|
57
|
+
modelValue: { type: Boolean },
|
|
58
|
+
label: null
|
|
59
|
+
},
|
|
60
|
+
emits: ["update:modelValue"],
|
|
61
|
+
setup(e, { emit: o }) {
|
|
62
|
+
const l = e, t = C(l.modelValue || l.checked);
|
|
63
|
+
function h() {
|
|
64
|
+
t.value = !t.value, o("update:modelValue", t.value);
|
|
65
|
+
}
|
|
66
|
+
const n = y(() => l.disabled ? m.disabled : t.value ? m[l.color] : m.empty);
|
|
67
|
+
return (d, c) => (u(), g("span", V, [
|
|
68
|
+
b("input", {
|
|
69
|
+
id: e.id,
|
|
70
|
+
class: i(a(r).hiddenInput),
|
|
71
|
+
name: e.name || e.id,
|
|
72
|
+
type: "checkbox",
|
|
73
|
+
onChange: h,
|
|
74
|
+
disabled: l.disabled,
|
|
75
|
+
checked: t.value
|
|
76
|
+
}, null, 42, E),
|
|
77
|
+
b("label", {
|
|
78
|
+
class: i(a(r).labelTag),
|
|
79
|
+
for: e.id
|
|
80
|
+
}, [
|
|
81
|
+
t.value ? (u(), v(a(O), {
|
|
82
|
+
key: 0,
|
|
83
|
+
strokeColor: "white",
|
|
84
|
+
class: "absolute"
|
|
85
|
+
})) : k("", !0),
|
|
86
|
+
b("span", {
|
|
87
|
+
class: i([a(n), a(r).visibleCheckbox])
|
|
88
|
+
}, null, 2),
|
|
89
|
+
w(d.$slots, "label", {}, () => [
|
|
90
|
+
e.label ? (u(), g("span", {
|
|
91
|
+
key: 0,
|
|
92
|
+
class: i([
|
|
93
|
+
a(r).trueLabel,
|
|
94
|
+
e.disabled ? "text-gray-500" : "text-gray-800"
|
|
95
|
+
])
|
|
96
|
+
}, B(e.label), 3)) : k("", !0)
|
|
97
|
+
])
|
|
98
|
+
], 10, I)
|
|
99
|
+
]));
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
export {
|
|
103
|
+
$ as default
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/* <windicss-keep class="relative flex items-center absolute text-gray-500 text-gray-800 icon-dark-white 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"> */
|
|
107
|
+
//# sourceMappingURL=index.es.mjs.map
|