@cypress-design/react-checkbox 0.2.2 → 0.4.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/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
  }
@@ -128,20 +135,20 @@ var IconCheckmarkSmall = function (props) {
128
135
  }
129
136
  return React__namespace.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
130
137
  };
138
+ /* <windicss-keep class=""> */
131
139
 
140
+ var uid = function () {
141
+ return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, '');
142
+ };
132
143
  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"]);
144
+ 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
145
  var _e = React__namespace.useState(checked), localChecked = _e[0], setChecked = _e[1];
139
146
  function onChangeInput(event) {
140
147
  setChecked(!localChecked);
141
148
  onChange(event);
142
149
  }
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 }),
150
+ return (React__namespace.createElement("div", __assign$1({ className: clsx__default["default"](className, 'relative flex items-center') }, rest),
151
+ 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
152
  localChecked && (React__namespace.createElement(IconCheckmarkSmall, { strokeColor: "white", className: "absolute" })),
146
153
  React__namespace.createElement("span", { className: clsx__default["default"]([
147
154
  "block border-1 rounded h-16px w-16px flex items-center text-white",
@@ -155,11 +162,13 @@ var Checkbox = function (_a) {
155
162
  }
156
163
  : 'border-gray-200 bg-white',
157
164
  ]) }),
158
- label && (React__namespace.createElement("span", { className: clsx__default["default"]([
165
+ React__namespace.createElement("label", { htmlFor: id }, label && (React__namespace.createElement("span", { className: clsx__default["default"]([
159
166
  disabled ? 'text-gray-500' : 'text-gray-800',
160
167
  'block ml-2 text-16px leading-normal font-light select-none',
161
- ]) }, label))));
168
+ ]) }, label)))));
162
169
  };
163
170
 
164
171
  module.exports = Checkbox;
172
+ /* <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"> */
173
+
165
174
  //# sourceMappingURL=index.umd.js.map