@cypress-design/react-checkbox 0.3.0 → 0.4.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/dist/index.umd.js CHANGED
@@ -105,10 +105,17 @@ function __rest(s, e) {
105
105
  }
106
106
 
107
107
  var compileReactIconProperties = function (_a) {
108
- var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size; _a.strokeColor; _a.fillColor; _a.secondaryStrokeColor; _a.secondaryFillColor; var attributes = __rest(_a, ["body", "compiledClasses", "size", "strokeColor", "fillColor", "secondaryStrokeColor", "secondaryFillColor"]);
108
+ var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size, attributes = __rest(_a, ["body", "compiledClasses", "size"]);
109
+ var filteredAttributes = Object.keys(attributes).reduce(function (newAttributes, attrName) {
110
+ if (!iconsRegistry.ICON_COLOR_PROP_NAMES.includes(attrName)) {
111
+ newAttributes[attrName] =
112
+ attributes[attrName];
113
+ }
114
+ return newAttributes;
115
+ }, {});
109
116
  var componentProps = __assign({ width: size, height: size, fill: 'none', dangerouslySetInnerHTML: {
110
117
  __html: body
111
- } }, attributes);
118
+ } }, filteredAttributes);
112
119
  if (attributes.className) {
113
120
  compiledClasses.push(attributes.className);
114
121
  }
@@ -129,19 +136,20 @@ var IconCheckmarkSmall = function (props) {
129
136
  return React__namespace.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
130
137
  };
131
138
 
139
+ /* <windicss-keep class=""> */
140
+
141
+ var uid = function () {
142
+ return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, '');
143
+ };
132
144
  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"]);
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$1(_a, ["id", "checked", "onChange", "color", "label", "disabled", "className", "name"]);
138
146
  var _e = React__namespace.useState(checked), localChecked = _e[0], setChecked = _e[1];
139
147
  function onChangeInput(event) {
140
148
  setChecked(!localChecked);
141
149
  onChange(event);
142
150
  }
143
- return (React__namespace.createElement("label", __assign$1({}, rest, { className: clsx__default["default"](rest.className, 'relative flex items-center') }),
144
- React__namespace.createElement("input", { id: id, className: "absolute inset-0 w-0 h-0 opacity-0", "aria-describedby": id + "-description", name: id, type: "checkbox", onChange: onChangeInput, disabled: disabled, checked: localChecked }),
151
+ return (React__namespace.createElement("div", __assign$1({ className: clsx__default["default"](className, 'relative flex items-center') }, rest),
152
+ React__namespace.createElement("input", { id: id, className: "absolute inset-0 w-0 h-0 opacity-0", "aria-describedby": id + "-description", name: name || id, type: "checkbox", onChange: onChangeInput, disabled: disabled, checked: localChecked }),
145
153
  localChecked && (React__namespace.createElement(IconCheckmarkSmall, { strokeColor: "white", className: "absolute" })),
146
154
  React__namespace.createElement("span", { className: clsx__default["default"]([
147
155
  "block border-1 rounded h-16px w-16px flex items-center text-white",
@@ -155,11 +163,13 @@ var Checkbox = function (_a) {
155
163
  }
156
164
  : 'border-gray-200 bg-white',
157
165
  ]) }),
158
- label && (React__namespace.createElement("span", { className: clsx__default["default"]([
166
+ React__namespace.createElement("label", { htmlFor: id }, label && (React__namespace.createElement("span", { className: clsx__default["default"]([
159
167
  disabled ? 'text-gray-500' : 'text-gray-800',
160
168
  'block ml-2 text-16px leading-normal font-light select-none',
161
- ]) }, label))));
169
+ ]) }, label)))));
162
170
  };
163
171
 
164
172
  module.exports = Checkbox;
173
+
174
+ /* <windicss-keep class="relative flex items-center absolute inset-0 w-0 h-0 opacity-0 block border-1 rounded h-16px w-16px 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-2 text-16px leading-normal font-light select-none"> */
165
175
  //# sourceMappingURL=index.umd.js.map