@fibrae/semi-foundation 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/components/date-picker/months-grid-foundation.d.ts +2 -2
  2. package/dist/components/form/form.css +47 -2
  3. package/dist/components/form/form.scss +44 -2
  4. package/dist/components/form/foundation.d.ts +2 -1
  5. package/dist/components/form/foundation.js +63 -3
  6. package/dist/components/form/interface.d.ts +9 -1
  7. package/dist/components/form/json-schema.d.ts +35 -2
  8. package/dist/components/form/json-schema.js +75 -8
  9. package/dist/components/form/variables.scss +4 -0
  10. package/dist/components/pagination/foundation.d.ts +1 -1
  11. package/dist/components/select/foundation.d.ts +1 -1
  12. package/dist/components/slider/foundation.d.ts +1 -1
  13. package/dist/components/table/foundation.d.ts +8 -0
  14. package/dist/components/table/foundation.js +12 -0
  15. package/dist/components/table/rtl.scss +5 -0
  16. package/dist/components/table/table.css +123 -0
  17. package/dist/components/table/table.scss +174 -0
  18. package/dist/components/toast/toast.css +1 -1
  19. package/dist/components/toast/toast.scss +2 -1
  20. package/dist/components/tooltip/tooltip.css +1 -1
  21. package/dist/components/tooltip/tooltip.scss +4 -2
  22. package/dist/components/upload/constants.d.ts +1 -1
  23. package/dist/locale/interface.d.ts +4 -0
  24. package/dist/locale/source/en_US.js +3 -1
  25. package/dist/locale/source/zh_CN.js +3 -1
  26. package/dist/utils/index.d.ts +2 -2
  27. package/dist/utils/index.js +2 -2
  28. package/dist/utils/scroll-lock.d.ts +4 -3
  29. package/dist/utils/scroll-lock.js +15 -11
  30. package/dist/utils/supports.d.ts +2 -0
  31. package/dist/utils/supports.js +7 -1
  32. package/package.json +2 -2
@@ -110,10 +110,10 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
110
110
  * Which panels show their year and month picker; while one does, its weeks need a minHeight, or a change of the
111
111
  * number of weeks makes the scroll list unstable
112
112
  */
113
- static getYAMOpenType(state: Pick<MonthsGridFoundationState, 'monthLeft' | 'monthRight'>): "left" | "right" | "none" | "both";
113
+ static getYAMOpenType(state: Pick<MonthsGridFoundationState, 'monthLeft' | 'monthRight'>): "none" | "left" | "right" | "both";
114
114
  static isYearOrTime(panel: PanelState): boolean;
115
115
  /** The `x-open-type` of a panel: what it shows in place of, or beside, its month */
116
- static getOpenType(panel: PanelState): "time" | "date" | "year";
116
+ static getOpenType(panel: PanelState): "date" | "time" | "year";
117
117
  static formatMonthText(locale: Pick<Locale['DatePicker'], 'monthText' | 'months'>, month?: Date): string;
118
118
  /** The texts of a panel's date and time switch; the date is the picked range endpoint, else the shown date */
119
119
  static getSwitchTexts({ rangeEndpoint, showDate, dateFormat, format: formatProp, locale, dateFnsLocale }: {
@@ -62,8 +62,8 @@
62
62
  align-items: center;
63
63
  margin-inline-start: 4px;
64
64
  }
65
- .semi-form-field-label-required .semi-form-field-label-text::after {
66
- margin-inline-start: 4px;
65
+ .semi-form-field-label-required .semi-form-field-label-text::before {
66
+ margin-inline-end: 4px;
67
67
  font-weight: var(--semi-font-weight-bold);
68
68
  color: var(--semi-color-danger);
69
69
  content: "*";
@@ -80,6 +80,37 @@
80
80
  .semi-form-field-label-right {
81
81
  text-align: end;
82
82
  }
83
+ .semi-form-field-label-with-tooltip {
84
+ display: flex;
85
+ flex-shrink: 0;
86
+ align-items: center;
87
+ max-width: 100%;
88
+ padding-inline-end: 16px;
89
+ }
90
+ .semi-form-field-label-with-tooltip .semi-form-field-label {
91
+ flex: 0 1 auto;
92
+ min-width: 0;
93
+ padding-inline-end: 4px;
94
+ }
95
+ .semi-form-field-label-tooltip {
96
+ padding: 0;
97
+ margin: 0;
98
+ font: inherit;
99
+ color: inherit;
100
+ cursor: pointer;
101
+ background: none;
102
+ border: 0;
103
+ }
104
+ .semi-form-field-label-tooltip:focus-visible {
105
+ outline: 2px solid var(--semi-color-primary-light-active);
106
+ }
107
+ .semi-form-field-label-tooltip {
108
+ display: inline-flex;
109
+ flex-shrink: 0;
110
+ align-items: center;
111
+ font-size: 12px;
112
+ color: var(--semi-color-tertiary);
113
+ }
83
114
  .semi-form-field-error-message, .semi-form-field-help-text {
84
115
  font-family: var(--semi-font-family-regular);
85
116
  font-size: var(--semi-font-size-regular);
@@ -217,6 +248,13 @@
217
248
  color: var(--semi-color-text-0);
218
249
  border-bottom: 1px solid var(--semi-color-border);
219
250
  }
251
+ .semi-form-section-extra {
252
+ font-family: var(--semi-font-family-regular);
253
+ font-size: var(--semi-font-size-regular);
254
+ line-height: var(--semi-line-height-regular);
255
+ margin-bottom: 4px;
256
+ color: var(--semi-color-tertiary);
257
+ }
220
258
  .semi-form-section:nth-of-type(1) {
221
259
  margin-top: 0;
222
260
  }
@@ -237,4 +275,11 @@
237
275
  flex-shrink: 0;
238
276
  gap: 4px;
239
277
  padding-block-end: 12px;
278
+ }
279
+
280
+ .semi-form-schema-array-row-single {
281
+ align-items: flex-start;
282
+ }
283
+ .semi-form-schema-array-row-single .semi-form-schema-array-row-actions {
284
+ padding-block: 12px 0;
240
285
  }}
@@ -1,5 +1,6 @@
1
1
  @use 'semi:theme' as *;
2
2
  @use 'variables' as *;
3
+ @use '../../base/mixin' as *;
3
4
 
4
5
  $form: #{$prefix}-form;
5
6
  $field: #{$prefix}-form-field;
@@ -102,8 +103,8 @@ $rating: #{$prefix}-rating;
102
103
 
103
104
  &-required {
104
105
  .#{$field}-label-text {
105
- &::after {
106
- margin-inline-start: $spacing-form_label_required-marginLeft;
106
+ &::before {
107
+ margin-inline-end: $spacing-form_label_required-marginLeft;
107
108
  font-weight: $font-form_requiredMark-fontWeight;
108
109
  color: $color-form_requiredMark-text-default;
109
110
  content: '*';
@@ -128,6 +129,31 @@ $rating: #{$prefix}-rating;
128
129
  }
129
130
  }
130
131
 
132
+ // The tooltip button sits beside the label element, not in it: a label's content names the control, and a
133
+ // button must not be nested in a label. The width of the label moves to this wrapper to keep columns aligned.
134
+ &-field-label-with-tooltip {
135
+ display: flex;
136
+ flex-shrink: 0;
137
+ align-items: center;
138
+ max-width: 100%;
139
+ padding-inline-end: $spacing-form_label-paddingRight;
140
+
141
+ .#{$field}-label {
142
+ flex: 0 1 auto;
143
+ min-width: 0;
144
+ padding-inline-end: $spacing-form_label_tooltip-marginLeft;
145
+ }
146
+ }
147
+
148
+ &-field-label-tooltip {
149
+ @include bare-button;
150
+ display: inline-flex;
151
+ flex-shrink: 0;
152
+ align-items: center;
153
+ font-size: $width-form_label_tooltip-icon;
154
+ color: $color-form_label_tooltip-icon-default;
155
+ }
156
+
131
157
  &-field-error-message,
132
158
  &-field-help-text {
133
159
  @include font-size-regular;
@@ -287,6 +313,12 @@ $rating: #{$prefix}-rating;
287
313
  border-bottom: $width-form_section-border solid $color-form_section-border-default;
288
314
  }
289
315
 
316
+ &-extra {
317
+ @include font-size-regular;
318
+ margin-bottom: $spacing-form_section_extra-marginBottom;
319
+ color: $color-form_label_extra-text-default;
320
+ }
321
+
290
322
  &:nth-of-type(1) {
291
323
  margin-top: 0;
292
324
  }
@@ -310,3 +342,13 @@ $rating: #{$prefix}-rating;
310
342
  // aligns the buttons with the control of the row's last field, not with the field's bottom padding
311
343
  padding-block-end: $spacing-form_field_vertical-paddingBottom;
312
344
  }
345
+
346
+ // a single-value row has no label: the buttons align with the control's top, so an error message below the control
347
+ // only grows the row downward
348
+ .#{$form}-schema-array-row-single {
349
+ align-items: flex-start;
350
+
351
+ .#{$form}-schema-array-row-actions {
352
+ padding-block: $spacing-form_field_vertical-paddingTop 0;
353
+ }
354
+ }
@@ -65,7 +65,8 @@ export default class FormFoundation<E = unknown> extends BaseFoundation<BaseForm
65
65
  setValues: (values: any, opts?: SetValuesConfig) => void;
66
66
  submitForm: () => void;
67
67
  getFieldExist: (field: string) => boolean;
68
- scrollToField: (field: string, scrollOpts?: Options) => void;
68
+ scrollToField: (field: string, scrollOpts?: Options) => Promise<void>;
69
+ focusField: (field: string, scrollOpts?: Options) => Promise<void>;
69
70
  scrollToError: (opts?: ScrollToErrorOpts) => void;
70
71
  setValue: (field: string, value: any, opts?: CallOpts) => void;
71
72
  setError: (field: string, error: unknown, opts?: CallOpts) => void;
@@ -1,4 +1,5 @@
1
1
  import BaseFoundation from "../../base/foundation.js";
2
+ import FocusTrapHandle from "../../base/focus-handle.js";
2
3
  import isPromise from "../../utils/is-promise.js";
3
4
  import warning from "../../utils/warning.js";
4
5
  import { get as get$1, has as has$1, isEmpty, remove, set as set$1 } from "../../utils/object.js";
@@ -15,6 +16,8 @@ const SILENT = {
15
16
  skipNotify: true,
16
17
  skipRender: true
17
18
  };
19
+ const REVEAL_TIMEOUT = 1e3;
20
+ const HIDDEN_SELECTOR = "[inert], [hidden]";
18
21
  const prefix = cssClasses.PREFIX;
19
22
  const ERROR_SELECTOR = `.${prefix}-field-error-message`;
20
23
  const errorField = (errorDOM) => errorDOM.closest(`.${prefix}-field, .${prefix}-field-group`);
@@ -61,6 +64,7 @@ var FormFoundation = class extends BaseFoundation {
61
64
  #pendingSchemaRun;
62
65
  #latestSchemaRun;
63
66
  #detachedErrorPaths = [];
67
+ #cancelReveal;
64
68
  constructor(adapter) {
65
69
  super(adapter);
66
70
  let { initValues } = this.adapter.getProps();
@@ -959,12 +963,64 @@ var FormFoundation = class extends BaseFoundation {
959
963
  const errorDOM = this.#getFieldDOM(field)?.querySelector(ERROR_SELECTOR);
960
964
  return errorDOM && errorField(errorDOM);
961
965
  }
966
+ /**
967
+ * A field root, or the element a SchemaField renderer gave the `x-field-id` of an array or object node. One inside
968
+ * collapsed content kept in the DOM (Collapsible keepDOM marks it inert) counts as not rendered.
969
+ */
970
+ #findRendered(field) {
971
+ const element = this.adapter.getFormElement()?.querySelector(`[x-field-id="${CSS.escape(field)}"]`);
972
+ return element && !element.closest(HIDDEN_SELECTOR) ? element : null;
973
+ }
974
+ /**
975
+ * Asks the caller to reveal `field` (expand a collapsed card) and resolves with its element once mounted, or null
976
+ * after REVEAL_TIMEOUT; a newer call or unmounting cancels the wait.
977
+ * shortcut: the element is scrolled to as soon as it mounts, so a container still running an expand animation can
978
+ * leave it short of the target; wait for transitionend if callers report that.
979
+ */
980
+ #reveal(field) {
981
+ const formElement = this.adapter.getFormElement();
982
+ if (!formElement) return Promise.resolve(null);
983
+ return new Promise((resolve) => {
984
+ const finish = (element) => {
985
+ observer.disconnect();
986
+ clearTimeout(timer);
987
+ this.#cancelReveal = void 0;
988
+ resolve(element);
989
+ };
990
+ const observer = new MutationObserver(() => {
991
+ const element = this.#findRendered(field);
992
+ if (element) finish(element);
993
+ });
994
+ const timer = setTimeout(() => finish(null), REVEAL_TIMEOUT);
995
+ this.#cancelReveal = () => finish(null);
996
+ observer.observe(formElement, {
997
+ childList: true,
998
+ subtree: true,
999
+ attributes: true,
1000
+ attributeFilter: [
1001
+ "x-field-id",
1002
+ "inert",
1003
+ "hidden"
1004
+ ]
1005
+ });
1006
+ this.adapter.notifyRevealField(field);
1007
+ });
1008
+ }
962
1009
  #scrollToField(field, scrollOpts = {
963
1010
  behavior: "smooth",
964
1011
  block: "start"
965
1012
  }) {
966
- const fieldDOM = this.#getFieldExist(field) ? this.#getFieldDOM(field) : null;
967
- if (fieldDOM) scrollIntoView$1(fieldDOM, scrollOpts);
1013
+ this.#cancelReveal?.();
1014
+ const scroll = (element) => {
1015
+ if (element) scrollIntoView$1(element, scrollOpts);
1016
+ return element;
1017
+ };
1018
+ const found = this.#findRendered(field);
1019
+ return found ? Promise.resolve(scroll(found)) : this.#reveal(field).then(scroll);
1020
+ }
1021
+ async #focusField(field, scrollOpts) {
1022
+ const element = await this.#scrollToField(field, scrollOpts);
1023
+ (element && FocusTrapHandle.getFocusableElements(element).find((candidate) => !candidate.closest(`.${prefix}-field-label, .${prefix}-field-label-with-tooltip`)))?.focus({ preventScroll: true });
968
1024
  }
969
1025
  #scrollToError(config) {
970
1026
  const { field, index, scrollOpts = {
@@ -1004,6 +1060,7 @@ var FormFoundation = class extends BaseFoundation {
1004
1060
  }
1005
1061
  destroy() {
1006
1062
  this.#destroyed = true;
1063
+ this.#cancelReveal?.();
1007
1064
  this.#cancelDebouncedValidation();
1008
1065
  this.#unregistered = [];
1009
1066
  }
@@ -1100,7 +1157,10 @@ var FormFoundation = class extends BaseFoundation {
1100
1157
  setValues: (values, opts) => this.#setValues(values, opts ?? { isOverride: false }),
1101
1158
  submitForm: () => this.submit(),
1102
1159
  getFieldExist: (field) => this.#getFieldExist(field),
1103
- scrollToField: (field, scrollOpts) => this.#scrollToField(field, scrollOpts),
1160
+ scrollToField: async (field, scrollOpts) => {
1161
+ await this.#scrollToField(field, scrollOpts);
1162
+ },
1163
+ focusField: (field, scrollOpts) => this.#focusField(field, scrollOpts),
1104
1164
  scrollToError: (opts) => this.#scrollToError(opts)
1105
1165
  };
1106
1166
  };
@@ -78,6 +78,8 @@ export interface BaseFormAdapter<P = Record<string, any>, Values extends object
78
78
  notifyValueChange: (values: any, changedValues: any) => void;
79
79
  notifyErrorChange: (errors: any, changedError: any) => void;
80
80
  notifyReset: () => void;
81
+ /** scrollToField or focusField found nothing rendered at `field`: the caller expands what hides it */
82
+ notifyRevealField: (field: string) => void;
81
83
  /** The rendered form element; null before mount and after unmount */
82
84
  getFormElement: () => Element | null;
83
85
  }
@@ -150,7 +152,13 @@ export interface BaseFormApi<T extends object = any, O = T> {
150
152
  getInitValues: () => any;
151
153
  getValues: () => T;
152
154
  setValues: (fieldsValue: Partial<T>, config?: SetValuesConfig) => void;
153
- scrollToField: <K extends FieldPath<T>>(field: K, scrollConfig?: Options) => void;
155
+ /**
156
+ * Scrolls to the field, ArrayField container or SchemaField node at `field`. When nothing is rendered there, calls
157
+ * the Form's onRevealField and waits up to a second for it to mount.
158
+ */
159
+ scrollToField: <K extends FieldPath<T>>(field: K, scrollConfig?: Options) => Promise<void>;
160
+ /** scrollToField, then focuses the first focusable element inside, a tooltip trigger in a label excepted */
161
+ focusField: <K extends FieldPath<T>>(field: K, scrollConfig?: Options) => Promise<void>;
154
162
  scrollToError: <K extends FieldPath<T>>(config?: ScrollToErrorOptions<K>) => void;
155
163
  }
