@spark-ui/checkbox 1.7.0 → 1.8.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 +8 -0
- package/dist/CheckboxInput.d.ts +7 -6
- package/dist/index.js +1 -1
- package/dist/index.mjs +24 -62
- package/package.json +10 -4
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [1.8.0](https://github.com/adevinta/spark/compare/@spark-ui/checkbox@1.7.0...@spark-ui/checkbox@1.8.0) (2023-04-19)
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
- **checkbox:** indeterminate status ([f5f7fb8](https://github.com/adevinta/spark/commit/f5f7fb88843559b25b2abf69ac32023fed973b15))
|
11
|
+
- **checkbox:** indeterminate status ([e6a66f1](https://github.com/adevinta/spark/commit/e6a66f151f907b848e1947a2799343dc70f9679a))
|
12
|
+
- **checkbox:** indeterminate status ([7f41e99](https://github.com/adevinta/spark/commit/7f41e996ca2ec85137a8f5518e98222a2dd6471a))
|
13
|
+
|
6
14
|
# [1.7.0](https://github.com/adevinta/spark/compare/@spark-ui/checkbox@1.6.7...@spark-ui/checkbox@1.7.0) (2023-04-19)
|
7
15
|
|
8
16
|
### Features
|
package/dist/CheckboxInput.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
import
|
1
|
+
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
2
2
|
import { type InputStylesProps } from './CheckboxInput.styles';
|
3
|
+
type CheckedStatus = boolean | 'indeterminate';
|
3
4
|
interface RadixProps {
|
4
5
|
/**
|
5
6
|
* The checked icon to use
|
@@ -8,15 +9,15 @@ interface RadixProps {
|
|
8
9
|
/**
|
9
10
|
* The checked state of the checkbox when it is initially rendered. Use when you do not need to control its checked state.
|
10
11
|
*/
|
11
|
-
defaultChecked?:
|
12
|
+
defaultChecked?: CheckedStatus;
|
12
13
|
/**
|
13
14
|
* The controlled checked state of the checkbox. Must be used in conjunction with onCheckedChange.
|
14
15
|
*/
|
15
|
-
checked?:
|
16
|
+
checked?: CheckedStatus;
|
16
17
|
/**
|
17
18
|
* Event handler called when the checked state of the checkbox changes.
|
18
19
|
*/
|
19
|
-
onCheckedChange?: (checked:
|
20
|
+
onCheckedChange?: (checked: CheckedStatus) => void;
|
20
21
|
/**
|
21
22
|
* When true, prevents the user from interacting with the checkbox.
|
22
23
|
*/
|
@@ -32,7 +33,7 @@ interface RadixProps {
|
|
32
33
|
}
|
33
34
|
export interface InputProps extends RadixProps, // Radix props
|
34
35
|
InputStylesProps, // CVA props (variants)
|
35
|
-
Omit<
|
36
|
+
Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'checked' | 'defaultChecked'> {
|
36
37
|
}
|
37
|
-
export declare const Input:
|
38
|
+
export declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLButtonElement>>;
|
38
39
|
export {};
|
package/dist/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),m=require("@radix-ui/react-checkbox"),c=require("@spark-ui/icons"),p=require("@spark-ui/use-merge-refs"),f=require("@spark-ui/internal-utils"),d=require("class-variance-authority"),h=require("@radix-ui/react-label");function g(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const i=g(m),y=d.cva(["h-sz-20 w-sz-20 border-md peer items-center justify-center rounded-sm bg-transparent","spark-disabled:opacity-dim-3 spark-disabled:cursor-not-allowed spark-disabled:hover:ring-0","focus-visible:ring-outline-high focus-visible:outline-none focus-visible:ring-2","hover:border-primary-container hover:outline-none hover:ring-2"],{variants:{intent:f.makeVariants({primary:["spark-state-unchecked:border-outline","spark-state-indeterminate:border-primary spark-state-indeterminate:bg-primary","spark-state-checked:border-primary spark-state-checked:bg-primary"],success:["spark-state-unchecked:border-success","spark-state-indeterminate:border-success spark-state-indeterminate:bg-success","spark-state-checked:border-success spark-state-checked:bg-success"],alert:["spark-state-unchecked:border-alert","spark-state-indeterminate:border-alert spark-state-indeterminate:bg-alert","spark-state-checked:border-alert spark-state-checked:bg-alert"],error:["spark-state-unchecked:border-error","spark-state-indeterminate:border-error spark-state-indeterminate:bg-error","spark-state-checked:border-error spark-state-checked:bg-error"]})},defaultVariants:{intent:"primary"}}),v=a.forwardRef(({intent:e,icon:r,...t},s)=>{const[o,l]=a.useState(),u=p.useMergeRefs(s,n=>{l(n?.getAttribute("aria-checked"))}),b=(({icon:n,checked:k})=>{if(n)return n;switch(k){case"true":return a.createElement(c.Check,null);case"mixed":return a.createElement(c.Minus,null);default:return null}})({icon:r,checked:o});return a.createElement(i.Root,{ref:u,className:y({intent:e}),...t},a.createElement(i.Indicator,{className:"text-surface flex items-center justify-center"},b))}),x=d.cva(["flex","items-center","gap-md","text-body-1"],{variants:{disabled:{true:["text-neutral/dim-2","cursor-not-allowed"],false:["cursor-pointer"]}},defaultVariants:{disabled:!1}}),j=({className:e,disabled:r,...t})=>a.createElement(h.Label,{className:x({className:e,disabled:r}),...t}),q=a.forwardRef(({children:e,...r},t)=>a.createElement(j,{"data-spark-component":"checkbox",disabled:r.disabled},a.createElement(v,{ref:t,...r}),e));exports.Checkbox=q;
|
package/dist/index.mjs
CHANGED
@@ -1,65 +1,27 @@
|
|
1
|
-
import
|
2
|
-
import * as
|
3
|
-
import { Check as
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import "
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
import e, { forwardRef as k, useState as u } from "react";
|
2
|
+
import * as c from "@radix-ui/react-checkbox";
|
3
|
+
import { Minus as b, Check as f } from "@spark-ui/icons";
|
4
|
+
import { useMergeRefs as h } from "@spark-ui/use-merge-refs";
|
5
|
+
import { makeVariants as g } from "@spark-ui/internal-utils";
|
6
|
+
import { cva as i } from "class-variance-authority";
|
7
|
+
import { Label as y } from "@radix-ui/react-label";
|
8
|
+
const v = i(["h-sz-20 w-sz-20 border-md peer items-center justify-center rounded-sm bg-transparent", "spark-disabled:opacity-dim-3 spark-disabled:cursor-not-allowed spark-disabled:hover:ring-0", "focus-visible:ring-outline-high focus-visible:outline-none focus-visible:ring-2", "hover:border-primary-container hover:outline-none hover:ring-2"], { variants: { intent: g({ primary: ["spark-state-unchecked:border-outline", "spark-state-indeterminate:border-primary spark-state-indeterminate:bg-primary", "spark-state-checked:border-primary spark-state-checked:bg-primary"], success: ["spark-state-unchecked:border-success", "spark-state-indeterminate:border-success spark-state-indeterminate:bg-success", "spark-state-checked:border-success spark-state-checked:bg-success"], alert: ["spark-state-unchecked:border-alert", "spark-state-indeterminate:border-alert spark-state-indeterminate:bg-alert", "spark-state-checked:border-alert spark-state-checked:bg-alert"], error: ["spark-state-unchecked:border-error", "spark-state-indeterminate:border-error spark-state-indeterminate:bg-error", "spark-state-checked:border-error spark-state-checked:bg-error"] }) }, defaultVariants: { intent: "primary" } }), x = k(({ intent: t, icon: r, ...a }, n) => {
|
9
|
+
const [o, d] = u(), l = h(n, (s) => {
|
10
|
+
d(s?.getAttribute("aria-checked"));
|
11
|
+
}), m = (({ icon: s, checked: p }) => {
|
12
|
+
if (s)
|
13
|
+
return s;
|
14
|
+
switch (p) {
|
15
|
+
case "true":
|
16
|
+
return e.createElement(f, null);
|
17
|
+
case "mixed":
|
18
|
+
return e.createElement(b, null);
|
19
|
+
default:
|
20
|
+
return null;
|
14
21
|
}
|
15
|
-
|
16
|
-
},
|
17
|
-
}
|
18
|
-
function C(...t) {
|
19
|
-
return (a) => t.forEach((e) => function(r, n) {
|
20
|
-
typeof r == "function" ? r(n) : r != null && (r.current = n);
|
21
|
-
}(e, a));
|
22
|
-
}
|
23
|
-
const y = p((t, a) => {
|
24
|
-
const { children: e, ...r } = t, n = i.toArray(e), s = n.find(R);
|
25
|
-
if (s) {
|
26
|
-
const o = s.props.children, m = n.map((b) => b === s ? i.count(o) > 1 ? i.only(null) : u(o) ? o.props.children : null : b);
|
27
|
-
return d(f, l({}, r, { ref: a }), u(o) ? k(o, void 0, m) : null);
|
28
|
-
}
|
29
|
-
return d(f, l({}, r, { ref: a }), e);
|
30
|
-
});
|
31
|
-
y.displayName = "Slot";
|
32
|
-
const f = p((t, a) => {
|
33
|
-
const { children: e, ...r } = t;
|
34
|
-
return u(e) ? k(e, { ...V(r, e.props), ref: C(a, e.ref) }) : i.count(e) > 1 ? i.only(null) : null;
|
35
|
-
});
|
36
|
-
f.displayName = "SlotClone";
|
37
|
-
const O = ({ children: t }) => d(g, null, t);
|
38
|
-
function R(t) {
|
39
|
-
return u(t) && t.type === O;
|
40
|
-
}
|
41
|
-
function V(t, a) {
|
42
|
-
const e = { ...a };
|
43
|
-
for (const r in a) {
|
44
|
-
const n = t[r], s = a[r];
|
45
|
-
/^on[A-Z]/.test(r) ? n && s ? e[r] = (...o) => {
|
46
|
-
s(...o), n(...o);
|
47
|
-
} : n && (e[r] = n) : r === "style" ? e[r] = { ...n, ...s } : r === "className" && (e[r] = [n, s].filter(Boolean).join(" "));
|
48
|
-
}
|
49
|
-
return { ...t, ...e };
|
50
|
-
}
|
51
|
-
const D = ["a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "span", "svg", "ul"].reduce((t, a) => {
|
52
|
-
const e = p((r, n) => {
|
53
|
-
const { asChild: s, ...o } = r, m = s ? y : a;
|
54
|
-
return w(() => {
|
55
|
-
window[Symbol.for("radix-ui")] = !0;
|
56
|
-
}, []), d(m, l({}, o, { ref: n }));
|
57
|
-
});
|
58
|
-
return e.displayName = `Primitive.${a}`, { ...t, [a]: e };
|
59
|
-
}, {}), P = p((t, a) => d(D.label, l({}, t, { ref: a, onMouseDown: (e) => {
|
60
|
-
var r;
|
61
|
-
(r = t.onMouseDown) === null || r === void 0 || r.call(t, e), !e.defaultPrevented && e.detail > 1 && e.preventDefault();
|
62
|
-
} }))), S = v(["flex", "items-center", "gap-md", "text-body-1"], { variants: { disabled: { true: ["text-neutral/dim-2", "cursor-not-allowed"], false: ["cursor-pointer"] } }, defaultVariants: { disabled: !1 } }), z = ({ className: t, disabled: a, ...e }) => c.createElement(P, { className: S({ className: t, disabled: a }), ...e }), Z = c.forwardRef(({ children: t, ...a }, e) => c.createElement(z, { "data-spark-component": "checkbox", disabled: a.disabled }, c.createElement(j, { ref: e, ...a }), t));
|
22
|
+
})({ icon: r, checked: o });
|
23
|
+
return e.createElement(c.Root, { ref: l, className: v({ intent: t }), ...a }, e.createElement(c.Indicator, { className: "text-surface flex items-center justify-center" }, m));
|
24
|
+
}), E = i(["flex", "items-center", "gap-md", "text-body-1"], { variants: { disabled: { true: ["text-neutral/dim-2", "cursor-not-allowed"], false: ["cursor-pointer"] } }, defaultVariants: { disabled: !1 } }), w = ({ className: t, disabled: r, ...a }) => e.createElement(y, { className: E({ className: t, disabled: r }), ...a }), M = e.forwardRef(({ children: t, ...r }, a) => e.createElement(w, { "data-spark-component": "checkbox", disabled: r.disabled }, e.createElement(x, { ref: a, ...r }), t));
|
63
25
|
export {
|
64
|
-
|
26
|
+
M as Checkbox
|
65
27
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@spark-ui/checkbox",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.8.0",
|
4
4
|
"description": "A control that allows the user to toggle between checked and not checked.",
|
5
5
|
"publishConfig": {
|
6
6
|
"access": "public"
|
@@ -13,8 +13,10 @@
|
|
13
13
|
},
|
14
14
|
"dependencies": {
|
15
15
|
"@radix-ui/react-checkbox": "1",
|
16
|
-
"@
|
17
|
-
"@spark-ui/
|
16
|
+
"@radix-ui/react-label": "^2.0.1",
|
17
|
+
"@spark-ui/icons": "1",
|
18
|
+
"@spark-ui/internal-utils": "1",
|
19
|
+
"@spark-ui/use-merge-refs": "0",
|
18
20
|
"class-variance-authority": "0.4.0"
|
19
21
|
},
|
20
22
|
"peerDependencies": {
|
@@ -22,5 +24,9 @@
|
|
22
24
|
"react-dom": "^16.8 || ^17.0 || ^18.0",
|
23
25
|
"tailwindcss": "^3.0.0"
|
24
26
|
},
|
25
|
-
"
|
27
|
+
"devDependencies": {
|
28
|
+
"@spark-ui/button": "1",
|
29
|
+
"@spark-ui/radio": "1"
|
30
|
+
},
|
31
|
+
"gitHead": "bfa98062c937ff5b2650dbab457a503578a42cb9"
|
26
32
|
}
|