@cypress-design/react-checkbox 1.0.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.
@@ -1,6 +1,8 @@
1
1
  $ yarn build:module && yarn build:types
2
2
  $ rollup -c ./rollup.config.mjs
3
+ (node:4175) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
4
+ (Use `node --trace-warnings ...` to show where the warning was created)
3
5
  
4
6
  ./index.ts → ./dist/index.umd.js, ./dist/index.es.mjs...
5
- created ./dist/index.umd.js, ./dist/index.es.mjs in 13.8s
7
+ created ./dist/index.umd.js, ./dist/index.es.mjs in 14.1s
6
8
  $ tsc --project ./tsconfig.build.json
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @cypress-design/react-checkbox
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#450](https://github.com/cypress-io/cypress-design/pull/450) [`927097f`](https://github.com/cypress-io/cypress-design/commit/927097f409235ac78c98b281c4d9b2ec70dfe01d) Thanks [@elevatebart](https://github.com/elevatebart)! - optim: do not package dependencies
8
+
9
+ - Updated dependencies [[`927097f`](https://github.com/cypress-io/cypress-design/commit/927097f409235ac78c98b281c4d9b2ec70dfe01d), [`927097f`](https://github.com/cypress-io/cypress-design/commit/927097f409235ac78c98b281c4d9b2ec70dfe01d)]:
10
+ - @cypress-design/react-icon@1.1.0
11
+
3
12
  ## 1.0.0
4
13
 
5
14
  ### Major Changes
package/dist/index.es.mjs CHANGED
@@ -1,52 +1,7 @@
1
1
  import clsx from 'clsx';
2
2
  import * as React from 'react';
3
- import * as iconsRegistry from '@cypress-design/icon-registry';
4
- import { ICON_COLOR_PROP_NAMES } from '@cypress-design/icon-registry';
5
-
6
- /******************************************************************************
7
- Copyright (c) Microsoft Corporation.
8
-
9
- Permission to use, copy, modify, and/or distribute this software for any
10
- purpose with or without fee is hereby granted.
11
-
12
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
13
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
15
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
17
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18
- PERFORMANCE OF THIS SOFTWARE.
19
- ***************************************************************************** */
20
- /* global Reflect, Promise, SuppressedError, Symbol */
21
-
22
-
23
- var __assign$1 = function() {
24
- __assign$1 = Object.assign || function __assign(t) {
25
- for (var s, i = 1, n = arguments.length; i < n; i++) {
26
- s = arguments[i];
27
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
28
- }
29
- return t;
30
- };
31
- return __assign$1.apply(this, arguments);
32
- };
33
-
34
- function __rest$1(s, e) {
35
- var t = {};
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
37
- t[p] = s[p];
38
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
39
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
40
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
41
- t[p[i]] = s[p[i]];
42
- }
43
- return t;
44
- }
45
-
46
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
47
- var e = new Error(message);
48
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
49
- };
3
+ import { IconCheckmarkSmall } from '@cypress-design/react-icon';
4
+ import { Classes, CheckboxColors } from '@cypress-design/constants-checkbox';
50
5
 
