@jonmilner/ui 0.13.1 → 0.13.2
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/Switch/Switch.css +1 -1
- package/dist/Switch/Switch.css.mjs +5 -2
- package/dist/Switch/index.d.mts +2 -1
- package/dist/Switch/index.mjs +48 -39
- package/dist/docs/Switch.md +4 -2
- package/dist/docs/manifest.json +10 -1
- package/package.json +1 -1
package/dist/Switch/Switch.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
@layer tokens, reset, atoms.base, atoms.sm, atoms.med, atoms.lg, atoms.xl, components.box, components.checkbox, components.clickable, components.icon, components.icon-button, components.inline, components.sidebar, components.sidebar-layout, components.stack, components.text, components.avatar, components.badge, components.button, components.chip, components.field, components.color-field, components.combobox, components.heading, components.dialog, components.alert-dialog, components.menu, components.multiselect, components.nav-list, components.radio-group, components.search-field, components.select, components.switch, components.tabs, components.tag, components.text-field, components.textarea, components.toast, components.tooltip, components.visually-hidden, components.table;
|
|
2
|
-
@layer components.switch{.njq9m00{clip-path:inset(50%);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:0;padding:0;position:absolute;overflow:hidden}.
|
|
2
|
+
@layer components.switch{.njq9m03{--njq9m00:var(--space-12);--njq9m01:var(--space-1);--njq9m02:calc(var(--distance-sm) + var(--distance-med))}.njq9m04{--njq9m00:var(--space-16);--njq9m01:var(--space-2);--njq9m02:var(--distance-lg)}.njq9m05{clip-path:inset(50%);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:0;padding:0;position:absolute;overflow:hidden}.njq9m06{cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;min-inline-size:var(--size-xs);min-block-size:var(--size-xs);border-radius:var(--radius-full);flex-shrink:0;justify-content:center;align-items:center;display:inline-flex}.njq9m06:focus-visible{outline:var(--space-2) solid var(--color-focus);outline-offset:var(--space-2)}.njq9m06[aria-disabled=true]{cursor:not-allowed}.njq9m06[aria-readonly=true]{cursor:default}.njq9m06[aria-busy=true]{cursor:progress}.njq9m07{grid-template-columns:repeat(2, var(--njq9m00));padding:var(--njq9m01);border:var(--space-1) solid var(--color-border-strong);border-radius:var(--radius-full);background-color:var(--color-bg);forced-color-adjust:none;align-items:center;display:grid}.njq9m06:not([aria-checked=true],[aria-invalid=true],[aria-disabled=true],[aria-readonly=true]):hover .njq9m07{border-color:var(--color-fg)}.njq9m06[aria-checked=true] .njq9m07{background-color:var(--color-accent);border-color:var(--color-accent)}.njq9m06[aria-readonly=true]:not([aria-busy=true]) .njq9m07{background-clip:padding-box;border-style:dotted}.njq9m06[aria-busy=true] .njq9m07{opacity:.5}.njq9m06[aria-disabled=true] .njq9m07{border-style:dashed;border-color:var(--color-border-strong);background-clip:border-box;background-color:var(--color-bg-muted)}.njq9m06[aria-invalid=true] .njq9m07{padding:calc(var(--njq9m01) - var(--space-1));border-width:var(--space-2);border-color:var(--color-danger)}.njq9m08{inline-size:var(--njq9m00);block-size:var(--njq9m00);border-radius:var(--radius-full);transition:opacity var(--duration-med) var(--easing-standard), translate var(--duration-med) var(--easing-standard);background-color:var(--color-fg-muted);grid-area:1/1/auto/-1;justify-self:start}.njq9m06[aria-checked=true] .njq9m08{opacity:0;translate:calc(var(--dir) * var(--njq9m02))}.njq9m09{inline-size:var(--njq9m00);block-size:var(--njq9m00);border-radius:var(--radius-full);transition:opacity var(--duration-med) var(--easing-standard), translate var(--duration-med) var(--easing-standard);background-color:var(--color-accent-fg);opacity:0;translate:calc(-1 * var(--dir) * var(--njq9m02));grid-area:1/1/auto/-1;justify-self:end}.njq9m06[aria-checked=true] .njq9m09{opacity:1;translate:0}.njq9m06[aria-disabled=true] .njq9m09{background-color:var(--color-fg-muted)}}
|
|
@@ -3,5 +3,8 @@ import "./Switch.css";
|
|
|
3
3
|
/* empty css */
|
|
4
4
|
/* empty css */
|
|
5
5
|
// src/Switch/Switch.css.ts
|
|
6
|
-
var e =
|
|
7
|
-
|
|
6
|
+
var e = {
|
|
7
|
+
sm: "njq9m03",
|
|
8
|
+
med: "njq9m04"
|
|
9
|
+
}, t = "njq9m05", n = "njq9m06", r = "njq9m07", i = "njq9m08", a = "njq9m09";
|
|
10
|
+
export { t as hiddenLabel, i as offThumb, a as onThumb, n as root, e as size, r as track };
|
package/dist/Switch/index.d.mts
CHANGED
|
@@ -21,9 +21,10 @@ export type SwitchProps = StyleProps & SwitchName & {
|
|
|
21
21
|
onCheckedChange?: (checked: boolean) => void;
|
|
22
22
|
readOnly?: boolean;
|
|
23
23
|
required?: boolean;
|
|
24
|
+
size?: "sm" | "med";
|
|
24
25
|
style?: CSSProperties;
|
|
25
26
|
uncheckedValue?: string;
|
|
26
27
|
value?: string;
|
|
27
28
|
};
|
|
28
|
-
export declare function Switch({ label, hideLabel, "aria-label": ariaLabel, checked, defaultChecked, onCheckedChange, description, error, name, value, uncheckedValue, disabled, readOnly, required, busy, className, style, ...atoms }: SwitchProps): import("react").JSX.Element;
|
|
29
|
+
export declare function Switch({ label, hideLabel, "aria-label": ariaLabel, checked, defaultChecked, onCheckedChange, description, error, name, value, uncheckedValue, disabled, readOnly, required, busy, size, className, style, ...atoms }: SwitchProps): import("react").JSX.Element;
|
|
29
30
|
export {};
|
package/dist/Switch/index.mjs
CHANGED
|
@@ -1,59 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { join as e } from "../styles/join.mjs";
|
|
2
|
+
import { Box as t } from "../Box/base.mjs";
|
|
3
|
+
import { controlText as n } from "../styles/control-size.mjs";
|
|
4
|
+
import { Field as r } from "../Field/index.mjs";
|
|
5
|
+
import { offThumb as i, onThumb as a, root as o, size as s, track as c } from "./Switch.css.mjs";
|
|
6
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
|
+
import { Switch as d } from "@base-ui/react/switch";
|
|
6
8
|
// src/Switch/index.tsx
|
|
7
|
-
function
|
|
8
|
-
let
|
|
9
|
-
return /* @__PURE__ */
|
|
10
|
-
...
|
|
11
|
-
className:
|
|
12
|
-
disabled:
|
|
13
|
-
invalid:
|
|
14
|
-
style:
|
|
9
|
+
function f({ label: f, hideLabel: p = !1, "aria-label": m, checked: h, defaultChecked: g, onCheckedChange: _, description: v, error: y, name: b, value: x, uncheckedValue: S, disabled: C = !1, readOnly: w = !1, required: T = !1, busy: E = !1, size: D = "med", className: O, style: k, ...A }) {
|
|
10
|
+
let j = E && !w && !C;
|
|
11
|
+
return /* @__PURE__ */ u(r, {
|
|
12
|
+
...A,
|
|
13
|
+
className: O,
|
|
14
|
+
disabled: C,
|
|
15
|
+
invalid: y != null && y !== !1 && y !== "",
|
|
16
|
+
style: k,
|
|
15
17
|
children: [
|
|
16
|
-
/* @__PURE__ */
|
|
18
|
+
/* @__PURE__ */ u(t, {
|
|
17
19
|
alignItems: "center",
|
|
18
20
|
as: "div",
|
|
19
21
|
display: "flex",
|
|
20
22
|
gap: "8",
|
|
21
|
-
children: [/* @__PURE__ */
|
|
22
|
-
"aria-busy":
|
|
23
|
-
"aria-label":
|
|
24
|
-
checked:
|
|
25
|
-
defaultChecked:
|
|
26
|
-
name:
|
|
27
|
-
onCheckedChange:
|
|
28
|
-
readOnly:
|
|
29
|
-
render: /* @__PURE__ */
|
|
23
|
+
children: [/* @__PURE__ */ l(d.Root, {
|
|
24
|
+
"aria-busy": j || void 0,
|
|
25
|
+
"aria-label": m,
|
|
26
|
+
checked: h,
|
|
27
|
+
defaultChecked: g,
|
|
28
|
+
name: b,
|
|
29
|
+
onCheckedChange: _ && ((e) => _(e)),
|
|
30
|
+
readOnly: w || j,
|
|
31
|
+
render: /* @__PURE__ */ l(t, {
|
|
30
32
|
as: "span",
|
|
31
|
-
className:
|
|
33
|
+
className: e(o, s[D])
|
|
32
34
|
}),
|
|
33
|
-
required:
|
|
34
|
-
uncheckedValue:
|
|
35
|
-
value:
|
|
36
|
-
children: /* @__PURE__ */
|
|
35
|
+
required: T,
|
|
36
|
+
uncheckedValue: S,
|
|
37
|
+
value: x,
|
|
38
|
+
children: /* @__PURE__ */ u(t, {
|
|
37
39
|
as: "span",
|
|
38
|
-
className:
|
|
39
|
-
children: [/* @__PURE__ */
|
|
40
|
+
className: c,
|
|
41
|
+
children: [/* @__PURE__ */ l(t, {
|
|
40
42
|
"aria-hidden": "true",
|
|
41
43
|
as: "span",
|
|
42
|
-
className:
|
|
43
|
-
}), /* @__PURE__ */
|
|
44
|
+
className: i
|
|
45
|
+
}), /* @__PURE__ */ l(t, {
|
|
44
46
|
"aria-hidden": "true",
|
|
45
47
|
as: "span",
|
|
46
|
-
className:
|
|
48
|
+
className: a
|
|
47
49
|
})]
|
|
48
50
|
})
|
|
49
|
-
}),
|
|
50
|
-
className:
|
|
51
|
-
|
|
51
|
+
}), f != null && /* @__PURE__ */ l(r.Label, {
|
|
52
|
+
className: p ? "njq9m05" : void 0,
|
|
53
|
+
size: n[D],
|
|
54
|
+
children: f
|
|
52
55
|
})]
|
|
53
56
|
}),
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
v != null && /* @__PURE__ */ l(r.Description, {
|
|
58
|
+
size: n[D],
|
|
59
|
+
children: v
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ l(r.Error, {
|
|
62
|
+
size: n[D],
|
|
63
|
+
children: y
|
|
64
|
+
})
|
|
56
65
|
]
|
|
57
66
|
});
|
|
58
67
|
}
|
|
59
|
-
export {
|
|
68
|
+
export { f as Switch };
|
package/dist/docs/Switch.md
CHANGED
|
@@ -24,7 +24,7 @@ Turns one setting on or off, and the change applies the moment it flips. Built o
|
|
|
24
24
|
- `description` and `error` render below the row through `Field`; a non-empty `error` marks it invalid (`aria-invalid`, a thicker `danger` border) and joins its `aria-describedby`.
|
|
25
25
|
- `disabled` takes it out of the tab order and dashes the border. `readOnly` keeps it focusable and announced (`aria-readonly`) but unchangeable and dots the border; say nearby why it cannot change.
|
|
26
26
|
- `name` submits `value` (default `"on"`) while on; off submits nothing unless you set `uncheckedValue`.
|
|
27
|
-
-
|
|
27
|
+
- `size` is `med` by default: a 38 by 22 track, the label at 14 px. `sm` is a 28 by 16 track with a 12 px thumb and the label, description and error at 12 px, for a toggle repeated down a dense table's rows. The target is 24 by 24 px at both sizes (ADR 0124, 0153). There is no `lg`. Style props, `className` and `style` go to the `Field` around the row and its messages, not to the switch.
|
|
28
28
|
- The module has no hooks, so a server component can render it. `onCheckedChange` is a function: set it from a client component.
|
|
29
29
|
|
|
30
30
|
## Do
|
|
@@ -53,8 +53,9 @@ Turns one setting on or off, and the change applies the moment it flips. Built o
|
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
```tsx
|
|
56
|
-
// The row's heading names the setting.
|
|
56
|
+
// The row's heading names the setting; `sm` fits a dense table row.
|
|
57
57
|
<Switch
|
|
58
|
+
size="sm"
|
|
58
59
|
aria-label={`Notifications for ${repo.name}`}
|
|
59
60
|
checked={repo.notify}
|
|
60
61
|
onCheckedChange={(next) => setNotify(repo.id, next)}
|
|
@@ -112,6 +113,7 @@ Generated from the TypeScript types.
|
|
|
112
113
|
| `onCheckedChange` | `((checked: boolean) => void)` | no | |
|
|
113
114
|
| `readOnly` | `boolean` | no | |
|
|
114
115
|
| `required` | `boolean` | no | |
|
|
116
|
+
| `size` | `"med" \| "sm"` | no | |
|
|
115
117
|
| `style` | `CSSProperties` | no | |
|
|
116
118
|
| `uncheckedValue` | `string` | no | |
|
|
117
119
|
| `value` | `string` | no | |
|
package/dist/docs/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./manifest.schema.json",
|
|
3
3
|
"package": "@jonmilner/ui",
|
|
4
|
-
"version": "0.13.
|
|
4
|
+
"version": "0.13.2",
|
|
5
5
|
"components": [
|
|
6
6
|
{
|
|
7
7
|
"name": "AlertDialog",
|
|
@@ -2356,6 +2356,15 @@
|
|
|
2356
2356
|
"type": "boolean",
|
|
2357
2357
|
"required": false
|
|
2358
2358
|
},
|
|
2359
|
+
{
|
|
2360
|
+
"name": "size",
|
|
2361
|
+
"type": "\"med\" | \"sm\"",
|
|
2362
|
+
"required": false,
|
|
2363
|
+
"values": [
|
|
2364
|
+
"med",
|
|
2365
|
+
"sm"
|
|
2366
|
+
]
|
|
2367
|
+
},
|
|
2359
2368
|
{
|
|
2360
2369
|
"name": "style",
|
|
2361
2370
|
"type": "CSSProperties",
|