mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 03:26:36 +00:00
Merge branch 'next/v11-styles' into v11-Layer
This commit is contained in:
commit
20ccb65e5d
12 changed files with 484 additions and 285 deletions
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -2,6 +2,17 @@
|
|||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [1.0.0-next.1](https://github.com/carbon-design-system/carbon-components-svelte/compare/v1.0.0-next.0...v1.0.0-next.1) (2024-01-17)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* TextInput v11 Styles (#1889)
|
||||
|
||||
### Features
|
||||
|
||||
* TextInput v11 Styles ([#1889](https://github.com/carbon-design-system/carbon-components-svelte/issues/1889)) ([c436dbd](https://github.com/carbon-design-system/carbon-components-svelte/commit/c436dbd76177f7553ba4206601f5ef2e416da594)), closes [#1667](https://github.com/carbon-design-system/carbon-components-svelte/issues/1667) [#1633](https://github.com/carbon-design-system/carbon-components-svelte/issues/1633) [#1621](https://github.com/carbon-design-system/carbon-components-svelte/issues/1621) [#1621](https://github.com/carbon-design-system/carbon-components-svelte/issues/1621) [#1888](https://github.com/carbon-design-system/carbon-components-svelte/issues/1888)
|
||||
|
||||
## [1.0.0-next.0](https://github.com/carbon-design-system/carbon-components-svelte/compare/v0.82.8...v1.0.0-next.0) (2024-01-12)
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Component Index
|
||||
|
||||
> 166 components exported from carbon-components-svelte@1.0.0-next.0.
|
||||
> 166 components exported from carbon-components-svelte@1.0.0-next.1.
|
||||
|
||||
## Components
|
||||
|
||||
|
@ -4154,42 +4154,50 @@ None.
|
|||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :---------- | :------- | :--------------- | :------- | --------------------------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
|
||||
| :-------------- | :------- | :--------------- | :------- | ---------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ref | No | <code>let</code> | Yes | <code>null | HTMLInputElement</code> | <code>null</code> | Obtain a reference to the input HTML element |
|
||||
| value | No | <code>let</code> | Yes | <code>null | number | string</code> | <code>""</code> | Specify the input value.<br /><br />`value` will be set to `null` if type="number"<br />and the value is empty. |
|
||||
| size | No | <code>let</code> | No | <code>"sm" | "lg"</code> | <code>undefined</code> | Set the size of the input |
|
||||
| value | No | <code>let</code> | Yes | <code>null | number | string</code> | <code>""</code> | Specify the input value<br />`value` will be set to `null` if `typeof value === "number"` and `value` is empty |
|
||||
| size | No | <code>let</code> | No | <code>"sm" | "md" | "lg"</code> | <code>"md"</code> | Set the size of the input |
|
||||
| placeholder | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the placeholder text |
|
||||
| light | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the light variant |
|
||||
| light | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the light variant<br />For use on $ui-01 backgrounds only. Don't use this to make tile background color same as container background color<br />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<br />@deprecated |
|
||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the input |
|
||||
| helperText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the helper text |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the input element |
|
||||
| name | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a name attribute for the input |
|
||||
| labelText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label text |
|
||||
| hideLabel | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to visually hide the label text |
|
||||
| helperText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the helper text |
|
||||
| counter | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable display the character counter. Requires `maxCount` to be set. |
|
||||
| maxCount | No | <code>let</code> | No | <code>number</code> | <code>undefined</code> | Specify the maximum number of characters/words allowed<br />This is needed in order for `counter` to display |
|
||||
| invalid | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to indicate an invalid state |
|
||||
| invalidText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the invalid state text |
|
||||
| warn | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to indicate an warning state |
|
||||
| warnText | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the warning state text |
|
||||
| required | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to mark the field as required |
|
||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the input element |
|
||||
| name | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify a name attribute for the input |
|
||||
| inline | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the inline variant |
|
||||
| required | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to mark the field as required |
|
||||
| readonly | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the read-only variant |
|
||||
| labelAttributes | No | <code>let</code> | No | <code>import('svelte/elements').HTMLLabelAttributes</code> | <code>{}</code> | Set HTML attributes on the `label` element |
|
||||
| inputAttributes | No | <code>let</code> | No | <code>import('svelte/elements').HTMLInputAttributes</code> | <code>{}</code> | Set HTML attributes on the `input` element |
|
||||
|
||||
### Slots
|
||||
|
||||
| Slot name | Default | Props | Fallback |
|
||||
| :-------- | :------ | :---- | :----------------------- |
|
||||
| :---------- | :------ | :---- | :------------------------- |
|
||||
| helperText | No | -- | <code>{helperText}</code> |
|
||||
| invalidText | No | -- | <code>{invalidText}</code> |
|
||||
| labelText | No | -- | <code>{labelText}</code> |
|
||||
| warnText | No | -- | <code>{warnText}</code> |
|
||||
|
||||
### Events
|
||||
|
||||
| Event name | Type | Detail |
|
||||
| :--------- | :--------- | :-------------------------------------------- |
|
||||
| change | dispatched | <code>null | number | string</code> |
|
||||
| input | dispatched | <code>null | number | string</code> |
|
||||
| :----------- | :-------- | :----- |
|
||||
| click | forwarded | -- |
|
||||
| mouseover | forwarded | -- |
|
||||
| mouseenter | forwarded | -- |
|
||||
| mouseleave | forwarded | -- |
|
||||
| pointerup | forwarded | -- |
|
||||
| pointerover | forwarded | -- |
|
||||
| pointerenter | forwarded | -- |
|
||||
| pointerleave | forwarded | -- |
|
||||
| change | forwarded | -- |
|
||||
| input | forwarded | -- |
|
||||
| keydown | forwarded | -- |
|
||||
| keyup | forwarded | -- |
|
||||
| focus | forwarded | -- |
|
||||
|
@ -4201,8 +4209,9 @@ None.
|
|||
### Props
|
||||
|
||||
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
|
||||
| :-------- | :------- | :--------------- | :------- | -------------------- | ------------------ | ------------------------------------ |
|
||||
| :------------ | :------- | :--------------- | :------- | -------------------------------------------------------- | ------------------ | ---------------------------------------------------------- |
|
||||
| hideLabel | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to hide the label text |
|
||||
| divAttributes | No | <code>let</code> | No | <code>import('svelte/elements').HTMLDivAttributes</code> | <code>{}</code> | Specify the div HTML attributes for the skeleton container |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -4211,11 +4220,12 @@ None.
|
|||
### Events
|
||||
|
||||
| Event name | Type | Detail |
|
||||
| :--------- | :-------- | :----- |
|
||||
| :----------- | :-------- | :----- |
|
||||
| click | forwarded | -- |
|
||||
| mouseover | forwarded | -- |
|
||||
| mouseenter | forwarded | -- |
|
||||
| mouseleave | forwarded | -- |
|
||||
| pointerup | forwarded | -- |
|
||||
| pointerover | forwarded | -- |
|
||||
| pointerenter | forwarded | -- |
|
||||
| pointerleave | forwarded | -- |
|
||||
|
||||
## `Theme`
|
||||
|
||||
|
|
|
@ -171,7 +171,15 @@ The workflow is automatically triggered when pushing a tag that begins with `v`
|
|||
|
||||
However, maintainers must perform a few things in preparation for a release.
|
||||
|
||||
Locally, while on `master` and the branch is clean, run `npm run release`. This command will:
|
||||
<!-- Instructions for next/* releases -->
|
||||
|
||||
While performing a prerelease:
|
||||
|
||||
1. manually bump `package.json`'s `version` key to your target version.
|
||||
2. ensure the `--first-release` flag is passed to the `standard-version` command.
|
||||
3. Run `npm run release` then continue below.
|
||||
|
||||
For regular releases, while on `master` and the branch is clean, run `npm run release`. This command will:
|
||||
|
||||
- Bump the semantic version in `package.json`
|
||||
- Generate notes in `CHANGELOG.md`
|
||||
|
|
10
docs/package-lock.json
generated
10
docs/package-lock.json
generated
|
@ -25,7 +25,7 @@
|
|||
}
|
||||
},
|
||||
"..": {
|
||||
"version": "0.82.7",
|
||||
"version": "1.0.0-next.0",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
|
@ -39,17 +39,17 @@
|
|||
"autoprefixer": "^10.4.8",
|
||||
"carbon-icons-svelte": "^12.1.0",
|
||||
"postcss": "^8.4.16",
|
||||
"prettier": "^3.1.1",
|
||||
"prettier-plugin-svelte": "^3.1.2",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier-plugin-svelte": "^2.10.1",
|
||||
"rollup": "^2.78.1",
|
||||
"rollup-plugin-svelte": "^7.1.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"sass": "^1.49.11",
|
||||
"standard-version": "^9.5.0",
|
||||
"sveld": "^0.19.0",
|
||||
"sveld": "^0.19.1",
|
||||
"svelte": "^4.2.0",
|
||||
"svelte-check": "^3.4.6",
|
||||
"typescript": "^4.7.4"
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@ampproject/remapping": {
|
||||
|
|
|
@ -12742,21 +12742,10 @@
|
|||
"moduleName": "TextInput",
|
||||
"filePath": "src/TextInput/TextInput.svelte",
|
||||
"props": [
|
||||
{
|
||||
"name": "size",
|
||||
"kind": "let",
|
||||
"description": "Set the size of the input",
|
||||
"type": "\"sm\" | \"lg\"",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"isRequired": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"kind": "let",
|
||||
"description": "Specify the input value.\n\n`value` will be set to `null` if type=\"number\"\nand the value is empty.",
|
||||
"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,
|
||||
|
@ -12765,6 +12754,30 @@
|
|||
"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",
|
||||
|
@ -12780,7 +12793,7 @@
|
|||
{
|
||||
"name": "light",
|
||||
"kind": "let",
|
||||
"description": "Set to `true` to enable the light variant",
|
||||
"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,
|
||||
|
@ -12801,41 +12814,6 @@
|
|||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "helperText",
|
||||
"kind": "let",
|
||||
"description": "Specify the helper text",
|
||||
"type": "string",
|
||||
"value": "\"\"",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"isRequired": false,
|
||||
"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": "labelText",
|
||||
"kind": "let",
|
||||
|
@ -12860,6 +12838,41 @@
|
|||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "helperText",
|
||||
"kind": "let",
|
||||
"description": "Specify the helper text",
|
||||
"type": "string",
|
||||
"value": "\"\"",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"isRequired": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "counter",
|
||||
"kind": "let",
|
||||
"description": "Set to `true` to enable display the character counter. Requires `maxCount` to be set.",
|
||||
"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": "invalid",
|
||||
"kind": "let",
|
||||
|
@ -12909,23 +12922,22 @@
|
|||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "ref",
|
||||
"name": "id",
|
||||
"kind": "let",
|
||||
"description": "Obtain a reference to the input HTML element",
|
||||
"type": "null | HTMLInputElement",
|
||||
"value": "null",
|
||||
"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": true
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "required",
|
||||
"name": "name",
|
||||
"kind": "let",
|
||||
"description": "Set to `true` to mark the field as required",
|
||||
"type": "boolean",
|
||||
"value": "false",
|
||||
"description": "Specify a name attribute for the input",
|
||||
"type": "string",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"isRequired": false,
|
||||
|
@ -12944,6 +12956,18 @@
|
|||
"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",
|
||||
|
@ -12955,40 +12979,74 @@
|
|||
"isRequired": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "labelAttributes",
|
||||
"kind": "let",
|
||||
"description": "Set HTML attributes on the `label` element",
|
||||
"type": "import('svelte/elements').HTMLLabelAttributes",
|
||||
"value": "{}",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"isRequired": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "inputAttributes",
|
||||
"kind": "let",
|
||||
"description": "Set HTML attributes on the `input` element",
|
||||
"type": "import('svelte/elements').HTMLInputAttributes",
|
||||
"value": "{}",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"isRequired": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
}
|
||||
],
|
||||
"moduleExports": [],
|
||||
"slots": [
|
||||
{
|
||||
"name": "helperText",
|
||||
"default": false,
|
||||
"fallback": "{helperText}",
|
||||
"slot_props": "{}"
|
||||
},
|
||||
{
|
||||
"name": "invalidText",
|
||||
"default": false,
|
||||
"fallback": "{invalidText}",
|
||||
"slot_props": "{}"
|
||||
},
|
||||
{
|
||||
"name": "labelText",
|
||||
"default": false,
|
||||
"fallback": "{labelText}",
|
||||
"slot_props": "{}"
|
||||
},
|
||||
{
|
||||
"name": "warnText",
|
||||
"default": false,
|
||||
"fallback": "{warnText}",
|
||||
"slot_props": "{}"
|
||||
}
|
||||
],
|
||||
"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": "mouseover", "element": "div" },
|
||||
{ "type": "forwarded", "name": "mouseenter", "element": "div" },
|
||||
{ "type": "forwarded", "name": "mouseleave", "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" },
|
||||
{ "type": "forwarded", "name": "blur", "element": "input" },
|
||||
{ "type": "forwarded", "name": "paste", "element": "input" }
|
||||
],
|
||||
"typedefs": [],
|
||||
"rest_props": { "type": "Element", "name": "input" }
|
||||
"typedefs": []
|
||||
},
|
||||
{
|
||||
"moduleName": "TextInputSkeleton",
|
||||
|
@ -13005,18 +13063,30 @@
|
|||
"isRequired": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "divAttributes",
|
||||
"kind": "let",
|
||||
"description": "Specify the div HTML attributes for the skeleton container",
|
||||
"type": "import('svelte/elements').HTMLDivAttributes",
|
||||
"value": "{}",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"isRequired": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
}
|
||||
],
|
||||
"moduleExports": [],
|
||||
"slots": [],
|
||||
"events": [
|
||||
{ "type": "forwarded", "name": "click", "element": "div" },
|
||||
{ "type": "forwarded", "name": "mouseover", "element": "div" },
|
||||
{ "type": "forwarded", "name": "mouseenter", "element": "div" },
|
||||
{ "type": "forwarded", "name": "mouseleave", "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" }
|
||||
],
|
||||
"typedefs": [],
|
||||
"rest_props": { "type": "Element", "name": "div" }
|
||||
"typedefs": []
|
||||
},
|
||||
{
|
||||
"moduleName": "Theme",
|
||||
|
|
|
@ -39,6 +39,10 @@ components: ["TextInput", "TextInputSkeleton"]
|
|||
|
||||
<TextInput size="sm" labelText="Username" placeholder="Enter username..." />
|
||||
|
||||
## Character Counter
|
||||
|
||||
<TextInput labelText="Username" placeholder="Enter username..." maxCount={32} counter />
|
||||
|
||||
## Invalid state
|
||||
|
||||
<TextInput invalid invalidText="Username is already taken. Please try another." labelText="Username" placeholder="Enter username..." />
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "carbon-components-svelte",
|
||||
"version": "1.0.0-next.0",
|
||||
"version": "1.0.0-next.1",
|
||||
"license": "Apache-2.0",
|
||||
"description": "Svelte implementation of the Carbon Design System",
|
||||
"svelte": "./src/index.js",
|
||||
|
@ -32,7 +32,7 @@
|
|||
"build:docs": "node scripts/build-docs",
|
||||
"build:lib": "rollup -c",
|
||||
"format": "prettier --write \"./**/*.{svelte,js,md}\"",
|
||||
"release": "standard-version && npm run build:docs"
|
||||
"release": "standard-version --first-release && npm run build:docs"
|
||||
},
|
||||
"dependencies": {
|
||||
"flatpickr": "4.6.9"
|
||||
|
|
|
@ -1,51 +1,52 @@
|
|||
<script>
|
||||
/**
|
||||
* @event {null | number | string} change
|
||||
* @event {null | number | string} input
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set the size of the input
|
||||
* @type {"sm" | "lg"}
|
||||
*/
|
||||
export let size = undefined;
|
||||
|
||||
/**
|
||||
* Specify the input value.
|
||||
*
|
||||
* `value` will be set to `null` if type="number"
|
||||
* and the value is empty.
|
||||
* Specify the input value
|
||||
* `value` will be set to `null` if `typeof value === "number"` and `value` is empty
|
||||
* @type {null | number | string}
|
||||
*/
|
||||
export let value = "";
|
||||
|
||||
/** Obtain a reference to the input HTML element */
|
||||
export let ref = null;
|
||||
/**
|
||||
* Set the size of the input
|
||||
* @type {"sm" | "md" | "lg"}
|
||||
*/
|
||||
export let size = "md";
|
||||
|
||||
/** Specify the placeholder text */
|
||||
export let placeholder = "";
|
||||
|
||||
/** Set to `true` to enable the light variant */
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export let light = false;
|
||||
|
||||
/** Set to `true` to disable the input */
|
||||
export let disabled = false;
|
||||
|
||||
/** Specify the helper text */
|
||||
export let helperText = "";
|
||||
|
||||
/** Set an id for the input element */
|
||||
export let id = "ccs-" + Math.random().toString(36);
|
||||
|
||||
/**
|
||||
* Specify a name attribute for the input
|
||||
* @type {string}
|
||||
*/
|
||||
export let name = undefined;
|
||||
|
||||
/** Specify the label text */
|
||||
export let labelText = "";
|
||||
|
||||
/** Set to `true` to visually hide the label text */
|
||||
export let hideLabel = false;
|
||||
|
||||
/** Specify the helper text */
|
||||
export let helperText = "";
|
||||
|
||||
/** Set to `true` to enable display the character counter. Requires `maxCount` to be set. */
|
||||
export let counter = false;
|
||||
|
||||
/**
|
||||
* Specify the maximum number of characters/words allowed
|
||||
* This is needed in order for `counter` to display
|
||||
* @type {number}
|
||||
*/
|
||||
export let maxCount = undefined;
|
||||
|
||||
/** Set to `true` to indicate an invalid state */
|
||||
export let invalid = false;
|
||||
|
||||
|
@ -58,42 +59,44 @@
|
|||
/** Specify the warning state text */
|
||||
export let warnText = "";
|
||||
|
||||
/** Obtain a reference to the input HTML element */
|
||||
export let ref = null;
|
||||
/** Set an id for the input element */
|
||||
export let id = "ccs-" + Math.random().toString(36);
|
||||
|
||||
/** Set to `true` to mark the field as required */
|
||||
export let required = false;
|
||||
/**
|
||||
* Specify a name attribute for the input
|
||||
* @type {string}
|
||||
*/
|
||||
export let name = undefined;
|
||||
|
||||
/** Set to `true` to use the inline variant */
|
||||
export let inline = false;
|
||||
|
||||
/** Set to `true` to mark the field as required */
|
||||
export let required = false;
|
||||
|
||||
/** Set to `true` to use the read-only variant */
|
||||
export let readonly = false;
|
||||
|
||||
import { createEventDispatcher, getContext } from "svelte";
|
||||
/**
|
||||
* Set HTML attributes on the `label` element
|
||||
* @type {import('svelte/elements').HTMLLabelAttributes}
|
||||
*/
|
||||
export let labelAttributes = {};
|
||||
|
||||
/**
|
||||
* Set HTML attributes on the `input` element
|
||||
* @type {import('svelte/elements').HTMLInputAttributes}
|
||||
*/
|
||||
export let inputAttributes = {};
|
||||
|
||||
import { getContext } from "svelte";
|
||||
import WarningFilled from "../icons/WarningFilled.svelte";
|
||||
import WarningAltFilled from "../icons/WarningAltFilled.svelte";
|
||||
import EditOff from "../icons/EditOff.svelte";
|
||||
|
||||
const ctx = getContext("Form");
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
function parse(raw) {
|
||||
if ($$restProps.type !== "number") return raw;
|
||||
return raw != "" ? Number(raw) : null;
|
||||
}
|
||||
|
||||
/** @type {(e: Event) => void} */
|
||||
const onInput = (e) => {
|
||||
value = parse(e.target.value);
|
||||
dispatch("input", value);
|
||||
};
|
||||
|
||||
/** @type {(e: Event) => void} */
|
||||
const onChange = (e) => {
|
||||
dispatch("change", parse(e.target.value));
|
||||
};
|
||||
|
||||
$: if (maxCount && value.length > maxCount) value = value.slice(0, maxCount);
|
||||
$: count = value.length;
|
||||
$: isFluid = !!ctx && ctx.isFluid;
|
||||
$: error = invalid && !readonly;
|
||||
$: helperId = `helper-${id}`;
|
||||
|
@ -111,9 +114,10 @@
|
|||
class:bx--text-input-wrapper--light="{light}"
|
||||
class:bx--text-input-wrapper--readonly="{readonly}"
|
||||
on:click
|
||||
on:mouseover
|
||||
on:mouseenter
|
||||
on:mouseleave
|
||||
on:pointerup
|
||||
on:pointerover
|
||||
on:pointerenter
|
||||
on:pointerleave
|
||||
>
|
||||
{#if inline}
|
||||
<div class:bx--text-input__label-helper-wrapper="{true}">
|
||||
|
@ -125,25 +129,38 @@
|
|||
class:bx--label--disabled="{disabled}"
|
||||
class:bx--label--inline="{inline}"
|
||||
class:bx--label--inline--sm="{size === 'sm'}"
|
||||
class:bx--label--inline--lg="{size === 'lg' || size === 'xl'}"
|
||||
class:bx--label--inline--md="{size === 'md'}"
|
||||
class:bx--label--inline--lg="{size === 'lg'}"
|
||||
{...labelAttributes}
|
||||
>
|
||||
<slot name="labelText">
|
||||
{labelText}
|
||||
</slot>
|
||||
</label>
|
||||
{#if maxCount && counter}
|
||||
<div
|
||||
class:bx--label="{true}"
|
||||
class:bx--text-input__label-counter="{true}"
|
||||
>
|
||||
{count}/{maxCount}
|
||||
</div>
|
||||
{/if}
|
||||
{#if !isFluid && helperText}
|
||||
{/if}
|
||||
{#if !isFluid && (helperText || $$slots.helperText)}
|
||||
<div
|
||||
class:bx--form__helper-text="{true}"
|
||||
class:bx--form__helper-text--disabled="{disabled}"
|
||||
class:bx--form__helper-text--inline="{inline}"
|
||||
>
|
||||
<slot name="helperText">
|
||||
{helperText}
|
||||
</slot>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{#if !inline && (labelText || $$slots.labelText)}
|
||||
<div class:bx--text-input__label-wrapper="{true}">
|
||||
<label
|
||||
for="{id}"
|
||||
class:bx--label="{true}"
|
||||
|
@ -151,12 +168,24 @@
|
|||
class:bx--label--disabled="{disabled}"
|
||||
class:bx--label--inline="{inline}"
|
||||
class:bx--label--inline-sm="{inline && size === 'sm'}"
|
||||
class:bx--label--inline-xl="{inline && size === 'xl'}"
|
||||
class:bx--label--inline-md="{inline && size === 'md'}"
|
||||
class:bx--label--inline-lg="{inline && size === 'lg'}"
|
||||
{...labelAttributes}
|
||||
>
|
||||
<slot name="labelText">
|
||||
{labelText}
|
||||
</slot>
|
||||
</label>
|
||||
{#if maxCount && counter}
|
||||
<div
|
||||
class:bx--label="{true}"
|
||||
class:bx--text-input__label-counter="{true}"
|
||||
class:fluid-form-fix__label-counter="{isFluid}"
|
||||
>
|
||||
{count}/{maxCount}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<div
|
||||
class:bx--text-input__field-outer-wrapper="{true}"
|
||||
|
@ -170,8 +199,15 @@
|
|||
>
|
||||
{#if !readonly}
|
||||
{#if invalid}
|
||||
{#if isFluid && invalidText.length === 0}
|
||||
<WarningFilled
|
||||
class="bx--text-input__invalid-icon"
|
||||
style="inset-block-start: 3rem;"
|
||||
/>
|
||||
{:else}
|
||||
<WarningFilled class="bx--text-input__invalid-icon" />
|
||||
{/if}
|
||||
{/if}
|
||||
{#if !invalid && warn}
|
||||
<WarningAltFilled
|
||||
class="bx--text-input__invalid-icon
|
||||
|
@ -195,7 +231,7 @@
|
|||
id="{id}"
|
||||
name="{name}"
|
||||
placeholder="{placeholder}"
|
||||
bind:value
|
||||
bind:value="{value}"
|
||||
required="{required}"
|
||||
readonly="{readonly}"
|
||||
class:bx--text-input="{true}"
|
||||
|
@ -203,10 +239,14 @@
|
|||
class:bx--text-input--invalid="{error}"
|
||||
class:bx--text-input--warning="{warn}"
|
||||
class:bx--text-input--sm="{size === 'sm'}"
|
||||
class:bx--text-input--lg="{size === 'lg' || size === 'xl'}"
|
||||
{...$$restProps}
|
||||
on:change="{onChange}"
|
||||
on:input="{onInput}"
|
||||
class:bx--text-input--md="{size === 'md'}"
|
||||
class:bx--text-input--lg="{size === 'lg'}"
|
||||
class:bx--layout--size-sm="{size === 'sm'}"
|
||||
class:bx--layout--size-md="{size === 'md'}"
|
||||
class:bx--layout--size-lg="{size === 'lg'}"
|
||||
{...inputAttributes}
|
||||
on:change
|
||||
on:input
|
||||
on:keydown
|
||||
on:keyup
|
||||
on:focus
|
||||
|
@ -218,30 +258,48 @@
|
|||
{/if}
|
||||
{#if isFluid && !inline && invalid}
|
||||
<div class:bx--form-requirement="{true}" id="{errorId}">
|
||||
<slot name="invalidText">
|
||||
{invalidText}
|
||||
</slot>
|
||||
</div>
|
||||
{/if}
|
||||
{#if isFluid && !inline && warn}
|
||||
<div class:bx--form-requirement="{true}" id="{warnId}">{warnText}</div>
|
||||
<div class:bx--form-requirement="{true}" id="{warnId}">
|
||||
<slot name="warnText">{warnText}</slot>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{#if !invalid && !warn && !isFluid && !inline && helperText}
|
||||
{#if !invalid && !warn && !isFluid && !inline && (helperText || $$slots.helperText)}
|
||||
<div
|
||||
id="{helperId}"
|
||||
class:bx--form__helper-text="{true}"
|
||||
class:bx--form__helper-text--disabled="{disabled}"
|
||||
class:bx--form__helper-text--inline="{inline}"
|
||||
>
|
||||
<slot name="helperText">
|
||||
{helperText}
|
||||
</slot>
|
||||
</div>
|
||||
{/if}
|
||||
{#if !isFluid && invalid}
|
||||
<div class:bx--form-requirement="{true}" id="{errorId}">
|
||||
<slot name="invalidText">
|
||||
{invalidText}
|
||||
</slot>
|
||||
</div>
|
||||
{/if}
|
||||
{#if !isFluid && !invalid && warn}
|
||||
<div class:bx--form-requirement="{true}" id="{warnId}">{warnText}</div>
|
||||
<div class:bx--form-requirement="{true}" id="{warnId}">
|
||||
<slot name="warnText">{warnText}</slot>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.fluid-form-fix__label-counter {
|
||||
right: 0;
|
||||
inset-inline-start: unset;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
<script>
|
||||
/** Set to `true` to hide the label text */
|
||||
export let hideLabel = false;
|
||||
|
||||
/**
|
||||
* Specify the div HTML attributes for the skeleton container
|
||||
* @type {import('svelte/elements').HTMLDivAttributes}
|
||||
*/
|
||||
export let divAttributes = {};
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<div
|
||||
class:bx--form-item="{true}"
|
||||
{...$$restProps}
|
||||
{...divAttributes}
|
||||
on:click
|
||||
on:mouseover
|
||||
on:mouseenter
|
||||
on:mouseleave
|
||||
on:pointerup
|
||||
on:pointerover
|
||||
on:pointerenter
|
||||
on:pointerleave
|
||||
>
|
||||
{#if !hideLabel}
|
||||
<span class:bx--label="{true}" class:bx--skeleton="{true}"></span>
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
</script>
|
||||
|
||||
<TextInput
|
||||
type="number"
|
||||
labelText="User name"
|
||||
placeholder="Enter user name..."
|
||||
bind:value
|
||||
on:input="{(e) => console.log(e.detail)}"
|
||||
on:change="{(e) => (value = e.detail)}"
|
||||
bind:value="{value}"
|
||||
on:input="{(e) => console.log(e)}"
|
||||
on:change="{(e) => (value = e)}"
|
||||
on:paste="{(e) => console.log(e)}"
|
||||
inputAttributes="{{ type: 'number' }}"
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
|
@ -20,6 +20,13 @@
|
|||
placeholder="Enter user name..."
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
labelText="Username"
|
||||
placeholder="Enter username..."
|
||||
maxCount="{32}"
|
||||
counter
|
||||
/>
|
||||
|
||||
<TextInput hideLabel labelText="User name" placeholder="Enter user name..." />
|
||||
|
||||
<TextInput light labelText="User name" placeholder="Enter user name..." />
|
||||
|
|
112
types/TextInput/TextInput.svelte.d.ts
vendored
112
types/TextInput/TextInput.svelte.d.ts
vendored
|
@ -1,24 +1,25 @@
|
|||
import type { SvelteComponentTyped } from "svelte";
|
||||
import type { SvelteHTMLElements } from "svelte/elements";
|
||||
|
||||
type RestProps = SvelteHTMLElements["input"];
|
||||
|
||||
export interface TextInputProps extends RestProps {
|
||||
export interface TextInputProps {
|
||||
/**
|
||||
* Set the size of the input
|
||||
* @default undefined
|
||||
*/
|
||||
size?: "sm" | "lg";
|
||||
|
||||
/**
|
||||
* Specify the input value.
|
||||
*
|
||||
* `value` will be set to `null` if type="number"
|
||||
* and the value is empty.
|
||||
* Specify the input value
|
||||
* `value` will be set to `null` if `typeof value === "number"` and `value` is empty
|
||||
* @default ""
|
||||
*/
|
||||
value?: null | number | string;
|
||||
|
||||
/**
|
||||
* Obtain a reference to the input HTML element
|
||||
* @default null
|
||||
*/
|
||||
ref?: null | HTMLInputElement;
|
||||
|
||||
/**
|
||||
* Set the size of the input
|
||||
* @default "md"
|
||||
*/
|
||||
size?: "sm" | "md" | "lg";
|
||||
|
||||
/**
|
||||
* Specify the placeholder text
|
||||
* @default ""
|
||||
|
@ -27,6 +28,9 @@ export interface TextInputProps extends RestProps {
|
|||
|
||||
/**
|
||||
* 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
|
||||
* @default false
|
||||
*/
|
||||
light?: boolean;
|
||||
|
@ -37,24 +41,6 @@ export interface TextInputProps extends RestProps {
|
|||
*/
|
||||
disabled?: boolean;
|
||||
|
||||
/**
|
||||
* Specify the helper text
|
||||
* @default ""
|
||||
*/
|
||||
helperText?: string;
|
||||
|
||||
/**
|
||||
* Set an id for the input element
|
||||
* @default "ccs-" + Math.random().toString(36)
|
||||
*/
|
||||
id?: string;
|
||||
|
||||
/**
|
||||
* Specify a name attribute for the input
|
||||
* @default undefined
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Specify the label text
|
||||
* @default ""
|
||||
|
@ -67,6 +53,25 @@ export interface TextInputProps extends RestProps {
|
|||
*/
|
||||
hideLabel?: boolean;
|
||||
|
||||
/**
|
||||
* Specify the helper text
|
||||
* @default ""
|
||||
*/
|
||||
helperText?: string;
|
||||
|
||||
/**
|
||||
* Set to `true` to enable display the character counter. Requires `maxCount` to be set.
|
||||
* @default false
|
||||
*/
|
||||
counter?: boolean;
|
||||
|
||||
/**
|
||||
* Specify the maximum number of characters/words allowed
|
||||
* This is needed in order for `counter` to display
|
||||
* @default undefined
|
||||
*/
|
||||
maxCount?: number;
|
||||
|
||||
/**
|
||||
* Set to `true` to indicate an invalid state
|
||||
* @default false
|
||||
|
@ -92,16 +97,16 @@ export interface TextInputProps extends RestProps {
|
|||
warnText?: string;
|
||||
|
||||
/**
|
||||
* Obtain a reference to the input HTML element
|
||||
* @default null
|
||||
* Set an id for the input element
|
||||
* @default "ccs-" + Math.random().toString(36)
|
||||
*/
|
||||
ref?: null | HTMLInputElement;
|
||||
id?: string;
|
||||
|
||||
/**
|
||||
* Set to `true` to mark the field as required
|
||||
* @default false
|
||||
* Specify a name attribute for the input
|
||||
* @default undefined
|
||||
*/
|
||||
required?: boolean;
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Set to `true` to use the inline variant
|
||||
|
@ -109,29 +114,46 @@ export interface TextInputProps extends RestProps {
|
|||
*/
|
||||
inline?: boolean;
|
||||
|
||||
/**
|
||||
* Set to `true` to mark the field as required
|
||||
* @default false
|
||||
*/
|
||||
required?: boolean;
|
||||
|
||||
/**
|
||||
* Set to `true` to use the read-only variant
|
||||
* @default false
|
||||
*/
|
||||
readonly?: boolean;
|
||||
|
||||
[key: `data-${string}`]: any;
|
||||
/**
|
||||
* Set HTML attributes on the `label` element
|
||||
* @default {}
|
||||
*/
|
||||
labelAttributes?: import("svelte/elements").HTMLLabelAttributes;
|
||||
|
||||
/**
|
||||
* Set HTML attributes on the `input` element
|
||||
* @default {}
|
||||
*/
|
||||
inputAttributes?: import("svelte/elements").HTMLInputAttributes;
|
||||
}
|
||||
|
||||
export default class TextInput extends SvelteComponentTyped<
|
||||
TextInputProps,
|
||||
{
|
||||
change: CustomEvent<null | number | string>;
|
||||
input: CustomEvent<null | number | string>;
|
||||
click: WindowEventMap["click"];
|
||||
mouseover: WindowEventMap["mouseover"];
|
||||
mouseenter: WindowEventMap["mouseenter"];
|
||||
mouseleave: WindowEventMap["mouseleave"];
|
||||
pointerup: WindowEventMap["pointerup"];
|
||||
pointerover: WindowEventMap["pointerover"];
|
||||
pointerenter: WindowEventMap["pointerenter"];
|
||||
pointerleave: WindowEventMap["pointerleave"];
|
||||
change: WindowEventMap["change"];
|
||||
input: WindowEventMap["input"];
|
||||
keydown: WindowEventMap["keydown"];
|
||||
keyup: WindowEventMap["keyup"];
|
||||
focus: WindowEventMap["focus"];
|
||||
blur: WindowEventMap["blur"];
|
||||
paste: DocumentAndElementEventHandlersEventMap["paste"];
|
||||
},
|
||||
{ labelText: {} }
|
||||
{ helperText: {}; invalidText: {}; labelText: {}; warnText: {} }
|
||||
> {}
|
||||
|
|
18
types/TextInput/TextInputSkeleton.svelte.d.ts
vendored
18
types/TextInput/TextInputSkeleton.svelte.d.ts
vendored
|
@ -1,25 +1,27 @@
|
|||
import type { SvelteComponentTyped } from "svelte";
|
||||
import type { SvelteHTMLElements } from "svelte/elements";
|
||||
|
||||
type RestProps = SvelteHTMLElements["div"];
|
||||
|
||||
export interface TextInputSkeletonProps extends RestProps {
|
||||
export interface TextInputSkeletonProps {
|
||||
/**
|
||||
* Set to `true` to hide the label text
|
||||
* @default false
|
||||
*/
|
||||
hideLabel?: boolean;
|
||||
|
||||
[key: `data-${string}`]: any;
|
||||
/**
|
||||
* Specify the div HTML attributes for the skeleton container
|
||||
* @default {}
|
||||
*/
|
||||
divAttributes?: import("svelte/elements").HTMLDivAttributes;
|
||||
}
|
||||
|
||||
export default class TextInputSkeleton extends SvelteComponentTyped<
|
||||
TextInputSkeletonProps,
|
||||
{
|
||||
click: WindowEventMap["click"];
|
||||
mouseover: WindowEventMap["mouseover"];
|
||||
mouseenter: WindowEventMap["mouseenter"];
|
||||
mouseleave: WindowEventMap["mouseleave"];
|
||||
pointerup: WindowEventMap["pointerup"];
|
||||
pointerover: WindowEventMap["pointerover"];
|
||||
pointerenter: WindowEventMap["pointerenter"];
|
||||
pointerleave: WindowEventMap["pointerleave"];
|
||||
},
|
||||
{}
|
||||
> {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue