From 6d9f45b107b10af02870846c6c0ad7527b98b6a3 Mon Sep 17 00:00:00 2001 From: Samuel Janda Date: Tue, 16 Jan 2024 19:25:13 +1100 Subject: [PATCH] Adopted suggested changes --- COMPONENT_INDEX.md | 84 ++++---- docs/src/COMPONENT_API.json | 274 ++++++++++++------------ docs/src/pages/components/TextInput.svx | 2 +- package.json | 3 +- src/TextInput/TextInput.svelte | 150 +++++-------- src/TextInput/TextInputSkeleton.svelte | 2 +- 6 files changed, 236 insertions(+), 279 deletions(-) diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index 820b060d..ff709735 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -4215,30 +4215,30 @@ None. ### Props -| Prop name | Required | Kind | Reactive | Type | Default value | Description | -| :-------------- | :------- | :--------------- | :------- | --------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| value | No | let | Yes | null | number | string | "" | Specify the input value
`value` will be set to `null` if `type = "number"` and the value is empty | -| ref | No | let | Yes | null | HTMLInputElement | null | Obtain a reference to the input HTML element | -| counter | No | let | No | "char" | "word" | undefined | Set to "char" to enable display the character counter or "word" to display the word count. | -| disabled | No | let | No | boolean | false | Set to `true` to disable the input | -| helperText | No | let | No | string | "" | Specify the helper text | -| hideLabel | No | let | No | boolean | false | Set to `true` to visually hide the label text | -| id | No | let | No | string | "ccs-" + Math.random().toString(36) | Set an id for the input element | -| inline | No | let | No | boolean | false | Set to `true` to use the inline variant | -| invalid | No | let | No | boolean | false | Set to `true` to indicate an invalid state | -| invalidText | No | let | No | string | "" | Specify the invalid state text | -| labelText | No | let | No | string | "" | Specify the label text | -| light | No | let | No | boolean | false | Set to `true` to enable the light variant
For use on $ui-01 backgrounds only. Don't use this to make tile background color same as container background color
The light prop for `TextInput` has been deprecated in favor of the new `Layer` Layer component. It will be removed in the next major release
@deprecated | -| maxCount | No | let | No | number | undefined | Specify the maximum number of characters/words allowed
This is needed in order for `counter` to display | -| name | No | let | No | string | undefined | Specify a name attribute for the input | -| placeholder | No | let | No | string | "" | Specify the placeholder text | -| readonly | No | let | No | boolean | false | Set to `true` to use the read-only variant | -| required | No | let | No | boolean | false | Set to `true` to mark the field as required | -| size | No | let | No | "sm" | "md" | "lg" | undefined | Set the size of the input | -| warn | No | let | No | boolean | false | Set to `true` to indicate an warning state | -| warnText | No | let | No | string | "" | Specify the warning state text | -| labelAttributes | No | let | No | Record | {} | Set HTML attributes on the `label` element | -| inputAttributes | No | let | No | Record | {} | Set HTML attributes on the `input` element | +| Prop name | Required | Kind | Reactive | Type | Default value | Description | +| :-------------- | :------- | :--------------- | :------- | ---------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ref | No | let | Yes | null | HTMLInputElement | null | Obtain a reference to the input HTML element | +| value | No | let | Yes | null | number | string | "" | Specify the input value
`value` will be set to `null` if `typeof value === "number"` and `value` is empty | +| size | No | let | No | "sm" | "md" | "lg" | "md" | Set the size of the input | +| placeholder | No | let | No | string | "" | Specify the placeholder text | +| light | No | let | No | boolean | false | Set to `true` to enable the light variant
For use on $ui-01 backgrounds only. Don't use this to make tile background color same as container background color
The light prop for `TextInput` has been deprecated in favor of the new `Layer` Layer component. It will be removed in the next major release
@deprecated | +| disabled | No | let | No | boolean | false | Set to `true` to disable the input | +| labelText | No | let | No | string | "" | Specify the label text | +| hideLabel | No | let | No | boolean | false | Set to `true` to visually hide the label text | +| helperText | No | let | No | string | "" | Specify the helper text | +| counter | No | let | No | boolean | false | Set to `true` to enable display the character counter. Requires `maxCount` to be set. | +| maxCount | No | let | No | number | undefined | Specify the maximum number of characters/words allowed
This is needed in order for `counter` to display | +| invalid | No | let | No | boolean | false | Set to `true` to indicate an invalid state | +| invalidText | No | let | No | string | "" | Specify the invalid state text | +| warn | No | let | No | boolean | false | Set to `true` to indicate an warning state | +| warnText | No | let | No | string | "" | Specify the warning state text | +| id | No | let | No | string | "ccs-" + Math.random().toString(36) | Set an id for the input element | +| name | No | let | No | string | undefined | Specify a name attribute for the input | +| inline | No | let | No | boolean | false | Set to `true` to use the inline variant | +| required | No | let | No | boolean | false | Set to `true` to mark the field as required | +| readonly | No | let | No | boolean | false | Set to `true` to use the read-only variant | +| labelAttributes | No | let | No | import('svelte/elements').HTMLLabelAttributes | {} | Set HTML attributes on the `label` element | +| inputAttributes | No | let | No | import('svelte/elements').HTMLInputAttributes | {} | Set HTML attributes on the `input` element | ### Slots @@ -4251,29 +4251,29 @@ None. ### Events -| Event name | Type | Detail | -| :----------- | :--------- | :-------------------------------------------- | -| change | dispatched | null | number | string | -| input | dispatched | null | number | string | -| click | forwarded | -- | -| pointerup | forwarded | -- | -| pointerover | forwarded | -- | -| pointerenter | forwarded | -- | -| pointerleave | forwarded | -- | -| keydown | forwarded | -- | -| keyup | forwarded | -- | -| focus | forwarded | -- | -| blur | forwarded | -- | -| paste | forwarded | -- | +| Event name | Type | Detail | +| :----------- | :-------- | :----- | +| click | forwarded | -- | +| pointerup | forwarded | -- | +| pointerover | forwarded | -- | +| pointerenter | forwarded | -- | +| pointerleave | forwarded | -- | +| change | forwarded | -- | +| input | forwarded | -- | +| keydown | forwarded | -- | +| keyup | forwarded | -- | +| focus | forwarded | -- | +| blur | forwarded | -- | +| paste | forwarded | -- | ## `TextInputSkeleton` ### Props -| Prop name | Required | Kind | Reactive | Type | Default value | Description | -| :------------ | :------- | :--------------- | :------- | ----------------------------------- | ------------------ | ---------------------------------------------------------- | -| hideLabel | No | let | No | boolean | false | Set to `true` to hide the label text | -| divAttributes | No | let | No | Record | {} | Specify the div HTML attributes for the skeleton container | +| Prop name | Required | Kind | Reactive | Type | Default value | Description | +| :------------ | :------- | :--------------- | :------- | -------------------------------------------------------- | ------------------ | ---------------------------------------------------------- | +| hideLabel | No | let | No | boolean | false | Set to `true` to hide the label text | +| divAttributes | No | let | No | import('svelte/elements').HTMLDivAttributes | {} | Specify the div HTML attributes for the skeleton container | ### Slots diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index 5d34b7d5..81ef5730 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -12698,10 +12698,59 @@ "filePath": "src/TextInput/TextInput.svelte", "props": [ { - "name": "counter", + "name": "value", "kind": "let", - "description": "Set to \"char\" to enable display the character counter or \"word\" to display the word count.", - "type": "\"char\" | \"word\"", + "description": "Specify the input value\n`value` will be set to `null` if `typeof value === \"number\"` and `value` is empty", + "type": "null | number | string", + "value": "\"\"", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": true + }, + { + "name": "ref", + "kind": "let", + "description": "Obtain a reference to the input HTML element", + "type": "null | HTMLInputElement", + "value": "null", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": true + }, + { + "name": "size", + "kind": "let", + "description": "Set the size of the input", + "type": "\"sm\" | \"md\" | \"lg\"", + "value": "\"md\"", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "placeholder", + "kind": "let", + "description": "Specify the placeholder text", + "type": "string", + "value": "\"\"", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "light", + "kind": "let", + "description": "Set to `true` to enable the light variant\nFor use on $ui-01 backgrounds only. Don't use this to make tile background color same as container background color\nThe light prop for `TextInput` has been deprecated in favor of the new `Layer` Layer component. It will be removed in the next major release\n@deprecated ", + "type": "boolean", + "value": "false", "isFunction": false, "isFunctionDeclaration": false, "isRequired": false, @@ -12721,9 +12770,9 @@ "reactive": false }, { - "name": "helperText", + "name": "labelText", "kind": "let", - "description": "Specify the helper text", + "description": "Specify the label text", "type": "string", "value": "\"\"", "isFunction": false, @@ -12745,11 +12794,11 @@ "reactive": false }, { - "name": "id", + "name": "helperText", "kind": "let", - "description": "Set an id for the input element", + "description": "Specify the helper text", "type": "string", - "value": "\"ccs-\" + Math.random().toString(36)", + "value": "\"\"", "isFunction": false, "isFunctionDeclaration": false, "isRequired": false, @@ -12757,9 +12806,9 @@ "reactive": false }, { - "name": "inline", + "name": "counter", "kind": "let", - "description": "Set to `true` to use the inline variant", + "description": "Set to `true` to enable display the character counter. Requires `maxCount` to be set.", "type": "boolean", "value": "false", "isFunction": false, @@ -12768,6 +12817,17 @@ "constant": false, "reactive": false }, + { + "name": "maxCount", + "kind": "let", + "description": "Specify the maximum number of characters/words allowed\nThis is needed in order for `counter` to display", + "type": "number", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, { "name": "invalid", "kind": "let", @@ -12792,123 +12852,6 @@ "constant": false, "reactive": false }, - { - "name": "labelText", - "kind": "let", - "description": "Specify the label text", - "type": "string", - "value": "\"\"", - "isFunction": false, - "isFunctionDeclaration": false, - "isRequired": false, - "constant": false, - "reactive": false - }, - { - "name": "light", - "kind": "let", - "description": "Set to `true` to enable the light variant\nFor use on $ui-01 backgrounds only. Don't use this to make tile background color same as container background color\nThe light prop for `TextInput` has been deprecated in favor of the new `Layer` Layer component. It will be removed in the next major release\n@deprecated ", - "type": "boolean", - "value": "false", - "isFunction": false, - "isFunctionDeclaration": false, - "isRequired": false, - "constant": false, - "reactive": false - }, - { - "name": "maxCount", - "kind": "let", - "description": "Specify the maximum number of characters/words allowed\nThis is needed in order for `counter` to display", - "type": "number", - "isFunction": false, - "isFunctionDeclaration": false, - "isRequired": false, - "constant": false, - "reactive": false - }, - { - "name": "name", - "kind": "let", - "description": "Specify a name attribute for the input", - "type": "string", - "isFunction": false, - "isFunctionDeclaration": false, - "isRequired": false, - "constant": false, - "reactive": false - }, - { - "name": "placeholder", - "kind": "let", - "description": "Specify the placeholder text", - "type": "string", - "value": "\"\"", - "isFunction": false, - "isFunctionDeclaration": false, - "isRequired": false, - "constant": false, - "reactive": false - }, - { - "name": "readonly", - "kind": "let", - "description": "Set to `true` to use the read-only variant", - "type": "boolean", - "value": "false", - "isFunction": false, - "isFunctionDeclaration": false, - "isRequired": false, - "constant": false, - "reactive": false - }, - { - "name": "ref", - "kind": "let", - "description": "Obtain a reference to the input HTML element", - "type": "null | HTMLInputElement", - "value": "null", - "isFunction": false, - "isFunctionDeclaration": false, - "isRequired": false, - "constant": false, - "reactive": true - }, - { - "name": "required", - "kind": "let", - "description": "Set to `true` to mark the field as required", - "type": "boolean", - "value": "false", - "isFunction": false, - "isFunctionDeclaration": false, - "isRequired": false, - "constant": false, - "reactive": false - }, - { - "name": "size", - "kind": "let", - "description": "Set the size of the input", - "type": "\"sm\" | \"md\" | \"lg\"", - "isFunction": false, - "isFunctionDeclaration": false, - "isRequired": false, - "constant": false, - "reactive": false - }, - { - "name": "value", - "kind": "let", - "description": "Specify the input value\n`value` will be set to `null` if `type = \"number\"` and the value is empty", - "type": "null | number | string", - "value": "\"\"", - "isFunction": false, - "isFunctionDeclaration": false, - "isRequired": false, - "constant": false, - "reactive": true - }, { "name": "warn", "kind": "let", @@ -12933,11 +12876,70 @@ "constant": false, "reactive": false }, + { + "name": "id", + "kind": "let", + "description": "Set an id for the input element", + "type": "string", + "value": "\"ccs-\" + Math.random().toString(36)", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "name", + "kind": "let", + "description": "Specify a name attribute for the input", + "type": "string", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "inline", + "kind": "let", + "description": "Set to `true` to use the inline variant", + "type": "boolean", + "value": "false", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "required", + "kind": "let", + "description": "Set to `true` to mark the field as required", + "type": "boolean", + "value": "false", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "readonly", + "kind": "let", + "description": "Set to `true` to use the read-only variant", + "type": "boolean", + "value": "false", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, { "name": "labelAttributes", "kind": "let", "description": "Set HTML attributes on the `label` element", - "type": "Record", + "type": "import('svelte/elements').HTMLLabelAttributes", "value": "{}", "isFunction": false, "isFunctionDeclaration": false, @@ -12949,7 +12951,7 @@ "name": "inputAttributes", "kind": "let", "description": "Set HTML attributes on the `input` element", - "type": "Record", + "type": "import('svelte/elements').HTMLInputAttributes", "value": "{}", "isFunction": false, "isFunctionDeclaration": false, @@ -12986,21 +12988,13 @@ } ], "events": [ - { - "type": "dispatched", - "name": "change", - "detail": "null | number | string" - }, - { - "type": "dispatched", - "name": "input", - "detail": "null | number | string" - }, { "type": "forwarded", "name": "click", "element": "div" }, { "type": "forwarded", "name": "pointerup", "element": "div" }, { "type": "forwarded", "name": "pointerover", "element": "div" }, { "type": "forwarded", "name": "pointerenter", "element": "div" }, { "type": "forwarded", "name": "pointerleave", "element": "div" }, + { "type": "forwarded", "name": "change", "element": "input" }, + { "type": "forwarded", "name": "input", "element": "input" }, { "type": "forwarded", "name": "keydown", "element": "input" }, { "type": "forwarded", "name": "keyup", "element": "input" }, { "type": "forwarded", "name": "focus", "element": "input" }, @@ -13029,7 +13023,7 @@ "name": "divAttributes", "kind": "let", "description": "Specify the div HTML attributes for the skeleton container", - "type": "Record", + "type": "import('svelte/elements').HTMLDivAttributes", "value": "{}", "isFunction": false, "isFunctionDeclaration": false, diff --git a/docs/src/pages/components/TextInput.svx b/docs/src/pages/components/TextInput.svx index 1022da6f..4ceb521d 100644 --- a/docs/src/pages/components/TextInput.svx +++ b/docs/src/pages/components/TextInput.svx @@ -41,7 +41,7 @@ components: ["TextInput", "TextInputSkeleton"] ## Character Counter - + ## Invalid state diff --git a/package.json b/package.json index 4580ed50..774bee0c 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,6 @@ "contributors": [ "Josef Aidt (https://github.com/josefaidt)", "Eric Liu (https://github.com/metonym)", - "Enrico Sacchetti (https://github.com/theetrain)", - "Samuel Janda (https://github.com/SimpleProgrammingAU)" + "Enrico Sacchetti (https://github.com/theetrain)" ] } diff --git a/src/TextInput/TextInput.svelte b/src/TextInput/TextInput.svelte index aecafe3e..51e3294f 100644 --- a/src/TextInput/TextInput.svelte +++ b/src/TextInput/TextInput.svelte @@ -1,38 +1,21 @@