@kubex/zinc 1.1.115 → 1.1.117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/zn.d.ts CHANGED
@@ -2765,6 +2765,8 @@ declare module "components/select/select.component" {
2765
2765
  * @slot label-tooltip - Used to add text that is displayed in a tooltip next to the label. Alternatively, you can use the `label-tooltip` attribute.
2766
2766
  * @slot context-note - Used to add contextual text that is displayed above the select, on the right. Alternatively, you can use the `context-note` attribute.
2767
2767
  * @slot prefix - Used to prepend a presentational icon or similar element to the combobox.
2768
+ * @slot suffix - Used to append a presentational element — a chip marking the selected option's state, for
2769
+ * instance — to the combobox, between the value and the clear and expand icons.
2768
2770
  * @slot clear-icon - An icon to use in lieu of the default clear icon.
2769
2771
  * @slot expand-icon - The icon to show when the control is expanded and collapsed. Rotates on open and close.
2770
2772
  * @slot help-text - Text that describes how to use the input. Alternatively, you can use the `help-text` attribute.
@@ -2790,6 +2792,7 @@ declare module "components/select/select.component" {
2790
2792
  * @csspart form-control-help-text - The help text's wrapper.
2791
2793
  * @csspart combobox - The container the wraps the prefix, combobox, clear icon, and expand button.
2792
2794
  * @csspart prefix - The container that wraps the prefix slot.
2795
+ * @csspart suffix - The container that wraps the suffix slot.
2793
2796
  * @csspart display-input - The element that displays the selected option's label, an `<input>` element.
2794
2797
  * @csspart listbox - The listbox container where options are slotted.
2795
2798
  * @csspart tags - The container that houses option tags when `multiselect` is used.
@@ -4805,6 +4808,7 @@ declare module "components/header/header.component" {
4805
4808
  * @slot example - An example slot.
4806
4809
  *
4807
4810
  * @csspart base - The component's base wrapper.
4811
+ * @csspart header-right - The container that wraps the actions slot.
4808
4812
  *
4809
4813
  * @cssproperty --example - An example CSS custom property.
4810
4814
  */
@@ -7284,7 +7288,7 @@ declare module "components/form-actions/index" {
7284
7288
  }
7285
7289
  }
7286
7290
  declare module "components/form-group/form-group.component" {
7287
- import { type CSSResultGroup } from 'lit';
7291
+ import { type CSSResultGroup, type PropertyValues } from 'lit';
7288
7292
  import ZincElement from "internal/zinc-element";
7289
7293
  /**
7290
7294
  * @summary Short summary of the component's intended use.
@@ -7295,6 +7299,10 @@ declare module "components/form-group/form-group.component" {
7295
7299
  * @slot - The default slot.
7296
7300
  * @slot chip - A chip displayed under the form group's help text.
7297
7301
  *
7302
+ * @csspart form-control-text - The column holding the label, help text and chip.
7303
+ *
7304
+ * @cssproperty --zn-form-group-sticky-top - Offset the label column sticks at while the inputs scroll past.
7305
+ *
7298
7306
  */
7299
7307
  export default class ZnFormGroup extends ZincElement {
7300
7308
  static styles: CSSResultGroup;
@@ -7314,6 +7322,37 @@ declare module "components/form-group/form-group.component" {
7314
7322
  forceCols: boolean;
7315
7323
  layout: string;
7316
7324
  pad: boolean;
7325
+ /** The scroller the label is tracked against by hand; null while native sticky is enough. */
7326
+ private tracked;
7327
+ private frame;
7328
+ private rebind;
7329
+ private offset;
7330
+ private resizeObserver;
7331
+ connectedCallback(): void;
7332
+ disconnectedCallback(): void;
7333
+ protected firstUpdated(changedProperties: PropertyValues): void;
7334
+ private get labelColumn();
7335
+ /** Coalesces scroll and resize work into one frame, and out of the ResizeObserver callback. */
7336
+ private schedule;
7337
+ /**
7338
+ * Native sticky only follows the nearest scroll container. Where that container isn't the one
7339
+ * the user actually scrolls — a `zn-panel` body sized to its content inside a scrolling
7340
+ * slideout, say — the label never moves, so it gets translated by hand instead.
7341
+ */
7342
+ private findScroller;
7343
+ private trackScroller;
7344
+ /** The document scrolls through the window, every other scroller reports its own events. */
7345
+ private scrollTarget;
7346
+ private readonly onScroll;
7347
+ private readonly onViewportResize;
7348
+ private positionLabel;
7349
+ /** The box native sticky would anchor to, whether or not it can be scrolled. */
7350
+ private nearestScrollContainer;
7351
+ /** The nearest ancestor the user can actually scroll, falling back to the document. */
7352
+ private scrollingAncestor;
7353
+ private isScrollContainer;
7354
+ /** Walks the flattened tree, so slots and shadow boundaries are crossed the way layout does. */
7355
+ private ancestors;
7317
7356
  render(): import("lit-html").TemplateResult<1>;
7318
7357
  }
7319
7358
  }
@@ -8958,39 +8997,88 @@ declare module "components/audio-select/index" {
8958
8997
  declare module "components/translations/translations.component" {
8959
8998
  import { type SlashMenuItem } from "components/slash-menu/index";
8960
8999
  import ZincElement from "internal/zinc-element";
8961
- import ZnButton from "components/button/index";
8962
- import ZnButtonGroup from "components/button-group/index";
8963
- import ZnDropdown from "components/dropdown/index";
9000
+ import ZnChip from "components/chip/index";
8964
9001
  import ZnInlineEdit from "components/inline-edit/index";
8965
9002
  import ZnInput from "components/input/index";
8966
- import ZnMenu from "components/menu/index";
9003
+ import ZnOption from "components/option/index";
9004
+ import ZnSelect from "components/select/index";
9005
+ import ZnTextarea from "components/textarea/index";
8967
9006
  import type { PropertyValues } from 'lit';
8968
9007
  import type { ZincFormControl } from "internal/zinc-element";
9008
+ /**
9009
+ * @summary Collects one piece of text in several languages, one language at a time.
9010
+ * @documentation https://zinc.style/components/translations
9011
+ * @status experimental
9012
+ * @since 1.0
9013
+ *
9014
+ * A select above the field chooses the language being edited. Closed, it carries how many languages are translated —
9015
+ * `1/5`; open, every language it offers carries a chip saying whether it has a translation of its own or falls back
9016
+ * to English. Blank languages fall back to English at render
9017
+ * time, so a blank field shows the English text as its placeholder rather than looking empty.
9018
+ *
9019
+ * The value submitted is a JSON object keyed by language code. A language stays out of it until it is typed into, so
9020
+ * browsing the languages does not pad the payload with empty translations.
9021
+ *
9022
+ * Put several of these in a `zn-translation-group` to have one select drive all of them.
9023
+ *
9024
+ * @dependency zn-chip
9025
+ * @dependency zn-inline-edit
9026
+ * @dependency zn-input
9027
+ * @dependency zn-option
9028
+ * @dependency zn-select
9029
+ * @dependency zn-textarea
9030
+ *
9031
+ * @slot label - The field's label. Alternatively, use the `label` attribute.
9032
+ * @slot help-text - Text describing how to fill the field in, shown below it and shared by every language.
9033
+ * Alternatively, use the `help-text` attribute.
9034
+ *
9035
+ * @event zn-change - Emitted when a translation's value changes.
9036
+ * @event zn-input - Emitted when a translation receives input.
9037
+ *
9038
+ * @csspart form-control - The form control that wraps the label, the language select, the field and the help text.
9039
+ * @csspart form-control-label - The label's wrapper.
9040
+ * @csspart form-control-input - The wrapper around the field being edited.
9041
+ * @csspart form-control-help-text - The help text's wrapper.
9042
+ * @csspart language-select - The select that chooses the language being edited.
9043
+ */
8969
9044
  export default class ZnTranslations extends ZincElement implements ZincFormControl {
8970
9045
  static styles: import("lit").CSSResult[];
8971
9046
  static dependencies: {
8972
- 'zn-button': typeof ZnButton;
8973
- 'zn-button-group': typeof ZnButtonGroup;
8974
- 'zn-dropdown': typeof ZnDropdown;
9047
+ 'zn-chip': typeof ZnChip;
8975
9048
  'zn-inline-edit': typeof ZnInlineEdit;
8976
9049
  'zn-input': typeof ZnInput;
8977
- 'zn-menu': typeof ZnMenu;
9050
+ 'zn-option': typeof ZnOption;
9051
+ 'zn-select': typeof ZnSelect;
9052
+ 'zn-textarea': typeof ZnTextarea;
8978
9053
  };
8979
9054
  private readonly formControlController;
8980
9055
  private readonly hasSlotController;
9056
+ /** The name submitted with the form. */
8981
9057
  name: string;
9058
+ /** The translations as a JSON object keyed by language code. The mirror of `values` in attribute form. */
8982
9059
  value: string;
9060
+ /** The label shown above the field. If you need HTML, use the `label` slot instead. */
8983
9061
  label: string;
8984
9062
  /**
8985
9063
  * Text shown below the field, describing how to fill it in. Applies to every language. If you need HTML, use the
8986
9064
  * `help-text` slot instead.
8987
9065
  */
8988
9066
  helpText: string;
9067
+ /** Disables editing in every language. */
8989
9068
  disabled: boolean;
9069
+ /** Marks the label required. Validity is not enforced per language. */
8990
9070
  required: boolean;
9071
+ /** Removes the component's own padding. */
8991
9072
  flush: boolean;
8992
- inputType: 'select' | 'text' | 'number' | 'textarea';
9073
+ /** The control each translation is edited through. */
9074
+ inputType: 'text' | 'number' | 'textarea';
9075
+ /** Rows of the textarea, when `input-type` is `textarea`. */
8993
9076
  textareaRows: number | undefined;
9077
+ /**
9078
+ * Edits the translation through a `zn-inline-edit` — the value reads as text until it is clicked — rather than a
9079
+ * plain input or textarea.
9080
+ */
9081
+ inlineEdit: boolean;
8994
9082
  /**
8995
9083
  * Quick insertions offered by the slash menu on `text` and `textarea` inputs. Accepts a JSON array of items, or
8996
9084
  * the shorthand `Brand name={{BRAND_NAME}}, Support email={{SUPPORT_EMAIL}}`. Every language shares the list.
@@ -9008,22 +9096,31 @@ declare module "components/translations/translations.component" {
9008
9096
  slashRecentKey: string;
9009
9097
  /** Resolves additional slash menu items each time the menu opens. JavaScript only. */
9010
9098
  slashItemsProvider?: (query: string) => SlashMenuItem[] | Promise<SlashMenuItem[]>;
9011
- /** When true, hides the individual language navbar and defers language control to a parent zn-translation-group. */
9099
+ /**
9100
+ * Hides this component's own language select and defers the choice to a parent zn-translation-group. The group sets
9101
+ * this on its children itself.
9102
+ */
9012
9103
  grouped: boolean;
9104
+ /**
9105
+ * The languages on offer, as language code to display name — `{"en": "English", "fr": "French"}`. Writing the code
9106
+ * as the name (`{"en": "EN"}`) is also accepted. `en` is the language every other one falls back to.
9107
+ */
9013
9108
  languages: Record<string, string>;
9109
+ /** The translations as an object keyed by language code. The mirror of `value` in property form. */
9014
9110
  values: Record<string, string>;
9111
+ /** The serialized translations a form reset restores. Taken from the `value` attribute where there is one. */
9112
+ defaultValue: string;
9015
9113
  private _activeLanguage;
9016
- private _overflowIndex;
9017
- private _lastObservedWidth;
9018
- private _measureRafId;
9019
- constructor();
9020
9114
  get validity(): ValidityState;
9021
9115
  get validationMessage(): string;
9022
9116
  checkValidity(): boolean;
9023
9117
  getForm(): HTMLFormElement | null;
9024
9118
  reportValidity(): boolean;
9025
9119
  setCustomValidity(): void;
9026
- /** Sets the active language externally. Used by zn-translation-group. */
9120
+ /**
9121
+ * Sets the active language externally. Used by zn-translation-group. Browsing to a language does not create a key
9122
+ * for it — an untouched language stays absent from `values` so it is not submitted as an empty translation.
9123
+ */
9027
9124
  setActiveLanguage(language: string): void;
9028
9125
  /** Returns the currently active language. */
9029
9126
  getActiveLanguage(): string;
@@ -9031,25 +9128,38 @@ declare module "components/translations/translations.component" {
9031
9128
  addLanguageKey(languageCode: string): void;
9032
9129
  /** Returns all language codes that have values. */
9033
9130
  getValueLanguages(): string[];
9131
+ /** Whether the language carries a translation of its own, rather than falling back to English. */
9132
+ hasTranslation(language: string): boolean;
9133
+ /** The chip shown against a language, in the select's value and against each of its options. */
9134
+ private languageState;
9135
+ /**
9136
+ * `English (EN)` — the configured name plus its code, unless the name already is the code, in which case the code
9137
+ * alone. `languages` is written both ways: `{"en": "English"}` and `{"en": "EN"}`.
9138
+ */
9139
+ private languageLabel;
9034
9140
  /**
9035
9141
  * `values`, falling back to the `value` attribute it is built from while that is still pending. A parent
9036
9142
  * zn-translation-group syncs its children from its own first update, which runs before theirs, so reading
9037
9143
  * `values` alone would see it empty and overwrite the value the server rendered.
9038
9144
  */
9039
9145
  private pendingValues;
9040
- disconnectedCallback(): void;
9041
9146
  protected firstUpdated(): void;
9042
- protected updated(changedProperties: PropertyValues): void;
9043
- private _scheduleLangOverflow;
9044
- private _computeLangOverflow;
9045
9147
  willUpdate(changedProperties: PropertyValues): void;
9046
- private handleLanguageAdd;
9047
- private handleOverflowSelect;
9148
+ /**
9149
+ * The select's own change and input events are stopped here: they describe the language being browsed, not the
9150
+ * translation being edited, and a consumer listening on zn-translations reads either as a value change.
9151
+ */
9152
+ private handleLanguageSelect;
9153
+ private handleLanguageInput;
9154
+ /** The language shown in the field, without touching `values`. */
9048
9155
  private switchLanguage;
9049
9156
  private handleValueUpdate;
9050
9157
  private updateValue;
9051
9158
  private handleKeyDown;
9052
9159
  private handleSubmit;
9160
+ /** The control the active language's translation is edited through. */
9161
+ private renderField;
9162
+ /** Arabic and Hebrew read right to left, so the field's `dir` follows the language being edited. */
9053
9163
  private isRTLLanguage;
9054
9164
  render(): import("lit-html").TemplateResult<1>;
9055
9165
  }
@@ -9198,61 +9308,120 @@ declare module "components/animated-button/index" {
9198
9308
  }
9199
9309
  declare module "components/translation-group/translation-group.component" {
9200
9310
  import { type CSSResultGroup, type PropertyValues } from 'lit';
9201
- import ZnButton from "components/button/index";
9202
- import ZnButtonGroup from "components/button-group/index";
9203
- import ZnDropdown from "components/dropdown/index";
9311
+ import ZnChip from "components/chip/index";
9204
9312
  import ZnHeader from "components/header/index";
9205
- import ZnMenu from "components/menu/index";
9313
+ import ZnOption from "components/option/index";
9206
9314
  import ZnPanel from "components/panel/panel.component";
9315
+ import ZnSelect from "components/select/index";
9207
9316
  /**
9208
- * @summary A panel-styled container that provides a shared language toggle for multiple zn-translations children.
9317
+ * @summary Puts several zn-translations fields behind one language select, so a whole form's worth of copy is
9318
+ * translated a language at a time.
9319
+ * @documentation https://zinc.style/components/translation-group
9320
+ * @status experimental
9321
+ * @since 1.0
9209
9322
  *
9210
- * @dependency zn-button
9211
- * @dependency zn-button-group
9212
- * @dependency zn-dropdown
9213
- * @dependency zn-menu
9323
+ * The select sits at the top right of the header, opposite the caption. Choosing a language switches every child at
9324
+ * once, and each child hides its own select while it is in a group — `grouped` is set on them here.
9325
+ *
9326
+ * Closed, the select carries how many target languages are done — `1/5`. Its options each carry a chip aggregated
9327
+ * across the children:
9328
+ *
9329
+ * - `Translated` — every child has a value for it
9330
+ * - `Partial` — only some children do
9331
+ * - `English` — none do, so all of them fall back to the English text
9332
+ *
9333
+ * `Empty` replaces the last of those for English itself, which has nothing to fall back to. English is the source
9334
+ * rather than a translation, so it is also left out of the `n of m translated` count beside the label.
9335
+ *
9336
+ * The children own their values; this component only chooses which language is shown and reports on what they hold.
9337
+ * It reads them back on every child `zn-change`, so the chips and the count follow an edit as it is typed.
9338
+ *
9339
+ * Extends `zn-panel`, so `caption`, `icon`, `flush`, `transparent` and the `footer` slot behave as they do there.
9340
+ * Nested inside another panel, add `inline` to drop the chrome and keep the fields aligned with the surrounding form.
9341
+ *
9342
+ * @dependency zn-chip
9343
+ * @dependency zn-header
9344
+ * @dependency zn-option
9345
+ * @dependency zn-select
9214
9346
  *
9215
9347
  * @event zn-language-change - Emitted when the active language changes. Detail: `{ language: string }`.
9216
9348
  *
9217
- * @slot - Default slot for `<zn-translations>` elements.
9218
- * @slot actions - Actions displayed in the panel header alongside language buttons.
9349
+ * @slot - The `zn-translations` fields the select drives.
9350
+ * @slot actions - Buttons for the bottom of the panel, on the white body rather than the grey footer. They sit on
9351
+ * the right, as zinc's form action rows do; `align="start"` moves one to the left. Write them in the order they
9352
+ * should be read — the sides are set by CSS ordering, so markup order is what a keyboard follows.
9353
+ * @slot footer - Content displayed in the grey panel footer. The header belongs to the language select; nothing
9354
+ * else is slotted into it.
9219
9355
  *
9220
9356
  * @csspart base - The component's base wrapper.
9357
+ * @csspart actions - The row of buttons at the bottom of the body.
9358
+ * @csspart language-field - The label and select that choose the language every child is editing.
9359
+ * @csspart language-select - The select itself.
9221
9360
  */
9222
9361
  export default class ZnTranslationGroup extends ZnPanel {
9223
9362
  static styles: CSSResultGroup;
9224
9363
  static dependencies: {
9225
- 'zn-button': typeof ZnButton;
9226
- 'zn-button-group': typeof ZnButtonGroup;
9227
- 'zn-dropdown': typeof ZnDropdown;
9364
+ 'zn-chip': typeof ZnChip;
9228
9365
  'zn-header': typeof ZnHeader;
9229
- 'zn-menu': typeof ZnMenu;
9366
+ 'zn-option': typeof ZnOption;
9367
+ 'zn-select': typeof ZnSelect;
9230
9368
  };
9231
9369
  private readonly _slotController;
9232
- /** The group label displayed in the panel header. */
9370
+ /** The caption shown in the panel header. An alias for the inherited `caption`, which wins where both are set. */
9233
9371
  label: string;
9234
- /** The available languages for the group. */
9372
+ /**
9373
+ * Drops the panel chrome — border, background and padding — so the group reads as a section of the form around it
9374
+ * rather than a panel of its own. For groups nested inside another panel, where the fields would otherwise sit
9375
+ * indented behind a second border.
9376
+ */
9377
+ inline: boolean;
9378
+ /**
9379
+ * The select's accessible name. Not shown — the caption is what names the section on screen — but read out by a
9380
+ * screen reader, which has nothing else to go on once the visible label is gone.
9381
+ */
9382
+ languageLabel: string;
9383
+ /**
9384
+ * The languages on offer, as language code to display name — `{"en": "English", "fr": "French"}`. Writing the code
9385
+ * as the name (`{"en": "EN"}`) is also accepted. `en` is the language every other one falls back to. Set on every
9386
+ * child, so they do not need their own copy.
9387
+ */
9235
9388
  languages: Record<string, string>;
9389
+ /** The language every child is currently editing. */
9236
9390
  private _activeLanguage;
9237
- /** Tracks all language codes that have been activated across children. */
9238
- private _activatedLanguages;
9239
- private _overflowIndex;
9240
- private _lastObservedWidth;
9241
- private _measureRafId;
9242
- constructor();
9391
+ private _form;
9392
+ connectedCallback(): void;
9243
9393
  disconnectedCallback(): void;
9244
9394
  protected firstUpdated(_changedProperties: PropertyValues): void;
9245
9395
  protected updated(changedProperties: PropertyValues): void;
9246
- private _scheduleLangOverflow;
9247
- private _computeLangOverflow;
9396
+ /** The children the select drives. Read live rather than cached, so markup added later is picked up. */
9248
9397
  private getAllTranslations;
9249
9398
  /** Sync grouped state, languages, and active language to all children. */
9250
9399
  private syncChildren;
9400
+ /**
9401
+ * A language is translated once every child carries a value for it, partial while only some do. The chips and the
9402
+ * count are read off the children, so a child's edit has to bring the group back round.
9403
+ */
9404
+ private languageState;
9405
+ /** `English (EN)`, or the code alone where the configured name already is the code. */
9406
+ private displayName;
9407
+ /** Children take their language list from the group, so a change to `languages` has to reach them. */
9251
9408
  private syncChildLanguages;
9252
9409
  private handleSlotChange;
9410
+ /** Moves every child onto `lang` and announces it. Does not touch their values. */
9253
9411
  private switchLanguage;
9254
- private handleLanguageAdd;
9255
- private handleOverflowSelect;
9412
+ /**
9413
+ * The select's own change and input events describe the language being browsed, not a translation being edited, so
9414
+ * they are stopped rather than allowed to reach a consumer listening for a child's value change.
9415
+ */
9416
+ private handleLanguageSelect;
9417
+ private handleLanguageInput;
9418
+ /** A child's edit changes which chips the select shows, and the translated count above it. */
9419
+ private handleChildChange;
9420
+ /**
9421
+ * The children restore their own values on the form's reset event without announcing it, and the chips and the
9422
+ * count are read off them — so re-read once every listener on that event has run.
9423
+ */
9424
+ private handleFormReset;
9256
9425
  render(): import("lit-html").TemplateResult<1>;
9257
9426
  }
9258
9427
  }