156
164
  export interface CallOpts {
@@ -1,3 +1,4 @@
1
+ import { Locale } from "../../locale/interface.js";
1
2
  import { StandardSchema } from "./interface.js";
2
3
  export type JsonSchema = Record<string, any>;
3
4
  export type SchemaFieldKind = 'input' | 'textarea' | 'number' | 'switch' | 'select' | 'object' | 'array' | 'unsupported';
@@ -12,6 +13,14 @@ export interface SchemaFieldNode {
12
13
  /** `title`, else the property name; undefined for an array item */
13
14
  title?: string;
14
15
  description?: string;
16
+ /** Path segments from the schema root: 0 for the root, also when SchemaField starts below it */
17
+ depth: number;
18
+ /** Set on an array item: its row index and the array's title (undefined for an untitled array item) and key */
19
+ item?: {
20
+ index: number;
21
+ arrayTitle?: string;
22
+ arrayKey: string | number;
23
+ };
15
24
  required: boolean;
16
25
  format?: string;
17
26
  default?: unknown;
@@ -38,5 +47,29 @@ export interface SchemaFieldNode {
38
47
  export declare function resolveJsonSchema(jsonSchema?: JsonSchema, schema?: StandardSchema): JsonSchema | undefined;
39
48
  /** The node at `field` ('' = root), walking properties and items; throws when the path is not in the schema */
40
49
  export declare function describeSchemaField(root: JsonSchema, field?: string): SchemaFieldNode;
41
- /** Value of a new array row: object -> {} with required nested objects and arrays prefilled (arrays with minItems blank rows), other -> undefined */
42
- export declare function blankRow(root: JsonSchema, arrayNode: SchemaFieldNode): unknown;
50
+ /**
51
+ * The semiRenderers name of a single-value array row, undefined for any other node. Such a row shows no label or
52
+ * description: the array's Section shows them once, and the row is named "<array title> item N".
53
+ */
54
+ export declare function singleItemName({ item, kind }: SchemaFieldNode, messages: Pick<Locale['Form'], 'item' | 'arrayItem'>): string;
55
+ /** What an array node allows with `count` rows; a fixed array (minItems === maxItems) neither adds nor removes */
56
+ export declare function arrayState(node: SchemaFieldNode, count: number): {
57
+ count: number;
58
+ minItems: number;
59
+ maxItems: number;
60
+ fixed: boolean;
61
+ canAdd: boolean;
62
+ canRemove: boolean;
63
+ };
64
+ /** The props semiRenderers gives the Form control of a leaf node, by kind */
65
+ export declare function controlProps(node: SchemaFieldNode): Record<string, unknown>;
66
+ export declare const schemaFieldWarnings: {
67
+ noSchema: string;
68
+ noRenderer: (field: string, kind: string) => string;
69
+ unsupported: (field: string) => string;
70
+ };
71
+ /**
72
+ * Value of a new row of the array at `arrayField`: object -> {} with required nested objects and arrays prefilled
73
+ * (arrays with minItems blank rows), other -> undefined
74
+ */
75
+ export declare function blankRow(root: JsonSchema, arrayField: string): unknown;
@@ -1,3 +1,4 @@
1
+ import { formatLocale } from "../../locale/format.js";
1
2
  import { toPath } from "es-toolkit/compat";
2
3
  // src/components/form/json-schema.ts
3
4
  const SINGLE_LINE_MAX_LENGTH = 160;
@@ -77,13 +78,15 @@ const bound = (values, pick) => {
77
78
  };
78
79
  const childPath = (field, name) => IDENTIFIER.test(name) ? field ? `${field}.${name}` : name : `${field}[${JSON.stringify(name)}]`;
79
80
  const isRequired = (parent, name) => Array.isArray(parent.required) && parent.required.includes(name);
80
- function buildNode(root, { schema, seen }, field, key, required, fallbackTitle) {
81
+ function buildNode(root, { schema, seen }, field, key, required, fallbackTitle, item) {
81
82
  const base = {
82
83
  field,
83
84
  pattern: field.replaceAll(/\[\d+\]/g, "[]"),
84
85
  key,
85
86
  title: schema.title ?? fallbackTitle,
86
87
  description: schema.description,
88
+ depth: field === "" ? 0 : toPath(field).length,
89
+ item,
87
90
  required,
88
91
  format: schema.format,
89
92
  default: schema.default,
@@ -155,8 +158,15 @@ function buildNode(root, { schema, seen }, field, key, required, fallbackTitle)
155
158
  }
156
159
  /** Explicit wins; otherwise the Form schema's Standard JSON Schema input (target draft-2020-12); undefined when neither exists */
157
160
  function resolveJsonSchema(jsonSchema, schema) {
158
- return jsonSchema ?? schema?.["~standard"].jsonSchema?.input({ target: "draft-2020-12" });
161
+ if (jsonSchema || !schema) return jsonSchema;
162
+ let converted = convertedSchemas.get(schema);
163
+ if (!converted) {
164
+ converted = schema["~standard"].jsonSchema?.input({ target: "draft-2020-12" });
165
+ if (converted) convertedSchemas.set(schema, converted);
166
+ }
167
+ return converted;
159
168
  }
169
+ const convertedSchemas = /* @__PURE__ */ new WeakMap();
160
170
  /** The node at `field` ('' = root), walking properties and items; throws when the path is not in the schema */
161
171
  function describeSchemaField(root, field = "") {
162
172
  const fail = () => /* @__PURE__ */ new Error(`Schema has no field "${field}"`);
@@ -164,16 +174,23 @@ function describeSchemaField(root, field = "") {
164
174
  let key = "";
165
175
  let required = false;
166
176
  let fallbackTitle;
177
+ let item;
167
178
  for (const segment of field === "" ? [] : toPath(field)) {
168
179
  const parent = current.schema;
169
180
  let child;
170
181
  if (parent.type === "array") {
171
182
  if (!/^\d+$/.test(segment)) throw fail();
172
183
  child = parent.items;
173
- key = Number(segment);
184
+ item = {
185
+ index: Number(segment),
186
+ arrayTitle: parent.title ?? fallbackTitle,
187
+ arrayKey: key
188
+ };
189
+ key = item.index;
174
190
  required = false;
175
191
  fallbackTitle = void 0;
176
192
  } else {
193
+ item = void 0;
177
194
  if (parent.type !== "object" || !isObject(parent.properties) || !Object.hasOwn(parent.properties, segment)) throw fail();
178
195
  child = parent.properties[segment];
179
196
  key = segment;
@@ -183,8 +200,55 @@ function describeSchemaField(root, field = "") {
183
200
  if (!isObject(child)) throw fail();
184
201
  current = resolve(root, child, current.seen);
185
202
  }
186
- return buildNode(root, current, field, key, required, fallbackTitle);
203
+ return buildNode(root, current, field, key, required, fallbackTitle, item);
204
+ }
205
+ /**
206
+ * The semiRenderers name of a single-value array row, undefined for any other node. Such a row shows no label or
207
+ * description: the array's Section shows them once, and the row is named "<array title> item N".
208
+ */
209
+ function singleItemName({ item, kind }, messages) {
210
+ if (!item || kind === "object" || kind === "array") return void 0;
211
+ const index = item.index + 1;
212
+ return item.arrayTitle === void 0 ? formatLocale(messages.item, { index }) : formatLocale(messages.arrayItem, {
213
+ title: item.arrayTitle,
214
+ index
215
+ });
216
+ }
217
+ /** What an array node allows with `count` rows; a fixed array (minItems === maxItems) neither adds nor removes */
218
+ function arrayState(node, count) {
219
+ const { minItems, maxItems } = node;
220
+ const fixed = Boolean(node.fixed);
221
+ return {
222
+ count,
223
+ minItems,
224
+ maxItems,
225
+ fixed,
226
+ canAdd: !fixed && (maxItems === void 0 || count < maxItems),
227
+ canRemove: !fixed && count > (minItems ?? 0)
228
+ };
187
229
  }
230
+ /** The props semiRenderers gives the Form control of a leaf node, by kind */
231
+ function controlProps(node) {
232
+ switch (node.kind) {
233
+ case "input": return { maxLength: node.maxLength };
234
+ case "textarea": return { maxCount: node.maxLength };
235
+ case "number": return {
236
+ max: node.maximum,
237
+ min: node.minimum,
238
+ precision: node.integer ? 0 : void 0
239
+ };
240
+ case "select": return {
241
+ multiple: node.multiple,
242
+ optionList: node.options
243
+ };
244
+ default: return {};
245
+ }
246
+ }
247
+ const schemaFieldWarnings = {
248
+ noSchema: "[Semi Form] SchemaField has no JSON Schema: pass jsonSchema, or give the Form a schema that exports one",
249
+ noRenderer: (field, kind) => `[Semi Form] SchemaField renders nothing for "${field}": renderers has no ${kind} entry`,
250
+ unsupported: (field) => `[Semi Form] SchemaField renders nothing for "${field}": its schema maps to no control`
251
+ };
188
252
  function blankValue(root, { schema, seen }) {
189
253
  if (schema.type === "object") {
190
254
  const row = {};
@@ -200,9 +264,12 @@ function blankValue(root, { schema, seen }) {
200
264
  return Array.from({ length: schema.minItems ?? 0 }, () => items && blankValue(root, items));
201
265
  }
202
266
  }
203
- /** Value of a new array row: object -> {} with required nested objects and arrays prefilled (arrays with minItems blank rows), other -> undefined */
204
- function blankRow(root, arrayNode) {
205
- const { items } = arrayNode.schema;
267
+ /**
268
+ * Value of a new row of the array at `arrayField`: object -> {} with required nested objects and arrays prefilled
269
+ * (arrays with minItems blank rows), other -> undefined
270
+ */
271
+ function blankRow(root, arrayField) {
272
+ const { items } = describeSchemaField(root, arrayField).schema;
206
273
  return isObject(items) ? blankValue(root, resolve(root, items, [])) : void 0;
207
274
  }
208
- export { blankRow, describeSchemaField, resolveJsonSchema };
275
+ export { arrayState, blankRow, controlProps, describeSchemaField, resolveJsonSchema, schemaFieldWarnings, singleItemName };
@@ -32,6 +32,9 @@ $font-form_label-fontWeight: $font-weight-bold; // 表单项标签字重
32
32
  $color-form_label-text-default: var(--semi-color-text-0); // 表单项标签文字颜色
33
33
  $color-form_label_optional-text-default: var(--semi-color-tertiary); // 表单项标签可选标记颜色
34
34
  $color-form_label_extra-text-default: var(--semi-color-tertiary); // 表单项标签图标颜色
35
+ $color-form_label_tooltip-icon-default: var(--semi-color-tertiary); // 表单项标签提示图标颜色
36
+ $spacing-form_label_tooltip-marginLeft: $spacing-extra-tight; // 表单项标签与提示图标的间距
37
+ $width-form_label_tooltip-icon: $width-icon-small; // 表单项标签提示图标大小
35
38
  $color-form_requiredMark-text-default: var(--semi-color-danger); // 必填标记颜色
36
39
  $font-form_requiredMark-fontWeight: $font-weight-bold; // 表单必填标识字重
37
40
 
@@ -48,5 +51,6 @@ $spacing-form_section_text-paddingBottom: $spacing-tight; // 表单分组标题
48
51
  $spacing-form_section_text-marginBottom: $spacing-extra-tight; // 表单分组标题底部外边距
49
52
  $spacing-form_section_text-paddingTop: 0px; // 表单分组标题顶部内边距
50
53
  $spacing-form_section_text-marginTop: 0px; // 表单分组标题顶部外边距
54
+ $spacing-form_section_extra-marginBottom: $spacing-extra-tight; // 表单分组说明文字底部外边距
51
55
  $spacing-form_schema_array_row-gap: $spacing-tight; // SchemaField 数组行内容与操作按钮的间距
52
56
  $spacing-form_schema_array_row_actions-gap: $spacing-extra-tight; // SchemaField 数组行操作按钮之间的间距
@@ -53,7 +53,7 @@ export default class PaginationFoundation<P extends PaginationBaseProps = Pagina
53
53
  sizeChangerShown: boolean;
54
54
  hidden: boolean;
55
55
  quickJumpDisabled: boolean;
56
- switchPosition: "bottomLeft" | "bottom" | "top" | "bottomRight" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
56
+ switchPosition: "bottom" | "top" | "left" | "right" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
57
57
  };
58
58
  static getDisabled(currentPage: number, total: number, pageSize: number): {
59
59
  prevDisabled: boolean;
@@ -77,7 +77,7 @@ export default class SelectFoundation<P extends SelectBaseProps = SelectBaseProp
77
77
  };
78
78
  protected initOnce(): void;
79
79
  /** The rtl default of `position`; `direction` is read from the host's config */
80
- static getPosition<P extends string>(position?: P, direction?: string): "bottomLeft" | P | "bottomRight";
80
+ static getPosition<P extends string>(position?: P, direction?: string): "bottomLeft" | "bottomRight" | P;
81
81
  static getVisibleOptions<O extends Pick<OptionRecord, 'show'>>(options: O[]): O[];
82
82
  /** The index the combobox points at with `aria-activedescendant`, or undefined when no option is highlighted */
83
83
  static getActiveOptionIndex({ isOpen, loading, focusIndex, visibleCount }: {
@@ -99,7 +99,7 @@ export default class SliderFoundation<P extends SliderProps = SliderProps> exten
99
99
  inputDir: "rtl" | "ltr";
100
100
  reverse: string;
101
101
  track: {
102
- sizeProp: "height" | "width";
102
+ sizeProp: "width" | "height";
103
103
  size: string;
104
104
  start: string;
105
105
  };
@@ -224,6 +224,14 @@ export default class TableFoundation<RecordType, P extends TableBaseProps<Record
224
224
  static getInitialState<R, C extends BaseColumnProps<R> = BaseColumnProps<R>>(props: TableBaseProps<R>, flattenColumns: C[], queries: C[]): TableColumnsState<R, C>;
225
225
  /** Hosts call it after mount, on body scroll and when the table or its content resizes */
226
226
  syncScrollEdges: () => void;
227
+ /**
228
+ * Whether a sticky header follows the body through a scroll-driven animation, which the compositor runs in the
229
+ * frame it scrolls the body, rather than through scrollLeft writes a frame late. Probed after mount, like
230
+ * syncScrollEdges. Removable with the scrollLeft path once Chrome 116, Firefox 159 and Safari 26 are the minimum.
231
+ */
232
+ headerFollowsInCss: () => boolean;
233
+ /** Hosts call it after commits and body resizes of a sticky table: the distance the header's animation spans */
234
+ syncHeaderScrollRange: () => void;
227
235
  /** `index` is the header row the widths were measured in */
228
236
  setHeadWidths: (widths: BaseHeadWidth[], index?: number) => void;
229
237
  setBodyHasScrollbar: (bodyHasScrollBar: boolean) => void;
@@ -11,6 +11,7 @@ import { get } from "es-toolkit/compat";
11
11
  // src/components/table/foundation.ts
12
12
  var TableFoundation = class TableFoundation extends BaseFoundation {
13
13
  #trackScrollEdges;
14
+ #headerFollowsInCss;
14
15
  #rangeAnchor = null;
15
16
  #rangeBase = null;
16
17
  #rangeResult = null;
@@ -755,6 +756,17 @@ var TableFoundation = class TableFoundation extends BaseFoundation {
755
756
  const body = this.#trackScrollEdges ? this.adapter.getBodyWrapper() : null;
756
757
  if (body) TableFoundation.#syncScrollableEdges(body);
757
758
  };
759
+ /**
760
+ * Whether a sticky header follows the body through a scroll-driven animation, which the compositor runs in the
761
+ * frame it scrolls the body, rather than through scrollLeft writes a frame late. Probed after mount, like
762
+ * syncScrollEdges. Removable with the scrollLeft path once Chrome 116, Firefox 159 and Safari 26 are the minimum.
763
+ */
764
+ headerFollowsInCss = () => this.#headerFollowsInCss ??= CSS.supports("timeline-scope", "--semi-table-body-x");
765
+ /** Hosts call it after commits and body resizes of a sticky table: the distance the header's animation spans */
766
+ syncHeaderScrollRange = () => {
767
+ const body = this.headerFollowsInCss() ? this.adapter.getBodyWrapper() : null;
768
+ body?.parentElement?.style.setProperty("--semi-table-scroll-range", `${body.scrollWidth - body.clientWidth}px`);
769
+ };
758
770
  /** `index` is the header row the widths were measured in */
759
771
  setHeadWidths = (widths, index = 0) => {
760
772
  const prevHeadWidths = this.getState("headWidths") ?? [];
@@ -5,6 +5,11 @@
5
5
 
6
6
  $module: #{$prefix}-table;
7
7
 
8
+ // an RTL body scrolls toward its left end, so the sticky header's table moves right
9
+ .#{$module}-container:dir(rtl) {
10
+ --semi-table-scroll-sign: 1;
11
+ }
12
+
8
13
  .#{$module}-align-left:dir(rtl) .#{$module}-operate-wrapper {
9
14
  justify-content: flex-end;
10
15
  }
@@ -73,6 +73,14 @@
73
73
  .semi-table-container {
74
74
  position: relative;
75
75
  }
76
+ @supports (timeline-scope: --semi-table-body-x) {
77
+ .semi-table-container {
78
+ timeline-scope: --semi-table-body-x;
79
+ }
80
+ .semi-table-container > .semi-table-body {
81
+ scroll-timeline: --semi-table-body-x x;
82
+ }
83
+ }
76
84
  .semi-table-header {
77
85
  container-name: semi-table-scroll;
78
86
  container-type: scroll-state;
@@ -96,6 +104,41 @@
96
104
  .semi-table-header-sticky .semi-table-thead > .semi-table-row > .semi-table-row-head {
97
105
  background-color: var(--semi-color-bg-1);
98
106
  }
107
+ @supports (timeline-scope: --semi-table-body-x) {
108
+ .semi-table-header-sticky {
109
+ container-type: normal;
110
+ }
111
+ .semi-table-header-sticky > .semi-table {
112
+ animation: semi-table-header-follow linear both;
113
+ animation-timeline: --semi-table-body-x;
114
+ }
115
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-cell-fixed-left, .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-cell-fixed-right {
116
+ animation: semi-table-header-pin linear both;
117
+ animation-timeline: --semi-table-body-x;
118
+ }
119
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-cell-fixed-left-last::after, .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-cell-fixed-right-first::after {
120
+ animation: semi-table-header-edge-start linear both;
121
+ animation-timeline: --semi-table-body-x;
122
+ }
123
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-cell-fixed-right-first::after, .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:dir(rtl) > .semi-table-cell-fixed-left-last::after {
124
+ animation-name: semi-table-header-edge-end;
125
+ }
126
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:dir(rtl) > .semi-table-cell-fixed-right-first::after {
127
+ animation-name: semi-table-header-edge-start;
128
+ }
129
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:where(:not(.semi-table-bordered *)) > .semi-table-cell-fixed-left-last {
130
+ animation-name: semi-table-header-pin, semi-table-header-line-left-start;
131
+ }
132
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:where(:not(.semi-table-bordered *)) > .semi-table-cell-fixed-right-first {
133
+ animation-name: semi-table-header-pin, semi-table-header-line-right-end;
134
+ }
135
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:where(:not(.semi-table-bordered *)):dir(rtl) > .semi-table-cell-fixed-left-last {
136
+ animation-name: semi-table-header-pin, semi-table-header-line-left-end;
137
+ }
138
+ .semi-table-header-sticky > .semi-table > .semi-table-thead > .semi-table-row:where(:not(.semi-table-bordered *)):dir(rtl) > .semi-table-cell-fixed-right-first {
139
+ animation-name: semi-table-header-pin, semi-table-header-line-right-start;
140
+ }
141
+ }
99
142
  .semi-table-header-hidden {
100
143
  height: 0;
101
144
  }
@@ -131,6 +174,18 @@
131
174
  outline: 2px solid var(--semi-color-primary-light-active);
132
175
  outline-offset: -2px;
133
176
  }
177
+ .semi-table-fixed-header > .semi-table-container > .semi-table-body > .semi-table > .semi-table-thead {
178
+ position: sticky;
179
+ top: 0;
180
+ z-index: 102;
181
+ }
182
+ .semi-table-list-header {
183
+ position: sticky;
184
+ top: 0;
185
+ z-index: 102;
186
+ inline-size: fit-content;
187
+ min-inline-size: 100%;
188
+ }
134
189
  .semi-table-row:focus-visible {
135
190
  outline: 2px solid var(--semi-color-primary-light-active);
136
191
  outline-offset: -2px;
@@ -449,6 +504,12 @@
449
504
  :where(.semi-table-bordered) > .semi-table-container > .semi-table-footer {
450
505
  border-bottom: 1px solid var(--semi-color-border);
451
506
  }
507
+ :where(.semi-table-bordered > .semi-table-container > .semi-table-body) {
508
+ border-bottom: 1px solid var(--semi-color-border);
509
+ }
510
+ :where(.semi-table-bordered > .semi-table-container > .semi-table-body) > .semi-table > .semi-table-tbody > :last-child > .semi-table-row-cell, :where(.semi-table-bordered > .semi-table-container > .semi-table-body) > .semi-table-placeholder {
511
+ border-bottom: 0;
512
+ }
452
513
  :where(.semi-table-bordered > .semi-table-container > .semi-table-body) > .semi-table > .semi-table-thead > .semi-table-row > .semi-table-row-head .semi-table-resize-handle {
453
514
  background-color: transparent;
454
515
  }
@@ -609,6 +670,64 @@
609
670
  overflow-y: auto;
610
671
  }
611
672
 
673
+ @keyframes semi-table-header-follow {
674
+ to {
675
+ translate: calc(var(--semi-table-scroll-range, 0px) * var(--semi-table-scroll-sign, -1)) 0;
676
+ }
677
+ }
678
+ @keyframes semi-table-header-pin {
679
+ to {
680
+ translate: calc(var(--semi-table-scroll-range, 0px) * var(--semi-table-scroll-sign, -1) * -1) 0;
681
+ }
682
+ }
683
+ @keyframes semi-table-header-edge-start {
684
+ from {
685
+ opacity: 0;
686
+ }
687
+ 0.01%, to {
688
+ opacity: 1;
689
+ }
690
+ }
691
+ @keyframes semi-table-header-edge-end {
692
+ from, 99.99% {
693
+ opacity: 1;
694
+ }
695
+ to {
696
+ opacity: 0;
697
+ }
698
+ }
699
+ @keyframes semi-table-header-line-left-start {
700
+ from {
701
+ border-right-color: transparent;
702
+ }
703
+ 0.01%, to {
704
+ border-right-color: var(--semi-color-border);
705
+ }
706
+ }
707
+ @keyframes semi-table-header-line-left-end {
708
+ from, 99.99% {
709
+ border-right-color: var(--semi-color-border);
710
+ }
711
+ to {
712
+ border-right-color: transparent;
713
+ }
714
+ }
715
+ @keyframes semi-table-header-line-right-start {
716
+ from {
717
+ border-left-color: transparent;
718
+ }
719
+ 0.01%, to {
720
+ border-left-color: var(--semi-color-border);
721
+ }
722
+ }
723
+ @keyframes semi-table-header-line-right-end {
724
+ from, 99.99% {
725
+ border-left-color: var(--semi-color-border);
726
+ }
727
+ to {
728
+ border-left-color: transparent;
729
+ }
730
+ }
612
731
  .semi-table-column-filter-footer {
613
732
  display: flex;
614
733
  justify-content: flex-end;
@@ -617,6 +736,10 @@
617
736
  border-block-start: 1px solid var(--semi-color-border);
618
737
  }
619
738
 
739
+ .semi-table-container:dir(rtl) {
740
+ --semi-table-scroll-sign: 1;
741
+ }
742
+
620
743
  .semi-table-align-left:dir(rtl) .semi-table-operate-wrapper {
621
744
  justify-content: flex-end;
622
745
  }
@@ -56,6 +56,15 @@ $module: #{$prefix}-table;
56
56
 
57
57
  &-container {
58
58
  position: relative;
59
+
60
+ // scoped here so the sticky header, a sibling of the body, can follow the body's timeline
61
+ @supports (timeline-scope: --semi-table-body-x) {
62
+ timeline-scope: --semi-table-body-x;
63
+
64
+ & > .#{$module}-body {
65
+ scroll-timeline: --semi-table-body-x x;
66
+ }
67
+ }
59
68
  }
60
69
 
61
70
  &-header {
@@ -85,6 +94,63 @@ $module: #{$prefix}-table;
85
94
  .#{$module}-thead > .#{$module}-row > .#{$module}-row-head {
86
95
  background-color: $color-table-bg-default;
87
96
  }
97
+
98
+ // The header stuck to the page sits outside the body's scroller. A scroll-driven animation on the body's
99
+ // timeline shifts it, and holds its fixed cells in place, in the frame the compositor scrolls the body; the
100
+ // foundation writes the range. Elsewhere the host copies scrollLeft a frame late. Removable together with
101
+ // the foundation's headerFollowsInCss.
102
+ @supports (timeline-scope: --semi-table-body-x) {
103
+ // the header never scrolls itself, so its scroll state says nothing; the edges follow the body's timeline
104
+ container-type: normal;
105
+
106
+ & > .#{$module} {
107
+ animation: #{$module}-header-follow linear both;
108
+ animation-timeline: --semi-table-body-x;
109
+
110
+ & > .#{$module}-thead > .#{$module}-row {
111
+ & > .#{$module}-cell-fixed-left,
112
+ & > .#{$module}-cell-fixed-right {
113
+ animation: #{$module}-header-pin linear both;
114
+ animation-timeline: --semi-table-body-x;
115
+ }
116
+
117
+ & > .#{$module}-cell-fixed-left-last::after,
118
+ & > .#{$module}-cell-fixed-right-first::after {
119
+ animation: #{$module}-header-edge-start linear both;
120
+ animation-timeline: --semi-table-body-x;
121
+ }
122
+
123
+ // physical sides like the shadows: in RTL the body scrolls from its right end
124
+ & > .#{$module}-cell-fixed-right-first::after,
125
+ &:dir(rtl) > .#{$module}-cell-fixed-left-last::after {
126
+ animation-name: #{$module}-header-edge-end;
127
+ }
128
+
129
+ &:dir(rtl) > .#{$module}-cell-fixed-right-first::after {
130
+ animation-name: #{$module}-header-edge-start;
131
+ }
132
+
133
+ // without `bordered` the edge lines show only with the shadows
134
+ &:where(:not(.#{$module}-bordered *)) {
135
+ & > .#{$module}-cell-fixed-left-last {
136
+ animation-name: #{$module}-header-pin, #{$module}-header-line-left-start;
137
+ }
138
+
139
+ & > .#{$module}-cell-fixed-right-first {
140
+ animation-name: #{$module}-header-pin, #{$module}-header-line-right-end;
141
+ }
142
+
143
+ &:dir(rtl) > .#{$module}-cell-fixed-left-last {
144
+ animation-name: #{$module}-header-pin, #{$module}-header-line-left-end;
145
+ }
146
+
147
+ &:dir(rtl) > .#{$module}-cell-fixed-right-first {
148
+ animation-name: #{$module}-header-pin, #{$module}-header-line-right-start;
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
88
154
  }
89
155
 
90
156
  &-hidden {
@@ -133,6 +199,23 @@ $module: #{$prefix}-table;
133
199
  &:focus-visible {
134
200
  @include focus-ring(-2px);
135
201
  }
202
+
203
+ // scroll.y keeps the header in the body's scroller, so the compositor moves both in the same frame; above the
204
+ // fixed body cells, and the fixed head cells inside stack above the other head cells
205
+ .#{$module}-fixed-header > .#{$module}-container > & > .#{$module} > .#{$module}-thead {
206
+ position: sticky;
207
+ top: 0;
208
+ z-index: $z-table_fixed_column + 1;
209
+ }
210
+ }
211
+
212
+ // the virtual list's header, in the list's scroller above the rows
213
+ &-list-header {
214
+ position: sticky;
215
+ top: 0;
216
+ z-index: $z-table_fixed_column + 1;
217
+ inline-size: fit-content;
218
+ min-inline-size: 100%;
136
219
  }
137
220
 
138
221
  // the scrolling body would clip an outside ring on a row focusable for drag sorting
@@ -552,7 +635,16 @@ $module: #{$prefix}-table;
552
635
  }
553
636
  }
554
637
 
638
+ // the container's side borders run down past a horizontal scrollbar; the body's bottom border closes the box
639
+ // below it, so the last row and the empty placeholder drop their own
555
640
  :where(& > .#{$module}-container > .#{$module}-body) {
641
+ border-bottom: $width-table_base_border $border-table_base-borderStyle $color-table-border-default;
642
+
643
+ & > .#{$module} > .#{$module}-tbody > :last-child > .#{$module}-row-cell,
644
+ & > .#{$module}-placeholder {
645
+ border-bottom: 0;
646
+ }
647
+
556
648
  & > .#{$module} > .#{$module}-thead > .#{$module}-row > .#{$module}-row-head {
557
649
  .#{$module}-resize-handle {
558
650
  background-color: transparent;
@@ -778,6 +870,88 @@ $module: #{$prefix}-table;
778
870
  }
779
871
  }