51
6
  /******************************************************************************
52
7
  Copyright (c) Microsoft Corporation.
@@ -93,93 +48,17 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
93
48
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
94
49
  };
95
50
 
96
- var compileReactIconProperties = function (_a) {
97
- var body = _a.body, defs = _a.defs, compiledClasses = _a.compiledClasses, size = _a.size, name = _a.name, alt = _a.alt, attributes = __rest(_a, ["body", "defs", "compiledClasses", "size", "name", "alt"]);
98
- var filteredAttributes = Object.keys(attributes).reduce(function (newAttributes, attrName) {
99
- if (!ICON_COLOR_PROP_NAMES.includes(attrName) &&
100
- attrName !== 'name') {
101
- // @ts-expect-error the ky of React's SVGProps is too broad and
102
- // breaks here. Since we do not need to check for it. We keep the expect error
103
- newAttributes[attrName] =
104
- attributes[attrName];
105
- }
106
- return newAttributes;
107
- }, {});
108
- // eslint-disable-next-line react-hooks/rules-of-hooks
109
- React.useEffect(function () {
110
- var iconFileId = "".concat(name, "_").concat(size);
111
- if (defs) {
112
- if (document.querySelector("[data-cy-svg-defs=\"".concat(iconFileId, "\"]"))) {
113
- return;
114
- }
115
- var svgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
116
- svgElement.setAttribute('data-cy-svg-defs', iconFileId);
117
- svgElement.setAttribute('width', '0');
118
- svgElement.setAttribute('height', '0');
119
- svgElement.innerHTML = defs;
120
- document.body.appendChild(svgElement);
121
- }
122
- }, [defs, name, size]);
123
- var componentProps = __assign({ width: size, height: size, viewBox: "0 0 ".concat(size, " ").concat(size), fill: 'none', dangerouslySetInnerHTML: {
124
- __html: alt
125
- ? "<title>".concat(alt.replace(/[><]/g, function (s) {
126
- return s === '>' ? '&gt;' : '&lt;';
127
- }), "</title>").concat(body)
128
- : body,
129
- }, className: undefined }, filteredAttributes);
130
- if (attributes.className) {
131
- compiledClasses.push(attributes.className);
132
- }
133
- if (compiledClasses.length) {
134
- componentProps.className = compiledClasses.join(' ');
135
- }
136
- return componentProps;
137
- };
138
-
139
- function useIconProps(props, iconBodiesAndDefs, availableSizes, name) {
140
- var interactiveColorsOnGroup = props.interactiveColorsOnGroup, cleanProps = __rest(props, ["interactiveColorsOnGroup"]);
141
- var _a = iconsRegistry.getComponentAttributes(__assign(__assign({}, cleanProps), { availableSizes: availableSizes, interactiveColorsOnGroup: interactiveColorsOnGroup })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
142
- var _b = iconBodiesAndDefs[size] || {}, body = _b.body, defs = _b.defs;
143
- if (!body) {
144
- throw Error("Icon \"".concat(name, "\" is not available in size ").concat(size));
145
- }
146
- return compileReactIconProperties(__assign(__assign({}, cleanProps), { name: name, size: size, body: body, defs: defs, compiledClasses: compiledClasses }));
147
- }
148
- var IconCheckmarkSmall = function (props) { return React.createElement('svg', useIconProps(props, {
149
- "16": {
150
- "body": "<path d=\"M5 8.5 7.5 11 11 5\" stroke=\"currentColor\" class=\"icon-dark\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"
151
- }
152
- }, ["16"], "checkmark-small")); };
153
-
154
-
155
- /* <wind-keep class="filter icon-light-secondary icon-dark-secondary"> */
156
-
157
- const Classes = {
158
- wrapper: 'relative flex items-center',
159
- hiddenInput: 'absolute inset-0 w-0 h-0 opacity-0',
160
- labelTag: 'flex items-center',
161
- visibleCheckbox: 'border border-solid rounded h-[16px] w-[16px] flex flex-shrink-0 items-center text-white',
162
- trueLabel: 'block ml-[8px] text-[16px] leading-[24px] font-light select-none',
163
- };
164
- const CheckboxColors = {
165
- indigo: 'border-indigo-500 bg-indigo-400',
166
- jade: 'border-jade-500 bg-jade-400',
167
- red: 'border-red-500 bg-red-400',
168
- disabled: 'border-gray-200 bg-gray-100',
169
- empty: 'border-gray-200 bg-white',
170
- };
171
-
172
51
  var uid = function () {
173
52
  return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, '');
174
53
  };
175
54
  var Checkbox = function (_a) {
176
- 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"]);
55
+ 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"]);
177
56
  var _e = React.useState(checked), localChecked = _e[0], setChecked = _e[1];
178
57
  function onChangeInput(event) {
179
58
  setChecked(!localChecked);
180
59
  onChange(event);
181
60
  }
182
- return (React.createElement("span", __assign$1({ className: clsx(className, Classes.wrapper) }, rest),
61
+ return (React.createElement("span", __assign({ className: clsx(className, Classes.wrapper) }, rest),
183
62
  React.createElement("input", { id: id, className: Classes.hiddenInput, "aria-describedby": "".concat(id, "-description"), name: name || id, type: "checkbox", onChange: onChangeInput, disabled: disabled, checked: localChecked }),
184
63
  React.createElement("label", { className: Classes.labelTag, htmlFor: id },
185
64
  localChecked && (
@@ -202,4 +81,4 @@ var Checkbox = function (_a) {
202
81
  export { Checkbox as default };
203
82
  //# sourceMappingURL=index.es.mjs.map
204
83
 
205
- /* <wind-keep class="absolute text-gray-500 text-gray-800 icon-dark-white relative flex items-center inset-0 w-0 h-0 opacity-0 border border-solid rounded h-[16px] w-[16px] flex-shrink-0 text-white block ml-[8px] text-[16px] leading-[24px] font-light select-none border-indigo-500 bg-indigo-400 border-jade-500 bg-jade-400 border-red-500 bg-red-400 border-gray-200 bg-gray-100 bg-white"> */
84
+ /* <wind-keep class="absolute text-gray-500 text-gray-800 icon-dark-white"> */