dsh-workbench-sites 1.12.9 → 1.12.12

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/lib/client.js CHANGED
@@ -178,13 +178,266 @@ var require_filter_checklist = __commonJS({
178
178
  }
179
179
  });
180
180
 
181
+ // packages/addons/lib/search-picker.cjs
182
+ var require_search_picker = __commonJS({
183
+ "packages/addons/lib/search-picker.cjs"(exports2, module2) {
184
+ "use strict";
185
+ var React2 = require("react");
186
+ var h2 = React2.createElement;
187
+ var FilterChecklist = require_filter_checklist();
188
+ var DEFAULT_TEXTS = {
189
+ all: "\u5168\u90E8",
190
+ selected: "\u5DF2\u9009",
191
+ clear: "\u6E05\u7A7A",
192
+ searchPlaceholder: "\u641C\u7D22",
193
+ empty: "\u6682\u65E0\u6570\u636E",
194
+ noMatch: "\u6CA1\u6709\u5339\u914D\u9879",
195
+ loading: "\u52A0\u8F7D\u4E2D\u2026",
196
+ noMore: "\u6CA1\u6709\u66F4\u591A"
197
+ };
198
+ function asText(x) {
199
+ return String(x == null ? "" : x).toLowerCase();
200
+ }
201
+ function filterLocal(items, query) {
202
+ var q = String(query || "").trim();
203
+ if (!q) return items;
204
+ var needle = asText(q);
205
+ return items.filter(function(x) {
206
+ return asText(x.name).indexOf(needle) >= 0 || asText(x.meta).indexOf(needle) >= 0;
207
+ });
208
+ }
209
+ function useRemoteSource(conf) {
210
+ var RT = conf.React || React2;
211
+ var open = conf.open;
212
+ var query = conf.query;
213
+ var fetchPage = conf.fetchPage;
214
+ var pageSize = conf.pageSize;
215
+ var debounce = conf.debounce;
216
+ var dedupe = conf.dedupe;
217
+ var mapPage = conf.mapPage;
218
+ var reloadKey = conf.reloadKey;
219
+ var rowsS = RT.useState([]);
220
+ var totalS = RT.useState(0);
221
+ var pageS = RT.useState(0);
222
+ var moreS = RT.useState(false);
223
+ var loadS = RT.useState(false);
224
+ var seq = RT.useRef ? RT.useRef(0) : { current: 0 };
225
+ function load(q, pageNumber, append) {
226
+ var mine = ++seq.current;
227
+ loadS[1](true);
228
+ return Promise.resolve(fetchPage(q, pageNumber)).then(function(raw) {
229
+ if (mine !== seq.current) return;
230
+ loadS[1](false);
231
+ var next = mapPage ? mapPage(raw, pageNumber) : raw || {};
232
+ var list = next.rows || [];
233
+ rowsS[1](function(prev) {
234
+ if (!append) return list;
235
+ var joined = dedupe === false ? prev.concat(list) : prev.concat(list);
236
+ if (dedupe === false) return joined;
237
+ var seen = {};
238
+ return joined.filter(function(x) {
239
+ var key = String(x.id);
240
+ if (seen[key]) return false;
241
+ seen[key] = true;
242
+ return true;
243
+ });
244
+ });
245
+ totalS[1](typeof next.total === "number" ? next.total : list.length);
246
+ pageS[1](next.page || pageNumber);
247
+ moreS[1](!!next.hasMore);
248
+ }).catch(function() {
249
+ if (mine === seq.current) loadS[1](false);
250
+ });
251
+ }
252
+ RT.useEffect(
253
+ function() {
254
+ if (!open) return void 0;
255
+ var timer = setTimeout(
256
+ function() {
257
+ load(query, 1, false);
258
+ },
259
+ query ? debounce : 0
260
+ );
261
+ return function() {
262
+ clearTimeout(timer);
263
+ };
264
+ },
265
+ [open, query, reloadKey]
266
+ );
267
+ return {
268
+ rows: rowsS[0],
269
+ total: totalS[0],
270
+ page: pageS[0],
271
+ hasMore: moreS[0],
272
+ loading: loadS[0],
273
+ loadQuery: load,
274
+ reset: function() {
275
+ seq.current += 1;
276
+ rowsS[1]([]);
277
+ totalS[1](0);
278
+ pageS[1](0);
279
+ moreS[1](false);
280
+ loadS[1](false);
281
+ }
282
+ };
283
+ }
284
+ function SearchPicker(props) {
285
+ var RT = props.React || React2;
286
+ var texts = Object.assign({}, DEFAULT_TEXTS, props.texts || {});
287
+ var classes = props.classes || {};
288
+ var mode = props.mode === "single" ? "single" : "multi";
289
+ var disabled = props.disabled === true;
290
+ var selected = (props.selected || []).map(String);
291
+ var items = props.items || null;
292
+ var fetchPage = props.fetchPage || null;
293
+ var pageSize = props.pageSize || 20;
294
+ var debounce = props.debounce === void 0 ? 200 : props.debounce;
295
+ var allItems = items || [];
296
+ var openS = RT.useState(false);
297
+ var open = openS[0];
298
+ var queryS = RT.useState("");
299
+ var query = queryS[0];
300
+ var boxRef = RT.useRef ? RT.useRef(null) : { current: null };
301
+ var remote = fetchPage ? useRemoteSource({
302
+ React: RT,
303
+ open,
304
+ query,
305
+ fetchPage,
306
+ pageSize,
307
+ debounce,
308
+ dedupe: props.dedupe,
309
+ mapPage: props.mapPage,
310
+ reloadKey: props.reloadKey
311
+ }) : null;
312
+ var rows = remote ? remote.rows : filterLocal(allItems, query);
313
+ var loading = remote ? remote.loading : false;
314
+ var total = remote ? remote.total : rows.length;
315
+ var hasMore = remote ? remote.hasMore : false;
316
+ RT.useEffect(function() {
317
+ if (!open || typeof document === "undefined") return void 0;
318
+ function onDown(e) {
319
+ var box = boxRef.current;
320
+ if (box && !box.contains(e.target)) openS[1](false);
321
+ }
322
+ function onKey(e) {
323
+ if (e.key === "Escape") openS[1](false);
324
+ }
325
+ document.addEventListener("mousedown", onDown);
326
+ document.addEventListener("keydown", onKey);
327
+ return function() {
328
+ document.removeEventListener("mousedown", onDown);
329
+ document.removeEventListener("keydown", onKey);
330
+ };
331
+ }, [open]);
332
+ function commit(next) {
333
+ if (props.onChange) props.onChange(next);
334
+ }
335
+ function toggle(id) {
336
+ if (disabled) return;
337
+ var key = String(id);
338
+ if (mode === "single") {
339
+ openS[1](false);
340
+ if (props.onPick) props.onPick(key, rowOf(key));
341
+ commit([key]);
342
+ return;
343
+ }
344
+ var next = selected.slice();
345
+ var i = next.indexOf(key);
346
+ if (i >= 0) next.splice(i, 1);
347
+ else next.push(key);
348
+ commit(next);
349
+ }
350
+ function rowOf(id) {
351
+ var hit = rows.filter(function(x) {
352
+ return String(x.id) === String(id);
353
+ })[0];
354
+ if (hit) return hit;
355
+ return (allItems || []).filter(function(x) {
356
+ return String(x.id) === String(id);
357
+ })[0] || null;
358
+ }
359
+ var label = props.label || texts.all;
360
+ var caret = props.caret === void 0 ? "\u25BE" : props.caret;
361
+ var count = selected.length;
362
+ var chips = props.renderSelected ? props.renderSelected({ ids: selected, toggle, nameOf: props.nameOf || rowOf, texts }) : null;
363
+ return h2(
364
+ "div",
365
+ { className: classes.root, ref: boxRef },
366
+ h2(
367
+ "button",
368
+ {
369
+ type: "button",
370
+ className: classes.btn + (count ? " " + (classes.btnOn || "is-on") : ""),
371
+ "aria-haspopup": "dialog",
372
+ "aria-expanded": open ? "true" : "false",
373
+ disabled,
374
+ onClick: function(e) {
375
+ if (props.stopPropagation) e.stopPropagation();
376
+ openS[1](!open);
377
+ }
378
+ },
379
+ props.icon ? props.icon : null,
380
+ label + (count ? " \xB7 " + count : ""),
381
+ typeof caret === "function" ? caret : caret
382
+ ),
383
+ chips,
384
+ open ? h2(
385
+ "div",
386
+ {
387
+ className: classes.menu,
388
+ role: props.menuRole,
389
+ style: props.menuStyle,
390
+ onClick: props.stopPropagation ? function(e) {
391
+ e.stopPropagation();
392
+ } : void 0
393
+ },
394
+ h2(FilterChecklist, {
395
+ mode,
396
+ items: rows,
397
+ selected,
398
+ onToggle: toggle,
399
+ onPick: toggle,
400
+ query,
401
+ onQuery: queryS[1],
402
+ title: props.title || label,
403
+ total,
404
+ selectedText: texts.selected,
405
+ clearText: texts.clear,
406
+ onClear: function() {
407
+ commit([]);
408
+ queryS[1]("");
409
+ },
410
+ searchPlaceholder: texts.searchPlaceholder,
411
+ loading,
412
+ hasMore,
413
+ onLoadMore: remote ? function() {
414
+ remote.loadQuery(query, (remote.page || 1) + 1, true);
415
+ } : void 0,
416
+ emptyText: texts.empty,
417
+ noMatchText: texts.noMatch,
418
+ loadingText: texts.loading,
419
+ noMoreText: texts.noMore,
420
+ groupLabel: props.title || label,
421
+ autoFocus: props.autoFocus,
422
+ beforeHead: props.beforeHead || null
423
+ }),
424
+ props.footer || null
425
+ ) : null
426
+ );
427
+ }
428
+ module2.exports = SearchPicker;
429
+ module2.exports.filterLocal = filterLocal;
430
+ module2.exports.DEFAULT_TEXTS = DEFAULT_TEXTS;
431
+ }
432
+ });
433
+
181
434
  // packages/addons/lib/tag-filter.cjs
