mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
Add required
prop to Select. (#968)
Upgrade sveld to set paths correctly on Windows. Make Prettier script compatible with Windows and run it.
This commit is contained in:
parent
26db657868
commit
6458c97c1a
14 changed files with 49 additions and 48 deletions
|
@ -3242,6 +3242,7 @@ None.
|
||||||
| noLabel | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to not render a label |
|
| noLabel | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to not render a label |
|
||||||
| labelText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label text |
|
| labelText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label text |
|
||||||
| hideLabel | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to visually hide the label text |
|
| hideLabel | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to visually hide the label text |
|
||||||
|
| required | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to mark the field as required |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
|
|
@ -9419,6 +9419,17 @@
|
||||||
"isFunctionDeclaration": false,
|
"isFunctionDeclaration": false,
|
||||||
"constant": false,
|
"constant": false,
|
||||||
"reactive": true
|
"reactive": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "required",
|
||||||
|
"kind": "let",
|
||||||
|
"description": "Set to `true` to mark the field as required",
|
||||||
|
"type": "boolean",
|
||||||
|
"value": "false",
|
||||||
|
"isFunction": false,
|
||||||
|
"isFunctionDeclaration": false,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"slots": [
|
"slots": [
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
<h6>on:match</h6>
|
<h6>on:match</h6>
|
||||||
<pre>
|
<pre>
|
||||||
{JSON.stringify(events,null, 2)}
|
{JSON.stringify(events, null, 2)}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
"build:api": "node scripts/build-api",
|
"build:api": "node scripts/build-api",
|
||||||
"build:lib": "rollup -c",
|
"build:lib": "rollup -c",
|
||||||
"prepack": "run-p build:*",
|
"prepack": "run-p build:*",
|
||||||
"format": "prettier --write './**/*.{svelte,js,md}'"
|
"format": "prettier --write \"./**/*.{svelte,js,md}\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"flatpickr": "4.6.9"
|
"flatpickr": "4.6.9"
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
"rollup-plugin-svelte": "^7.1.0",
|
"rollup-plugin-svelte": "^7.1.0",
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
"sass": "^1.42.1",
|
"sass": "^1.42.1",
|
||||||
"sveld": "^0.10.2",
|
"sveld": "^0.11.1",
|
||||||
"svelte": "^3.44.3",
|
"svelte": "^3.44.3",
|
||||||
"svelte-check": "^1.1.32",
|
"svelte-check": "^1.1.32",
|
||||||
"typescript": "^4.1.3"
|
"typescript": "^4.1.3"
|
||||||
|
|
|
@ -150,14 +150,10 @@
|
||||||
feedback="{feedback}"
|
feedback="{feedback}"
|
||||||
feedbackTimeout="{feedbackTimeout}"
|
feedbackTimeout="{feedbackTimeout}"
|
||||||
class="bx--snippet {type && `bx--snippet--${type}`}
|
class="bx--snippet {type && `bx--snippet--${type}`}
|
||||||
{type ===
|
{type === 'inline' && 'bx--btn--copy'}
|
||||||
'inline' && 'bx--btn--copy'}
|
{expanded && 'bx--snippet--expand'}
|
||||||
{expanded &&
|
{light && 'bx--snippet--light'}
|
||||||
'bx--snippet--expand'}
|
{hideCopyButton && 'bx--snippet--no-copy'}
|
||||||
{light &&
|
|
||||||
'bx--snippet--light'}
|
|
||||||
{hideCopyButton &&
|
|
||||||
'bx--snippet--no-copy'}
|
|
||||||
{wrapText && 'bx--snippet--wraptext'}"
|
{wrapText && 'bx--snippet--wraptext'}"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
|
@ -194,8 +190,7 @@
|
||||||
class:bx--snippet-container="{true}"
|
class:bx--snippet-container="{true}"
|
||||||
style="width: 100%; min-height: {minHeight}px; max-height: {maxHeight}"
|
style="width: 100%; min-height: {minHeight}px; max-height: {maxHeight}"
|
||||||
>
|
>
|
||||||
<pre
|
<pre bind:this="{ref}">
|
||||||
bind:this="{ref}">
|
|
||||||
<code><slot>{code}</slot></code>
|
<code><slot>{code}</slot></code>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -229,8 +229,7 @@
|
||||||
class:bx--date-picker="{true}"
|
class:bx--date-picker="{true}"
|
||||||
class:bx--date-picker--short="{short}"
|
class:bx--date-picker--short="{short}"
|
||||||
class:bx--date-picker--light="{light}"
|
class:bx--date-picker--light="{light}"
|
||||||
class="{datePickerType &&
|
class="{datePickerType && `bx--date-picker--${datePickerType}`}
|
||||||
`bx--date-picker--${datePickerType}`}
|
|
||||||
{datePickerType === 'range' &&
|
{datePickerType === 'range' &&
|
||||||
$labelTextEmpty &&
|
$labelTextEmpty &&
|
||||||
'bx--date-picker--nolabel'}"
|
'bx--date-picker--nolabel'}"
|
||||||
|
|
|
@ -170,14 +170,10 @@
|
||||||
'bx--dropdown--invalid'} {!invalid &&
|
'bx--dropdown--invalid'} {!invalid &&
|
||||||
warn &&
|
warn &&
|
||||||
'bx--dropdown--warning'} {open && 'bx--dropdown--open'}
|
'bx--dropdown--warning'} {open && 'bx--dropdown--open'}
|
||||||
{size ===
|
{size === 'sm' && 'bx--dropdown--sm'}
|
||||||
'sm' && 'bx--dropdown--sm'}
|
{size === 'xl' && 'bx--dropdown--xl'}
|
||||||
{size === 'xl' &&
|
{inline && 'bx--dropdown--inline'}
|
||||||
'bx--dropdown--xl'}
|
{disabled && 'bx--dropdown--disabled'}
|
||||||
{inline &&
|
|
||||||
'bx--dropdown--inline'}
|
|
||||||
{disabled &&
|
|
||||||
'bx--dropdown--disabled'}
|
|
||||||
{light && 'bx--dropdown--light'}"
|
{light && 'bx--dropdown--light'}"
|
||||||
on:click="{({ target }) => {
|
on:click="{({ target }) => {
|
||||||
open = ref.contains(target) ? !open : false;
|
open = ref.contains(target) ? !open : false;
|
||||||
|
|
|
@ -280,14 +280,10 @@
|
||||||
warnText="{warnText}"
|
warnText="{warnText}"
|
||||||
class="bx--multi-select {direction === 'top' &&
|
class="bx--multi-select {direction === 'top' &&
|
||||||
'bx--list-box--up'} {filterable && 'bx--combo-box'}
|
'bx--list-box--up'} {filterable && 'bx--combo-box'}
|
||||||
{filterable &&
|
{filterable && 'bx--multi-select--filterable'}
|
||||||
'bx--multi-select--filterable'}
|
{invalid && 'bx--multi-select--invalid'}
|
||||||
{invalid &&
|
{inline && 'bx--multi-select--inline'}
|
||||||
'bx--multi-select--invalid'}
|
{checked.length > 0 && 'bx--multi-select--selected'}"
|
||||||
{inline &&
|
|
||||||
'bx--multi-select--inline'}
|
|
||||||
{checked.length > 0 &&
|
|
||||||
'bx--multi-select--selected'}"
|
|
||||||
>
|
>
|
||||||
{#if invalid}
|
{#if invalid}
|
||||||
<WarningFilled16 class="bx--list-box__invalid-icon" />
|
<WarningFilled16 class="bx--list-box__invalid-icon" />
|
||||||
|
|
|
@ -95,8 +95,7 @@
|
||||||
<title>{description}</title>
|
<title>{description}</title>
|
||||||
<path
|
<path
|
||||||
d="M8 1C4.1 1 1 4.1 1 8s3.1 7 7 7 7-3.1 7-7-3.1-7-7-7zm0 13c-3.3
|
d="M8 1C4.1 1 1 4.1 1 8s3.1 7 7 7 7-3.1 7-7-3.1-7-7-7zm0 13c-3.3
|
||||||
0-6-2.7-6-6s2.7-6 6-6 6 2.7 6 6-2.7 6-6 6z"
|
0-6-2.7-6-6s2.7-6 6-6 6 2.7 6 6-2.7 6-6 6z"></path>
|
||||||
></path>
|
|
||||||
</svg>
|
</svg>
|
||||||
{/if}
|
{/if}
|
||||||
<slot props="{{ class: 'bx--progress-label' }}">
|
<slot props="{{ class: 'bx--progress-label' }}">
|
||||||
|
|
|
@ -60,6 +60,9 @@
|
||||||
/** Obtain a reference to the select HTML element */
|
/** Obtain a reference to the select HTML element */
|
||||||
export let ref = null;
|
export let ref = null;
|
||||||
|
|
||||||
|
/** Set to `true` to mark the field as required */
|
||||||
|
export let required = false;
|
||||||
|
|
||||||
import { createEventDispatcher, setContext, afterUpdate } from "svelte";
|
import { createEventDispatcher, setContext, afterUpdate } from "svelte";
|
||||||
import { writable } from "svelte/store";
|
import { writable } from "svelte/store";
|
||||||
import ChevronDown16 from "../icons/ChevronDown16.svelte";
|
import ChevronDown16 from "../icons/ChevronDown16.svelte";
|
||||||
|
@ -112,6 +115,7 @@
|
||||||
aria-describedby="{invalid ? errorId : undefined}"
|
aria-describedby="{invalid ? errorId : undefined}"
|
||||||
aria-invalid="{invalid || undefined}"
|
aria-invalid="{invalid || undefined}"
|
||||||
disabled="{disabled || undefined}"
|
disabled="{disabled || undefined}"
|
||||||
|
required="{required || undefined}"
|
||||||
id="{id}"
|
id="{id}"
|
||||||
name="{name}"
|
name="{name}"
|
||||||
class:bx--select-input="{true}"
|
class:bx--select-input="{true}"
|
||||||
|
@ -156,6 +160,7 @@
|
||||||
name="{name}"
|
name="{name}"
|
||||||
aria-describedby="{invalid ? errorId : undefined}"
|
aria-describedby="{invalid ? errorId : undefined}"
|
||||||
disabled="{disabled || undefined}"
|
disabled="{disabled || undefined}"
|
||||||
|
required="{required || undefined}"
|
||||||
aria-invalid="{invalid || undefined}"
|
aria-invalid="{invalid || undefined}"
|
||||||
class:bx--select-input="{true}"
|
class:bx--select-input="{true}"
|
||||||
class="{size && `bx--select-input--${size}`}"
|
class="{size && `bx--select-input--${size}`}"
|
||||||
|
|
|
@ -198,10 +198,8 @@
|
||||||
class:bx--btn--disabled="{disabled}"
|
class:bx--btn--disabled="{disabled}"
|
||||||
class:bx--tooltip__trigger="{true}"
|
class:bx--tooltip__trigger="{true}"
|
||||||
class:bx--tooltip--a11y="{true}"
|
class:bx--tooltip--a11y="{true}"
|
||||||
class="{tooltipPosition &&
|
class="{tooltipPosition && `bx--tooltip--${tooltipPosition}`}
|
||||||
`bx--tooltip--${tooltipPosition}`}
|
{tooltipAlignment && `bx--tooltip--align-${tooltipAlignment}`}"
|
||||||
{tooltipAlignment &&
|
|
||||||
`bx--tooltip--align-${tooltipAlignment}`}"
|
|
||||||
on:click="{() => {
|
on:click="{() => {
|
||||||
type = type === 'password' ? 'text' : 'password';
|
type = type === 'password' ? 'text' : 'password';
|
||||||
}}"
|
}}"
|
||||||
|
|
|
@ -55,13 +55,8 @@
|
||||||
let refLabel = null;
|
let refLabel = null;
|
||||||
let prevActiveId = undefined;
|
let prevActiveId = undefined;
|
||||||
|
|
||||||
const {
|
const { activeNodeId, selectedNodeIds, clickNode, selectNode, focusNode } =
|
||||||
activeNodeId,
|
getContext("TreeView");
|
||||||
selectedNodeIds,
|
|
||||||
clickNode,
|
|
||||||
selectNode,
|
|
||||||
focusNode,
|
|
||||||
} = getContext("TreeView");
|
|
||||||
const offset = () =>
|
const offset = () =>
|
||||||
computeTreeLeafDepth(refLabel) + (leaf && icon ? 2 : 2.5);
|
computeTreeLeafDepth(refLabel) + (leaf && icon ? 2 : 2.5);
|
||||||
|
|
||||||
|
|
6
types/Select/Select.svelte.d.ts
vendored
6
types/Select/Select.svelte.d.ts
vendored
|
@ -95,6 +95,12 @@ export interface SelectProps
|
||||||
* @default null
|
* @default null
|
||||||
*/
|
*/
|
||||||
ref?: null | HTMLSelectElement;
|
ref?: null | HTMLSelectElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to `true` to mark the field as required
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
required?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Select extends SvelteComponentTyped<
|
export default class Select extends SvelteComponentTyped<
|
||||||
|
|
|
@ -2292,10 +2292,10 @@ supports-color@^7.0.0, supports-color@^7.1.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
has-flag "^4.0.0"
|
has-flag "^4.0.0"
|
||||||
|
|
||||||
sveld@^0.10.2:
|
sveld@^0.11.1:
|
||||||
version "0.10.2"
|
version "0.11.1"
|
||||||
resolved "https://registry.yarnpkg.com/sveld/-/sveld-0.10.2.tgz#24366250a2b8021d76a0c4c641adc4f858c2a56f"
|
resolved "https://registry.yarnpkg.com/sveld/-/sveld-0.11.1.tgz#2b24fb8dae6fcd9bb14f826c89480cf88b079dca"
|
||||||
integrity sha512-51pf6aNw9Ks13/7DiA7UvriqittW6320g/14a9XxiN5/f7Yg6/IfByoKkFHyTf2RdeREvjITuJT5G8Me0tDvxw==
|
integrity sha512-cb6sUB6yVomLgeDny0sXSGxgNGrwYPg8CHuI0k80DcGFNF2ML6k7yZeVeFjWjh2Tmj8+/PgSLJj5IYuZEjyQVA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@rollup/plugin-node-resolve" "^11.0.1"
|
"@rollup/plugin-node-resolve" "^11.0.1"
|
||||||
acorn "^8.4.1"
|
acorn "^8.4.1"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue