@cypress-design/vue-checkbox 0.2.1 → 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.
- package/.turbo/turbo-build.log +13 -0
- package/CHANGELOG.md +114 -0
- package/Checkbox.rootstory.tsx +9 -0
- package/Checkbox.vue +74 -30
- package/CheckboxVue.cy.tsx +43 -4
- package/ReadMe.md +13 -0
- package/dist/Checkbox.vue.d.ts +64 -13
- package/dist/Checkbox.vue.d.ts.map +1 -1
- package/dist/index.es.mjs +116 -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/package.json +10 -5
- package/tsconfig.build.json +2 -1
- package/tsconfig.json +10 -1
- package/Checkbox.stories.mdx +0 -75
- package/dist/index.es.js +0 -102
- package/dist/index.es.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress-design/vue-checkbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"*"
|
|
6
6
|
],
|
|
7
7
|
"typings": "./dist/index.d.ts",
|
|
8
|
+
"module": "./dist/index.es.mjs",
|
|
8
9
|
"main": "./dist/index.umd.js",
|
|
9
|
-
"module": "./dist/index.es.js",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"import": "./dist/index.es.
|
|
13
|
-
"require": "./dist/index.umd.js"
|
|
12
|
+
"import": "./dist/index.es.mjs",
|
|
13
|
+
"require": "./dist/index.umd.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
14
15
|
}
|
|
15
16
|
},
|
|
16
17
|
"scripts": {
|
|
@@ -19,7 +20,11 @@
|
|
|
19
20
|
"build:types": "yarn vue-tsc --project ./tsconfig.build.json"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@cypress-design/
|
|
23
|
+
"@cypress-design/constants-checkbox": "*",
|
|
24
|
+
"@cypress-design/react-icon": "*"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@cypress-design/css": "*"
|
|
23
28
|
},
|
|
24
29
|
"license": "MIT"
|
|
25
30
|
}
|
package/tsconfig.build.json
CHANGED
package/tsconfig.json
CHANGED
package/Checkbox.stories.mdx
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
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 chedked 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/dist/index.es.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { h, defineComponent, ref, computed, openBlock, createElementBlock, createElementVNode, createBlock, unref, createCommentVNode, normalizeClass, renderSlot, toDisplayString } from "vue";
|
|
2
|
-
import * as iconsRegistry from "@cypress-design/icon-registry";
|
|
3
|
-
const compileVueIconProperties = ({
|
|
4
|
-
body,
|
|
5
|
-
compiledClasses,
|
|
6
|
-
size,
|
|
7
|
-
class: className,
|
|
8
|
-
interactiveColorsOnGroup,
|
|
9
|
-
...attributes
|
|
10
|
-
}) => {
|
|
11
|
-
Object.keys(attributes).forEach((key) => {
|
|
12
|
-
if (key.toLowerCase().endsWith("color")) {
|
|
13
|
-
delete attributes[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
const componentProps = {
|
|
17
|
-
width: size,
|
|
18
|
-
height: size,
|
|
19
|
-
fill: "none",
|
|
20
|
-
innerHTML: body,
|
|
21
|
-
...attributes
|
|
22
|
-
};
|
|
23
|
-
if (compiledClasses.length) {
|
|
24
|
-
componentProps.class = compiledClasses.join(" ");
|
|
25
|
-
}
|
|
26
|
-
return componentProps;
|
|
27
|
-
};
|
|
28
|
-
const IconCheckmarkSmall = (props) => {
|
|
29
|
-
const { sizeWithDefault: size, compiledClasses } = iconsRegistry.getComponentAttributes({ ...props, availableSizes: ["16"] });
|
|
30
|
-
const iconBodies = {
|
|
31
|
-
"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"/>'
|
|
32
|
-
};
|
|
33
|
-
const body = iconBodies[size];
|
|
34
|
-
if (!body) {
|
|
35
|
-
throw Error(`Icon "checkmark-small" is not available in size ${size}`);
|
|
36
|
-
}
|
|
37
|
-
return h("svg", compileVueIconProperties({
|
|
38
|
-
...props,
|
|
39
|
-
size,
|
|
40
|
-
body,
|
|
41
|
-
compiledClasses
|
|
42
|
-
}));
|
|
43
|
-
};
|
|
44
|
-
const _hoisted_1 = { class: "relative flex items-center" };
|
|
45
|
-
const _hoisted_2 = ["id", "name", "disabled", "checked"];
|
|
46
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
47
|
-
__name: "Checkbox",
|
|
48
|
-
props: {
|
|
49
|
-
id: { default: crypto.randomUUID() },
|
|
50
|
-
modelValue: { type: Boolean },
|
|
51
|
-
color: { default: "indigo" },
|
|
52
|
-
label: null,
|
|
53
|
-
disabled: { type: Boolean },
|
|
54
|
-
checked: { type: Boolean }
|
|
55
|
-
},
|
|
56
|
-
emits: ["update:modelValue"],
|
|
57
|
-
setup(__props, { emit }) {
|
|
58
|
-
const props = __props;
|
|
59
|
-
const localChecked = ref(props.modelValue || props.checked);
|
|
60
|
-
function updated() {
|
|
61
|
-
localChecked.value = !localChecked.value;
|
|
62
|
-
emit("update:modelValue", localChecked.value);
|
|
63
|
-
}
|
|
64
|
-
const checkboxClasses = computed(() => [
|
|
65
|
-
"block border-1 rounded h-16px w-16px",
|
|
66
|
-
props.disabled ? "border-gray-200 bg-gray-100" : localChecked.value ? {
|
|
67
|
-
"border-indigo-500 bg-indigo-400": props.color === "indigo",
|
|
68
|
-
"border-jade-500 bg-jade-400": props.color === "jade",
|
|
69
|
-
"border-red-500 bg-red-400": props.color === "red"
|
|
70
|
-
} : "border-gray-200 bg-white"
|
|
71
|
-
]);
|
|
72
|
-
return (_ctx, _cache) => {
|
|
73
|
-
return openBlock(), createElementBlock("label", _hoisted_1, [
|
|
74
|
-
createElementVNode("input", {
|
|
75
|
-
id: __props.id,
|
|
76
|
-
class: "absolute inset-0 w-0 h-0 opacity-0",
|
|
77
|
-
name: __props.id,
|
|
78
|
-
type: "checkbox",
|
|
79
|
-
onChange: updated,
|
|
80
|
-
disabled: props.disabled,
|
|
81
|
-
checked: localChecked.value
|
|
82
|
-
}, null, 40, _hoisted_2),
|
|
83
|
-
localChecked.value ? (openBlock(), createBlock(unref(IconCheckmarkSmall), {
|
|
84
|
-
key: 0,
|
|
85
|
-
strokeColor: "white",
|
|
86
|
-
class: "absolute"
|
|
87
|
-
})) : createCommentVNode("", true),
|
|
88
|
-
createElementVNode("span", {
|
|
89
|
-
class: normalizeClass(unref(checkboxClasses))
|
|
90
|
-
}, null, 2),
|
|
91
|
-
renderSlot(_ctx.$slots, "label", {}, () => [
|
|
92
|
-
__props.label ? (openBlock(), createElementBlock("span", {
|
|
93
|
-
key: 0,
|
|
94
|
-
class: normalizeClass(["block ml-2 text-16px leading-normal font-light select-none", __props.disabled ? "text-gray-500" : "text-gray-800"])
|
|
95
|
-
}, toDisplayString(__props.label), 3)) : createCommentVNode("", true)
|
|
96
|
-
])
|
|
97
|
-
]);
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
export { _sfc_main as default };
|
|
102
|
-
//# sourceMappingURL=index.es.js.map
|