@plastic-js/tsumiki 0.1.59 → 0.1.61
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.
|
@@ -282,8 +282,8 @@ var Select = (props) => {
|
|
|
282
282
|
isSelected,
|
|
283
283
|
selectedItem,
|
|
284
284
|
setValue,
|
|
285
|
-
disabled: () => local.disabled ?? false,
|
|
286
|
-
invalid: () => local.invalid ?? false,
|
|
285
|
+
disabled: () => read(local.disabled) ?? false,
|
|
286
|
+
invalid: () => read(local.invalid) ?? false,
|
|
287
287
|
size: () => read(local.size),
|
|
288
288
|
variant: () => read(local.variant),
|
|
289
289
|
intent: () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, mergeProps } from "@plastic-js/plastic/jsx-runtime";
|
|
2
2
|
import { css } from "@emotion/css";
|
|
3
|
-
import { ToggleGroup } from "@plastic-js/ark";
|
|
3
|
+
import { ToggleGroup, useFieldContext } from "@plastic-js/ark";
|
|
4
4
|
import { mergeProps as mergeProps$2, splitProps } from "@plastic-js/plastic";
|
|
5
5
|
//#region src/components/ToggleGroup.jsx
|
|
6
6
|
var rootClass = css({
|
|
@@ -41,6 +41,7 @@ var intentClasses = {
|
|
|
41
41
|
default: css({ "--_tg-border": "var(--tsu-accent-solid-bg)" }),
|
|
42
42
|
neutral: css({ "--_tg-border": "var(--tsu-neutral-outline-border)" })
|
|
43
43
|
};
|
|
44
|
+
var errorClass = css({ "--_tg-border": "var(--tsu-danger-outline-border) !important" });
|
|
44
45
|
var sizeVars = {
|
|
45
46
|
xs: {
|
|
46
47
|
"--_tg-height": "var(--tsu-comp-height-xs)",
|
|
@@ -78,6 +79,7 @@ var sizeVars = {
|
|
|
78
79
|
"--_tg-radius": "var(--tsu-radius-l1-xl)"
|
|
79
80
|
}
|
|
80
81
|
};
|
|
82
|
+
var read = (v) => typeof v === "function" ? v() : v;
|
|
81
83
|
var ToggleGroupItem = (props = {}) => {
|
|
82
84
|
const [local, rest] = splitProps(props, ["className", "children"]);
|
|
83
85
|
return jsx(ToggleGroup.Item, mergeProps(rest, {
|
|
@@ -90,28 +92,34 @@ var ToggleGroupItem = (props = {}) => {
|
|
|
90
92
|
var ToggleGroup$1 = (props = {}) => {
|
|
91
93
|
const [local, rest] = splitProps(mergeProps$2({
|
|
92
94
|
size: "md",
|
|
93
|
-
intent: "default"
|
|
95
|
+
intent: "default",
|
|
96
|
+
invalid: false
|
|
94
97
|
}, props), [
|
|
95
98
|
"className",
|
|
96
99
|
"children",
|
|
97
100
|
"size",
|
|
98
101
|
"intent",
|
|
102
|
+
"invalid",
|
|
99
103
|
"style"
|
|
100
104
|
]);
|
|
105
|
+
const field = useFieldContext();
|
|
106
|
+
const fieldInvalid = () => field?.invalid?.() ?? false;
|
|
107
|
+
const effectiveInvalid = () => read(local.invalid) || fieldInvalid();
|
|
101
108
|
return jsx(ToggleGroup.Root, mergeProps(rest, {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
+
className: () => [
|
|
110
|
+
rootClass,
|
|
111
|
+
intentClasses[local.intent],
|
|
112
|
+
effectiveInvalid() && errorClass,
|
|
113
|
+
local.className
|
|
114
|
+
].filter(Boolean).join(" "),
|
|
109
115
|
get style() {
|
|
110
116
|
return {
|
|
111
117
|
...sizeVars[local.size],
|
|
112
118
|
...local.style
|
|
113
119
|
};
|
|
114
120
|
},
|
|
121
|
+
"aria-invalid": () => effectiveInvalid() ? "true" : "false",
|
|
122
|
+
"data-invalid": () => effectiveInvalid() ? "" : void 0,
|
|
115
123
|
children: () => local.children
|
|
116
124
|
}));
|
|
117
125
|
};
|