780
872
 
873
+ // the sticky header's table moves against the body's scroll, and its fixed cells move back by as much
874
+ @keyframes #{$module}-header-follow {
875
+ to {
876
+ translate: calc(var(--semi-table-scroll-range, 0px) * var(--semi-table-scroll-sign, -1)) 0;
877
+ }
878
+ }
879
+
880
+ @keyframes #{$module}-header-pin {
881
+ to {
882
+ translate: calc(var(--semi-table-scroll-range, 0px) * var(--semi-table-scroll-sign, -1) * -1) 0;
883
+ }
884
+ }
885
+
886
+ // a fixed edge shows while content hides behind it: past the scroll start, or short of the end
887
+ @keyframes #{$module}-header-edge-start {
888
+ from {
889
+ opacity: 0;
890
+ }
891
+
892
+ 0.01%,
893
+ to {
894
+ opacity: 1;
895
+ }
896
+ }
897
+
898
+ @keyframes #{$module}-header-edge-end {
899
+ from,
900
+ 99.99% {
901
+ opacity: 1;
902
+ }
903
+
904
+ to {
905
+ opacity: 0;
906
+ }
907
+ }
908
+
909
+ // stylelint-disable property-disallowed-list -- physical sides like the fixed-cell class names
910
+ @keyframes #{$module}-header-line-left-start {
911
+ from {
912
+ border-right-color: transparent;
913
+ }
914
+
915
+ 0.01%,
916
+ to {
917
+ border-right-color: $color-table_shadow-border-default;
918
+ }
919
+ }
920
+
921
+ @keyframes #{$module}-header-line-left-end {
922
+ from,
923
+ 99.99% {
924
+ border-right-color: $color-table_shadow-border-default;
925
+ }
926
+
927
+ to {
928
+ border-right-color: transparent;
929
+ }
930
+ }
931
+
932
+ @keyframes #{$module}-header-line-right-start {
933
+ from {
934
+ border-left-color: transparent;
935
+ }
936
+
937
+ 0.01%,
938
+ to {
939
+ border-left-color: $color-table_shadow-border-default;
940
+ }
941
+ }
942
+
943
+ @keyframes #{$module}-header-line-right-end {
944
+ from,
945
+ 99.99% {
946
+ border-left-color: $color-table_shadow-border-default;
947
+ }
948
+
949
+ to {
950
+ border-left-color: transparent;
951
+ }
952
+ }
953
+ // stylelint-enable property-disallowed-list
954
+
781
955
  .#{$module}-column-filter-footer {
