@cypress-design/react-checkbox 0.5.0 → 1.0.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 +8 -0
- package/CHANGELOG.md +85 -0
- package/Checkbox.rootstory.tsx +17 -0
- package/Checkbox.tsx +11 -17
- package/CheckboxReact.cy.tsx +14 -7
- package/ReadMe.md +19 -0
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.mjs +20 -89
- package/dist/index.es.mjs.map +1 -1
- package/dist/index.umd.js +26 -99
- package/dist/index.umd.js.map +1 -1
- package/package.json +11 -6
- package/rollup.config.mjs +7 -0
- package/tsconfig.build.json +1 -0
- package/Checkbox.stories.mdx +0 -67
- package/rollup.config.js +0 -3
- package/tsconfig.json +0 -4
package/dist/index.umd.js
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var clsx = require('clsx');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var
|
|
5
|
+
var reactIcon = require('@cypress-design/react-icon');
|
|
6
|
+
var constantsCheckbox = require('@cypress-design/constants-checkbox');
|
|
6
7
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
function _interopNamespace(e) {
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
11
9
|
var n = Object.create(null);
|
|
12
10
|
if (e) {
|
|
13
11
|
Object.keys(e).forEach(function (k) {
|
|
@@ -20,13 +18,11 @@ function _interopNamespace(e) {
|
|
|
20
18
|
}
|
|
21
19
|
});
|
|
22
20
|
}
|
|
23
|
-
n
|
|
21
|
+
n.default = e;
|
|
24
22
|
return Object.freeze(n);
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
var
|
|
28
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
|
-
var iconsRegistry__namespace = /*#__PURE__*/_interopNamespace(iconsRegistry);
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
30
26
|
|
|
31
27
|
/******************************************************************************
|
|
32
28
|
Copyright (c) Microsoft Corporation.
|
|
@@ -42,44 +38,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
42
38
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
43
39
|
PERFORMANCE OF THIS SOFTWARE.
|
|
44
40
|
***************************************************************************** */
|
|
41
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
45
42
|
|
|
46
|
-
var __assign$1 = function() {
|
|
47
|
-
__assign$1 = Object.assign || function __assign(t) {
|
|
48
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
49
|
-
s = arguments[i];
|
|
50
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
51
|
-
}
|
|
52
|
-
return t;
|
|
53
|
-
};
|
|
54
|
-
return __assign$1.apply(this, arguments);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function __rest$1(s, e) {
|
|
58
|
-
var t = {};
|
|
59
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
60
|
-
t[p] = s[p];
|
|
61
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
62
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
63
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
64
|
-
t[p[i]] = s[p[i]];
|
|
65
|
-
}
|
|
66
|
-
return t;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/******************************************************************************
|
|
70
|
-
Copyright (c) Microsoft Corporation.
|
|
71
|
-
|
|
72
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
73
|
-
purpose with or without fee is hereby granted.
|
|
74
|
-
|
|
75
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
76
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
77
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
78
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
79
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
80
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
81
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
82
|
-
***************************************************************************** */
|
|
83
43
|
|
|
84
44
|
var __assign = function() {
|
|
85
45
|
__assign = Object.assign || function __assign(t) {
|
|
@@ -102,77 +62,44 @@ function __rest(s, e) {
|
|
|
102
62
|
t[p[i]] = s[p[i]];
|
|
103
63
|
}
|
|
104
64
|
return t;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
if (!iconsRegistry.ICON_COLOR_PROP_NAMES.includes(attrName) && attrName !== 'name') {
|
|
111
|
-
newAttributes[attrName] =
|
|
112
|
-
attributes[attrName];
|
|
113
|
-
}
|
|
114
|
-
return newAttributes;
|
|
115
|
-
}, {});
|
|
116
|
-
var componentProps = __assign({ width: size, height: size, viewBox: "0 0 " + size + " " + size, fill: 'none', dangerouslySetInnerHTML: {
|
|
117
|
-
__html: body
|
|
118
|
-
} }, filteredAttributes);
|
|
119
|
-
if (attributes.className) {
|
|
120
|
-
compiledClasses.push(attributes.className);
|
|
121
|
-
}
|
|
122
|
-
if (compiledClasses.length) {
|
|
123
|
-
componentProps.className = compiledClasses.join(' ');
|
|
124
|
-
}
|
|
125
|
-
return componentProps;
|
|
126
|
-
};
|
|
127
|
-
var IconCheckmarkSmall = function (props) {
|
|
128
|
-
var _a = iconsRegistry__namespace.getComponentAttributes(__assign(__assign({}, props), { availableSizes: ["16"] })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
|
|
129
|
-
var iconBodies = {
|
|
130
|
-
"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\"/>"
|
|
131
|
-
};
|
|
132
|
-
var body = iconBodies[size];
|
|
133
|
-
if (!body) {
|
|
134
|
-
throw Error("Icon \"checkmark-small\" is not available in size " + size);
|
|
135
|
-
}
|
|
136
|
-
return React__namespace.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
68
|
+
var e = new Error(message);
|
|
69
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
137
70
|
};
|
|
138
71
|
|
|
139
|
-
/* <windicss-keep class=""> */
|
|
140
|
-
|
|
141
72
|
var uid = function () {
|
|
142
73
|
return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, '');
|
|
143
74
|
};
|
|
144
75
|
var Checkbox = function (_a) {
|
|
145
|
-
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
|
|
76
|
+
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(_a, ["id", "checked", "onChange", "color", "label", "disabled", "className", "name"]);
|
|
146
77
|
var _e = React__namespace.useState(checked), localChecked = _e[0], setChecked = _e[1];
|
|
147
78
|
function onChangeInput(event) {
|
|
148
79
|
setChecked(!localChecked);
|
|
149
80
|
onChange(event);
|
|
150
81
|
}
|
|
151
|
-
return (React__namespace.createElement("span", __assign
|
|
152
|
-
React__namespace.createElement("input", { id: id, className:
|
|
153
|
-
React__namespace.createElement("label", { className:
|
|
82
|
+
return (React__namespace.createElement("span", __assign({ className: clsx(className, constantsCheckbox.Classes.wrapper) }, rest),
|
|
83
|
+
React__namespace.createElement("input", { id: id, className: constantsCheckbox.Classes.hiddenInput, "aria-describedby": "".concat(id, "-description"), name: name || id, type: "checkbox", onChange: onChangeInput, disabled: disabled, checked: localChecked }),
|
|
84
|
+
React__namespace.createElement("label", { className: constantsCheckbox.Classes.labelTag, htmlFor: id },
|
|
154
85
|
localChecked && (
|
|
155
|
-
// <
|
|
156
|
-
React__namespace.createElement(IconCheckmarkSmall, { strokeColor: "white", className: "absolute" })),
|
|
157
|
-
React__namespace.createElement("span", { className:
|
|
158
|
-
|
|
86
|
+
// <tw-keep strokeColor="white"/>
|
|
87
|
+
React__namespace.createElement(reactIcon.IconCheckmarkSmall, { strokeColor: "white", className: "absolute" })),
|
|
88
|
+
React__namespace.createElement("span", { className: clsx([
|
|
89
|
+
constantsCheckbox.Classes.visibleCheckbox,
|
|
159
90
|
disabled
|
|
160
|
-
?
|
|
91
|
+
? constantsCheckbox.CheckboxColors.disabled
|
|
161
92
|
: localChecked
|
|
162
|
-
?
|
|
163
|
-
|
|
164
|
-
'border-jade-500 bg-jade-400': color === 'jade',
|
|
165
|
-
'border-red-500 bg-red-400': color === 'red'
|
|
166
|
-
}
|
|
167
|
-
: 'border-gray-200 bg-white',
|
|
93
|
+
? constantsCheckbox.CheckboxColors[color]
|
|
94
|
+
: constantsCheckbox.CheckboxColors.empty,
|
|
168
95
|
]) }),
|
|
169
|
-
label && (React__namespace.createElement("span", { className:
|
|
96
|
+
label && (React__namespace.createElement("span", { className: clsx([
|
|
170
97
|
disabled ? 'text-gray-500' : 'text-gray-800',
|
|
171
|
-
|
|
98
|
+
constantsCheckbox.Classes.trueLabel,
|
|
172
99
|
]) }, label)))));
|
|
173
100
|
};
|
|
174
101
|
|
|
175
102
|
module.exports = Checkbox;
|
|
176
|
-
|
|
177
|
-
/* <windicss-keep class="block relative flex items-center absolute inset-0 w-0 h-0 opacity-0 border border-solid rounded h-[16px] w-[16px] flex-shrink-0 text-white border-gray-200 bg-gray-100 border-indigo-500 bg-indigo-400 border-jade-500 bg-jade-400 border-red-500 bg-red-400 bg-white text-gray-500 text-gray-800 ml-[8px] text-[16px] leading-[24px] font-light select-none icon-dark-white"> */
|
|
178
103
|
//# sourceMappingURL=index.umd.js.map
|
|
104
|
+
|
|
105
|
+
/* <wind-keep class="absolute text-gray-500 text-gray-800 icon-dark-white"> */
|