@snowui-design-system/components 0.3.0-alpha.15 → 0.3.0-alpha.16
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/client/blocks/SearchPopup.js +1 -1
- package/dist/client/blocks/Sidebar.d.ts +4 -0
- package/dist/client/blocks/Sidebar.js +692 -335
- package/dist/client/blocks/SidebarItem.js +50 -88
- package/dist/client/blocks/SidebarSection.js +1 -1
- package/dist/client/components/Avatar.d.ts +1 -0
- package/dist/client/components/Avatar.js +5 -0
- package/dist/client/components/Breadcrumb.js +1 -1
- package/dist/client/components/Button.js +108 -34
- package/dist/client/components/Checkbox.d.ts +3 -0
- package/dist/client/components/Checkbox.js +137 -91
- package/dist/client/components/Chip.js +1 -1
- package/dist/client/components/CodeBlock.js +1 -1
- package/dist/client/components/ColorSchemeButton.d.ts +4 -1
- package/dist/client/components/ColorSchemeButton.js +30 -5
- package/dist/client/components/CopyButton.js +15 -10
- package/dist/client/components/DataTable.js +40 -5
- package/dist/client/components/Dialog.js +1 -1
- package/dist/client/components/Field.js +1 -1
- package/dist/client/components/Frame.js +4 -2
- package/dist/client/components/Input.js +135 -61
- package/dist/client/components/Link.js +11 -16
- package/dist/client/components/Listbox.d.ts +1 -1
- package/dist/client/components/Listbox.js +3 -1
- package/dist/client/components/MetricCard.js +22 -5
- package/dist/client/components/OTPInput.js +24 -5
- package/dist/client/components/Pagination.js +225 -208
- package/dist/client/components/Radio.d.ts +3 -0
- package/dist/client/components/Radio.js +156 -112
- package/dist/client/components/SearchBox.js +1 -1
- package/dist/client/components/SearchInput.js +2 -1
- package/dist/client/components/Select.js +345 -298
- package/dist/client/components/SelectButton.js +2 -1
- package/dist/client/components/SidePanel.js +3 -1
- package/dist/client/components/Skeleton.d.ts +2 -0
- package/dist/client/components/Skeleton.js +115 -20
- package/dist/client/components/Slider.js +1 -1
- package/dist/client/components/Switch.d.ts +3 -0
- package/dist/client/components/Switch.js +126 -87
- package/dist/client/components/Tab.js +1 -1
- package/dist/client/components/Table.js +1 -1
- package/dist/client/components/TableBody.js +43 -10
- package/dist/client/components/TableHead.js +96 -67
- package/dist/client/components/TableToolbar.js +20 -16
- package/dist/client/components/Tag.js +2 -0
- package/dist/client/components/Textarea.d.ts +1 -0
- package/dist/client/components/Textarea.js +281 -207
- package/dist/client/components/Toast.js +14 -6
- package/dist/client/components/Tooltip.js +1 -1
- package/dist/client/i18n/messages.d.ts +1 -1
- package/dist/client/i18n/messages.js +4 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -0
- package/dist/client/lib/chart/ChartHoverPanel.js +1 -1
- package/dist/client/lib/number-format.d.ts +1 -1
- package/dist/client/lib/number-format.js +1 -1
- package/dist/client/lib/table-context.d.ts +1 -0
- package/dist/client/lib/table-context.js +1 -0
- package/dist/client/logic/RequiredFeedback.d.ts +10 -0
- package/dist/client/logic/RequiredFeedback.js +71 -0
- package/dist/client/logic/color-scheme-preference.d.ts +5 -0
- package/dist/client/logic/color-scheme-preference.js +46 -0
- package/dist/client/logic/content-line.js +1 -1
- package/dist/client/logic/frame-inline-style.d.ts +1 -0
- package/dist/client/logic/frame-inline-style.js +1 -0
- package/dist/client/logic/frame-responsive.js +10 -8
- package/dist/client/logic/native-validation.d.ts +5 -0
- package/dist/client/logic/native-validation.js +60 -0
- package/dist/client/logic/required-feedback.d.ts +1 -0
- package/dist/client/logic/required-feedback.js +61 -0
- package/dist/client/motion/presets/effects.d.ts +1 -0
- package/dist/client/motion/presets/effects.js +12 -1
- package/dist/client/motion/presets/input-required.d.ts +2 -0
- package/dist/client/motion/presets/input-required.js +14 -0
- package/dist/client/motion/presets/sidebar-drawer.d.ts +1 -0
- package/dist/client/motion/presets/sidebar-drawer.js +13 -0
- package/dist/client/styles/auto-layout.css +6 -1
- package/dist/client/styles/backdrop.css +1 -1
- package/dist/client/styles/components.css +7 -2
- package/dist/client/styles/layout.css +20 -1
- package/dist/server/blocks/SearchPopup.js +1 -0
- package/dist/server/blocks/Sidebar.d.ts +4 -0
- package/dist/server/blocks/Sidebar.js +278 -24
- package/dist/server/blocks/SidebarItem.js +23 -47
- package/dist/server/blocks/SidebarSection.js +1 -1
- package/dist/server/components/Avatar.d.ts +1 -0
- package/dist/server/components/Avatar.js +5 -0
- package/dist/server/components/Breadcrumb.js +1 -1
- package/dist/server/components/Button.js +58 -6
- package/dist/server/components/Checkbox.d.ts +3 -0
- package/dist/server/components/Checkbox.js +70 -44
- package/dist/server/components/Chip.js +1 -1
- package/dist/server/components/CodeBlock.js +1 -1
- package/dist/server/components/ColorSchemeButton.d.ts +4 -1
- package/dist/server/components/ColorSchemeButton.js +18 -5
- package/dist/server/components/CopyButton.js +1 -0
- package/dist/server/components/DataTable.js +30 -2
- package/dist/server/components/Dialog.js +1 -1
- package/dist/server/components/Field.js +1 -1
- package/dist/server/components/Frame.js +4 -2
- package/dist/server/components/Input.js +82 -29
- package/dist/server/components/Link.js +3 -3
- package/dist/server/components/Listbox.d.ts +1 -1
- package/dist/server/components/Listbox.js +3 -1
- package/dist/server/components/MetricCard.js +13 -4
- package/dist/server/components/OTPInput.js +22 -5
- package/dist/server/components/Pagination.js +139 -129
- package/dist/server/components/Radio.d.ts +3 -0
- package/dist/server/components/Radio.js +79 -51
- package/dist/server/components/SearchBox.js +1 -1
- package/dist/server/components/SearchInput.js +2 -1
- package/dist/server/components/Select.js +164 -139
- package/dist/server/components/SelectButton.js +2 -1
- package/dist/server/components/SidePanel.js +3 -1
- package/dist/server/components/Skeleton.d.ts +2 -0
- package/dist/server/components/Skeleton.js +62 -4
- package/dist/server/components/Slider.js +1 -1
- package/dist/server/components/Switch.d.ts +3 -0
- package/dist/server/components/Switch.js +61 -41
- package/dist/server/components/Tab.js +1 -1
- package/dist/server/components/Table.js +1 -1
- package/dist/server/components/TableBody.js +12 -1
- package/dist/server/components/TableHead.js +67 -45
- package/dist/server/components/TableToolbar.js +21 -15
- package/dist/server/components/Tag.js +2 -0
- package/dist/server/components/Textarea.d.ts +1 -0
- package/dist/server/components/Textarea.js +57 -8
- package/dist/server/components/Toast.js +3 -2
- package/dist/server/components/Tooltip.js +1 -1
- package/dist/server/i18n/messages.d.ts +1 -1
- package/dist/server/i18n/messages.js +4 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/lib/chart/ChartHoverPanel.js +1 -1
- package/dist/server/lib/number-format.d.ts +1 -1
- package/dist/server/lib/number-format.js +1 -1
- package/dist/server/lib/table-context.d.ts +1 -0
- package/dist/server/lib/table-context.js +1 -0
- package/dist/server/logic/RequiredFeedback.d.ts +10 -0
- package/dist/server/logic/RequiredFeedback.js +45 -0
- package/dist/server/logic/color-scheme-preference.d.ts +5 -0
- package/dist/server/logic/color-scheme-preference.js +46 -0
- package/dist/server/logic/content-line.js +1 -1
- package/dist/server/logic/frame-inline-style.d.ts +1 -0
- package/dist/server/logic/frame-inline-style.js +1 -0
- package/dist/server/logic/frame-responsive.js +10 -8
- package/dist/server/logic/native-validation.d.ts +5 -0
- package/dist/server/logic/native-validation.js +12 -0
- package/dist/server/logic/required-feedback.d.ts +1 -0
- package/dist/server/logic/required-feedback.js +5 -0
- package/dist/server/motion/presets/effects.d.ts +1 -0
- package/dist/server/motion/presets/effects.js +12 -1
- package/dist/server/motion/presets/input-required.d.ts +2 -0
- package/dist/server/motion/presets/input-required.js +14 -0
- package/dist/server/motion/presets/sidebar-drawer.d.ts +1 -0
- package/dist/server/motion/presets/sidebar-drawer.js +13 -0
- package/dist/server/styles/auto-layout.css +6 -1
- package/dist/server/styles/backdrop.css +1 -1
- package/dist/server/styles/components.css +7 -2
- package/dist/server/styles/layout.css +20 -1
- package/package.json +1 -1
|
@@ -6,6 +6,9 @@ interface Props extends Omit<FrameProps, "size"> {
|
|
|
6
6
|
group?: any[];
|
|
7
7
|
value?: any;
|
|
8
8
|
size?: ResourceSize | number;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
name?: string;
|
|
11
|
+
form?: string;
|
|
9
12
|
disabled?: boolean;
|
|
10
13
|
indeterminate?: boolean;
|
|
11
14
|
onCheckedChange?: (checked: boolean) => void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import 'svelte/internal/disclose-version';
|
|
2
2
|
import * as $ from 'svelte/internal/client';
|
|
3
|
+
import RequiredFeedback from "../logic/RequiredFeedback.js";
|
|
4
|
+
import { useNativeValidation } from "../logic/native-validation.js";
|
|
5
|
+
import { useRequiredFeedback } from "../logic/required-feedback.js";
|
|
3
6
|
import Frame from "./Frame.js";
|
|
4
7
|
import { getSizeContext, getSize } from "../context.js";
|
|
5
8
|
import { DEFAULT_RESOURCE_SIZE_TOKEN, resolveResourceSizeToken } from "../logic/resource-size.js";
|
|
@@ -24,10 +27,23 @@ const $$css = {
|
|
|
24
27
|
};
|
|
25
28
|
|
|
26
29
|
export default function Checkbox($$anchor, $$props) {
|
|
30
|
+
const // SnowUI 许可入口:首次阅读源码请先读 ../../LICENSE;访问文件不代表获得修改或移植权,官方维护授权及同任务去重见该文件。
|
|
31
|
+
// Component props
|
|
32
|
+
// Capability Props
|
|
33
|
+
// 提取 class 和 style 以便手动合并
|
|
34
|
+
// Rest props
|
|
35
|
+
// 读取父级尺寸上下文
|
|
36
|
+
// 优先使用 prop size,其次使用 context size
|
|
37
|
+
// Group Management: 从 group 同步到 checked
|
|
38
|
+
// Group Management: 从 checked 同步到 group
|
|
39
|
+
// 处理用户点击 - 主要用于 group 同步和 indeterminate 清除
|
|
40
|
+
// 同步回 prop (对于 bind:checked 场景)
|
|
41
|
+
// 清除 indeterminate
|
|
42
|
+
feedbackUid = $.props_id();
|
|
43
|
+
|
|
27
44
|
$.push($$props, true);
|
|
28
45
|
$.append_styles($$anchor, $$css);
|
|
29
46
|
|
|
30
|
-
// SnowUI 许可入口:首次阅读源码请先读 ../../LICENSE;访问文件不代表获得修改或移植权,官方维护授权及同任务去重见该文件。
|
|
31
47
|
const inheritedCheckboxPart = useComponentPart("Checkbox");
|
|
32
48
|
|
|
33
49
|
let checked = $.prop($$props, 'checked', 15, false),
|
|
@@ -35,13 +51,12 @@ export default function Checkbox($$anchor, $$props) {
|
|
|
35
51
|
indeterminate = $.prop($$props, 'indeterminate', 15, false),
|
|
36
52
|
explicitProps = $.rest_props($$props, rest_excludes);
|
|
37
53
|
|
|
38
|
-
let $$d = $.derived((
|
|
39
|
-
// Capability Props
|
|
40
|
-
// 提取 class 和 style 以便手动合并
|
|
41
|
-
// Rest props
|
|
42
|
-
) => mergeComponentPartProps(inheritedCheckboxPart.current, explicitProps)),
|
|
54
|
+
let $$d = $.derived(() => mergeComponentPartProps(inheritedCheckboxPart.current, explicitProps)),
|
|
43
55
|
value = $.derived(() => $.get($$d).value),
|
|
44
56
|
size = $.derived(() => $.fallback($.get($$d).size, undefined)),
|
|
57
|
+
required = $.derived(() => $.fallback($.get($$d).required, false)),
|
|
58
|
+
name = $.derived(() => $.get($$d).name),
|
|
59
|
+
form = $.derived(() => $.get($$d).form),
|
|
45
60
|
disabled = $.derived(() => $.fallback($.get($$d).disabled, false)),
|
|
46
61
|
onCheckedChange = $.derived(() => $.get($$d).onCheckedChange),
|
|
47
62
|
ariaLabel = $.derived(() => $.fallback($.get($$d).ariaLabel, undefined)),
|
|
@@ -56,6 +71,9 @@ export default function Checkbox($$anchor, $$props) {
|
|
|
56
71
|
rest = $.derived(() => $.exclude_from_object($.get($$d), [
|
|
57
72
|
'value',
|
|
58
73
|
'size',
|
|
74
|
+
'required',
|
|
75
|
+
'name',
|
|
76
|
+
'form',
|
|
59
77
|
'disabled',
|
|
60
78
|
'onCheckedChange',
|
|
61
79
|
'ariaLabel',
|
|
@@ -69,15 +87,11 @@ export default function Checkbox($$anchor, $$props) {
|
|
|
69
87
|
'renderHints'
|
|
70
88
|
]));
|
|
71
89
|
|
|
72
|
-
// 读取父级尺寸上下文
|
|
73
90
|
getSize();
|
|
74
91
|
|
|
75
92
|
const sizeCtx = getSizeContext();
|
|
76
93
|
const contextSize = $.derived(() => sizeCtx?.iconSize !== undefined ? sizeCtx.iconSize : sizeCtx?.size);
|
|
77
|
-
|
|
78
|
-
// 优先使用 prop size,其次使用 context size
|
|
79
94
|
const resolvedSize = $.derived(() => $.get(size) ?? $.get(contextSize) ?? 16);
|
|
80
|
-
|
|
81
95
|
const resolvedSizeToken = $.derived(() => resolveResourceSizeToken($.get(resolvedSize)));
|
|
82
96
|
const DEFAULT_CHECKBOX_SIZE_TOKEN = DEFAULT_RESOURCE_SIZE_TOKEN;
|
|
83
97
|
|
|
@@ -100,7 +114,6 @@ export default function Checkbox($$anchor, $$props) {
|
|
|
100
114
|
radius: $.get(userRenderHints)?.radius ?? `calc(${$.get(resolvedSizeToken)} * 0.3125)`
|
|
101
115
|
}));
|
|
102
116
|
|
|
103
|
-
// Group Management: 从 group 同步到 checked
|
|
104
117
|
$.user_effect(() => {
|
|
105
118
|
if (group() !== undefined) {
|
|
106
119
|
if (Array.isArray(group())) {
|
|
@@ -137,95 +150,128 @@ export default function Checkbox($$anchor, $$props) {
|
|
|
137
150
|
}
|
|
138
151
|
}
|
|
139
152
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
153
|
+
let inputRef = $.state(void 0);
|
|
154
|
+
let feedbackSurface = $.state(void 0);
|
|
155
|
+
const feedbackId = `snowui-required-${feedbackUid}`;
|
|
156
|
+
const nativeValidation = useNativeValidation(() => $.get(inputRef));
|
|
143
157
|
|
|
144
|
-
|
|
145
|
-
{
|
|
146
|
-
tag: 'label',
|
|
147
|
-
get singleLine() {
|
|
148
|
-
return $.get(singleLine);
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
get class() {
|
|
152
|
-
return $.get($0);
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
get 'data-disabled'() {
|
|
156
|
-
return $.get($1);
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
get disabled() {
|
|
160
|
-
return $.get(disabled);
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
get style() {
|
|
164
|
-
return $.get(checkboxRootStyle);
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
get enableResponsive() {
|
|
168
|
-
return $.get(enableResponsive);
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
get enableContext() {
|
|
172
|
-
return $.get(enableContext);
|
|
173
|
-
},
|
|
174
|
-
enableScaleObserver: false,
|
|
175
|
-
get renderHints() {
|
|
176
|
-
return $.get(checkboxRenderHints);
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
() => $.get(rest),
|
|
180
|
-
{
|
|
181
|
-
children: ($$anchor, $$slotProps) => {
|
|
182
|
-
var fragment_1 = root_1();
|
|
183
|
-
var span = $.first_child(fragment_1);
|
|
184
|
-
var input = $.child(span);
|
|
158
|
+
useRequiredFeedback(() => $.get(inputRef), () => $.get(feedbackSurface));
|
|
185
159
|
|
|
186
|
-
|
|
160
|
+
RequiredFeedback($$anchor, {
|
|
161
|
+
get enabled() {
|
|
162
|
+
return $.get(required);
|
|
163
|
+
},
|
|
187
164
|
|
|
188
|
-
|
|
165
|
+
get message() {
|
|
166
|
+
return nativeValidation.message;
|
|
167
|
+
},
|
|
189
168
|
|
|
190
|
-
|
|
191
|
-
|
|
169
|
+
get id() {
|
|
170
|
+
return feedbackId;
|
|
171
|
+
},
|
|
192
172
|
|
|
193
|
-
|
|
173
|
+
children: ($$anchor, $$slotProps) => {
|
|
174
|
+
{
|
|
175
|
+
let $0 = $.derived(() => `snowui-checkbox${$.get(userClass) ? ` ${$.get(userClass)}` : ""}`);
|
|
176
|
+
let $1 = $.derived(() => $.get(disabled) ? "true" : undefined);
|
|
194
177
|
|
|
178
|
+
Frame($$anchor, $.spread_props(
|
|
195
179
|
{
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
$.
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
180
|
+
tag: 'label',
|
|
181
|
+
get singleLine() {
|
|
182
|
+
return $.get(singleLine);
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
get class() {
|
|
186
|
+
return $.get($0);
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
get 'data-disabled'() {
|
|
190
|
+
return $.get($1);
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
get disabled() {
|
|
194
|
+
return $.get(disabled);
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
get style() {
|
|
198
|
+
return $.get(checkboxRootStyle);
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
get enableResponsive() {
|
|
202
|
+
return $.get(enableResponsive);
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
get enableContext() {
|
|
206
|
+
return $.get(enableContext);
|
|
207
|
+
},
|
|
208
|
+
enableScaleObserver: false,
|
|
209
|
+
get renderHints() {
|
|
210
|
+
return $.get(checkboxRenderHints);
|
|
217
211
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
212
|
+
},
|
|
213
|
+
() => $.get(rest),
|
|
214
|
+
{
|
|
215
|
+
children: ($$anchor, $$slotProps) => {
|
|
216
|
+
var fragment_2 = root_1();
|
|
217
|
+
var span = $.first_child(fragment_2);
|
|
218
|
+
var input = $.child(span);
|
|
219
|
+
|
|
220
|
+
$.remove_input_defaults(input);
|
|
221
|
+
$.bind_this(input, ($$value) => $.set(inputRef, $$value), () => $.get(inputRef));
|
|
222
|
+
|
|
223
|
+
var input_value;
|
|
224
|
+
var span_1 = $.sibling(input, 2);
|
|
225
|
+
|
|
226
|
+
$.bind_this(span_1, ($$value) => $.set(feedbackSurface, $$value), () => $.get(feedbackSurface));
|
|
227
|
+
$.reset(span);
|
|
228
|
+
|
|
229
|
+
var node = $.sibling(span, 2);
|
|
230
|
+
|
|
231
|
+
{
|
|
232
|
+
var consequent = ($$anchor) => {
|
|
233
|
+
var span_2 = root();
|
|
234
|
+
var node_1 = $.child(span_2);
|
|
235
|
+
|
|
236
|
+
$.snippet(node_1, () => $.get(children));
|
|
237
|
+
$.reset(span_2);
|
|
238
|
+
$.append($$anchor, span_2);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
$.if(node, ($$render) => {
|
|
242
|
+
if ($.get(children)) $$render(consequent);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
$.template_effect(() => {
|
|
247
|
+
input.required = $.get(required);
|
|
248
|
+
$.set_attribute(input, 'name', $.get(name));
|
|
249
|
+
$.set_attribute(input, 'form', $.get(form));
|
|
250
|
+
$.set_attribute(input, 'aria-invalid', nativeValidation.message ? "true" : undefined);
|
|
251
|
+
$.set_attribute(input, 'aria-describedby', nativeValidation.message ? feedbackId : undefined);
|
|
252
|
+
input.disabled = $.get(disabled);
|
|
253
|
+
$.set_attribute(input, 'tabindex', $.get(disabled) ? -1 : 0);
|
|
254
|
+
$.set_attribute(input, 'aria-label', $.get(ariaLabel));
|
|
255
|
+
|
|
256
|
+
if (input_value !== (input_value = $.get(value))) {
|
|
257
|
+
input.value = (input.__value = $.get(value)) ?? '';
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
$.set_attribute(span_1, 'data-required-invalid', nativeValidation.message ? "true" : undefined);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
$.delegated('change', input, handleChange);
|
|
264
|
+
$.bind_checked(input, checked);
|
|
265
|
+
$.bind_property('indeterminate', 'change', input, indeterminate, indeterminate);
|
|
266
|
+
$.append($$anchor, fragment_2);
|
|
267
|
+
},
|
|
268
|
+
$$slots: { default: true }
|
|
269
|
+
}
|
|
270
|
+
));
|
|
226
271
|
}
|
|
227
|
-
|
|
228
|
-
|
|
272
|
+
},
|
|
273
|
+
$$slots: { default: true }
|
|
274
|
+
});
|
|
229
275
|
|
|
230
276
|
$.pop();
|
|
231
277
|
}
|
|
@@ -19,7 +19,7 @@ var root_1 = $.from_html(`<!> <!>`, 1);
|
|
|
19
19
|
|
|
20
20
|
const $$css = {
|
|
21
21
|
hash: 'svelte-1eqf306',
|
|
22
|
-
code: '\n /* Level 2: 组件基类(specificity = 0) */:where(.snowui-chip) {--snowui-chip-font-size: var(--text-12);--snowui-chip-line-height: var(--leading-12);--snowui-chip-gap:
|
|
22
|
+
code: '\n /* Level 2: 组件基类(specificity = 0) */:where(.snowui-chip) {--snowui-chip-font-size: var(--text-12);--snowui-chip-line-height: var(--leading-12);--snowui-chip-gap: 0px;--snowui-chip-icon-size: calc(var(--size-4) * 3 / 4); /* 12px */--snowui-chip-padding: 0;--snowui-chip-radius: 0;--snowui-chip-bg: transparent;\n /* 描边使用 inset box-shadow,避免占用布局空间且与背景共享圆角 */--snowui-chip-shadow: none;display:inline-flex;flex:0 0 auto;flex-wrap:nowrap;align-items:center;width:max-content;max-width:100%;min-width:0;box-sizing:border-box;color:inherit;font-size:var(\n --snowui-chip-font-size-override,\n var(--snowui-chip-font-size)\n );line-height:var(\n --snowui-chip-line-height-override,\n var(--snowui-chip-line-height)\n );\n /* Shared capability: singleLine; LayoutProtocol §4.6 registers Chip as a zero-gap exception. */gap:var(--snowui-chip-gap-override, var(--snowui-chip-gap));padding:var(\n --snowui-chip-padding-override,\n var(--snowui-chip-padding)\n );border-radius:var(\n --snowui-chip-radius-override,\n var(--snowui-chip-radius)\n );background-color:var(\n --snowui-chip-background-override,\n var(--snowui-chip-bg)\n );box-shadow:var(\n --snowui-chip-shadow-override,\n var(--snowui-chip-shadow)\n );white-space:nowrap;--snowui-frame-component-transition:\n background-color\n var(--snowui-frame-color-motion-duration, 0.15s)\n var(--snowui-frame-color-motion-easing, ease-out),\n box-shadow var(--snowui-frame-color-motion-duration, 0.15s)\n var(--snowui-frame-color-motion-easing, ease-out),\n color var(--snowui-frame-color-motion-duration, 0.15s)\n var(--snowui-frame-color-motion-easing, ease-out);}\n\n /* Level 4: 尺寸档位(仅更新变量) */:where(.snowui-chip).snowui-chip-lg {--snowui-chip-font-size: var(--text-14);--snowui-chip-line-height: var(--leading-14);--snowui-chip-icon-size: var(--size-4); /* 16px */}\n\n /* Level 4: background 变体 — 文字色派生背景与边框,胶囊圆角 */:where(.snowui-chip).snowui-chip-background {--snowui-chip-padding: 2px var(--padding-2);--snowui-chip-radius: 9999px;--snowui-chip-bg: color-mix(in srgb, currentColor 10%, transparent);--snowui-chip-shadow: inset 0 0 0 0.5px\n color-mix(in srgb, currentColor 20%, transparent);}\n :where(.snowui-chip).snowui-chip-background.snowui-chip-lg\n {--snowui-chip-padding: var(--padding-1) var(--padding-3);}\n\n /* background 变体中,有图标的一侧按尺寸收紧:sm 4px,lg 8px。 */\n :where(.snowui-chip).snowui-chip-background[data-edge-left="icon"]\n {padding-left:var(--padding-1);}\n :where(.snowui-chip).snowui-chip-background[data-edge-right="icon"]\n {padding-right:var(--padding-1);}\n :where(.snowui-chip).snowui-chip-background.snowui-chip-lg[data-edge-left="icon"]\n {padding-left:var(--padding-2);}\n :where(.snowui-chip).snowui-chip-background.snowui-chip-lg[data-edge-right="icon"]\n {padding-right:var(--padding-2);}\n\n /* 内置默认 Dot 图标 */:where(.snowui-chip-default-icon) {display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:var(--snowui-chip-icon-size);height:var(--snowui-chip-icon-size);color:inherit;}:where(.snowui-chip-default-icon) > svg {width:100%;height:100%;display:block;}'
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export default function Chip($$anchor, $$props) {
|
|
@@ -59,7 +59,7 @@ var root_17 = $.from_html(`<div class="snowui-code-block-toolbar snowui-code-blo
|
|
|
59
59
|
|
|
60
60
|
const $$css = {
|
|
61
61
|
hash: 'svelte-ipr7k2',
|
|
62
|
-
code: '\n /* ─── Level 2:组件基类(降权 0,0,0) ─── */:where(.snowui-code-block) {--snowui-code-block-bg: var(--background-2, #f9f9fa);--snowui-code-block-fg: var(--black-100, #000000ff);--snowui-code-block-muted-fg: var(--black-40, #00000066);--snowui-code-block-gutter-fg: var(--black-20, #00000033);--snowui-code-block-btn-fg: var(--black-100, #000000ff);--snowui-code-block-keyword-fg: #ff32c6;--snowui-code-block-function-fg: #ffac60;--snowui-code-block-property-fg: #1ac69c;--snowui-code-block-string-fg: #3fa4ff;--snowui-code-block-variable-fg: #c478ff;--snowui-code-block-radius: var(--radius-4);--snowui-code-block-padding-x: var(--padding-5);--snowui-code-block-padding-y: var(--padding-5);--snowui-code-block-gap: var(--gap-2);--snowui-code-block-code-gap: var(--gap-3);--snowui-code-block-footer-height: var(--padding-3);--snowui-code-block-font-size: var(--text-12);--snowui-code-block-line-height: var(--leading-12);--snowui-code-block-font-family: inherit;--snowui-code-block-visible-lines: 5;--snowui-code-block-content-height: calc(\n var(--snowui-code-block-visible-lines) * 1lh\n );background-color:var(\n --snowui-code-block-bg-override,\n var(--snowui-code-block-bg)\n );color:var(\n --snowui-code-block-fg-override,\n var(--snowui-code-block-fg)\n );border-radius:var(\n --snowui-code-block-radius-override,\n var(--snowui-code-block-radius)\n );padding:var(\n --snowui-code-block-padding-override,\n var(\n --snowui-code-block-padding-y-override,\n var(--snowui-code-block-padding-y)\n )\n var(\n --snowui-code-block-padding-x-override,\n var(--snowui-code-block-padding-x)\n )\n );font-size:var(--snowui-code-block-font-size);line-height:var(--snowui-code-block-line-height);font-family:var(--snowui-code-block-font-family);overflow:hidden;position:relative;width:100%;}:where(.snowui-code-block[data-variant="default"]) {display:flex;flex-direction:column;gap:var(--gap-2);}\n\n /* singleLine:沿用 Input 的 Leading / Content / Trailing 三槽结构。 */:where(.snowui-code-block[data-variant="singleLine"]) {--snowui-code-block-padding-x: var(--padding-4);--snowui-code-block-padding-y: var(--padding-3);gap:max(4px, var(\n --snowui-code-block-gap-override,\n var(--snowui-code-block-gap)\n ));box-sizing:border-box;height:auto;}:where(.snowui-code-block-single-line-content) {grid-row:1;min-width:0;overflow-x:auto;overflow-y:hidden;white-space:nowrap;scrollbar-width:none;}:where(.snowui-code-block-single-line-content::-webkit-scrollbar) {display:none;}\n :where(\n .snowui-code-block[data-variant="singleLine"]\n > [data-as="leading"],\n .snowui-code-block[data-variant="singleLine"]\n > [data-as="trailing"]\n )\n {display:inline-flex;align-items:center;justify-content:center;min-width:0;white-space:nowrap;line-height:inherit;}:where(.snowui-code-block-fullscreen) {--snowui-code-block-bg: var(--background-2, #f9f9fa);--snowui-code-block-fg: var(--black-100, #000000ff);--snowui-code-block-muted-fg: var(--black-40, #00000066);--snowui-code-block-gutter-fg: var(--black-20, #00000033);--snowui-code-block-btn-fg: var(--black-100, #000000ff);--snowui-code-block-radius: var(--radius-4);--snowui-code-block-padding-x: var(--padding-5);--snowui-code-block-padding-y: var(--padding-5);--snowui-code-block-gap: var(--gap-2);--snowui-code-block-code-gap: var(--gap-3);--snowui-code-block-footer-height: var(--padding-3);--snowui-code-block-font-size: var(--text-12);--snowui-code-block-line-height: var(--leading-12);--snowui-code-block-font-family: inherit;--snowui-code-block-content-height: 5lh;}\n\n /* ─── 工具栏 ─── */:where(.snowui-code-block-toolbar) {display:flex;align-items:center;justify-content:space-between;gap:max(4px, var(--gap-2));max-width:calc(100% - var(--size-3));padding:var(--padding-1) var(--padding-2);border-radius:var(--radius-2);isolation:isolate;z-index:3;}\n\n /* 模糊层与工具栏同尺寸,只影响其后方内容。 */:where(.snowui-code-block-toolbar)::before {content:"";position:absolute;inset:0;border-radius:inherit
|
|
62
|
+
code: '\n /* ─── Level 2:组件基类(降权 0,0,0) ─── */:where(.snowui-code-block) {--snowui-code-block-bg: var(--background-2, #f9f9fa);--snowui-code-block-fg: var(--black-100, #000000ff);--snowui-code-block-muted-fg: var(--black-40, #00000066);--snowui-code-block-gutter-fg: var(--black-20, #00000033);--snowui-code-block-btn-fg: var(--black-100, #000000ff);--snowui-code-block-keyword-fg: #ff32c6;--snowui-code-block-function-fg: #ffac60;--snowui-code-block-property-fg: #1ac69c;--snowui-code-block-string-fg: #3fa4ff;--snowui-code-block-variable-fg: #c478ff;--snowui-code-block-radius: var(--radius-4);--snowui-code-block-padding-x: var(--padding-5);--snowui-code-block-padding-y: var(--padding-5);--snowui-code-block-gap: var(--gap-2);--snowui-code-block-code-gap: var(--gap-3);--snowui-code-block-footer-height: var(--padding-3);--snowui-code-block-font-size: var(--text-12);--snowui-code-block-line-height: var(--leading-12);--snowui-code-block-font-family: inherit;--snowui-code-block-visible-lines: 5;--snowui-code-block-content-height: calc(\n var(--snowui-code-block-visible-lines) * 1lh\n );background-color:var(\n --snowui-code-block-bg-override,\n var(--snowui-code-block-bg)\n );color:var(\n --snowui-code-block-fg-override,\n var(--snowui-code-block-fg)\n );border-radius:var(\n --snowui-code-block-radius-override,\n var(--snowui-code-block-radius)\n );padding:var(\n --snowui-code-block-padding-override,\n var(\n --snowui-code-block-padding-y-override,\n var(--snowui-code-block-padding-y)\n )\n var(\n --snowui-code-block-padding-x-override,\n var(--snowui-code-block-padding-x)\n )\n );font-size:var(--snowui-code-block-font-size);line-height:var(--snowui-code-block-line-height);font-family:var(--snowui-code-block-font-family);overflow:hidden;position:relative;width:100%;}:where(.snowui-code-block[data-variant="default"]) {display:flex;flex-direction:column;gap:var(--gap-2);}\n\n /* singleLine:沿用 Input 的 Leading / Content / Trailing 三槽结构。 */:where(.snowui-code-block[data-variant="singleLine"]) {--snowui-code-block-padding-x: var(--padding-4);--snowui-code-block-padding-y: var(--padding-3);gap:max(4px, var(\n --snowui-code-block-gap-override,\n var(--snowui-code-block-gap)\n ));box-sizing:border-box;height:auto;}:where(.snowui-code-block-single-line-content) {grid-row:1;min-width:0;overflow-x:auto;overflow-y:hidden;white-space:nowrap;scrollbar-width:none;}:where(.snowui-code-block-single-line-content::-webkit-scrollbar) {display:none;}\n :where(\n .snowui-code-block[data-variant="singleLine"]\n > [data-as="leading"],\n .snowui-code-block[data-variant="singleLine"]\n > [data-as="trailing"]\n )\n {display:inline-flex;align-items:center;justify-content:center;min-width:0;white-space:nowrap;line-height:inherit;}:where(.snowui-code-block-fullscreen) {--snowui-code-block-bg: var(--background-2, #f9f9fa);--snowui-code-block-fg: var(--black-100, #000000ff);--snowui-code-block-muted-fg: var(--black-40, #00000066);--snowui-code-block-gutter-fg: var(--black-20, #00000033);--snowui-code-block-btn-fg: var(--black-100, #000000ff);--snowui-code-block-radius: var(--radius-4);--snowui-code-block-padding-x: var(--padding-5);--snowui-code-block-padding-y: var(--padding-5);--snowui-code-block-gap: var(--gap-2);--snowui-code-block-code-gap: var(--gap-3);--snowui-code-block-footer-height: var(--padding-3);--snowui-code-block-font-size: var(--text-12);--snowui-code-block-line-height: var(--leading-12);--snowui-code-block-font-family: inherit;--snowui-code-block-content-height: 5lh;}\n\n /* ─── 工具栏 ─── */:where(.snowui-code-block-toolbar) {display:flex;align-items:center;justify-content:space-between;gap:max(4px, var(--gap-2));max-width:calc(100% - var(--size-3));padding:var(--padding-1) var(--padding-2);border-radius:var(--radius-2);isolation:isolate;z-index:3;}\n\n /* 模糊层与工具栏同尺寸,只影响其后方内容。 */:where(.snowui-code-block-toolbar)::before {content:"";position:absolute;inset:0;border-radius:inherit;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);pointer-events:none;z-index:-1;}:where(.snowui-code-block-lang) {color:var(--snowui-code-block-muted-fg);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;user-select:none;}:where(.snowui-code-block-actions) {display:flex;align-items:center;flex-shrink:0;gap:var(\n --snowui-code-block-gap-override,\n var(--snowui-code-block-gap)\n );}\n\n /* 工具栏按钮沿用 bare 外观。 */:where(.snowui-code-block-toolbar button).snowui-code-block-btn {--snowui-field-focus-ring-width: 0;color:var(--snowui-code-block-btn-fg);transition:color var(--snowui-frame-color-motion-duration, 0.15s)\n var(--snowui-frame-color-motion-easing, ease-out);}\n :where(.snowui-code-block-toolbar button).snowui-code-block-btn:focus-visible\n {outline:2px solid var(--brand, #33d1ffff);outline-offset:1px;}:where(.snowui-code-block-toolbar button).snowui-code-block-btn:hover:not(:disabled) {background-image:none;}\n\n /* ─── 代码主体区域 ─── */:where(.snowui-code-block-scroll-shell) {position:relative;height:var(\n --snowui-code-block-content-height-override,\n var(--snowui-code-block-content-height)\n );min-height:0;overflow:clip;background:transparent;}:where(.snowui-code-block[data-resized="true"] .snowui-code-block-scroll-shell) {flex:1 1 0;height:auto;}\n\n /* 上下滚动渐隐:接入「内容渐隐层」通用能力的 CSS 静态形态(.snowui-scroll-mask,见 lib/edge-fade.md)。 */:where(.snowui-code-block-body) {--snowui-code-block-scroll-mask-size: var(\n --snowui-code-block-scroll-mask-size-override,\n 32px\n );display:flex;align-items:flex-start;gap:var(\n --snowui-code-block-code-gap-override,\n var(--snowui-code-block-code-gap)\n );flex:1 1 0;height:100%;overflow-x:auto;min-height:0;background:transparent;}\n\n /* ─── 行号槽 ─── */:where(.snowui-code-block-gutter) {display:block;flex-shrink:0;width:max-content;color:var(--snowui-code-block-gutter-fg);background:transparent;text-align:right;user-select:none;font:inherit;}:where(.snowui-code-block-line-number) {display:block;line-height:inherit;}:where(.snowui-code-block-pre-wrap) {flex:1 1 0;min-width:0;overflow:visible;background:transparent;}:where(.snowui-code-block-pre) {box-sizing:border-box;margin:0;tab-size:4;white-space:pre;overflow:visible;background:transparent;font:inherit;}:where(.snowui-code-block-code) {box-sizing:border-box;display:block;color:inherit;background:transparent;border-radius:0;font:inherit;margin:0;padding:0;}\n :where(\n .snowui-code-block[data-variant="singleLine"]\n .snowui-code-block-pre\n )\n {white-space:nowrap;}\n :where(\n .snowui-code-block[data-variant="singleLine"]\n .snowui-code-block-code\n )\n {display:inline;}:where(.snowui-code-block-line) {display:block;line-height:inherit;}:where(.snowui-code-block-token-comment) {color:var(--black-40, #00000066);}:where(.snowui-code-block-token-keyword) {color:#ff32c6;}:where(.snowui-code-block-token-function) {color:#ffac60;}:where(.snowui-code-block-token-property) {color:#1ac69c;}:where(.snowui-code-block-token-string) {color:#3fa4ff;}:where(.snowui-code-block-token-variable) {color:#c478ff;}\n\n /* ─── 全屏覆盖层 ─── */:where(.snowui-code-block-fullscreen) {position:fixed;inset:0;z-index:9999;display:flex;flex-direction:column;font-size:var(--snowui-code-block-font-size);line-height:var(--snowui-code-block-line-height);font-family:var(--snowui-code-block-font-family);background-color:var(\n --snowui-code-block-bg-override,\n var(--snowui-code-block-bg)\n );color:var(\n --snowui-code-block-fg-override,\n var(--snowui-code-block-fg)\n );border-radius:0;padding:var(\n --snowui-code-block-padding-override,\n var(\n --snowui-code-block-padding-y-override,\n var(--snowui-code-block-padding-y)\n )\n var(\n --snowui-code-block-padding-x-override,\n var(--snowui-code-block-padding-x)\n )\n );}:where(.snowui-code-block-body-fullscreen) {padding-bottom:max(var(--padding-0), env(safe-area-inset-bottom));}:where(.snowui-code-block-scroll-shell-fullscreen) {flex:1 1 0;height:auto;}\n\n /* 组件只声明轨道定位;视觉样式由 scrollbar.css 的 .snowui-overlay-scrollbar 承接。 */\n /* 滚动条提升到根容器(position:relative),绕开 scroll-shell 的 overflow:clip 裁切。 */\n /* 纵向轨道上下使用相同留白,right: 4px 贴近右边缘。 */:where(.snowui-code-block-scrollbar[data-axis="vertical"]) {top:var(--snowui-code-block-footer-height);right:4px;bottom:var(--snowui-code-block-footer-height);z-index:4;}:where(.snowui-code-block-accessories) {position:absolute;width:0;height:0;overflow:hidden;pointer-events:none;opacity:0;}\n\n /* ─── 内置 SVG 图标基础样式 ─── */:where(.snowui-code-block-icon-builtin),\n :where(.snowui-code-block-icon-custom) {display:block;flex-shrink:0;color:inherit;}:where(.snowui-code-block-icon-custom > *) {display:block;}:where(.snowui-code-block-trailing-custom) {display:inline-flex;align-items:center;justify-content:center;color:inherit;}:where(.snowui-code-block-trailing-custom > *) {display:inline-flex;}'
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
export default function CodeBlock($$anchor, $$props) {
|
|
@@ -6,6 +6,7 @@ interface Props extends Omit<ButtonProps, "children" | "onclick" | "disabled" |
|
|
|
6
6
|
scheme?: ColorScheme;
|
|
7
7
|
defaultScheme?: ColorScheme;
|
|
8
8
|
applyToDocument?: boolean;
|
|
9
|
+
systemPreference?: boolean;
|
|
9
10
|
ariaLabel?: string;
|
|
10
11
|
lightIcon?: Snippet;
|
|
11
12
|
darkIcon?: Snippet;
|
|
@@ -15,6 +16,8 @@ interface Props extends Omit<ButtonProps, "children" | "onclick" | "disabled" |
|
|
|
15
16
|
onclick?: (event: MouseEvent) => void;
|
|
16
17
|
[key: string]: any;
|
|
17
18
|
}
|
|
18
|
-
declare const ColorSchemeButton: import("svelte").Component<Props, {
|
|
19
|
+
declare const ColorSchemeButton: import("svelte").Component<Props, {
|
|
20
|
+
toggleScheme: () => void;
|
|
21
|
+
}, "scheme">;
|
|
19
22
|
type ColorSchemeButton = ReturnType<typeof ColorSchemeButton>;
|
|
20
23
|
export default ColorSchemeButton;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import 'svelte/internal/disclose-version';
|
|
2
2
|
import * as $ from 'svelte/internal/client';
|
|
3
|
-
import { onMount } from "svelte";
|
|
3
|
+
import { onMount, untrack } from "svelte";
|
|
4
4
|
import { ComponentIcon } from "../internal/component-icon/index.js";
|
|
5
|
+
import { observeColorSchemePreference, saveColorSchemePreference } from "../logic/color-scheme-preference.js";
|
|
5
6
|
import Frame from "./Frame.js";
|
|
6
7
|
import Button from "./Button.js";
|
|
7
8
|
|
|
@@ -31,6 +32,7 @@ export default function ColorSchemeButton($$anchor, $$props) {
|
|
|
31
32
|
let $$d = $.derived(() => mergeComponentPartProps(inheritedPart.current, explicitProps)),
|
|
32
33
|
defaultScheme = $.derived(() => $.fallback($.get($$d).defaultScheme, undefined)),
|
|
33
34
|
applyToDocument = $.derived(() => $.fallback($.get($$d).applyToDocument, true)),
|
|
35
|
+
systemPreference = $.derived(() => $.fallback($.get($$d).systemPreference, true)),
|
|
34
36
|
ariaLabel = $.derived(() => $.fallback($.get($$d).ariaLabel, undefined)),
|
|
35
37
|
lightIcon = $.derived(() => $.get($$d).lightIcon),
|
|
36
38
|
darkIcon = $.derived(() => $.get($$d).darkIcon),
|
|
@@ -42,6 +44,7 @@ export default function ColorSchemeButton($$anchor, $$props) {
|
|
|
42
44
|
rest = $.derived(() => $.exclude_from_object($.get($$d), [
|
|
43
45
|
'defaultScheme',
|
|
44
46
|
'applyToDocument',
|
|
47
|
+
'systemPreference',
|
|
45
48
|
'ariaLabel',
|
|
46
49
|
'lightIcon',
|
|
47
50
|
'darkIcon',
|
|
@@ -75,6 +78,8 @@ export default function ColorSchemeButton($$anchor, $$props) {
|
|
|
75
78
|
function applyDocumentScheme(nextScheme) {
|
|
76
79
|
if (!$.get(applyToDocument)) return;
|
|
77
80
|
|
|
81
|
+
document.documentElement.style.colorScheme = nextScheme;
|
|
82
|
+
|
|
78
83
|
if (nextScheme === "dark") {
|
|
79
84
|
document.documentElement.setAttribute("theme", "dark");
|
|
80
85
|
} else {
|
|
@@ -116,19 +121,39 @@ export default function ColorSchemeButton($$anchor, $$props) {
|
|
|
116
121
|
applyDocumentScheme(scheme());
|
|
117
122
|
});
|
|
118
123
|
|
|
119
|
-
|
|
120
|
-
if (
|
|
124
|
+
$.user_effect(() => {
|
|
125
|
+
if (!$.get(mounted) || !$.get(systemPreference)) return;
|
|
121
126
|
|
|
122
|
-
|
|
127
|
+
return untrack(() => observeColorSchemePreference((next) => {
|
|
128
|
+
$.set(internalScheme, next, true);
|
|
129
|
+
scheme(next);
|
|
130
|
+
applyDocumentScheme(next);
|
|
131
|
+
}));
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
function toggleScheme() {
|
|
135
|
+
if ($.get(disabled)) return;
|
|
123
136
|
|
|
124
137
|
const nextScheme = $.get(resolvedScheme) === "dark" ? "light" : "dark";
|
|
125
138
|
|
|
126
139
|
$.set(internalScheme, nextScheme, true);
|
|
127
140
|
scheme(nextScheme);
|
|
141
|
+
|
|
142
|
+
if ($.get(systemPreference)) saveColorSchemePreference(nextScheme);
|
|
143
|
+
|
|
128
144
|
applyDocumentScheme(nextScheme);
|
|
129
145
|
$.get(onSchemeChange)?.(nextScheme);
|
|
130
146
|
}
|
|
131
147
|
|
|
148
|
+
function handleClick(event) {
|
|
149
|
+
if ($.get(disabled)) return;
|
|
150
|
+
|
|
151
|
+
$.get(onclick)?.(event);
|
|
152
|
+
toggleScheme();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
var $$exports = { toggleScheme };
|
|
156
|
+
|
|
132
157
|
{
|
|
133
158
|
let $0 = $.derived(() => `${controlButtonMotionStyle(`var(--snowui-color-scheme-button-motion-duration-override, ${CONTROL_BUTTON_MOTION_DURATION_MS}ms)`)} ${$.get(userStyle)}`);
|
|
134
159
|
let $1 = $.derived(() => !$.get(rest).bare && !$.get(children));
|
|
@@ -248,5 +273,5 @@ export default function ColorSchemeButton($$anchor, $$props) {
|
|
|
248
273
|
}));
|
|
249
274
|
}
|
|
250
275
|
|
|
251
|
-
$.pop();
|
|
276
|
+
return $.pop($$exports);
|
|
252
277
|
}
|
|
@@ -164,25 +164,30 @@ export default function CopyButton($$anchor, $$props) {
|
|
|
164
164
|
onDestroy(() => clearTimeout(resetTimer));
|
|
165
165
|
|
|
166
166
|
{
|
|
167
|
-
let $0 = $.derived(() =>
|
|
168
|
-
let $1 = $.derived(() =>
|
|
167
|
+
let $0 = $.derived(() => $.get(rest).loading || $.get(rest).skeleton === false && $.get(status) === "pending");
|
|
168
|
+
let $1 = $.derived(() => `${controlButtonMotionStyle(`var(--snowui-copy-button-motion-duration-override, ${CONTROL_BUTTON_MOTION_DURATION_MS}ms)`)} ${$.get(userStyle)}`);
|
|
169
|
+
let $2 = $.derived(() => !$.get(rest).bare && !$.get(showText));
|
|
169
170
|
|
|
170
|
-
let $
|
|
171
|
+
let $3 = $.derived(() => $.get(ariaLabel) ?? ($.get(showText)
|
|
171
172
|
? undefined
|
|
172
173
|
: localeContext.t($.get(status) === "success" ? "copyButton.copied" : "copyButton.copy")));
|
|
173
174
|
|
|
174
|
-
let $
|
|
175
|
-
let $
|
|
175
|
+
let $4 = $.derived(() => $.get(status) === "pending" ? "true" : undefined);
|
|
176
|
+
let $5 = $.derived(() => $.get(status) === "idle" ? $.get(userWhileClick) : false);
|
|
176
177
|
|
|
177
178
|
Button($$anchor, $.spread_props(() => $.get(rest), {
|
|
178
|
-
get
|
|
179
|
+
get loading() {
|
|
179
180
|
return $.get($0);
|
|
180
181
|
},
|
|
181
182
|
|
|
182
|
-
get
|
|
183
|
+
get style() {
|
|
183
184
|
return $.get($1);
|
|
184
185
|
},
|
|
185
186
|
|
|
187
|
+
get iconOnly() {
|
|
188
|
+
return $.get($2);
|
|
189
|
+
},
|
|
190
|
+
|
|
186
191
|
get disabled() {
|
|
187
192
|
return $.get(disabled);
|
|
188
193
|
},
|
|
@@ -192,15 +197,15 @@ export default function CopyButton($$anchor, $$props) {
|
|
|
192
197
|
},
|
|
193
198
|
|
|
194
199
|
get 'aria-label'() {
|
|
195
|
-
return $.get($
|
|
200
|
+
return $.get($3);
|
|
196
201
|
},
|
|
197
202
|
'aria-live': 'polite',
|
|
198
203
|
get 'aria-busy'() {
|
|
199
|
-
return $.get($
|
|
204
|
+
return $.get($4);
|
|
200
205
|
},
|
|
201
206
|
|
|
202
207
|
get whileClick() {
|
|
203
|
-
return $.get($
|
|
208
|
+
return $.get($5);
|
|
204
209
|
},
|
|
205
210
|
onclick: handleClick,
|
|
206
211
|
children: ($$anchor, $$slotProps) => {
|
|
@@ -3,6 +3,8 @@ import * as $ from 'svelte/internal/client';
|
|
|
3
3
|
import { onDestroy, tick } from "svelte";
|
|
4
4
|
import { provideTableContext } from "../lib/table-context.js";
|
|
5
5
|
import Frame from "./Frame.js";
|
|
6
|
+
import Button from "./Button.js";
|
|
7
|
+
import { useLocale } from "../i18n/locale.js";
|
|
6
8
|
import { paginateDataTableRows, sortDataTableRows } from "../lib/data-table.js";
|
|
7
9
|
|
|
8
10
|
var rest_excludes = new Set([
|
|
@@ -57,11 +59,11 @@ var rest_excludes = new Set([
|
|
|
57
59
|
]);
|
|
58
60
|
|
|
59
61
|
var root = $.from_html(`<span class="snowui-data-table-auto-load-sentinel" aria-hidden="true"></span>`);
|
|
60
|
-
var root_1 = $.from_html(`<!> <!>`, 1);
|
|
62
|
+
var root_1 = $.from_html(`<!> <!> <!>`, 1);
|
|
61
63
|
|
|
62
64
|
const $$css = {
|
|
63
65
|
hash: 'svelte-b78yyc',
|
|
64
|
-
code: ':where(.snowui-data-table) {position:relative;width:100%;min-width:0;gap:var(--gap-3, .75rem);}:where(.snowui-data-table-auto-load-sentinel) {position:absolute;right:0;bottom:0;left:0;height:1px;pointer-events:none;}'
|
|
66
|
+
code: ':where(.snowui-data-table) {position:relative;width:100%;min-width:0;gap:var(--gap-3, .75rem);}:where(.snowui-data-table-load-more) {width:100%;justify-content:center;}:where(.snowui-data-table-auto-load-sentinel) {position:absolute;right:0;bottom:0;left:0;height:1px;pointer-events:none;}'
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
export default function DataTable($$anchor, $$props) {
|
|
@@ -69,8 +71,9 @@ export default function DataTable($$anchor, $$props) {
|
|
|
69
71
|
$.append_styles($$anchor, $$css);
|
|
70
72
|
|
|
71
73
|
// SnowUI 许可入口:首次阅读源码请先读 ../../LICENSE;访问文件不代表获得修改或移植权,官方维护授权及同任务去重见该文件。
|
|
72
|
-
const
|
|
74
|
+
const locale = useLocale();
|
|
73
75
|
|
|
76
|
+
const LOAD_MORE_ROW_APPEAR_DURATION_MS = 2000;
|
|
74
77
|
const LOAD_MORE_ROW_REVEAL_INTERVAL_MS = 20;
|
|
75
78
|
const DEFAULT_LOAD_MORE_THRESHOLD_PX = 80;
|
|
76
79
|
const DEFAULT_LOAD_MORE_THROTTLE_MS = 500;
|
|
@@ -514,6 +517,7 @@ export default function DataTable($$anchor, $$props) {
|
|
|
514
517
|
isActionsResizable: () => $.get(actionsConfig)?.resizable === true,
|
|
515
518
|
getVariant: () => variant(),
|
|
516
519
|
getLoading: () => loading() && $.get(visibleRows).length === 0,
|
|
520
|
+
isEmpty: () => !loading() && !refreshing() && error() === undefined && $.get(visibleRows).length === 0,
|
|
517
521
|
getLoadingMore: () => $.get(loadingMore),
|
|
518
522
|
getLoadingRowCount: () => $.get(resolvedPageSize),
|
|
519
523
|
getLoadingSpinner: () => $.get(showLoadingSpinner) || (loading() || refreshing()) && $.get(visibleRows).length > 0,
|
|
@@ -734,6 +738,37 @@ export default function DataTable($$anchor, $$props) {
|
|
|
734
738
|
|
|
735
739
|
{
|
|
736
740
|
var consequent_1 = ($$anchor) => {
|
|
741
|
+
Frame($$anchor, {
|
|
742
|
+
row: true,
|
|
743
|
+
class: 'snowui-data-table-load-more',
|
|
744
|
+
children: ($$anchor, $$slotProps) => {
|
|
745
|
+
Button($$anchor, {
|
|
746
|
+
variant: 'outline',
|
|
747
|
+
onclick: () => void runLoadMore(),
|
|
748
|
+
children: ($$anchor, $$slotProps) => {
|
|
749
|
+
$.next();
|
|
750
|
+
|
|
751
|
+
var text = $.text();
|
|
752
|
+
|
|
753
|
+
$.template_effect(($0) => $.set_text(text, $0), [() => locale.t("table.loadMore")]);
|
|
754
|
+
$.append($$anchor, text);
|
|
755
|
+
},
|
|
756
|
+
$$slots: { default: true }
|
|
757
|
+
});
|
|
758
|
+
},
|
|
759
|
+
$$slots: { default: true }
|
|
760
|
+
});
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
$.if(node_3, ($$render) => {
|
|
764
|
+
if (loadMoreMode() === "manual" && loadMoreSource() !== undefined && $.get(resolvedHasMore) && !loading() && !refreshing() && !$.get(loadingMore)) $$render(consequent_1);
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
var node_4 = $.sibling(node_3, 2);
|
|
769
|
+
|
|
770
|
+
{
|
|
771
|
+
var consequent_2 = ($$anchor) => {
|
|
737
772
|
var span = root();
|
|
738
773
|
let styles;
|
|
739
774
|
|
|
@@ -742,8 +777,8 @@ export default function DataTable($$anchor, $$props) {
|
|
|
742
777
|
$.append($$anchor, span);
|
|
743
778
|
};
|
|
744
779
|
|
|
745
|
-
$.if(
|
|
746
|
-
if (loadMoreMode() === "auto" && loadMoreSource() !== undefined && $.get(resolvedHasMore)) $$render(
|
|
780
|
+
$.if(node_4, ($$render) => {
|
|
781
|
+
if (loadMoreMode() === "auto" && loadMoreSource() !== undefined && $.get(resolvedHasMore)) $$render(consequent_2);
|
|
747
782
|
});
|
|
748
783
|
}
|
|
749
784
|
|