182
435
  var require_tag_filter = __commonJS({
183
436
  "packages/addons/lib/tag-filter.cjs"(exports2, module2) {
184
437
  "use strict";
185
438
  var React2 = require("react");
186
439
  var h2 = React2.createElement;
187
- var FilterChecklist = require_filter_checklist();
440
+ var SearchPicker = require_search_picker();
188
441
  module2.exports = function createTagFilter(options) {
189
442
  var conf = options || {};
190
443
  var classes = conf.classes || {};
@@ -220,99 +473,26 @@ var require_tag_filter = __commonJS({
220
473
  var ids = props.ids || [];
221
474
  var onChange = props.onChange || function() {
222
475
  };
223
- var t = text(props);
224
- var availS = React2.useState(true);
225
- var openS = React2.useState(false);
226
- var open = openS[0];
227
- var setOpen = openS[1];
228
- var queryS = React2.useState("");
229
- var query = queryS[0];
230
- var setQuery = queryS[1];
231
- var rowsS = React2.useState([]);
232
- var rows = rowsS[0];
233
- var setRows = rowsS[1];
234
- var totalS = React2.useState(0);
235
- var total = totalS[0];
236
- var setTotal = totalS[1];
237
- var pageS = React2.useState(0);
238
- var page = pageS[0];
239
- var setPage = pageS[1];
240
- var hasMoreS = React2.useState(false);
241
- var hasMore = hasMoreS[0];
242
- var setHasMore = hasMoreS[1];
243
- var loadingS = React2.useState(false);
244
- var loading = loadingS[0];
245
- var setLoading = loadingS[1];
476
+ var tx = text(props);
246
477
  var namesS = React2.useState({});
247
478
  var names = namesS[0];
248
- var setNames = namesS[1];
249
- var seq = React2.useRef(0);
250
- var load = React2.useCallback(
251
- function(q, pageNumber, append) {
252
- var mine = ++seq.current;
253
- setLoading(true);
254
- return api.call(conf.action, { text: q || "", pageNumber, pageSize }).then(function(r) {
255
- if (mine !== seq.current) return;
256
- setLoading(false);
257
- if (!r || !r.ok) return;
258
- var next = mapPage(r.result || {}, pageNumber);
259
- setRows(function(prev) {
260
- if (!append) return next.rows;
261
- if (!dedupe) return prev.concat(next.rows);
262
- var seen = {};
263
- var out = [];
264
- prev.concat(next.rows).forEach(function(x) {
265
- var key = String(x.id);
266
- if (seen[key]) return;
267
- seen[key] = true;
268
- out.push(x);
269
- });
270
- return out;
271
- });
272
- setTotal(next.total);
273
- setPage(next.page);
274
- setHasMore(next.hasMore);
275
- setNames(function(prev) {
276
- var map = Object.assign({}, prev);
277
- next.rows.forEach(function(x) {
278
- map[String(x.id)] = x.name;
279
- });
280
- return map;
281
- });
282
- }).catch(function() {
283
- if (mine === seq.current) setLoading(false);
284
- });
285
- },
286
- [api]
287
- );
288
- React2.useEffect(
289
- function() {
290
- if (!open) return void 0;
291
- var timer = setTimeout(
292
- function() {
293
- load(query, 1, false);
294
- },
295
- query ? debounce : 0
296
- );
297
- return function() {
298
- clearTimeout(timer);
299
- };
300
- },
301
- [open, query, load, props.reloadKey]
302
- );
303
- React2.useEffect(
304
- function() {
305
- if (!conf.probe) return;
306
- api.call(conf.probe.action || conf.action, conf.probe.args || {}).then(function(r) {
307
- if (r && r.ok) availS[1](!!(conf.probe.available && conf.probe.available(r.result)));
308
- }).catch(function() {
479
+ function mergeNames(rows) {
480
+ if (!rows || !rows.length) return;
481
+ namesS[1](function(prev) {
482
+ var next = Object.assign({}, prev);
483
+ var changed = false;
484
+ rows.forEach(function(x) {
485
+ if (next[String(x.id)] !== x.name) {
486
+ next[String(x.id)] = x.name;
487
+ changed = true;
488
+ }
309
489
  });
310
- },
311
- [api]
312
- );
490
+ return changed ? next : prev;
491
+ });
492
+ }
313
493
  React2.useEffect(
314
494
  function() {
315
- if (!open || !ids.length || !conf.names) return;
495
+ if (!ids.length || !conf.names) return;
316
496
  var wanted = ids.filter(function(id) {
317
497
  return !names[String(id)];
318
498
  });
@@ -320,99 +500,65 @@ var require_tag_filter = __commonJS({
320
500
  var args = conf.names.args ? conf.names.args(wanted) : { ids: wanted };
321
501
  api.call(conf.names.action, args).then(function(r) {
322
502
  if (!r || !r.ok) return;
323
- var map = {};
324
- (r.result && r.result.records || []).forEach(function(x) {
325
- map[String(x.id)] = x.name;
326
- });
327
- if (!Object.keys(map).length) return;
328
- setNames(function(prev) {
329
- return Object.assign({}, prev, map);
330
- });
503
+ mergeNames(r.result && r.result.records || []);
331
504
  }).catch(function() {
332
505
  });
333
506
  },
334
- [open, ids.join(",")]
507
+ [ids.join(",")]
335
508
  );
336
- React2.useEffect(
337
- function() {
338
- if (!open) return void 0;
339
- function onKey(e) {
340
- if (e.key === "Escape") setOpen(false);
341
- }
342
- document.addEventListener("keydown", onKey);
343
- return function() {
344
- document.removeEventListener("keydown", onKey);
345
- };
346
- },
347
- [open]
348
- );
349
- function toggle(id) {
350
- var key = String(id);
351
- var next = ids.slice();
352
- var i = next.indexOf(key);
353
- if (i >= 0) next.splice(i, 1);
354
- else next.push(key);
355
- onChange(next);
509
+ function fetchPage(q, pageNumber) {
510
+ return api.call(conf.action, { text: q || "", pageNumber, pageSize }).then(function(r) {
511
+ if (!r || !r.ok) return { rows: [], total: 0, page: pageNumber, hasMore: false };
512
+ var next = mapPage(r.result || {}, pageNumber);
513
+ mergeNames(next.rows);
514
+ return { rows: items(next.rows), total: next.total, page: next.page, hasMore: next.hasMore };
515
+ });
516
+ }
517
+ function nameOf(id) {
518
+ return names[String(id)] || String(id).slice(0, 6);
356
519
  }
357
520
  if (!enabled(props)) return null;
358
- var caretNode = typeof caret === "function" ? caret(props, t) : caret;
359
- var selectedNode = renderSelected ? renderSelected({ ids, names, toggle, text: t, classes, h: h2 }) : null;
360
- return h2(
361
- "div",
362
- { className: classes.root },
363
- h2(
364
- "button",
365
- {
366
- type: "button",
367
- className: classes.btn + (ids.length ? " " + (classes.btnOn || "on") : ""),
368
- "aria-expanded": open ? "true" : "false",
369
- onClick: function(e) {
370
- if (conf.stopPropagation) e.stopPropagation();
371
- setOpen(!open);
372
- }
373
- },
374
- icon(props, "tag", 13),
375
- t.label + (ids.length ? " \xB7 " + ids.length : ""),
376
- caretNode
377
- ),
378
- open ? h2(
379
- "div",
380
- {
381
- className: classes.menu,
382
- role: conf.menuRole,
383
- style: conf.menuStyle,
384
- onClick: conf.stopPropagation ? function(e) {
385
- e.stopPropagation();
386
- } : void 0
387
- },
388
- h2(FilterChecklist, {
389
- beforeHead: selectedNode,
390
- items: items(rows),
391
- selected: ids,
392
- onToggle: toggle,
393
- query,
394
- onQuery: setQuery,
395
- title: t.all,
396
- total,
397
- selectedText: t.selected,
398
- clearText: t.clear,
399
- onClear: function() {
400
- onChange([]);
401
- setQuery("");
402
- },
403
- searchPlaceholder: t.searchPlaceholder,
404
- loading,
405
- hasMore,
406
- onLoadMore: function() {
407
- load(query, (page || 1) + 1, true);
408
- },
409
- emptyText: t.empty,
410
- noMatchText: t.noMatch,
411
- loadingText: t.loading,
412
- noMoreText: t.noMore
413
- })
414
- ) : null
415
- );
521
+ return h2(SearchPicker, {
522
+ h: h2,
523
+ React: React2,
524
+ mode: "multi",
525
+ label: tx.label,
526
+ title: tx.all,
527
+ fetchPage,
528
+ pageSize,
529
+ debounce,
530
+ dedupe,
531
+ classes,
532
+ menuRole: conf.menuRole,
533
+ menuStyle: conf.menuStyle,
534
+ stopPropagation: conf.stopPropagation,
535
+ reloadKey: props.reloadKey,
536
+ texts: {
537
+ all: tx.all,
538
+ selected: tx.selected,
539
+ clear: tx.clear,
540
+ searchPlaceholder: tx.searchPlaceholder,
541
+ empty: tx.empty,
542
+ noMatch: tx.noMatch,
543
+ loading: tx.loading,
544
+ noMore: tx.noMore
545
+ },
546
+ icon: icon(props, "tag", 13),
547
+ caret: typeof caret === "function" ? caret(props) : caret,
548
+ selected: ids,
549
+ onChange,
550
+ nameOf,
551
+ renderSelected: renderSelected ? function(ctx) {
552
+ return renderSelected({
553
+ ids: ctx.ids,
554
+ names,
555
+ toggle: ctx.toggle,
556
+ text: tx,
557
+ classes,
558
+ h: h2
559
+ });
560
+ } : null
561
+ });
416
562
  };
417
563
  };
418
564
  }
@@ -528,8 +674,9 @@ var require_overlay = __commonJS({
528
674
  var autoFocusDialog = opts.autoFocusDialog !== false;
529
675
  var focusableSelector = opts.focusableSelector || FOCUSABLE;
530
676
  function Modal(props) {
531
- var ref = React2.useRef(null);
532
- React2.useEffect(function() {
677
+ var R = props.React || React2;
678
+ var ref = R.useRef(null);
679
+ R.useEffect(function() {
533
680
  var previous = typeof document !== "undefined" ? document.activeElement : null;
534
681
  var focusIt = props.autoFocus !== void 0 ? props.autoFocus : autoFocusDialog;
535
682
  if (focusIt && ref.current) ref.current.focus();
@@ -595,6 +742,305 @@ var require_overlay = __commonJS({
595
742
  }
596
743
  });
597
744
 
745
+ // packages/addons/lib/stepper.cjs
746
+ var require_stepper = __commonJS({
747
+ "packages/addons/lib/stepper.cjs"(exports2, module2) {
748
+ "use strict";
749
+ function stepState(index, current, maxVisited) {
750
+ if (index === current) return "current";
751
+ if (index < current) return "done";
752
+ if (index <= maxVisited) return "visited";
753
+ return "todo";
754
+ }
755
+ function Steps(props) {
756
+ var h2 = props.h;
757
+ var steps = props.steps || [];
758
+ var current = props.current || 0;
759
+ var maxVisited = props.maxVisited === void 0 ? current : props.maxVisited;
760
+ var invalid = props.invalid || {};
761
+ var disabled = !!props.disabled;
762
+ var label = props.label || "\u6B65\u9AA4";
763
+ return h2(
764
+ "nav",
765
+ { className: "wbctl-steps" + (props.className ? " " + props.className : ""), "aria-label": label },
766
+ h2(
767
+ "ol",
768
+ { className: "wbctl-step-list" },
769
+ steps.map(function(step, index) {
770
+ var state = stepState(index, current, maxVisited);
771
+ var canJump = !disabled && typeof props.onJump === "function" && state !== "current" && state !== "todo";
772
+ var isInvalid = !!invalid[index] || !!invalid[step.key];
773
+ return h2(
774
+ "li",
775
+ { key: step.key || index, className: "wbctl-step-item" },
776
+ h2(
777
+ "button",
778
+ {
779
+ type: "button",
780
+ className: "wbctl-step",
781
+ "data-state": state,
782
+ "data-invalid": isInvalid ? "true" : null,
783
+ "aria-current": state === "current" ? "step" : void 0,
784
+ "aria-label": index + 1 + " \xB7 " + step.label + (state === "done" ? "\uFF08\u5DF2\u5B8C\u6210\uFF09" : ""),
785
+ disabled: disabled || state === "todo",
786
+ title: step.hint || "",
787
+ onClick: function() {
788
+ if (canJump) props.onJump(index);
789
+ }
790
+ },
791
+ h2("span", { className: "wbctl-step-index", "aria-hidden": "true" }, state === "done" ? "\u2713" : String(index + 1)),
792
+ h2("span", { className: "wbctl-step-label" }, step.label),
793
+ step.hint ? h2("span", { className: "wbctl-step-hint" }, step.hint) : null,
794
+ step.optional ? h2("span", { className: "wbctl-step-opt" }, "\u53EF\u9009") : null
795
+ )
796
+ );
797
+ })
798
+ )
799
+ );
800
+ }
801
+ var STYLES = [
802
+ ".wbctl-steps{display:block;min-width:0}",
803
+ ".wbctl-step-list{display:flex;align-items:stretch;gap:6px;list-style:none;margin:0 0 14px;padding:0;min-width:0}",
804
+ ".wbctl-step-item{display:flex;flex:1 1 0;min-width:0}",
805
+ ".wbctl-step{display:flex;align-items:center;gap:7px;flex:1 1 auto;min-width:0;padding:7px 9px;border:1px solid var(--wb-line,var(--wb-border));border-radius:10px;background:transparent;color:var(--wb-muted,inherit);font:inherit;font-size:12px;line-height:1.35;text-align:left;cursor:default;transition:background .14s ease,border-color .14s ease,color .14s ease}",
806
+ ".wbctl-step[data-state=done],.wbctl-step[data-state=visited]{color:inherit;cursor:pointer}",
807
+ ".wbctl-step[data-state=done]{border-color:color-mix(in oklab,var(--wb-ok,var(--wb-accent,#2563eb)) 36%,var(--wb-border))}",
808
+ ".wbctl-step[data-state=current]{border-color:color-mix(in oklab,var(--wb-accent,#2563eb) 58%,var(--wb-border));background:color-mix(in oklab,var(--wb-accent,#2563eb) 8%,transparent);color:inherit;font-weight:600}",
809
+ ".wbctl-step[data-state=visited]:hover,.wbctl-step[data-state=done]:hover{background:color-mix(in oklab,currentColor 7%,transparent)}",
810
+ ".wbctl-step[data-invalid=true]{border-color:var(--wb-danger,#d33)}",
811
+ ".wbctl-step:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
812
+ ".wbctl-step:disabled{cursor:default;opacity:.72}",
813
+ ".wbctl-step-index{display:inline-flex;align-items:center;justify-content:center;flex:none;width:20px;height:20px;border-radius:50%;font-size:11px;font-variant-numeric:tabular-nums;background:color-mix(in oklab,currentColor 15%,transparent)}",
814
+ ".wbctl-step[data-state=current] .wbctl-step-index{background:var(--wb-accent,#2563eb);color:var(--wb-on-accent,#fff)}",
815
+ ".wbctl-step[data-state=done] .wbctl-step-index{background:color-mix(in oklab,var(--wb-ok,var(--wb-accent,#2563eb)) 20%,transparent);color:var(--wb-ok,var(--wb-accent,#2563eb))}",
816
+ ".wbctl-step-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
817
+ ".wbctl-step-hint{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;font-weight:400;opacity:.62}",
818
+ ".wbctl-step-opt{flex:none;font-size:10px;font-weight:400;opacity:.55}",
819
+ "@media (max-width:760px){.wbctl-step{padding:6px 7px;font-size:11.5px}.wbctl-step-hint,.wbctl-step-opt{display:none}.wbctl-step-index{width:18px;height:18px;font-size:10px}}",
820
+ "@media (max-width:520px){.wbctl-step-list{gap:4px}.wbctl-step-label{white-space:normal}.wbctl-step{gap:5px}}",
821
+ "@media (prefers-reduced-motion:reduce){.wbctl-step{transition:none}}"
822
+ ];
823
+ module2.exports = { Steps, stepState, styles: STYLES };
824
+ }
825
+ });
826
+
827
+ // packages/addons/lib/staged-dialog.cjs
828
+ var require_staged_dialog = __commonJS({
829
+ "packages/addons/lib/staged-dialog.cjs"(exports2, module2) {
830
+ "use strict";
831
+ var defaultReact = require("react");
832
+ var overlayFactory = require_overlay();
833
+ var stepper = require_stepper();
834
+ function validateStep(step) {
835
+ if (!step || typeof step.validate !== "function") return "";
836
+ var message = step.validate();
837
+ return message ? String(message) : "";
838
+ }
839
+ function firstFailing(steps) {
840
+ var list = steps || [];
841
+ for (var i = 0; i < list.length; i += 1) {
842
+ var message = validateStep(list[i]);
843
+ if (message) return { index: i, key: list[i] && list[i].key, message };
844
+ }
845
+ return null;
846
+ }
847
+ function createStagedDialog(options) {
848
+ var opts = options || {};
849
+ var React2 = opts.React || defaultReact;
850
+ var h2 = React2.createElement;
851
+ var dialogClass = ((opts.dialogClass || "") + " wbctl-dialog").trim();
852
+ var Overlay = overlayFactory(
853
+ Object.assign({}, opts, {
854
+ React: React2,
855
+ dialogClass,
856
+ // 首焦点由外壳送进对话框,字段由 focusStep 负责,避免打开瞬间落进第一个输入框。
857
+ autoFocusDialog: opts.autoFocusDialog !== false
858
+ })
859
+ );
860
+ function StagedDialog(props) {
861
+ var R = props.React || React2;
862
+ var steps = props.steps || [];
863
+ var count = steps.length;
864
+ var busy = !!props.submitting || !!props.busy;
865
+ var indexState = R.useState(props.initialStep || 0);
866
+ var rawIndex = indexState[0];
867
+ var setIndex = indexState[1];
868
+ var index = count === 0 ? 0 : Math.min(Math.max(rawIndex, 0), count - 1);
869
+ var visitedState = R.useState(props.initialStep || 0);
870
+ var maxVisited = count === 0 ? 0 : Math.min(Math.max(visitedState[0], index), count - 1);
871
+ var setMaxVisited = visitedState[1];
872
+ var errorState = R.useState("");
873
+ var stepError = errorState[0];
874
+ var setStepError = errorState[1];
875
+ var invalidState = R.useState({});
876
+ var invalid = invalidState[0];
877
+ var setInvalid = invalidState[1];
878
+ var bodyRef = R.useRef(null);
879
+ var mounted = R.useRef(true);
880
+ function runValidate(step) {
881
+ return validateStep(step);
882
+ }
883
+ function markInvalid(i, bad) {
884
+ setInvalid(function(prev) {
885
+ var next2 = Object.assign({}, prev);
886
+ if (bad) next2[i] = true;
887
+ else delete next2[i];
888
+ return next2;
889
+ });
890
+ }
891
+ function focusBody() {
892
+ var el = bodyRef.current;
893
+ if (el && typeof el.focus === "function") el.focus();
894
+ }
895
+ R.useEffect(
896
+ function() {
897
+ if (!mounted.current) return;
898
+ focusBody();
899
+ },
900
+ [index]
901
+ );
902
+ R.useEffect(function() {
903
+ mounted.current = true;
904
+ return function() {
905
+ mounted.current = false;
906
+ };
907
+ }, []);
908
+ function goTo(i) {
909
+ if (busy || i < 0 || i >= count) return;
910
+ setIndex(i);
911
+ if (i > maxVisited) setMaxVisited(i);
912
+ setStepError("");
913
+ }
914
+ function fail(i, message) {
915
+ markInvalid(i, true);
916
+ goTo(i);
917
+ setStepError(message);
918
+ focusBody();
919
+ }
920
+ function next() {
921
+ if (busy) return;
922
+ var message = runValidate(steps[index]);
923
+ if (message) {
924
+ fail(index, message);
925
+ return;
926
+ }
927
+ markInvalid(index, false);
928
+ goTo(Math.min(index + 1, count - 1));
929
+ }
930
+ function back() {
931
+ if (busy || index === 0) return;
932
+ goTo(index - 1);
933
+ }
934
+ function jump(i) {
935
+ if (busy || i > maxVisited) return;
936
+ goTo(i);
937
+ }
938
+ function submit() {
939
+ if (busy) return;
940
+ var bad = firstFailing(steps);
941
+ if (bad) {
942
+ fail(bad.index, bad.message);
943
+ return;
944
+ }
945
+ for (var i = 0; i < count; i++) markInvalid(i, false);
946
+ setStepError("");
947
+ if (typeof props.onSubmit === "function") props.onSubmit();
948
+ }
949
+ function cancel() {
950
+ if (busy) return;
951
+ if (typeof props.onClose === "function") props.onClose();
952
+ }
953
+ var current = steps[index];
954
+ var isLast = index >= count - 1;
955
+ var saveText = props.submitText || "\u4FDD\u5B58";
956
+ var shownError = stepError || props.error || "";
957
+ return h2(
958
+ Overlay,
959
+ props,
960
+ count > 1 ? h2(stepper.Steps, {
961
+ h: h2,
962
+ steps: steps.map(function(step) {
963
+ return { key: step.key, label: step.label, hint: step.hint, optional: step.optional };
964
+ }),
965
+ current: index,
966
+ maxVisited,
967
+ onJump: jump,
968
+ invalid,
969
+ disabled: busy,
970
+ label: props.stepsLabel || "\u521B\u5EFA\u6B65\u9AA4"
971
+ }) : null,
972
+ h2(
973
+ "div",
974
+ {
975
+ className: "wbctl-dialog-body" + (props.bodyClassName ? " " + props.bodyClassName : ""),
976
+ ref: bodyRef,
977
+ tabIndex: -1
978
+ },
979
+ current ? current.render(h2, props) : null
980
+ ),
981
+ props.footerExtra || null,
982
+ shownError ? h2("div", { className: "wbctl-dialog-err", role: "alert" }, shownError) : null,
983
+ h2(
984
+ "div",
985
+ { className: "wbctl-dialog-foot" },
986
+ count > 1 ? h2("span", { className: "wbctl-dialog-progress" }, index + 1 + " / " + count) : null,
987
+ props.footerNote ? h2("span", { className: "wbctl-dialog-note" }, props.footerNote) : null,
988
+ h2("span", { className: "wbctl-dialog-spacer" }),
989
+ index > 0 ? h2(
990
+ "button",
991
+ { type: "button", className: "wbctl-btn", onClick: back, disabled: busy },
992
+ props.backText || "\u4E0A\u4E00\u6B65"
993
+ ) : null,
994
+ h2("button", { type: "button", className: "wbctl-btn", onClick: cancel, disabled: busy }, props.cancelText || "\u53D6\u6D88"),
995
+ h2(
996
+ "button",
997
+ {
998
+ type: "button",
999
+ className: "wbctl-btn wbctl-btn-p",
1000
+ onClick: isLast ? submit : next,
1001
+ // submitDisabled 只作用于末步的保存:插件据此把「结构性不合法」(JSON 语法、无可选 action)
1002
+ // 提前反映成禁用态,避免用户点到保存才被弹回第一步。
1003
+ disabled: busy || isLast && !!props.submitDisabled
1004
+ },
1005
+ busy ? saveText + "\u4E2D\u2026" : isLast ? saveText : props.nextText || "\u4E0B\u4E00\u6B65"
1006
+ )
1007
+ )
1008
+ );
1009
+ }
1010
+ StagedDialog.displayName = opts.displayName || "StagedDialog";
1011
+ return StagedDialog;
1012
+ }
1013
+ var STYLES = [
1014
+ // 宽表单:内容多时给足横向空间,窄屏留 16px 边距后铺满。
1015
+ ".wbctl-dialog{width:min(880px,calc(100vw - 32px));max-height:min(92vh,760px);display:flex;flex-direction:column;overflow:hidden}",
1016
+ ".wbctl-dialog-body{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;padding:2px 2px 10px;outline:none}",
1017
+ ".wbctl-dialog-body:focus-visible{outline:none}",
1018
+ ".wbctl-dialog-foot{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding-top:10px;margin-top:10px;border-top:1px solid var(--wb-line,var(--wb-border))}",
1019
+ ".wbctl-dialog-progress{font-size:11.5px;color:var(--wb-muted,#666);font-variant-numeric:tabular-nums}",
1020
+ ".wbctl-dialog-note{font-size:11.5px;color:var(--wb-muted,#666);min-width:0}",
1021
+ ".wbctl-dialog-spacer{flex:1 1 auto}",
1022
+ ".wbctl-dialog-err{margin-top:8px;padding:7px 10px;border-radius:8px;border:1px solid color-mix(in oklab,var(--wb-danger,#d33) 45%,transparent);background:color-mix(in oklab,var(--wb-danger,#d33) 8%,transparent);color:var(--wb-danger,#d33);font-size:12px}",
1023
+ ".wbctl-btn{padding:6px 14px;border:1px solid var(--wb-border,#d0d5dd);border-radius:8px;background:var(--wb-card,#fff);color:inherit;font:inherit;font-size:12.5px;cursor:pointer}",
1024
+ ".wbctl-btn:hover:not(:disabled){background:color-mix(in oklab,currentColor 7%,transparent)}",
1025
+ ".wbctl-btn:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
1026
+ ".wbctl-btn:disabled{opacity:.55;cursor:default}",
1027
+ ".wbctl-btn.wbctl-btn-p{background:var(--wb-accent,#2563eb);border-color:transparent;color:var(--wb-on-accent,#fff)}",
1028
+ ".wbctl-btn.wbctl-btn-p:hover:not(:disabled){background:color-mix(in oklab,var(--wb-accent,#2563eb) 86%,#000)}",
1029
+ // 确认步:键值对清单,各插件共用,避免再各写一套只读摘要。\n ".wbctl-review{display:flex;flex-direction:column;border:1px solid var(--wb-line,var(--wb-border));border-radius:10px;overflow:hidden}",\n ".wbctl-review-row{display:grid;grid-template-columns:96px minmax(0,1fr);gap:10px;padding:8px 12px;font-size:12.5px;background:var(--wb-surface,transparent)}",\n ".wbctl-review-row+.wbctl-review-row{border-top:1px solid var(--wb-line,var(--wb-border))}",\n ".wbctl-review-k{color:var(--wb-muted,inherit);font-size:11.5px;line-height:1.6}",\n ".wbctl-review-v{min-width:0;word-break:break-word;line-height:1.6}",\n ".wbctl-note{margin:10px 0 0;font-size:11.5px;color:var(--wb-muted,inherit)}",\n // 两列字段布局:内容多的弹窗不再单列拉长,窄屏回落单列。
1030
+ ".wbctl-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 14px}",
1031
+ ".wbctl-form>.full{grid-column:1/-1}",
1032
+ "@media (max-width:760px){.wbctl-dialog{width:calc(100vw - 16px);max-height:94vh}.wbctl-form{grid-template-columns:1fr}.wbctl-form>.full{grid-column:auto}}",
1033
+ "@media (prefers-reduced-motion:reduce){.wbctl-btn{transition:none}}"
1034
+ ];
1035
+ module2.exports = {
1036
+ createStagedDialog,
1037
+ validateStep,
1038
+ firstFailing,
1039
+ styles: STYLES
1040
+ };
1041
+ }
1042
+ });
1043
+
598
1044
  // packages/addons/lib/date-picker.cjs
599
1045
  var require_date_picker = __commonJS({
600
1046
  "packages/addons/lib/date-picker.cjs"(exports2, module2) {
@@ -5495,7 +5941,7 @@ var require_styles = __commonJS({
5495
5941
  ".wbs-toast{position:fixed;left:50%;bottom:38px;transform:translateX(-50%);z-index:1200;background:var(--dsw-alias-toast-bg,#26302d);color:var(--dsw-alias-toast-label,#fff);border-radius:8px;padding:8px 14px;font-size:12px;box-shadow:0 8px 24px rgba(0,0,0,.22);max-width:80vw}",
5496
5942
  ".wbs-toast.err{background:var(--dsw-alias-state-error-primary,#9d332b)}",
5497
5943
  ".wbs-mask{position:fixed;inset:0;z-index:900;background:rgba(24,28,26,.34);display:flex;align-items:center;justify-content:center;padding:22px}",
5498
- ".wbs-modal{width:min(700px,96vw);max-height:88vh;overflow:auto;background:var(--dsw-alias-bg-layer-1,#fffdf7);border:1px solid var(--wbs-line);border-radius:14px;box-shadow:0 24px 70px rgba(0,0,0,.24);padding:18px}",
5944
+ // 分步表单的字段容器:两列排布,窄屏回落单列(宽度与步骤条来自 lib/staged-dialog.cjs)。\n ".wbs-field{display:flex;flex-direction:column;gap:5px;min-width:0}",\n ".wbs-field.full{grid-column:1 / -1}",\n ".wbs-field .wbs-label{margin:0}",\n ".wbs-modal{width:min(700px,96vw);max-height:88vh;overflow:auto;background:var(--dsw-alias-bg-layer-1,#fffdf7);border:1px solid var(--wbs-line);border-radius:14px;box-shadow:0 24px 70px rgba(0,0,0,.24);padding:18px}",
5499
5945
  ".wbs-modal.small{width:min(430px,94vw)}",
5500
5946
  ".wbs-modal-title{display:flex;align-items:center;gap:8px;font-size:16px;font-weight:650;margin-bottom:4px}",
5501
5947
  ".wbs-modal-title .wbs-svg{color:var(--wbs-accent);opacity:.85;flex:none}",
@@ -5527,7 +5973,7 @@ var require_styles = __commonJS({
5527
5973
  ".wbs-note{font-size:11px;color:var(--wbs-muted);line-height:1.6}",
5528
5974
  "@media(max-width:860px){.wbs-body{flex-direction:column}.wbs-tree{width:100%;max-height:220px}.wbs-table{min-width:760px}.wbs-root{min-height:0}}",
5529
5975
  "@media(max-width:600px){.wbs-head h2{font-size:18px}.wbs-linkrow{grid-template-columns:1fr 1fr}.wbs-modal{padding:14px}}"
5530
- ].concat(require_filter_checklist_styles()).concat(require_client_base_styles().secretFieldStyles).concat([require_date_picker_styles()("wbs")]).concat(require_switch().styles).join("\n");
5976
+ ].concat(require_stepper().styles, require_staged_dialog().styles).concat(require_filter_checklist_styles()).concat(require_client_base_styles().secretFieldStyles).concat([require_date_picker_styles()("wbs")]).concat(require_switch().styles).join("\n");
5531
5977
  }
5532
5978
  });
5533
5979
 
@@ -6809,6 +7255,7 @@ var React = require("react");
6809
7255
  var h = React.createElement;
6810
7256
  var TagFilter = require_tagfilter();
6811
7257
  var createOverlay = require_overlay();
7258
+ var staged = require_staged_dialog();
6812
7259
  (function() {
6813
7260
  var host = window.__WB_HOST__;
6814
7261
  if (!host) {
@@ -6887,6 +7334,28 @@ var createOverlay = require_overlay();
6887
7334
  return props.small ? " small" : "";
6888
7335
  }
6889
7336
  });
7337
+ var SiteFormDialog = staged.createStagedDialog({
7338
+ React: React2,
7339
+ tag: "div",
7340
+ displayName: "SiteFormDialog",
7341
+ maskClass: "wbs-mask",
7342
+ dialogClass: "wbs-modal",
7343
+ header: function(p) {
7344
+ return h2(
7345
+ "div",
7346
+ { className: "wbs-modal-title" },
7347
+ h2(Icon2, { name: p.mode === "edit" ? "edit" : "plus", size: 15 }),
7348
+ p.title,
7349
+ h2("button", { type: "button", className: "wbs-mini wbs-modal-x", title: p.cancelLabel, disabled: !!p.submitting, onClick: p.onClose }, h2(Icon2, { name: "x", size: 15 }))
7350
+ );
7351
+ },
7352
+ closeOnEscape: function(p) {
7353
+ return !p.submitting;
7354
+ },
7355
+ closeOnMask: function(p) {
7356
+ return !p.submitting;
7357
+ }
7358
+ });
6890
7359
  function SiteFormModal(props) {
6891
7360
  var api = props.api;
6892
7361
  var lang = props.lang || "zh";
@@ -6894,8 +7363,6 @@ var createOverlay = require_overlay();
6894
7363
  var site = props.site;
6895
7364
  var current = props.current || { id: "0", path: [] };
6896
7365
  var tagOn = !!props.tagOn;
6897
- var maxStep = tagOn ? 2 : 1;
6898
- var [step, setStep] = useState(0);
6899
7366
  var [name, setName] = useState(site ? site.siteName : "");
6900
7367
  var [desc, setDesc] = useState(site ? site.description : "");
6901
7368
  var [links, setLinks] = useState(function() {
@@ -6989,33 +7456,23 @@ var createOverlay = require_overlay();
6989
7456
  }
6990
7457
  function removeLink(index) {
6991
7458
  setLinks(function(prev) {
6992
- var next2 = prev.filter(function(_, i) {
7459
+ var next = prev.filter(function(_, i) {
6993
7460
  return i !== index;
6994
7461
  });
6995
- return next2.length ? next2 : [{ description: "", link: "" }];
7462
+ return next.length ? next : [{ description: "", link: "" }];
6996
7463
  });
6997
7464
  if (defaultIdx === index) setDefaultIdx(0);
6998
7465
  else if (defaultIdx > index) setDefaultIdx(defaultIdx - 1);
6999
7466
  }
7000
- function validate(toStep) {
7001
- if (toStep >= 1 && !String(name).trim()) {
7467
+ function save() {
7468
+ if (!String(name).trim()) {
7002
7469
  setError(text(lang, "requiredName"));
7003
- return false;
7470
+ return;
7004
7471
  }
7005
- if (toStep >= 2 && !dirIds.length) {
7472
+ if (!dirIds.length) {
7006
7473
  setError(text(lang, "requiredDirs"));
7007
- return false;
7474
+ return;
7008
7475
  }
7009
- setError("");
7010
- return true;
7011
- }
7012
- function next() {
7013
- if (step >= maxStep) return;
7014
- if (!validate(step + 1)) return;
7015
- setStep(step + 1);
7016
- }
7017
- function save() {
7018
- if (!validate(2)) return;
7019
7476
  setSaving(true);
7020
7477
  setError("");
7021
7478
  var siteLinks = links.filter(function(l) {
@@ -7046,170 +7503,199 @@ var createOverlay = require_overlay();
7046
7503
  setError(errText(e));
7047
7504
  });
7048
7505
  }
7049
- var steps = tagOn ? [text(lang, "step1"), text(lang, "step2"), text(lang, "step3")] : [text(lang, "step1"), text(lang, "step2")];
7050
7506
  var title = mode === "edit" ? text(lang, "editTitle") : text(lang, "createTitle");
7051
- return h2(
7052
- Modal,
7053
- { "aria-label": title, onClose: saving ? null : props.onClose },
7054
- h2(
7055
- "div",
7056
- { className: "wbs-modal-title" },
7057
- h2(Icon2, { name: mode === "edit" ? "edit" : "plus", size: 15 }),
7058
- title,
7059
- h2("button", { type: "button", className: "wbs-mini wbs-modal-x", title: text(lang, "cancel"), onClick: props.onClose }, h2(Icon2, { name: "x", size: 15 }))
7060
- ),
7061
- h2("div", { className: "wbs-steps" }, steps.map(function(s, i) {
7062
- return h2("span", { key: i, className: "wbs-step" + (i === step ? " on" : "") }, i + 1 + " \xB7 " + s);
7063
- })),
7064
- step === 0 ? h2(
7065
- "div",
7066
- null,
7067
- h2("label", { className: "wbs-label" }, text(lang, "siteName")),
7068
- h2("input", {
7069
- className: "wbs-input",
7070
- value: name,
7071
- autoFocus: true,
7072
- placeholder: text(lang, "siteNamePh"),
7073
- onChange: function(e) {
7074
- setName(e.target.value);
7075
- }
7076
- }),
7077
- h2("label", { className: "wbs-label" }, text(lang, "desc")),
7078
- h2("textarea", {
7079
- className: "wbs-textarea",
7080
- value: desc,
7081
- placeholder: text(lang, "descPh"),
7082
- onChange: function(e) {
7083
- setDesc(e.target.value);
7084
- }
7085
- }),
7086
- h2("label", { className: "wbs-label" }, text(lang, "linkList")),
7087
- links.map(function(l, i) {
7088
- return h2(
7507
+ var steps = [
7508
+ {
7509
+ key: "basic",
7510
+ label: text(lang, "step1"),
7511
+ render: function(hh) {
7512
+ return hh(
7089
7513
  "div",
7090
- { className: "wbs-linkrow", key: i },
7091
- h2("input", {
7092
- className: "wbs-input",
7093
- value: l.description,
7094
- placeholder: text(lang, "linkDesc"),
7095
- onChange: function(e) {
7096
- updateLink(i, "description", e.target.value);
7097
- }
7098
- }),
7099
- h2("input", {
7100
- className: "wbs-input",
7101
- value: l.link,
7102
- placeholder: text(lang, "linkUrl"),
7103
- onChange: function(e) {
7104
- updateLink(i, "link", e.target.value);
7105
- }
7106
- }),
7107
- h2(
7108
- "label",
7109
- { className: "wbs-radio", title: text(lang, "setDefault") },
7110
- h2("input", {
7111
- type: "radio",
7112
- name: "wbs-default-link",
7113
- checked: defaultIdx === i,
7114
- onChange: function() {
7115
- setDefaultIdx(i);
7514
+ { className: "wbctl-form" },
7515
+ hh(
7516
+ "div",
7517
+ { className: "wbs-field" },
7518
+ hh("label", { className: "wbs-label" }, text(lang, "siteName")),
7519
+ hh("input", {
7520
+ className: "wbs-input",
7521
+ value: name,
7522
+ placeholder: text(lang, "siteNamePh"),
7523
+ onChange: function(e) {
7524
+ setName(e.target.value);
7116
7525
  }
7117
- }),
7118
- text(lang, "default")
7526
+ })
7119
7527
  ),
7120
- h2("button", { type: "button", className: "wbs-mini", title: text(lang, "removeLink"), onClick: function() {
7121
- removeLink(i);
7122
- } }, h2(Icon2, { name: "x", size: 13 }))
7123
- );
7124
- }),
7125
- h2("button", { type: "button", className: "wbs-btn sm", onClick: addLink }, h2(Icon2, { name: "plus", size: 13 }), text(lang, "addLink"))
7126
- ) : null,
7127
- step === 1 ? h2(
7128
- "div",
7129
- null,
7130
- h2("div", { className: "wbs-label" }, text(lang, "chooseDirs")),
7131
- !flatDirs.length ? h2("div", { className: "wbs-note" }, text(lang, "noDirs")) : h2(
7132
- "div",
7133
- { className: "wbs-dirlist" },
7134
- flatDirs.map(function(item) {
7135
- var id = String(item.node.id);
7136
- return h2(
7137
- "label",
7138
- {
7139
- key: id,
7140
- className: "wbs-dircheck",
7141
- style: { paddingLeft: 6 + item.depth * 16 }
7142
- },
7143
- h2("input", {
7144
- type: "checkbox",
7145
- checked: dirIds.indexOf(id) >= 0,
7146
- onChange: function() {
7147
- toggleDir(id);
7528
+ hh(
7529
+ "div",
7530
+ { className: "wbs-field" },
7531
+ hh("label", { className: "wbs-label" }, text(lang, "desc")),
7532
+ hh("textarea", {
7533
+ className: "wbs-textarea",
7534
+ rows: 3,
7535
+ value: desc,
7536
+ placeholder: text(lang, "descPh"),
7537
+ onChange: function(e) {
7538
+ setDesc(e.target.value);
7148
7539
  }
7540
+ })
7541
+ ),
7542
+ hh(
7543
+ "div",
7544
+ { className: "wbs-field full" },
7545
+ hh("label", { className: "wbs-label" }, text(lang, "linkList")),
7546
+ links.map(function(l, i) {
7547
+ return hh(
7548
+ "div",
7549
+ { className: "wbs-linkrow", key: i },
7550
+ hh("input", {
7551
+ className: "wbs-input",
7552
+ value: l.description,
7553
+ placeholder: text(lang, "linkDesc"),
7554
+ onChange: function(e) {
7555
+ updateLink(i, "description", e.target.value);
7556
+ }
7557
+ }),
7558
+ hh("input", {
7559
+ className: "wbs-input",
7560
+ value: l.link,
7561
+ placeholder: text(lang, "linkUrl"),
7562
+ onChange: function(e) {
7563
+ updateLink(i, "link", e.target.value);
7564
+ }
7565
+ }),
7566
+ hh(
7567
+ "label",
7568
+ { className: "wbs-radio", title: text(lang, "setDefault") },
7569
+ hh("input", {
7570
+ type: "radio",
7571
+ name: "wbs-default-link",
7572
+ checked: defaultIdx === i,
7573
+ onChange: function() {
7574
+ setDefaultIdx(i);
7575
+ }
7576
+ }),
7577
+ text(lang, "default")
7578
+ ),
7579
+ hh("button", { type: "button", className: "wbs-mini", title: text(lang, "removeLink"), onClick: function() {
7580
+ removeLink(i);
7581
+ } }, hh(Icon2, { name: "x", size: 13 }))
7582
+ );
7149
7583
  }),
7150
- h2("span", null, item.node.name)
7151
- );
7152
- })
7153
- ),
7154
- h2("div", { className: "wbs-note", style: { marginTop: 8 } }, "\u7AD9\u70B9\u53EF\u540C\u65F6\u6302\u5728\u591A\u4E2A\u76EE\u5F55\u4E0B\uFF1B\u5217\u8868\u4F1A\u6309\u76EE\u5F55\u5B50\u6811\u8FC7\u6EE4\u3002")
7155
- ) : null,
7156
- tagOn && step === 2 ? h2(
7157
- "div",
7158
- null,
7159
- h2("div", { className: "wbs-label" }, text(lang, "chooseTags")),
7160
- tags.length ? h2("div", { className: "wbs-chips" }, tags.map(function(t) {
7161
- return h2(
7162
- "span",
7163
- { className: "wbs-chip", key: t.id },
7164
- t.name,
7165
- h2("button", { type: "button", onClick: function() {
7166
- toggleTag(t);
7167
- }, title: "\u79FB\u9664" }, h2(Icon2, { name: "x", size: 12 }))
7584
+ hh("button", { type: "button", className: "wbs-btn sm", onClick: addLink }, hh(Icon2, { name: "plus", size: 13 }), text(lang, "addLink"))
7585
+ )
7168
7586
  );
7169
- })) : h2("div", { className: "wbs-note" }, "\u6682\u672A\u9009\u62E9\u6807\u7B7E"),
7170
- h2(
7171
- "div",
7172
- { className: "wbs-tagsearch", style: { marginTop: 10 } },
7173
- h2("input", {
7174
- className: "wbs-input",
7175
- value: tagQuery,
7176
- placeholder: text(lang, "tagSearch"),
7177
- onChange: function(e) {
7178
- setTagQuery(e.target.value);
7179
- }
7180
- })
7181
- ),
7182
- h2("div", { className: "wbs-tagresults" }, tagResults.length ? tagResults.map(function(t) {
7183
- var on = tags.some(function(x) {
7184
- return x.id === t.id;
7185
- });
7186
- return h2(
7187
- "button",
7188
- {
7189
- key: t.id,
7190
- type: "button",
7191
- className: "wbs-tagresult" + (on ? " on" : ""),
7192
- onClick: function() {
7193
- toggleTag(t);
7194
- }
7195
- },
7196
- h2(Icon2, { name: on ? "check" : "plus", size: 12 }),
7197
- h2("span", null, t.name)
7587
+ },
7588
+ validate: function() {
7589
+ return String(name).trim() ? "" : text(lang, "requiredName");
7590
+ }
7591
+ },
7592
+ {
7593
+ key: "dirs",
7594
+ label: text(lang, "step2"),
7595
+ render: function(hh) {
7596
+ return hh(
7597
+ "div",
7598
+ { className: "wbs-field" },
7599
+ hh("div", { className: "wbs-label" }, text(lang, "chooseDirs")),
7600
+ !flatDirs.length ? hh("div", { className: "wbs-note" }, text(lang, "noDirs")) : hh(
7601
+ "div",
7602
+ { className: "wbs-dirlist" },
7603
+ flatDirs.map(function(item) {
7604
+ var id = String(item.node.id);
7605
+ return hh(
7606
+ "label",
7607
+ {
7608
+ key: id,
7609
+ className: "wbs-dircheck",
7610
+ style: { paddingLeft: 6 + item.depth * 16 }
7611
+ },
7612
+ hh("input", {
7613
+ type: "checkbox",
7614
+ checked: dirIds.indexOf(id) >= 0,
7615
+ onChange: function() {
7616
+ toggleDir(id);
7617
+ }
7618
+ }),
7619
+ hh("span", null, item.node.name)
7620
+ );
7621
+ })
7622
+ ),
7623
+ hh("div", { className: "wbs-note", style: { marginTop: 8 } }, "\u7AD9\u70B9\u53EF\u540C\u65F6\u6302\u5728\u591A\u4E2A\u76EE\u5F55\u4E0B\uFF1B\u5217\u8868\u4F1A\u6309\u76EE\u5F55\u5B50\u6811\u8FC7\u6EE4\u3002")
7198
7624
  );
7199
- }) : h2("div", { className: "wbs-note", style: { padding: 6 } }, text(lang, "noTags"))),
7200
- h2("div", { className: "wbs-note", style: { marginTop: 8 } }, "\u6807\u7B7E\u7531\u6807\u7B7E\u5B50\u63D2\u4EF6\u63D0\u4F9B\uFF0C\u53EF\u591A\u9009\u3002")
7201
- ) : null,
7202
- h2(
7203
- "div",
7204
- { className: "wbs-formfoot" },
7205
- h2("div", { className: "wbs-formerr" }, error || ""),
7206
- step > 0 ? h2("button", { type: "button", className: "wbs-btn", disabled: saving, onClick: function() {
7207
- setStep(step - 1);
7208
- } }, h2(Icon2, { name: "chevron-left", size: 13 }), text(lang, "back")) : null,
7209
- h2("button", { type: "button", className: "wbs-btn", disabled: saving, onClick: props.onClose }, text(lang, "cancel")),
7210
- step < maxStep ? h2("button", { type: "button", className: "wbs-btn primary", onClick: next }, text(lang, "nextStep"), h2(Icon2, { name: "chevron-right", size: 13 })) : h2("button", { type: "button", className: "wbs-btn primary", disabled: saving, onClick: save }, h2(Icon2, { name: "check", size: 13 }), saving ? text(lang, "saving") : text(lang, "save"))
7211
- )
7212
- );
7625
+ },
7626
+ validate: function() {
7627
+ return dirIds.length ? "" : text(lang, "requiredDirs");
7628
+ }
7629
+ },
7630
+ tagOn ? {
7631
+ key: "tags",
7632
+ label: text(lang, "step3"),
7633
+ optional: true,
7634
+ render: function(hh) {
7635
+ return hh(
7636
+ "div",
7637
+ { className: "wbs-field" },
7638
+ hh("div", { className: "wbs-label" }, text(lang, "chooseTags")),
7639
+ tags.length ? hh("div", { className: "wbs-chips" }, tags.map(function(t) {
7640
+ return hh(
7641
+ "span",
7642
+ { className: "wbs-chip", key: t.id },
7643
+ t.name,
7644
+ hh("button", { type: "button", onClick: function() {
7645
+ toggleTag(t);
7646
+ }, title: "\u79FB\u9664" }, hh(Icon2, { name: "x", size: 12 }))
7647
+ );
7648
+ })) : hh("div", { className: "wbs-note" }, "\u6682\u672A\u9009\u62E9\u6807\u7B7E"),
7649
+ hh(
7650
+ "div",
7651
+ { className: "wbs-tagsearch", style: { marginTop: 10 } },
7652
+ hh("input", {
7653
+ className: "wbs-input",
7654
+ value: tagQuery,
7655
+ placeholder: text(lang, "tagSearch"),
7656
+ onChange: function(e) {
7657
+ setTagQuery(e.target.value);
7658
+ }
7659
+ })
7660
+ ),
7661
+ hh("div", { className: "wbs-tagresults" }, tagResults.length ? tagResults.map(function(t) {
7662
+ var on = tags.some(function(x) {
7663
+ return x.id === t.id;
7664
+ });
7665
+ return hh(
7666
+ "button",
7667
+ {
7668
+ key: t.id,
7669
+ type: "button",
7670
+ className: "wbs-tagresult" + (on ? " on" : ""),
7671
+ onClick: function() {
7672
+ toggleTag(t);
7673
+ }
7674
+ },
7675
+ hh(Icon2, { name: on ? "check" : "plus", size: 12 }),
7676
+ hh("span", null, t.name)
7677
+ );
7678
+ }) : hh("div", { className: "wbs-note", style: { padding: 6 } }, text(lang, "noTags"))),
7679
+ hh("div", { className: "wbs-note", style: { marginTop: 8 } }, "\u6807\u7B7E\u7531\u6807\u7B7E\u5B50\u63D2\u4EF6\u63D0\u4F9B\uFF0C\u53EF\u591A\u9009\u3002")
7680
+ );
7681
+ }
7682
+ } : null
7683
+ ].filter(Boolean);
7684
+ return h2(SiteFormDialog, {
7685
+ title,
7686
+ mode,
7687
+ cancelLabel: text(lang, "cancel"),
7688
+ steps,
7689
+ submitting: saving,
7690
+ error,
7691
+ onClose: props.onClose,
7692
+ onSubmit: save,
7693
+ submitText: text(lang, "save"),
7694
+ cancelText: text(lang, "cancel"),
7695
+ nextText: text(lang, "nextStep"),
7696
+ backText: text(lang, "back"),
7697
+ stepsLabel: text(lang, "createTitle")
7698
+ });
7213
7699
  }
7214
7700
  function DirModal(props) {
7215
7701
  var api = props.api;
@@ -8036,7 +8522,7 @@ var createOverlay = require_overlay();
8036
8522
  injectCss();
8037
8523
  host.registerAddon({
8038
8524
  id: "wb-addon-sites",
8039
- version: "1.12.9",
8525
+ version: "1.12.11",
8040
8526
  icon: icons.ICONS["globe"],
8041
8527
  views: [
8042
8528
  { id: "stats", icon: tabIcon("chart"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: statsView.SitesStatsView },