@manakind/ui-core 0.3.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/README.md +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/switch/index.d.ts +3 -0
- package/dist/switch/index.d.ts.map +1 -0
- package/dist/switch/index.js +2 -0
- package/dist/switch/index.js.map +1 -0
- package/dist/switch/switch.css +141 -0
- package/dist/switch/switch.css.d.ts +2 -0
- package/dist/switch/switch.d.ts +76 -0
- package/dist/switch/switch.d.ts.map +1 -0
- package/dist/switch/switch.js +42 -0
- package/dist/switch/switch.js.map +1 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ separately, so an app can load only what it renders.
|
|
|
64
64
|
| `@manakind/ui-core/illustration` | `Illustration` + `illustrationPaint` |
|
|
65
65
|
| `@manakind/ui-core/progress` | `Progress` |
|
|
66
66
|
| `@manakind/ui-core/select` | `Select` |
|
|
67
|
+
| `@manakind/ui-core/switch` | `Switch` |
|
|
67
68
|
| `@manakind/ui-core/tabs` | `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent` |
|
|
68
69
|
| `@manakind/ui-core/css/badge` | Badge structural CSS |
|
|
69
70
|
| `@manakind/ui-core/css/button` | Button + IconButton structural CSS |
|
|
@@ -72,6 +73,7 @@ separately, so an app can load only what it renders.
|
|
|
72
73
|
| `@manakind/ui-core/css/illustration` | Illustration structural CSS, including the paint roles |
|
|
73
74
|
| `@manakind/ui-core/css/progress` | Progress structural CSS |
|
|
74
75
|
| `@manakind/ui-core/css/select` | Select structural CSS |
|
|
76
|
+
| `@manakind/ui-core/css/switch` | Switch structural CSS |
|
|
75
77
|
| `@manakind/ui-core/css/tabs` | Tabs structural CSS |
|
|
76
78
|
|
|
77
79
|
Structural CSS is only half of what a component needs — it consumes `--ds-*` custom
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/switch/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/switch/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.ds-switch {
|
|
3
|
+
/*
|
|
4
|
+
* Underscore-prefixed, NOT `--ds-`: that namespace is the contract a
|
|
5
|
+
* product implements. These are the component's own derivations from it.
|
|
6
|
+
*
|
|
7
|
+
* The thumb is the track's height less its border and inset on each
|
|
8
|
+
* side, and it travels the difference between the track's width and
|
|
9
|
+
* height, so the gap around it is the same at every size and in every
|
|
10
|
+
* state: the invalid state widens the border and the thumb shrinks with
|
|
11
|
+
* it.
|
|
12
|
+
*/
|
|
13
|
+
--_switch-track-border-width: 1px;
|
|
14
|
+
--_switch-track-inset: 2px;
|
|
15
|
+
--_switch-thumb-size: calc(
|
|
16
|
+
var(--_switch-track-height) -
|
|
17
|
+
2 *
|
|
18
|
+
var(--_switch-track-border-width) -
|
|
19
|
+
2 *
|
|
20
|
+
var(--_switch-track-inset)
|
|
21
|
+
);
|
|
22
|
+
--_switch-thumb-travel: calc(var(--_switch-track-width) - var(--_switch-track-height));
|
|
23
|
+
|
|
24
|
+
display: inline-flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
gap: var(--ds-switch-label-gap);
|
|
27
|
+
color: var(--ds-switch-label-text);
|
|
28
|
+
font-size: var(--_switch-font-size);
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
|
|
31
|
+
&[data-disabled] {
|
|
32
|
+
cursor: not-allowed;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&[data-readonly] {
|
|
36
|
+
cursor: default;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
& .ds-switch__control {
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
display: inline-flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
flex-shrink: 0;
|
|
44
|
+
width: var(--_switch-track-width);
|
|
45
|
+
height: var(--_switch-track-height);
|
|
46
|
+
padding: var(--_switch-track-inset);
|
|
47
|
+
border: var(--_switch-track-border-width) solid var(--ds-switch-track-border);
|
|
48
|
+
border-radius: var(--ds-switch-track-radius);
|
|
49
|
+
background-color: var(--ds-switch-track-bg);
|
|
50
|
+
transition:
|
|
51
|
+
background-color 150ms cubic-bezier(0, 0, 0.2, 1),
|
|
52
|
+
border-color 150ms cubic-bezier(0, 0, 0.2, 1);
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
* The border stays in the checked state. The checked fill is a brand
|
|
56
|
+
* colour that may not clear 3:1 against the page on its own (Manuia's
|
|
57
|
+
* olive does not in light), so the border is what bounds the track.
|
|
58
|
+
*/
|
|
59
|
+
&[data-state="checked"] {
|
|
60
|
+
background-color: var(--ds-switch-track-bg-checked);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
* Thicker as well as red, as on Select: colour alone is a weak signal on
|
|
65
|
+
* a control, and this one has to survive a red-green colour deficiency.
|
|
66
|
+
* Scoped above `checked` on purpose, so an invalid switch keeps saying
|
|
67
|
+
* so in either state.
|
|
68
|
+
*/
|
|
69
|
+
&[data-invalid] {
|
|
70
|
+
--_switch-track-border-width: 2px;
|
|
71
|
+
|
|
72
|
+
border-color: var(--ds-switch-track-border-invalid);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
* Ark moves focus to the hidden input and mirrors its `:focus-visible`
|
|
77
|
+
* onto the control as a data attribute, so the ring is drawn here, where
|
|
78
|
+
* the user is looking. Same ring as every control: 2px, 3px out.
|
|
79
|
+
*/
|
|
80
|
+
&[data-focus-visible] {
|
|
81
|
+
outline: 2px solid var(--ds-switch-focus-ring);
|
|
82
|
+
outline-offset: 3px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&[data-disabled] {
|
|
86
|
+
opacity: var(--ds-opacity-disabled);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* The thumb carries its own border. On the resting track it sits on a
|
|
92
|
+
* neighbouring neutral, where its fill alone is near-invisible, and the
|
|
93
|
+
* thumb's position is what says "off".
|
|
94
|
+
*/
|
|
95
|
+
& .ds-switch__thumb {
|
|
96
|
+
box-sizing: border-box;
|
|
97
|
+
width: var(--_switch-thumb-size);
|
|
98
|
+
height: var(--_switch-thumb-size);
|
|
99
|
+
border: 1px solid var(--ds-switch-thumb-border);
|
|
100
|
+
border-radius: var(--ds-switch-track-radius);
|
|
101
|
+
background-color: var(--ds-switch-thumb-bg);
|
|
102
|
+
box-shadow: var(--ds-switch-thumb-shadow);
|
|
103
|
+
transition: translate 150ms cubic-bezier(0, 0, 0.2, 1);
|
|
104
|
+
|
|
105
|
+
/*
|
|
106
|
+
* On the checked track the thumb's fill may not contrast with the fill
|
|
107
|
+
* behind it, so the border changes with the state. A product whose
|
|
108
|
+
* thumb already contrasts sets it to the thumb's own colour.
|
|
109
|
+
*/
|
|
110
|
+
&[data-state="checked"] {
|
|
111
|
+
border-color: var(--ds-switch-thumb-border-checked);
|
|
112
|
+
translate: var(--_switch-thumb-travel) 0;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@media (prefers-reduced-motion: reduce) {
|
|
117
|
+
& .ds-switch__control,
|
|
118
|
+
& .ds-switch__thumb {
|
|
119
|
+
transition: none;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&.ds-switch--sm {
|
|
124
|
+
--_switch-track-width: var(--ds-switch-size-sm-track-width);
|
|
125
|
+
--_switch-track-height: var(--ds-switch-size-sm-track-height);
|
|
126
|
+
--_switch-font-size: var(--ds-switch-size-sm-font-size);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&.ds-switch--md {
|
|
130
|
+
--_switch-track-width: var(--ds-switch-size-md-track-width);
|
|
131
|
+
--_switch-track-height: var(--ds-switch-size-md-track-height);
|
|
132
|
+
--_switch-font-size: var(--ds-switch-size-md-font-size);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
&.ds-switch--lg {
|
|
136
|
+
--_switch-track-width: var(--ds-switch-size-lg-track-width);
|
|
137
|
+
--_switch-track-height: var(--ds-switch-size-lg-track-height);
|
|
138
|
+
--_switch-font-size: var(--ds-switch-size-lg-font-size);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import './switch.css';
|
|
3
|
+
export type SwitchSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
export type SwitchLabelPlacement = 'start' | 'end';
|
|
5
|
+
/**
|
|
6
|
+
* A switch has to have a name. A visible `label` is the one to reach for: the
|
|
7
|
+
* whole label is the click target, so it also enlarges the hit area. Expressed
|
|
8
|
+
* as a union so an unnamed switch is a compile error rather than an axe
|
|
9
|
+
* finding, the way `IconProps` pairs label and decorative.
|
|
10
|
+
*/
|
|
11
|
+
type SwitchName = {
|
|
12
|
+
/** Visible label. The whole label is the click target. */
|
|
13
|
+
label: ReactNode;
|
|
14
|
+
'aria-label'?: string;
|
|
15
|
+
} | {
|
|
16
|
+
label?: undefined;
|
|
17
|
+
/** Accessible name when no visible label fits, such as a table cell whose row already says what the switch is. */
|
|
18
|
+
'aria-label': string;
|
|
19
|
+
};
|
|
20
|
+
export type SwitchProps = SwitchName & {
|
|
21
|
+
/**
|
|
22
|
+
* Which side of the control the label sits on. `end` (default) reads
|
|
23
|
+
* "control, then what it does"; `start` puts the label first, for a
|
|
24
|
+
* settings row. Only the order changes; the row's layout is the caller's.
|
|
25
|
+
*/
|
|
26
|
+
labelPlacement?: SwitchLabelPlacement;
|
|
27
|
+
/** Controlled checked state. Leave undefined to let the component own it. */
|
|
28
|
+
checked?: boolean;
|
|
29
|
+
/** Initial state when uncontrolled. */
|
|
30
|
+
defaultChecked?: boolean;
|
|
31
|
+
/** Fired with the new state whenever the user toggles the switch. */
|
|
32
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
33
|
+
/** Control size and label type scale. */
|
|
34
|
+
size?: SwitchSize;
|
|
35
|
+
/** Disable the control. It keeps its state and stops responding. */
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Marks the control invalid for assistive tech and styling (`data-invalid`).
|
|
39
|
+
* Pair it with a message the control points at through `aria-describedby`;
|
|
40
|
+
* a red border alone is not an accessible error.
|
|
41
|
+
*/
|
|
42
|
+
invalid?: boolean;
|
|
43
|
+
/** Id of the element that describes the control, such as an error message. */
|
|
44
|
+
'aria-describedby'?: string;
|
|
45
|
+
/** Show the state without letting the user change it. */
|
|
46
|
+
readOnly?: boolean;
|
|
47
|
+
/** Marks the hidden input required for native form validation. */
|
|
48
|
+
required?: boolean;
|
|
49
|
+
/** Name for native form participation. */
|
|
50
|
+
name?: string;
|
|
51
|
+
/** Value submitted under `name` while checked. Defaults to `on`. */
|
|
52
|
+
value?: string;
|
|
53
|
+
/** Extra class names appended after the `ds-switch` modifiers. */
|
|
54
|
+
className?: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* On/off control for a setting that takes effect at once, built on Ark UI.
|
|
58
|
+
*
|
|
59
|
+
* Ark owns the behaviour: a hidden checkbox carries the checked state, the
|
|
60
|
+
* root is the `<label>` that names it, and keyboard (Space) and pointer
|
|
61
|
+
* toggling come for free. The input is given `role="switch"` and
|
|
62
|
+
* `aria-readonly` here, which Ark leaves off, so it is announced as a switch
|
|
63
|
+
* rather than a checkbox, and a read-only one says so. This wrapper contributes `ds-`
|
|
64
|
+
* classes, the `--ds-switch-*` bindings, and a flat prop API.
|
|
65
|
+
*
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <Switch label="Gap view" checked={gapView} onCheckedChange={setGapView} />
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* A switch is for a setting that applies immediately. A choice that is only
|
|
71
|
+
* saved on submit is a checkbox; a choice between several values is a select
|
|
72
|
+
* or a segmented control.
|
|
73
|
+
*/
|
|
74
|
+
export declare function Switch({ label, labelPlacement, checked, defaultChecked, onCheckedChange, size, disabled, invalid, readOnly, required, name, value, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, }: SwitchProps): import("react/jsx-runtime").JSX.Element;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=switch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/switch/switch.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAU,MAAM,OAAO,CAAC;AAC/C,OAAO,cAAc,CAAC;AAGtB,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,KAAK,CAAC;AAEnD;;;;;GAKG;AACH,KAAK,UAAU,GACX;IACE,0DAA0D;IAC1D,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACD;IACE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,kHAAkH;IAClH,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEN,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IACrC;;;;OAIG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uCAAuC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qEAAqE;IACrE,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,yCAAyC;IACzC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8EAA8E;IAC9E,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,cAAsB,EACtB,OAAO,EACP,cAAc,EACd,eAAe,EACf,IAAW,EACX,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,SAAS,EACT,YAAY,EAAE,SAAS,EACvB,kBAAkB,EAAE,eAAe,GACpC,EAAE,WAAW,2CA+Cb"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Switch as ArkSwitch } from '@ark-ui/react/switch';
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
import './switch.css';
|
|
5
|
+
import { cx } from '../cx';
|
|
6
|
+
/**
|
|
7
|
+
* On/off control for a setting that takes effect at once, built on Ark UI.
|
|
8
|
+
*
|
|
9
|
+
* Ark owns the behaviour: a hidden checkbox carries the checked state, the
|
|
10
|
+
* root is the `<label>` that names it, and keyboard (Space) and pointer
|
|
11
|
+
* toggling come for free. The input is given `role="switch"` and
|
|
12
|
+
* `aria-readonly` here, which Ark leaves off, so it is announced as a switch
|
|
13
|
+
* rather than a checkbox, and a read-only one says so. This wrapper contributes `ds-`
|
|
14
|
+
* classes, the `--ds-switch-*` bindings, and a flat prop API.
|
|
15
|
+
*
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <Switch label="Gap view" checked={gapView} onCheckedChange={setGapView} />
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* A switch is for a setting that applies immediately. A choice that is only
|
|
21
|
+
* saved on submit is a checkbox; a choice between several values is a select
|
|
22
|
+
* or a segmented control.
|
|
23
|
+
*/
|
|
24
|
+
export function Switch({ label, labelPlacement = 'end', checked, defaultChecked, onCheckedChange, size = 'md', disabled, invalid, readOnly, required, name, value, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, }) {
|
|
25
|
+
const labelNode = label ? (_jsx(ArkSwitch.Label, { className: "ds-switch__label", children: label })) : null;
|
|
26
|
+
const inputRef = useRef(null);
|
|
27
|
+
/*
|
|
28
|
+
* Ark renders the hidden input uncontrolled (`defaultChecked`) and syncs it
|
|
29
|
+
* only when its own state changes. A controlled parent that declines a
|
|
30
|
+
* toggle therefore leaves the native input flipped while the control shows
|
|
31
|
+
* the old state, and assistive tech reads the input. Ark reports the toggle
|
|
32
|
+
* after reading the input, so restoring the parent's value here is safe:
|
|
33
|
+
* a parent that accepts re-renders, and Ark syncs the input again.
|
|
34
|
+
*/
|
|
35
|
+
const handleCheckedChange = (details) => {
|
|
36
|
+
onCheckedChange?.(details.checked);
|
|
37
|
+
if (checked !== undefined && inputRef.current)
|
|
38
|
+
inputRef.current.checked = checked;
|
|
39
|
+
};
|
|
40
|
+
return (_jsxs(ArkSwitch.Root, { className: cx('ds-switch', `ds-switch--${size}`, className), checked: checked, defaultChecked: defaultChecked, onCheckedChange: handleCheckedChange, disabled: disabled, invalid: invalid, readOnly: readOnly, required: required, name: name, value: value, children: [labelPlacement === 'start' && labelNode, _jsx(ArkSwitch.Control, { className: "ds-switch__control", children: _jsx(ArkSwitch.Thumb, { className: "ds-switch__thumb" }) }), labelPlacement === 'end' && labelNode, _jsx(ArkSwitch.HiddenInput, { ref: inputRef, role: "switch", "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, "aria-readonly": readOnly || undefined })] }));
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/switch/switch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAkB,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AA6D3B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,KAAK,EACL,cAAc,GAAG,KAAK,EACtB,OAAO,EACP,cAAc,EACd,eAAe,EACf,IAAI,GAAG,IAAI,EACX,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,SAAS,EACT,YAAY,EAAE,SAAS,EACvB,kBAAkB,EAAE,eAAe,GACvB;IACZ,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CACxB,KAAC,SAAS,CAAC,KAAK,IAAC,SAAS,EAAC,kBAAkB,YAAE,KAAK,GAAmB,CACxE,CAAC,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAEhD;;;;;;;OAOG;IACH,MAAM,mBAAmB,GAAG,CAAC,OAA6B,EAAE,EAAE;QAC5D,eAAe,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,OAAO,KAAK,SAAS,IAAI,QAAQ,CAAC,OAAO;YAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IACpF,CAAC,CAAC;IAEF,OAAO,CACL,MAAC,SAAS,CAAC,IAAI,IACb,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,cAAc,IAAI,EAAE,EAAE,SAAS,CAAC,EAC3D,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,mBAAmB,EACpC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,aAEX,cAAc,KAAK,OAAO,IAAI,SAAS,EACxC,KAAC,SAAS,CAAC,OAAO,IAAC,SAAS,EAAC,oBAAoB,YAC/C,KAAC,SAAS,CAAC,KAAK,IAAC,SAAS,EAAC,kBAAkB,GAAG,GAC9B,EACnB,cAAc,KAAK,KAAK,IAAI,SAAS,EACtC,KAAC,SAAS,CAAC,WAAW,IACpB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAC,QAAQ,gBACD,SAAS,sBACH,eAAe,mBAClB,QAAQ,IAAI,SAAS,GACpC,IACa,CAClB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manakind/ui-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -64,6 +64,10 @@
|
|
|
64
64
|
"types": "./dist/select/select.css.d.ts",
|
|
65
65
|
"default": "./dist/select/select.css"
|
|
66
66
|
},
|
|
67
|
+
"./css/switch": {
|
|
68
|
+
"types": "./dist/switch/switch.css.d.ts",
|
|
69
|
+
"default": "./dist/switch/switch.css"
|
|
70
|
+
},
|
|
67
71
|
"./css/tabs": {
|
|
68
72
|
"types": "./dist/tabs/tabs.css.d.ts",
|
|
69
73
|
"default": "./dist/tabs/tabs.css"
|
|
@@ -84,6 +88,10 @@
|
|
|
84
88
|
"types": "./dist/select/index.d.ts",
|
|
85
89
|
"import": "./dist/select/index.js"
|
|
86
90
|
},
|
|
91
|
+
"./switch": {
|
|
92
|
+
"types": "./dist/switch/index.d.ts",
|
|
93
|
+
"import": "./dist/switch/index.js"
|
|
94
|
+
},
|
|
87
95
|
"./tabs": {
|
|
88
96
|
"types": "./dist/tabs/index.d.ts",
|
|
89
97
|
"import": "./dist/tabs/index.js"
|
|
@@ -106,7 +114,7 @@
|
|
|
106
114
|
},
|
|
107
115
|
"devDependencies": {
|
|
108
116
|
"@manakind/ds-config": "*",
|
|
109
|
-
"@manakind/manuia-tokens": "0.
|
|
117
|
+
"@manakind/manuia-tokens": "0.4.0",
|
|
110
118
|
"@testing-library/jest-dom": "^6.9.1",
|
|
111
119
|
"@testing-library/react": "^16.3.2",
|
|
112
120
|
"@testing-library/user-event": "^14.6.1",
|