782
956
  display: flex;
783
957
  justify-content: flex-end;
@@ -61,7 +61,7 @@
61
61
  justify-content: center;
62
62
  padding-block: 12px 12px;
63
63
  padding-inline: 8px 8px;
64
- margin: 12px;
64
+ margin: 12px 12px 0;
65
65
  font-weight: var(--semi-font-weight-bold);
66
66
  color: var(--semi-color-text-0);
67
67
  pointer-events: all;
@@ -86,7 +86,8 @@ $icon: #{$prefix}-toast-icon;
86
86
  justify-content: center;
87
87
  padding-block: $spacing-toast_content-paddingTop $spacing-toast_content-paddingBottom;
88
88
  padding-inline: $spacing-toast_content-paddingLeft $spacing-toast_content-paddingRight;
89
- margin: $spacing-toast_content-margin;
89
+ // no bottom margin: the gap between stacked toasts equals the first toast's distance from the top
90
+ margin: $spacing-toast_content-margin $spacing-toast_content-margin 0;
90
91
  font-weight: $font-toast_content-fontWeight;
91
92
  color: $color-toast-text-default;
92
93
  pointer-events: all;
@@ -16,7 +16,7 @@
16
16
  outline: 2px solid var(--semi-color-primary-light-active);
17
17
  }
