fix: remove translateWithIdMenu, use translateWithId instead, rename translateWithIdInput (#1285)

* fix: remove translateWithIdMenu, use translateWithId instead

* chore: rename translateWithIdInput to translateWithIdSelection
This commit is contained in:
metonym 2022-05-04 07:40:10 -07:00 committed by GitHub
commit f7146b61dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 81 additions and 135 deletions

View file

@ -650,7 +650,7 @@ export interface ComboBoxItem {
### Props ### Props
| Prop name | Kind | Reactive | Type | Default value | Description | | Prop name | Kind | Reactive | Type | Default value | Description |
| :------------------- | :-------------------- | :------- | :---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | | :----------------------- | :-------------------- | :------- | :---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| listRef | <code>let</code> | Yes | <code>null &#124; HTMLDivElement</code> | <code>null</code> | Obtain a reference to the list HTML element | | listRef | <code>let</code> | Yes | <code>null &#124; HTMLDivElement</code> | <code>null</code> | Obtain a reference to the list HTML element |
| ref | <code>let</code> | Yes | <code>null &#124; HTMLInputElement</code> | <code>null</code> | Obtain a reference to the input HTML element | | ref | <code>let</code> | Yes | <code>null &#124; HTMLInputElement</code> | <code>null</code> | Obtain a reference to the input HTML element |
| open | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the combobox menu dropdown | | open | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the combobox menu dropdown |
@ -671,8 +671,7 @@ export interface ComboBoxItem {
| light | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the light variant | | light | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the light variant |
| shouldFilterItem | <code>let</code> | No | <code>(item: ComboBoxItem, value: string) => boolean</code> | <code>() => true</code> | Determine if an item should be filtered given the current combobox value | | shouldFilterItem | <code>let</code> | No | <code>(item: ComboBoxItem, value: string) => boolean</code> | <code>() => true</code> | Determine if an item should be filtered given the current combobox value |
| translateWithId | <code>let</code> | No | <code>(id: import("../ListBox/ListBoxMenuIcon.svelte").ListBoxMenuIconTranslationId) => string</code> | <code>undefined</code> | Override the chevron icon label based on the open state.<br />Defaults to "Open menu" when closed and "Close menu" when open | | translateWithId | <code>let</code> | No | <code>(id: import("../ListBox/ListBoxMenuIcon.svelte").ListBoxMenuIconTranslationId) => string</code> | <code>undefined</code> | Override the chevron icon label based on the open state.<br />Defaults to "Open menu" when closed and "Close menu" when open |
| translateWithIdMenu | <code>let</code> | No | <code>(id: any) => string</code> | <code>undefined</code> | Override the menu label based on the open state.<br />Defaults to "Open menu" and "Close menu" | | translateWithIdSelection | <code>let</code> | No | <code>(id: "clearSelection") => string</code> | <code>undefined</code> | Override the label of the clear button when the input has a selection.<br />Defaults to "Clear selected item" since a combo box can only have on selection. |
| translateWithIdInput | <code>let</code> | No | <code>(id: "clearSelection") => string</code> | <code>undefined</code> | Override the label of the clear button when the input has a selection.<br />Defaults to "Clear selected item" |
| id | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the list box component | | id | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the list box component |
| name | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a name attribute for the input | | name | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a name attribute for the input |
| clear | <code>function</code> | No | <code>(options?: { focus?: boolean; }) => void</code> | <code>() => { prevSelectedId = null; highlightedIndex = -1; highlightedId = undefined; selectedId = undefined; selectedItem = undefined; open = false; inputValue = ""; if (options?.focus !== false) ref?.focus(); }</code> | Clear the combo box programmatically | | clear | <code>function</code> | No | <code>(options?: { focus?: boolean; }) => void</code> | <code>() => { prevSelectedId = null; highlightedIndex = -1; highlightedId = undefined; selectedId = undefined; selectedItem = undefined; open = false; inputValue = ""; if (options?.focus !== false) ref?.focus(); }</code> | Clear the combo box programmatically |
@ -2328,7 +2327,7 @@ export interface MultiSelectItem {
### Props ### Props
| Prop name | Kind | Reactive | Type | Default value | Description | | Prop name | Kind | Reactive | Type | Default value | Description |
| :------------------- | :--------------- | :------- | :------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- | | :----------------------- | :--------------- | :------- | :------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| highlightedId | <code>let</code> | Yes | <code>null &#124; MultiSelectItemId</code> | <code>null</code> | Id of the highlighted ListBoxMenuItem | | highlightedId | <code>let</code> | Yes | <code>null &#124; MultiSelectItemId</code> | <code>null</code> | Id of the highlighted ListBoxMenuItem |
| selectionRef | <code>let</code> | Yes | <code>null &#124; HTMLDivElement</code> | <code>null</code> | Obtain a reference to the selection element | | selectionRef | <code>let</code> | Yes | <code>null &#124; HTMLDivElement</code> | <code>null</code> | Obtain a reference to the selection element |
| fieldRef | <code>let</code> | Yes | <code>null &#124; HTMLDivElement</code> | <code>null</code> | Obtain a reference to the field box element | | fieldRef | <code>let</code> | Yes | <code>null &#124; HTMLDivElement</code> | <code>null</code> | Obtain a reference to the field box element |
@ -2352,8 +2351,7 @@ export interface MultiSelectItem {
| placeholder | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the placeholder text | | placeholder | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the placeholder text |
| sortItem | <code>let</code> | No | <code>((a: MultiSelectItem, b: MultiSelectItem) => MultiSelectItem) &#124; (() => void)</code> | <code>(a, b) => a.text.localeCompare(b.text, locale, { numeric: true })</code> | Override the sorting logic<br />The default sorting compare the item text value | | sortItem | <code>let</code> | No | <code>((a: MultiSelectItem, b: MultiSelectItem) => MultiSelectItem) &#124; (() => void)</code> | <code>(a, b) => a.text.localeCompare(b.text, locale, { numeric: true })</code> | Override the sorting logic<br />The default sorting compare the item text value |
| translateWithId | <code>let</code> | No | <code>(id: import("../ListBox/ListBoxMenuIcon.svelte").ListBoxMenuIconTranslationId) => string</code> | <code>undefined</code> | Override the chevron icon label based on the open state.<br />Defaults to "Open menu" when closed and "Close menu" when open | | translateWithId | <code>let</code> | No | <code>(id: import("../ListBox/ListBoxMenuIcon.svelte").ListBoxMenuIconTranslationId) => string</code> | <code>undefined</code> | Override the chevron icon label based on the open state.<br />Defaults to "Open menu" when closed and "Close menu" when open |
| translateWithIdMenu | <code>let</code> | No | <code>(id: any) => string</code> | <code>undefined</code> | Override the default translation ids for the menu | | translateWithIdSelection | <code>let</code> | No | <code>(id: import("../ListBox/ListBoxSelection.svelte").ListBoxSelectionTranslationId) => string</code> | <code>undefined</code> | Override the label of the clear button when the input has a selection.<br />Defaults to "Clear selected item" and "Clear all items" if more than one item is selected |
| translateWithIdInput | <code>let</code> | No | <code>(id: import("../ListBox/ListBoxSelection.svelte").ListBoxSelectionTranslationId) => string</code> | <code>undefined</code> | Override the label of the clear button when the input has a selection.<br />Defaults to "Clear selected item" and "Clear all items" |
| titleText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the title text | | titleText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the title text |
| useTitleInItem | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to pass the item to `itemToString` in the checkbox | | useTitleInItem | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to pass the item to `itemToString` in the checkbox |
| invalid | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to indicate an invalid state | | invalid | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to indicate an invalid state |

View file

@ -1563,19 +1563,9 @@
"reactive": false "reactive": false
}, },
{ {
"name": "translateWithIdMenu", "name": "translateWithIdSelection",
"kind": "let", "kind": "let",
"description": "Override the menu label based on the open state.\nDefaults to \"Open menu\" and \"Close menu\"", "description": "Override the label of the clear button when the input has a selection.\nDefaults to \"Clear selected item\" since a combo box can only have on selection.",
"type": "(id: any) => string",
"isFunction": false,
"isFunctionDeclaration": false,
"constant": false,
"reactive": false
},
{
"name": "translateWithIdInput",
"kind": "let",
"description": "Override the label of the clear button when the input has a selection.\nDefaults to \"Clear selected item\"",
"type": "(id: \"clearSelection\") => string", "type": "(id: \"clearSelection\") => string",
"isFunction": false, "isFunction": false,
"isFunctionDeclaration": false, "isFunctionDeclaration": false,
@ -6611,19 +6601,9 @@
"reactive": false "reactive": false
}, },
{ {
"name": "translateWithIdMenu", "name": "translateWithIdSelection",
"kind": "let", "kind": "let",
"description": "Override the default translation ids for the menu", "description": "Override the label of the clear button when the input has a selection.\nDefaults to \"Clear selected item\" and \"Clear all items\" if more than one item is selected",
"type": "(id: any) => string",
"isFunction": false,
"isFunctionDeclaration": false,
"constant": false,
"reactive": false
},
{
"name": "translateWithIdInput",
"kind": "let",
"description": "Override the label of the clear button when the input has a selection.\nDefaults to \"Clear selected item\" and \"Clear all items\"",
"type": "(id: import(\"../ListBox/ListBoxSelection.svelte\").ListBoxSelectionTranslationId) => string", "type": "(id: import(\"../ListBox/ListBoxSelection.svelte\").ListBoxSelectionTranslationId) => string",
"isFunction": false, "isFunction": false,
"isFunctionDeclaration": false, "isFunctionDeclaration": false,

View file

@ -82,19 +82,12 @@
*/ */
export let translateWithId = undefined; export let translateWithId = undefined;
/**
* Override the menu label based on the open state.
* Defaults to "Open menu" and "Close menu"
* @type {(id: any) => string}
*/
export let translateWithIdMenu = undefined;
/** /**
* Override the label of the clear button when the input has a selection. * Override the label of the clear button when the input has a selection.
* Defaults to "Clear selected item" since a combo box can only have on selection. * Defaults to "Clear selected item" since a combo box can only have on selection.
* @type {(id: "clearSelection") => string} * @type {(id: "clearSelection") => string}
*/ */
export let translateWithIdInput = undefined; export let translateWithIdSelection = undefined;
/** Set an id for the list box component */ /** Set an id for the list box component */
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
@ -246,7 +239,7 @@
}}" }}"
id="{id}" id="{id}"
disabled="{disabled}" disabled="{disabled}"
translateWithId="{translateWithIdMenu}" translateWithId="{translateWithId}"
> >
<input <input
bind:this="{ref}" bind:this="{ref}"
@ -340,7 +333,7 @@
<ListBoxSelection <ListBoxSelection
on:clear on:clear
on:clear="{clear}" on:clear="{clear}"
translateWithId="{translateWithIdInput}" translateWithId="{translateWithIdSelection}"
disabled="{disabled}" disabled="{disabled}"
open="{open}" open="{open}"
/> />

View file

@ -101,18 +101,12 @@
*/ */
export let translateWithId = undefined; export let translateWithId = undefined;
/**
* Override the default translation ids for the menu
* @type {(id: any) => string}
*/
export let translateWithIdMenu = undefined;
/** /**
* Override the label of the clear button when the input has a selection. * Override the label of the clear button when the input has a selection.
* Defaults to "Clear selected item" and "Clear all items" * Defaults to "Clear selected item" and "Clear all items" if more than one item is selected
* @type {(id: import("../ListBox/ListBoxSelection.svelte").ListBoxSelectionTranslationId) => string} * @type {(id: import("../ListBox/ListBoxSelection.svelte").ListBoxSelectionTranslationId) => string}
*/ */
export let translateWithIdInput = undefined; export let translateWithIdSelection = undefined;
/** Specify the title text */ /** Specify the title text */
export let titleText = ""; export let titleText = "";
@ -375,7 +369,7 @@
}}" }}"
id="{id}" id="{id}"
disabled="{disabled}" disabled="{disabled}"
translateWithId="{translateWithIdMenu}" translateWithId="{translateWithId}"
> >
{#if checked.length > 0} {#if checked.length > 0}
<ListBoxSelection <ListBoxSelection
@ -388,7 +382,7 @@
})); }));
if (fieldRef) fieldRef.blur(); if (fieldRef) fieldRef.blur();
}}" }}"
translateWithId="{translateWithIdInput}" translateWithId="{translateWithIdSelection}"
disabled="{disabled}" disabled="{disabled}"
/> />
{/if} {/if}
@ -453,7 +447,7 @@
inputValue = ''; inputValue = '';
open = false; open = false;
}}" }}"
translateWithId="{translateWithIdInput}" translateWithId="{translateWithIdSelection}"
disabled="{disabled}" disabled="{disabled}"
open="{open}" open="{open}"
/> />

