@cypress-design/react-checkbox 0.2.0 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @cypress-design/react-checkbox
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#44](https://github.com/cypress-io/cypress-design/pull/44) [`2fdaf6b`](https://github.com/cypress-io/cypress-design/commit/2fdaf6be6f81a2a851761258347ed213577c5b26) Thanks [@elevatebart](https://github.com/elevatebart)! - Add missing descriptions of props in button, tooltip, checkbox
8
+
9
+ ## 0.2.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`e3eb9c7`](https://github.com/cypress-io/cypress-design/commit/e3eb9c7fee2d7a6e0a773e85ed4b73be04d83587) Thanks [@elevatebart](https://github.com/elevatebart)! - downgrade typescript to 4.4 for compat with app
14
+
15
+ ## 0.2.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [#39](https://github.com/cypress-io/cypress-design/pull/39) [`1b383f3`](https://github.com/cypress-io/cypress-design/commit/1b383f3d149948bf2cc062d3baa17d5ce032f07e) Thanks [@elevatebart](https://github.com/elevatebart)! - fix file path of sourcemaps
20
+
21
+ - Updated dependencies [[`4259026`](https://github.com/cypress-io/cypress-design/commit/4259026314464260e89bcd88690c8a60ad2f0459), [`1b383f3`](https://github.com/cypress-io/cypress-design/commit/1b383f3d149948bf2cc062d3baa17d5ce032f07e)]:
22
+ - @cypress-design/react-icon@0.3.0
23
+
3
24
  ## 0.2.0
4
25
 
5
26
  ### Minor Changes
package/Checkbox.tsx CHANGED
@@ -5,15 +5,34 @@ import { IconCheckmarkSmall } from '@cypress-design/react-icon'
5
5
 
6
6
  export interface CheckboxProps
7
7
  extends Omit<HTMLProps<HTMLLabelElement>, 'label' | 'onChange'> {
8
+ /**
9
+ * A unique identifier for the checkbox on the whole page.
10
+ * It will be used to give match label with input for a11y.
11
+ */
8
12
  id?: string
9
- checked: boolean
10
- onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
11
- color?: 'indigo' | 'red' | 'jade'
12
- label?: ReactNode
13
+ /**
14
+ * Is the checkbox checked when it is first rendered.
15
+ */
16
+ checked?: boolean
17
+ /**
18
+ * The color of the background in the checkbox.
19
+ * The checkmark will always be white.
20
+ */
21
+ color?: 'red' | 'indigo' | 'jade'
22
+ /**
23
+ * If the checkbox is disabled, it will not be clickable.
24
+ */
13
25
  disabled?: boolean
26
+ /**
27
+ * Label for the checkbox.
28
+ * It is very important to set this to make the checkbox accessible.
29
+ */
30
+ label?: ReactNode
31
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
14
32
  }
15
33
 
16
34
  export const Checkbox: FunctionComponent<CheckboxProps> = ({
35
+ // @ts-ignore
17
36
  id = crypto.randomUUID(),
18
37
  checked = false,
19
38
  onChange,
@@ -1,12 +1,30 @@
1
1
  import * as React from 'react';
2
2
  import type { FunctionComponent, HTMLProps, ReactNode } from 'react';
3
3
  export interface CheckboxProps extends Omit<HTMLProps<HTMLLabelElement>, 'label' | 'onChange'> {
4
+ /**
5
+ * A unique identifier for the checkbox on the whole page.
6
+ * It will be used to give match label with input for a11y.
7
+ */
4
8
  id?: string;
5
- checked: boolean;
6
- onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
7
- color?: 'indigo' | 'red' | 'jade';
8
- label?: ReactNode;
9
+ /**
10
+ * Is the checkbox checked when it is first rendered.
11
+ */
12
+ checked?: boolean;
13
+ /**
14
+ * The color of the background in the checkbox.
15
+ * The checkmark will always be white.
16
+ */
17
+ color?: 'red' | 'indigo' | 'jade';
18
+ /**
19
+ * If the checkbox is disabled, it will not be clickable.
20
+ */
9
21
  disabled?: boolean;
22
+ /**
23
+ * Label for the checkbox.
24
+ * It is very important to set this to make the checkbox accessible.
25
+ */
26
+ label?: ReactNode;
27
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
10
28
  }
11
29
  export declare const Checkbox: FunctionComponent<CheckboxProps>;
12
30
  export default Checkbox;
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../Checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGpE,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/D,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IAC9D,KAAK,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAA;IACjC,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,CA4DrD,CAAA;AAED,eAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../Checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGpE,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/D;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;IACjC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;CAC/D;AAED,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,CA6DrD,CAAA;AAED,eAAe,QAAQ,CAAA"}
package/dist/index.es.js CHANGED
@@ -98,20 +98,24 @@ var IconCheckmarkSmall = function (props) {
98
98
  };
99
99
  var body = iconBodies[size];
100
100
  if (!body) {
101
- throw Error("Icon \"checkmark-small\" is not available in size ".concat(size));
101
+ throw Error("Icon \"checkmark-small\" is not available in size " + size);
102
102
  }
103
103
  return React.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
104
104
  };
105
105
 
106
106
  var Checkbox = function (_a) {
107
- 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"]);
107
+ var
108
+ // @ts-ignore
109
+ _b = _a.id,
110
+ // @ts-ignore
111
+ 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"]);
108
112
  var _e = React.useState(checked), localChecked = _e[0], setChecked = _e[1];
109
113
  function onChangeInput(event) {
110
114
  setChecked(!localChecked);
111
115
  onChange(event);
112
116
  }
113
117
  return (React.createElement("label", __assign$1({}, rest, { className: clsx(rest.className, 'relative flex items-center') }),
114
- React.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 }),
118
+ React.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 }),
115
119
  localChecked && (React.createElement(IconCheckmarkSmall, { strokeColor: "white", className: "absolute" })),
116
120
  React.createElement("span", { className: clsx([
117
121
  "block border-1 rounded h-16px w-16px flex items-center text-white",