18
18
 
19
- [popover][data-semi-covered] {
19
+ :popover-open[data-semi-covered] {
20
20
  visibility: hidden;
21
21
  }
22
22
 
@@ -16,8 +16,10 @@ $module-icon: #{$module}-icon-arrow;
16
16
  @include focus-ring;
17
17
  }
18
18
 
19
- // utils/layer.ts marks a popup a modal layer covers: the top layer would otherwise paint it above the modal's mask
20
- [popover][data-semi-covered] {
19
+ // utils/layer.ts marks a popup a modal layer covers: the top layer would otherwise paint it above the modal's mask. A
20
+ // closed popover is not in the top layer and may be a box the page shows (a sidebar that is a drawer only on narrow
21
+ // screens); the mask covers it already
22
+ :popover-open[data-semi-covered] {
21
23
  visibility: hidden;
22
24
  }
23
25
 
@@ -11,7 +11,7 @@ export declare const strings: {
11
11
  FILE_STATUS_WAIT_UPLOAD: string;
12
12
  FILE_LIST_PIC: "picture";
13
13
  FILE_LIST_DEFAULT: "list";
14
- LIST_TYPE: ("none" | "list" | "picture")[];
14
+ LIST_TYPE: ("none" | "picture" | "list")[];
15
15
  DRAG_AREA_DEFAULT: string;
16
16
  DRAG_AREA_LEGAL: string;
17
17
  TRIGGER_AUTO: "auto";
@@ -362,6 +362,8 @@ export interface Locale {
362
362
  };
363
363
  Form: {
364
364
  optional: string;
365
+ /** name of the button that shows the tooltip of a label */
366
+ labelTooltip: string;
365
367
  /** Default rule messages; `${len}`, `${min}`, `${max}` are the rule's bounds */
366
368
  required: string;
367
369
  invalid: string;
@@ -380,6 +382,8 @@ export interface Locale {
380
382
  moveUpItem: string;
381
383
  moveDownItem: string;
382
384
  item: string;
385
+ /** Name of a single-value row, which shows no label; `${title}` is the array's title */
386
+ arrayItem: string;
383
387
  };
384
388
  Image: {
385
389
  preview: string;
@@ -289,6 +289,7 @@ const local = {
289
289
  },
290
290
  Form: {
291
291
  optional: "(optional)",
292
+ labelTooltip: "More information",
292
293
  required: "This field is required",
293
294
  invalid: "Invalid value",
294
295
  stringLen: "Must be exactly ${len} characters",
@@ -304,7 +305,8 @@ const local = {
304
305
  removeItem: "Remove item ${index}",
305
306
  moveUpItem: "Move item ${index} up",
306
307
  moveDownItem: "Move item ${index} down",
307
- item: "Item ${index}"
308
+ item: "Item ${index}",
309
+ arrayItem: "${title} item ${index}"
308
310
  },
309
311
  Image: {
310
312
  fallback: "fallback",
@@ -289,6 +289,7 @@ const local = {
289
289
  },
290
290
  Form: {
291
291
  optional: "(可选)",
292
+ labelTooltip: "更多说明",
292
293
  required: "此项为必填项",
293
294
  invalid: "格式不正确",
294
295
  stringLen: "长度须为 ${len} 个字符",
@@ -304,7 +305,8 @@ const local = {
304
305
  removeItem: "删除第 ${index} 项",
305
306
  moveUpItem: "上移第 ${index} 项",
306
307
  moveDownItem: "下移第 ${index} 项",
307
- item: "第 ${index} 项"
308
+ item: "第 ${index} 项",
309
+ arrayItem: "${title} 第 ${index} 项"
308
310
  },
309
311
  Image: {
310
312
  fallback: "占位图",
@@ -24,9 +24,9 @@ import { get, has, isEmpty, remove, set } from "./object.js";
24
24
  import { isSecondaryPress } from "./pointer.js";
25
25
  import { lockBodyScroll } from "./scroll-lock.js";
26
26
  import shallowEqualObjects from "./shallow-equal-objects.js";
27
- import { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption } from "./supports.js";
27
+ import { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption, supportsScrollbarGutter } from "./supports.js";
28
28
  import { Easing, TweenOptions, easeInOutCubic, linear, tween } from "./tween.js";
29
29
  import { ArrayElement, Size } from "./type.js";
30
30
  import { createId } from "./uuid.js";
31
31
  import warning, { isDev } from "./warning.js";
32
- export { ANNOUNCE_DELAY, ANNOUNCE_HOLD, Announcer, ArrayElement, CopiedTimer, ENTER_KEY, ESC_KEY, Easing, Event as EventEmitter, KEEP_INTERACTIVE_ATTRIBUTE, Layer, ListNavigationOptions, POPUP_ID_ATTRIBUTE, POPUP_SELECTOR, RegisterMediaQueryOption, Size, TweenOptions, Typeahead, addClass, arrayMove, assertClient, centerInScroller, containsWithPopups, copyText, coversPage, createId, crossesFocusBoundary, defaultPopupContainer, differenceUnique, easeInOutCubic, escapeHtmlInMarkdown, findFocusAfter, fitInputWidth, fitTextareaHeight, focusWithoutRing, get, getDataAttr, getEnabledStepIndex, getListTargetIndex, getOptionId, getPopupTrigger, handlePrevent, handoverFocus, has, ignoreExpectedMediaErrors, isAriaKey, isBrowserChord, isComposing, isDev, isEmpty, isEnterPress, isEventInside, isHTMLElement, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isObject, isPromise, isSecondaryPress, isTextEditor, isValidTimeZone, joinIds, linear, lockBodyScroll, namedRole, noop, onFontsLoaded, openLayer, pinAnimatedHeight, popupTriggerSelector, popupTriggers, registerMediaQuery, remove, removeClass, resolvePopupContainer, revealOption, scrollIntoViewWithin, set, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, shallowEqualObjects, stopButtonActivationKeys, supportsFieldSizing, supportsFocusVisibleOption, supportsScrollContainerOption, toCssLength, tween, warnIfDialogUnnamed, warning, withOrderSort };
32
+ export { ANNOUNCE_DELAY, ANNOUNCE_HOLD, Announcer, ArrayElement, CopiedTimer, ENTER_KEY, ESC_KEY, Easing, Event as EventEmitter, KEEP_INTERACTIVE_ATTRIBUTE, Layer, ListNavigationOptions, POPUP_ID_ATTRIBUTE, POPUP_SELECTOR, RegisterMediaQueryOption, Size, TweenOptions, Typeahead, addClass, arrayMove, assertClient, centerInScroller, containsWithPopups, copyText, coversPage, createId, crossesFocusBoundary, defaultPopupContainer, differenceUnique, easeInOutCubic, escapeHtmlInMarkdown, findFocusAfter, fitInputWidth, fitTextareaHeight, focusWithoutRing, get, getDataAttr, getEnabledStepIndex, getListTargetIndex, getOptionId, getPopupTrigger, handlePrevent, handoverFocus, has, ignoreExpectedMediaErrors, isAriaKey, isBrowserChord, isComposing, isDev, isEmpty, isEnterPress, isEventInside, isHTMLElement, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isObject, isPromise, isSecondaryPress, isTextEditor, isValidTimeZone, joinIds, linear, lockBodyScroll, namedRole, noop, onFontsLoaded, openLayer, pinAnimatedHeight, popupTriggerSelector, popupTriggers, registerMediaQuery, remove, removeClass, resolvePopupContainer, revealOption, scrollIntoViewWithin, set, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, shallowEqualObjects, stopButtonActivationKeys, supportsFieldSizing, supportsFocusVisibleOption, supportsScrollContainerOption, supportsScrollbarGutter, toCssLength, tween, warnIfDialogUnnamed, warning, withOrderSort };
@@ -24,8 +24,8 @@ import { get, has, isEmpty, remove, set } from "./object.js";
24
24
  import { isSecondaryPress } from "./pointer.js";
25
25
  import { lockBodyScroll } from "./scroll-lock.js";
26
26
  import shallowEqualObjects from "./shallow-equal-objects.js";
27
- import { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption } from "./supports.js";
27
+ import { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption, supportsScrollbarGutter } from "./supports.js";
28
28
  import { easeInOutCubic, linear, tween } from "./tween.js";
29
29
  import { createId } from "./uuid.js";
30
30
  import warning, { isDev } from "./warning.js";
31
- export { ANNOUNCE_DELAY, ANNOUNCE_HOLD, Announcer, CopiedTimer, ENTER_KEY, ESC_KEY, Event as EventEmitter, KEEP_INTERACTIVE_ATTRIBUTE, POPUP_ID_ATTRIBUTE, POPUP_SELECTOR, Typeahead, addClass, arrayMove, assertClient, centerInScroller, containsWithPopups, copyText, coversPage, createId, crossesFocusBoundary, defaultPopupContainer, differenceUnique, easeInOutCubic, escapeHtmlInMarkdown, findFocusAfter, fitInputWidth, fitTextareaHeight, focusWithoutRing, get, getDataAttr, getEnabledStepIndex, getListTargetIndex, getOptionId, getPopupTrigger, handlePrevent, handoverFocus, has, ignoreExpectedMediaErrors, isAriaKey, isBrowserChord, isComposing, isDev, isEmpty, isEnterPress, isEventInside, isHTMLElement, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isObject, isPromise, isSecondaryPress, isTextEditor, isValidTimeZone, joinIds, linear, lockBodyScroll, namedRole, noop, onFontsLoaded, openLayer, pinAnimatedHeight, popupTriggerSelector, popupTriggers, registerMediaQuery, remove, removeClass, resolvePopupContainer, revealOption, scrollIntoViewWithin, set, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, shallowEqualObjects, stopButtonActivationKeys, supportsFieldSizing, supportsFocusVisibleOption, supportsScrollContainerOption, toCssLength, tween, warnIfDialogUnnamed, warning, withOrderSort };
31
+ export { ANNOUNCE_DELAY, ANNOUNCE_HOLD, Announcer, CopiedTimer, ENTER_KEY, ESC_KEY, Event as EventEmitter, KEEP_INTERACTIVE_ATTRIBUTE, POPUP_ID_ATTRIBUTE, POPUP_SELECTOR, Typeahead, addClass, arrayMove, assertClient, centerInScroller, containsWithPopups, copyText, coversPage, createId, crossesFocusBoundary, defaultPopupContainer, differenceUnique, easeInOutCubic, escapeHtmlInMarkdown, findFocusAfter, fitInputWidth, fitTextareaHeight, focusWithoutRing, get, getDataAttr, getEnabledStepIndex, getListTargetIndex, getOptionId, getPopupTrigger, handlePrevent, handoverFocus, has, ignoreExpectedMediaErrors, isAriaKey, isBrowserChord, isComposing, isDev, isEmpty, isEnterPress, isEventInside, isHTMLElement, isInnerControl, isInnerControlActivation, isInnerControlKey, isNativeInputKey, isObject, isPromise, isSecondaryPress, isTextEditor, isValidTimeZone, joinIds, linear, lockBodyScroll, namedRole, noop, onFontsLoaded, openLayer, pinAnimatedHeight, popupTriggerSelector, popupTriggers, registerMediaQuery, remove, removeClass, resolvePopupContainer, revealOption, scrollIntoViewWithin, set, setFocusToFirstItem, setFocusToItem, setFocusToLastItem, shallowEqualObjects, stopButtonActivationKeys, supportsFieldSizing, supportsFocusVisibleOption, supportsScrollContainerOption, supportsScrollbarGutter, toCssLength, tween, warnIfDialogUnnamed, warning, withOrderSort };
@@ -1,6 +1,7 @@
1
1
  /**
2
- * Locks are counted, so stacked overlays release the page only when the last one closes. The body's end padding grows
3
- * by the scrollbar width, so the page does not shift sideways when its scrollbar disappears; padding rather than width
4
- * keeps the body's own margin and any width set by the page's stylesheet.
2
+ * Locks are counted, so stacked overlays release the page only when the last one closes. While the page shows a
3
+ * scrollbar, the root keeps its gutter, so nothing shifts sideways when the scrollbar disappears, fixed elements
4
+ * included. Without scrollbar-gutter the body's end padding grows by the scrollbar width instead, which fixed elements
5
+ * do not follow; padding rather than width keeps the body's own margin and any width set by the page's stylesheet.
5
6
  */
6
7
  export declare function lockBodyScroll(): () => void;
@@ -1,24 +1,27 @@
1
+ import { supportsScrollbarGutter } from "./supports.js";
1
2
  // src/utils/scroll-lock.ts
2
3
  let lockCount = 0;
3
4
  let restore = null;
4
5
  /**
5
- * Locks are counted, so stacked overlays release the page only when the last one closes. The body's end padding grows
6
- * by the scrollbar width, so the page does not shift sideways when its scrollbar disappears; padding rather than width
7
- * keeps the body's own margin and any width set by the page's stylesheet.
6
+ * Locks are counted, so stacked overlays release the page only when the last one closes. While the page shows a
7
+ * scrollbar, the root keeps its gutter, so nothing shifts sideways when the scrollbar disappears, fixed elements
8
+ * included. Without scrollbar-gutter the body's end padding grows by the scrollbar width instead, which fixed elements
9
+ * do not follow; padding rather than width keeps the body's own margin and any width set by the page's stylesheet.
8
10
  */
9
11
  function lockBodyScroll() {
10
12
  if (lockCount === 0) {
11
- const { style } = document.body;
12
- if (style.overflow === "hidden") restore = null;
13
+ const { body, documentElement: root } = document;
14
+ if (body.style.overflow === "hidden") restore = null;
13
15
  else {
14
- const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
15
- const padding = getComputedStyle(document.body).paddingInlineEnd;
16
+ const scrollbarWidth = window.innerWidth - root.clientWidth;
16
17
  restore = {
17
- overflow: style.overflow,
18
- paddingInlineEnd: style.paddingInlineEnd
18
+ overflow: body.style.overflow,
19
+ paddingInlineEnd: body.style.paddingInlineEnd,
20
+ scrollbarGutter: root.style.scrollbarGutter
19
21
  };
20
- style.overflow = "hidden";
21
- style.paddingInlineEnd = `calc(${padding} + ${scrollbarWidth}px)`;
22
+ body.style.overflow = "hidden";
23
+ if (scrollbarWidth > 0 && supportsScrollbarGutter()) root.style.scrollbarGutter = "stable";
24
+ else if (scrollbarWidth > 0) body.style.paddingInlineEnd = `calc(${getComputedStyle(body).paddingInlineEnd} + ${scrollbarWidth}px)`;
22
25
  }
23
26
  }
24
27
  lockCount++;
@@ -30,6 +33,7 @@ function lockBodyScroll() {
30
33
  if (lockCount === 0 && restore) {
31
34
  document.body.style.overflow = restore.overflow;
32
35
  document.body.style.paddingInlineEnd = restore.paddingInlineEnd;
36
+ document.documentElement.style.scrollbarGutter = restore.scrollbarGutter;
33
37
  restore = null;
34
38
  }
35
39
  };
@@ -1,3 +1,5 @@
1
+ /** CSS `scrollbar-gutter`. Removable once the oldest supported Safari is 18.2. */
2
+ export declare function supportsScrollbarGutter(): boolean;
1
3
  /**
2
4
  * `scrollIntoView({ container: 'nearest' })` limits scrolling to the nearest scroller.
3
5
  * Removable once the oldest supported browsers are Chrome 140, Firefox and Safari (neither supports it yet).
@@ -1,6 +1,12 @@
1
1
  // src/utils/supports.ts
2
2
  let containerOption;
3
3
  let focusVisibleOption;
4
+ let scrollbarGutter;
5
+ /** CSS `scrollbar-gutter`. Removable once the oldest supported Safari is 18.2. */
6
+ function supportsScrollbarGutter() {
7
+ scrollbarGutter ??= CSS.supports("scrollbar-gutter", "stable");
8
+ return scrollbarGutter;
9
+ }
4
10
  /**
5
11
  * `scrollIntoView({ container: 'nearest' })` limits scrolling to the nearest scroller.
6
12
  * Removable once the oldest supported browsers are Chrome 140, Firefox and Safari (neither supports it yet).
@@ -90,4 +96,4 @@ function focusWithoutRing(el, options = {}) {
90
96
  el.focus(options);
91
97
  if (el.ownerDocument.activeElement !== el) clear();
92
98
  }
93
- export { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption };
99
+ export { focusWithoutRing, scrollIntoViewWithin, supportsFocusVisibleOption, supportsScrollContainerOption, supportsScrollbarGutter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibrae/semi-foundation",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "homepage": "https://semi-design-next.pages.dev",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@date-fns/tz": "^1.5.0",
30
30
  "@dnd-kit/dom": "~0.5.3",
31
- "@fibrae/semi-json-viewer-core": "0.7.0",
31
+ "@fibrae/semi-json-viewer-core": "0.8.0",
32
32
  "@mdx-js/mdx": "^3.1.1",
33
33
  "@shikijs/core": "^4.6.0",
34
34
  "clsx": "^2.1.1",