@cypress-design/react-checkbox 0.2.1 → 0.4.0

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
  }
@@ -124,20 +131,24 @@ var IconCheckmarkSmall = function (props) {
124
131
  };
125
132
  var body = iconBodies[size];
126
133
  if (!body) {
127
- throw Error("Icon \"checkmark-small\" is not available in size ".concat(size));
134
+ throw Error("Icon \"checkmark-small\" is not available in size " + size);
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 _b = _a.id, 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"]);
134
145
  var _e = React__namespace.useState(checked), localChecked = _e[0], setChecked = _e[1];
135
146
  function onChangeInput(event) {
136
147
  setChecked(!localChecked);
137
148
  onChange(event);
138
149
  }
139
- return (React__namespace.createElement("label", __assign$1({}, rest, { className: clsx__default["default"](rest.className, 'relative flex items-center') }),
140
- React__namespace.createElement("input", { id: id, className: "absolute inset-0 w-0 h-0 opacity-0", "aria-describedby": "".concat(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 }),
141
152
  localChecked && (React__namespace.createElement(IconCheckmarkSmall, { strokeColor: "white", className: "absolute" })),
142
153
  React__namespace.createElement("span", { className: clsx__default["default"]([
143
154
  "block border-1 rounded h-16px w-16px flex items-center text-white",
@@ -151,11 +162,13 @@ var Checkbox = function (_a) {
151
162
  }
152
163
  : 'border-gray-200 bg-white',
153
164
  ]) }),
154
- 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"]([
155
166
  disabled ? 'text-gray-500' : 'text-gray-800',
156
167
  'block ml-2 text-16px leading-normal font-light select-none',
157
- ]) }, label))));
168
+ ]) }, label)))));
158
169
  };
159
170
 
160
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
+
161
174
  //# sourceMappingURL=index.umd.js.map