View file

@ -27,10 +27,7 @@
console.log(id); // "open" | "close" console.log(id); // "open" | "close"
return id; return id;
}}" }}"
translateWithIdMenu="{(id) => { translateWithIdSelection="{(id) => {
return id;
}}"
translateWithIdInput="{(id) => {
console.log(id); // "clearSelection" console.log(id); // "clearSelection"
return id; return id;
}}" }}"

View file

@ -24,10 +24,7 @@
console.log(id); // "open" | "close" console.log(id); // "open" | "close"
return id; return id;
}}" }}"
translateWithIdMenu="{(id) => { translateWithIdSelection="{(id) => {
return id;
}}"
translateWithIdInput="{(id) => {
console.log(id); // "clearAll" | "clearSelection" console.log(id); // "clearAll" | "clearSelection"
return id; return id;
}}" }}"

View file

@ -121,19 +121,12 @@ export interface ComboBoxProps
id: import("../ListBox/ListBoxMenuIcon.svelte").ListBoxMenuIconTranslationId id: import("../ListBox/ListBoxMenuIcon.svelte").ListBoxMenuIconTranslationId
) => string; ) => string;
/**
* Override the menu label based on the open state.
* Defaults to "Open menu" and "Close menu"
* @default undefined
*/
translateWithIdMenu?: (id: any) => string;
/** /**
* Override the label of the clear button when the input has a selection. * Override the label of the clear button when the input has a selection.
* Defaults to "Clear selected item" * Defaults to "Clear selected item" since a combo box can only have on selection.
* @default undefined * @default undefined
*/ */
translateWithIdInput?: (id: "clearSelection") => string; translateWithIdSelection?: (id: "clearSelection") => string;
/** /**
* Set an id for the list box component * Set an id for the list box component

View file

@ -131,18 +131,12 @@ export interface MultiSelectProps
id: import("../ListBox/ListBoxMenuIcon.svelte").ListBoxMenuIconTranslationId id: import("../ListBox/ListBoxMenuIcon.svelte").ListBoxMenuIconTranslationId
) => string; ) => string;
/**
* Override the default translation ids for the menu
* @default undefined
*/
translateWithIdMenu?: (id: any) => string;
/** /**
* Override the label of the clear button when the input has a selection. * Override the label of the clear button when the input has a selection.
* Defaults to "Clear selected item" and "Clear all items" * Defaults to "Clear selected item" and "Clear all items" if more than one item is selected
* @default undefined * @default undefined
*/ */
translateWithIdInput?: ( translateWithIdSelection?: (
id: import("../ListBox/ListBoxSelection.svelte").ListBoxSelectionTranslationId id: import("../ListBox/ListBoxSelection.svelte").ListBoxSelectionTranslationId
) => string; ) => string;