@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.
- package/.turbo/turbo-build.log +6 -0
- package/CHANGELOG.md +114 -0
- package/Checkbox.rootstory.tsx +17 -0
- package/Checkbox.tsx +64 -38
- package/CheckboxReact.cy.tsx +44 -3
- package/ReadMe.md +13 -0
- package/dist/Checkbox.d.ts +27 -5
- 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
package/dist/index.umd.js
CHANGED
|
@@ -4,10 +4,7 @@ var clsx = require('clsx');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var iconsRegistry = require('@cypress-design/icon-registry');
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
function _interopNamespace(e) {
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
11
8
|
var n = Object.create(null);
|
|
12
9
|
if (e) {
|
|
13
10
|
Object.keys(e).forEach(function (k) {
|
|
@@ -20,13 +17,12 @@ function _interopNamespace(e) {
|
|
|
20
17
|
}
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
|
-
n
|
|
20
|
+
n.default = e;
|
|
24
21
|
return Object.freeze(n);
|
|
25
22
|
}
|
|
26
23
|
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var iconsRegistry__namespace = /*#__PURE__*/_interopNamespace(iconsRegistry);
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
25
|
+
var iconsRegistry__namespace = /*#__PURE__*/_interopNamespaceDefault(iconsRegistry);
|
|
30
26
|
|
|
31
27
|
/******************************************************************************
|
|
32
28
|
Copyright (c) Microsoft Corporation.
|
|
@@ -105,10 +101,17 @@ function __rest(s, e) {
|
|
|
105
101
|
}
|
|
106
102
|
|
|
107
103
|
var compileReactIconProperties = function (_a) {
|
|
108
|
-
var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size
|
|
109
|
-
var
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size, attributes = __rest(_a, ["body", "compiledClasses", "size"]);
|
|
105
|
+
var filteredAttributes = Object.keys(attributes).reduce(function (newAttributes, attrName) {
|
|
106
|
+
if (!iconsRegistry.ICON_COLOR_PROP_NAMES.includes(attrName) && attrName !== 'name') {
|
|
107
|
+
newAttributes[attrName] =
|
|
108
|
+
attributes[attrName];
|
|
109
|
+
}
|
|
110
|
+
return newAttributes;
|
|
111
|
+
}, {});
|
|
112
|
+
var componentProps = __assign({ width: size, height: size, viewBox: "0 0 ".concat(size, " ").concat(size), fill: 'none', dangerouslySetInnerHTML: {
|
|
113
|
+
__html: body,
|
|
114
|
+
} }, filteredAttributes);
|
|
112
115
|
if (attributes.className) {
|
|
113
116
|
compiledClasses.push(attributes.className);
|
|
114
117
|
}
|
|
@@ -120,46 +123,64 @@ var compileReactIconProperties = function (_a) {
|
|
|
120
123
|
var IconCheckmarkSmall = function (props) {
|
|
121
124
|
var _a = iconsRegistry__namespace.getComponentAttributes(__assign(__assign({}, props), { availableSizes: ["16"] })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
|
|
122
125
|
var iconBodies = {
|
|
123
|
-
"16": "<path
|
|
126
|
+
"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\"/>"
|
|
124
127
|
};
|
|
125
128
|
var body = iconBodies[size];
|
|
126
129
|
if (!body) {
|
|
127
|
-
throw Error("Icon \"checkmark-small\" is not available in size "
|
|
130
|
+
throw Error("Icon \"checkmark-small\" is not available in size ".concat(size));
|
|
128
131
|
}
|
|
129
132
|
return React__namespace.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
|
|
130
133
|
};
|
|
131
134
|
|
|
135
|
+
|
|
136
|
+
/* <windicss-keep class=""> */
|
|
137
|
+
|
|
138
|
+
const Classes = {
|
|
139
|
+
wrapper: 'relative flex items-center',
|
|
140
|
+
hiddenInput: 'absolute inset-0 w-0 h-0 opacity-0',
|
|
141
|
+
labelTag: 'flex items-center',
|
|
142
|
+
visibleCheckbox: 'border border-solid rounded h-[16px] w-[16px] flex flex-shrink-0 items-center text-white',
|
|
143
|
+
trueLabel: 'block ml-[8px] text-[16px] leading-[24px] font-light select-none',
|
|
144
|
+
};
|
|
145
|
+
const CheckboxColors = {
|
|
146
|
+
indigo: 'border-indigo-500 bg-indigo-400',
|
|
147
|
+
jade: 'border-jade-500 bg-jade-400',
|
|
148
|
+
red: 'border-red-500 bg-red-400',
|
|
149
|
+
disabled: 'border-gray-200 bg-gray-100',
|
|
150
|
+
empty: 'border-gray-200 bg-white',
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
var uid = function () {
|
|
154
|
+
return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, '');
|
|
155
|
+
};
|
|
132
156
|
var Checkbox = function (_a) {
|
|
133
|
-
var
|
|
134
|
-
// @ts-ignore
|
|
135
|
-
_b = _a.id,
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
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"]);
|
|
157
|
+
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"]);
|
|
138
158
|
var _e = React__namespace.useState(checked), localChecked = _e[0], setChecked = _e[1];
|
|
139
159
|
function onChangeInput(event) {
|
|
140
160
|
setChecked(!localChecked);
|
|
141
161
|
onChange(event);
|
|
142
162
|
}
|
|
143
|
-
return (React__namespace.createElement("
|
|
144
|
-
React__namespace.createElement("input", { id: id, className:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
]) }, label))));
|
|
163
|
+
return (React__namespace.createElement("span", __assign$1({ className: clsx(className, Classes.wrapper) }, rest),
|
|
164
|
+
React__namespace.createElement("input", { id: id, className: Classes.hiddenInput, "aria-describedby": "".concat(id, "-description"), name: name || id, type: "checkbox", onChange: onChangeInput, disabled: disabled, checked: localChecked }),
|
|
165
|
+
React__namespace.createElement("label", { className: Classes.labelTag, htmlFor: id },
|
|
166
|
+
localChecked && (
|
|
167
|
+
// <tw-keep strokeColor="white"/>
|
|
168
|
+
React__namespace.createElement(IconCheckmarkSmall, { strokeColor: "white", className: "absolute" })),
|
|
169
|
+
React__namespace.createElement("span", { className: clsx([
|
|
170
|
+
Classes.visibleCheckbox,
|
|
171
|
+
disabled
|
|
172
|
+
? CheckboxColors.disabled
|
|
173
|
+
: localChecked
|
|
174
|
+
? CheckboxColors[color]
|
|
175
|
+
: CheckboxColors.empty,
|
|
176
|
+
]) }),
|
|
177
|
+
label && (React__namespace.createElement("span", { className: clsx([
|
|
178
|
+
disabled ? 'text-gray-500' : 'text-gray-800 dark:text-gray-200',
|
|
179
|
+
Classes.trueLabel,
|
|
180
|
+
]) }, label)))));
|
|
162
181
|
};
|
|
163
182
|
|
|
164
183
|
module.exports = Checkbox;
|
|
165
184
|
//# sourceMappingURL=index.umd.js.map
|
|
185
|
+
|
|
186
|
+
/* <windicss-keep class="absolute text-gray-500 text-gray-800 dark:text-gray-200 icon-dark-white"> */
|