@kubex/zinc 1.1.115 → 1.1.116

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
  */
@@ -8958,39 +8962,88 @@ declare module "components/audio-select/index" {
8958
8962
  declare module "components/translations/translations.component" {
8959
8963
  import { type SlashMenuItem } from "components/slash-menu/index";
8960
8964
  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";
8965
+ import ZnChip from "components/chip/index";
8964
8966
  import ZnInlineEdit from "components/inline-edit/index";
8965
8967
  import ZnInput from "components/input/index";
8966
- import ZnMenu from "components/menu/index";
8968
+ import ZnOption from "components/option/index";
8969
+ import ZnSelect from "components/select/index";
8970
+ import ZnTextarea from "components/textarea/index";
8967
8971
  import type { PropertyValues } from 'lit';
8968
8972
  import type { ZincFormControl } from "internal/zinc-element";
8973
+ /**
8974
+ * @summary Collects one piece of text in several languages, one language at a time.
8975
+ * @documentation https://zinc.style/components/translations
8976
+ * @status experimental
8977
+ * @since 1.0
8978
+ *
8979
+ * A select above the field chooses the language being edited. Closed, it carries how many languages are translated —
8980
+ * `1/5`; open, every language it offers carries a chip saying whether it has a translation of its own or falls back
8981
+ * to English. Blank languages fall back to English at render
8982
+ * time, so a blank field shows the English text as its placeholder rather than looking empty.
8983
+ *
8984
+ * The value submitted is a JSON object keyed by language code. A language stays out of it until it is typed into, so
8985
+ * browsing the languages does not pad the payload with empty translations.
8986
+ *
8987
+ * Put several of these in a `zn-translation-group` to have one select drive all of them.
8988
+ *
8989
+ * @dependency zn-chip
8990
+ * @dependency zn-inline-edit
8991
+ * @dependency zn-input
8992
+ * @dependency zn-option
8993
+ * @dependency zn-select
8994
+ * @dependency zn-textarea
8995
+ *
8996
+ * @slot label - The field's label. Alternatively, use the `label` attribute.
8997
+ * @slot help-text - Text describing how to fill the field in, shown below it and shared by every language.
8998
+ * Alternatively, use the `help-text` attribute.
8999
+ *
9000
+ * @event zn-change - Emitted when a translation's value changes.
9001
+ * @event zn-input - Emitted when a translation receives input.
9002
+ *
9003
+ * @csspart form-control - The form control that wraps the label, the language select, the field and the help text.
9004
+ * @csspart form-control-label - The label's wrapper.
9005
+ * @csspart form-control-input - The wrapper around the field being edited.
9006
+ * @csspart form-control-help-text - The help text's wrapper.
9007
+ * @csspart language-select - The select that chooses the language being edited.
9008
+ */
8969
9009
  export default class ZnTranslations extends ZincElement implements ZincFormControl {
8970
9010
  static styles: import("lit").CSSResult[];
8971
9011
  static dependencies: {
8972
- 'zn-button': typeof ZnButton;
8973
- 'zn-button-group': typeof ZnButtonGroup;
8974
- 'zn-dropdown': typeof ZnDropdown;
9012
+ 'zn-chip': typeof ZnChip;
8975
9013
  'zn-inline-edit': typeof ZnInlineEdit;
8976
9014
  'zn-input': typeof ZnInput;
8977
- 'zn-menu': typeof ZnMenu;
9015
+ 'zn-option': typeof ZnOption;
9016
+ 'zn-select': typeof ZnSelect;
9017
+ 'zn-textarea': typeof ZnTextarea;
8978
9018
  };
8979
9019
  private readonly formControlController;
8980
9020
  private readonly hasSlotController;
9021
+ /** The name submitted with the form. */
8981
9022
  name: string;
9023
+ /** The translations as a JSON object keyed by language code. The mirror of `values` in attribute form. */
8982
9024
  value: string;
9025
+ /** The label shown above the field. If you need HTML, use the `label` slot instead. */
8983
9026
  label: string;
8984
9027
  /**
8985
9028
  * Text shown below the field, describing how to fill it in. Applies to every language. If you need HTML, use the
8986
9029
  * `help-text` slot instead.
8987
9030
  */
8988
9031
  helpText: string;
9032
+ /** Disables editing in every language. */
8989
9033
  disabled: boolean;
9034
+ /** Marks the label required. Validity is not enforced per language. */
8990
9035
  required: boolean;
9036
+ /** Removes the component's own padding. */
8991
9037
  flush: boolean;
8992
- inputType: 'select' | 'text' | 'number' | 'textarea';
9038
+ /** The control each translation is edited through. */
9039
+ inputType: 'text' | 'number' | 'textarea';
9040
+ /** Rows of the textarea, when `input-type` is `textarea`. */
8993
9041
  textareaRows: number | undefined;
9042
+ /**
9043
+ * Edits the translation through a `zn-inline-edit` — the value reads as text until it is clicked — rather than a
9044
+ * plain input or textarea.
9045
+ */
9046
+ inlineEdit: boolean;
8994
9047
  /**
8995
9048
  * Quick insertions offered by the slash menu on `text` and `textarea` inputs. Accepts a JSON array of items, or
8996
9049
  * the shorthand `Brand name={{BRAND_NAME}}, Support email={{SUPPORT_EMAIL}}`. Every language shares the list.
@@ -9008,22 +9061,31 @@ declare module "components/translations/translations.component" {
9008
9061
  slashRecentKey: string;
9009
9062
  /** Resolves additional slash menu items each time the menu opens. JavaScript only. */
9010
9063
  slashItemsProvider?: (query: string) => SlashMenuItem[] | Promise<SlashMenuItem[]>;
9011
- /** When true, hides the individual language navbar and defers language control to a parent zn-translation-group. */
9064
+ /**
9065
+ * Hides this component's own language select and defers the choice to a parent zn-translation-group. The group sets
9066
+ * this on its children itself.
9067
+ */
9012
9068
  grouped: boolean;
9069
+ /**
9070
+ * The languages on offer, as language code to display name — `{"en": "English", "fr": "French"}`. Writing the code
9071
+ * as the name (`{"en": "EN"}`) is also accepted. `en` is the language every other one falls back to.
9072
+ */
9013
9073
  languages: Record<string, string>;
9074
+ /** The translations as an object keyed by language code. The mirror of `value` in property form. */
9014
9075
  values: Record<string, string>;
9076
+ /** The serialized translations a form reset restores. Taken from the `value` attribute where there is one. */
9077
+ defaultValue: string;
9015
9078
  private _activeLanguage;
9016
- private _overflowIndex;
9017
- private _lastObservedWidth;
9018
- private _measureRafId;
9019
- constructor();
9020
9079
  get validity(): ValidityState;
9021
9080
  get validationMessage(): string;
9022
9081
  checkValidity(): boolean;
9023
9082
  getForm(): HTMLFormElement | null;
9024
9083
  reportValidity(): boolean;
9025
9084
  setCustomValidity(): void;
9026
- /** Sets the active language externally. Used by zn-translation-group. */
9085
+ /**
9086
+ * Sets the active language externally. Used by zn-translation-group. Browsing to a language does not create a key
9087
+ * for it — an untouched language stays absent from `values` so it is not submitted as an empty translation.
9088
+ */
9027
9089
  setActiveLanguage(language: string): void;
9028
9090
  /** Returns the currently active language. */
9029
9091
  getActiveLanguage(): string;
@@ -9031,25 +9093,38 @@ declare module "components/translations/translations.component" {
9031
9093
  addLanguageKey(languageCode: string): void;
9032
9094
  /** Returns all language codes that have values. */
9033
9095
  getValueLanguages(): string[];
9096
+ /** Whether the language carries a translation of its own, rather than falling back to English. */
9097
+ hasTranslation(language: string): boolean;
9098
+ /** The chip shown against a language, in the select's value and against each of its options. */
9099
+ private languageState;
9100
+ /**
9101
+ * `English (EN)` — the configured name plus its code, unless the name already is the code, in which case the code
9102
+ * alone. `languages` is written both ways: `{"en": "English"}` and `{"en": "EN"}`.
9103
+ */
9104
+ private languageLabel;
9034
9105
  /**
9035
9106
  * `values`, falling back to the `value` attribute it is built from while that is still pending. A parent
9036
9107
  * zn-translation-group syncs its children from its own first update, which runs before theirs, so reading
9037
9108
  * `values` alone would see it empty and overwrite the value the server rendered.
9038
9109
  */
9039
9110
  private pendingValues;
9040
- disconnectedCallback(): void;
9041
9111
  protected firstUpdated(): void;
9042
- protected updated(changedProperties: PropertyValues): void;
9043
- private _scheduleLangOverflow;
9044
- private _computeLangOverflow;
9045
9112
  willUpdate(changedProperties: PropertyValues): void;
9046
- private handleLanguageAdd;
9047
- private handleOverflowSelect;
9113
+ /**
9114
+ * The select's own change and input events are stopped here: they describe the language being browsed, not the
9115
+ * translation being edited, and a consumer listening on zn-translations reads either as a value change.
9116
+ */
9117
+ private handleLanguageSelect;
9118
+ private handleLanguageInput;
9119
+ /** The language shown in the field, without touching `values`. */
9048
9120
  private switchLanguage;
9049
9121
  private handleValueUpdate;
9050
9122
  private updateValue;
9051
9123
  private handleKeyDown;
9052
9124
  private handleSubmit;
9125
+ /** The control the active language's translation is edited through. */
9126
+ private renderField;
9127
+ /** Arabic and Hebrew read right to left, so the field's `dir` follows the language being edited. */
9053
9128
  private isRTLLanguage;
9054
9129
  render(): import("lit-html").TemplateResult<1>;
9055
9130
  }
@@ -9198,61 +9273,120 @@ declare module "components/animated-button/index" {
9198
9273
  }
9199
9274
  declare module "components/translation-group/translation-group.component" {
9200
9275
  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";
9276
+ import ZnChip from "components/chip/index";
9204
9277
  import ZnHeader from "components/header/index";
9205
- import ZnMenu from "components/menu/index";
9278
+ import ZnOption from "components/option/index";
9206
9279
  import ZnPanel from "components/panel/panel.component";
9280
+ import ZnSelect from "components/select/index";
9207
9281
  /**
9208
- * @summary A panel-styled container that provides a shared language toggle for multiple zn-translations children.
9282
+ * @summary Puts several zn-translations fields behind one language select, so a whole form's worth of copy is
9283
+ * translated a language at a time.
9284
+ * @documentation https://zinc.style/components/translation-group
9285
+ * @status experimental
9286
+ * @since 1.0
9209
9287
  *
9210
- * @dependency zn-button
9211
- * @dependency zn-button-group
9212
- * @dependency zn-dropdown
9213
- * @dependency zn-menu
9288
+ * The select sits at the top right of the header, opposite the caption. Choosing a language switches every child at
9289
+ * once, and each child hides its own select while it is in a group — `grouped` is set on them here.
9290
+ *
9291
+ * Closed, the select carries how many target languages are done — `1/5`. Its options each carry a chip aggregated
9292
+ * across the children:
9293
+ *
9294
+ * - `Translated` — every child has a value for it
9295
+ * - `Partial` — only some children do
9296
+ * - `English` — none do, so all of them fall back to the English text
9297
+ *
9298
+ * `Empty` replaces the last of those for English itself, which has nothing to fall back to. English is the source
9299
+ * rather than a translation, so it is also left out of the `n of m translated` count beside the label.
9300
+ *
9301
+ * The children own their values; this component only chooses which language is shown and reports on what they hold.
9302
+ * It reads them back on every child `zn-change`, so the chips and the count follow an edit as it is typed.
9303
+ *
9304
+ * Extends `zn-panel`, so `caption`, `icon`, `flush`, `transparent` and the `footer` slot behave as they do there.
9305
+ * Nested inside another panel, add `inline` to drop the chrome and keep the fields aligned with the surrounding form.
9306
+ *
9307
+ * @dependency zn-chip
9308
+ * @dependency zn-header
9309
+ * @dependency zn-option
9310
+ * @dependency zn-select
9214
9311
  *
9215
9312
  * @event zn-language-change - Emitted when the active language changes. Detail: `{ language: string }`.
9216
9313
  *
9217
- * @slot - Default slot for `<zn-translations>` elements.
9218
- * @slot actions - Actions displayed in the panel header alongside language buttons.
9314
+ * @slot - The `zn-translations` fields the select drives.
9315
+ * @slot actions - Buttons for the bottom of the panel, on the white body rather than the grey footer. They sit on
9316
+ * the right, as zinc's form action rows do; `align="start"` moves one to the left. Write them in the order they
9317
+ * should be read — the sides are set by CSS ordering, so markup order is what a keyboard follows.
9318
+ * @slot footer - Content displayed in the grey panel footer. The header belongs to the language select; nothing
9319
+ * else is slotted into it.
9219
9320
  *
9220
9321
  * @csspart base - The component's base wrapper.
9322
+ * @csspart actions - The row of buttons at the bottom of the body.
9323
+ * @csspart language-field - The label and select that choose the language every child is editing.
9324
+ * @csspart language-select - The select itself.
9221
9325
  */
9222
9326
  export default class ZnTranslationGroup extends ZnPanel {
9223
9327
  static styles: CSSResultGroup;
9224
9328
  static dependencies: {
9225
- 'zn-button': typeof ZnButton;
9226
- 'zn-button-group': typeof ZnButtonGroup;
9227
- 'zn-dropdown': typeof ZnDropdown;
9329
+ 'zn-chip': typeof ZnChip;
9228
9330
  'zn-header': typeof ZnHeader;
9229
- 'zn-menu': typeof ZnMenu;
9331
+ 'zn-option': typeof ZnOption;
9332
+ 'zn-select': typeof ZnSelect;
9230
9333
  };
9231
9334
  private readonly _slotController;
9232
- /** The group label displayed in the panel header. */
9335
+ /** The caption shown in the panel header. An alias for the inherited `caption`, which wins where both are set. */
9233
9336
  label: string;
9234
- /** The available languages for the group. */
9337
+ /**
9338
+ * Drops the panel chrome — border, background and padding — so the group reads as a section of the form around it
9339
+ * rather than a panel of its own. For groups nested inside another panel, where the fields would otherwise sit
9340
+ * indented behind a second border.
9341
+ */
9342
+ inline: boolean;
9343
+ /**
9344
+ * The select's accessible name. Not shown — the caption is what names the section on screen — but read out by a
9345
+ * screen reader, which has nothing else to go on once the visible label is gone.
9346
+ */
9347
+ languageLabel: string;
9348
+ /**
9349
+ * The languages on offer, as language code to display name — `{"en": "English", "fr": "French"}`. Writing the code
9350
+ * as the name (`{"en": "EN"}`) is also accepted. `en` is the language every other one falls back to. Set on every
9351
+ * child, so they do not need their own copy.
9352
+ */
9235
9353
  languages: Record<string, string>;
9354
+ /** The language every child is currently editing. */
9236
9355
  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();
9356
+ private _form;
9357
+ connectedCallback(): void;
9243
9358
  disconnectedCallback(): void;
9244
9359
  protected firstUpdated(_changedProperties: PropertyValues): void;
9245
9360
  protected updated(changedProperties: PropertyValues): void;
9246
- private _scheduleLangOverflow;
9247
- private _computeLangOverflow;
9361
+ /** The children the select drives. Read live rather than cached, so markup added later is picked up. */
9248
9362
  private getAllTranslations;
9249
9363
  /** Sync grouped state, languages, and active language to all children. */
9250
9364
  private syncChildren;
9365
+ /**
9366
+ * A language is translated once every child carries a value for it, partial while only some do. The chips and the
9367
+ * count are read off the children, so a child's edit has to bring the group back round.
9368
+ */
9369
+ private languageState;
9370
+ /** `English (EN)`, or the code alone where the configured name already is the code. */
9371
+ private displayName;
9372
+ /** Children take their language list from the group, so a change to `languages` has to reach them. */
9251
9373
  private syncChildLanguages;
9252
9374
  private handleSlotChange;
9375
+ /** Moves every child onto `lang` and announces it. Does not touch their values. */
9253
9376
  private switchLanguage;
9254
- private handleLanguageAdd;
9255
- private handleOverflowSelect;
9377
+ /**
9378
+ * The select's own change and input events describe the language being browsed, not a translation being edited, so
9379
+ * they are stopped rather than allowed to reach a consumer listening for a child's value change.
9380
+ */
9381
+ private handleLanguageSelect;
9382
+ private handleLanguageInput;
9383
+ /** A child's edit changes which chips the select shows, and the translated count above it. */
9384
+ private handleChildChange;
9385
+ /**
9386
+ * The children restore their own values on the form's reset event without announcing it, and the chips and the
9387
+ * count are read off them — so re-read once every listener on that event has run.
9388
+ */
9389
+ private handleFormReset;
9256
9390
  render(): import("lit-html").TemplateResult<1>;
9257
9391
  }
9258
9392
  }