diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b0815e..2a8eb2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), enforced with [semantic-release](https://github.com/semantic-release/semantic-release). +## [11.3.0](https://github.com/silinternational/ui-components/compare/v11.2.0...v11.3.0) (2024-04-16) + + +### Fixed + +* **Select:** update to match installed version of material/select ([a739d35](https://github.com/silinternational/ui-components/commit/a739d35b5635c74f3846feb3cee3485e5db2929d)) + + +### Added + +* **Select:** Add Select.name for convenient form submission ([8f7380b](https://github.com/silinternational/ui-components/commit/8f7380bcd34df41600d3be7bbe9fafc3187c4df8)) +* **Select:** Add Select.required prop ([94bab91](https://github.com/silinternational/ui-components/commit/94bab918ba3a6560c49670622802aa942ee32628)) +* **Select:** Add Select.ShowError prop which applies the mdc-select--invalid class to the ([3d8f95d](https://github.com/silinternational/ui-components/commit/3d8f95d4657a1ee99f6900522a3449126790f20e)) + + ## [11.2.0](https://github.com/silinternational/ui-components/compare/v11.1.2...v11.2.0) (2024-04-09) diff --git a/components/mdc/Select/Select.svelte b/components/mdc/Select/Select.svelte index d9879e3..08c09c4 100644 --- a/components/mdc/Select/Select.svelte +++ b/components/mdc/Select/Select.svelte @@ -15,6 +15,12 @@ export let width = '280px' export let disabled = false /** @type {string} The ID of the selected option. */ export let selectedID = '' +/** @type {boolean} makes a selection required and adds invalid class when none selected */ +export let required = false +/** @type {boolean} applies the mdc-select--invalid class */ +export let showError = false +/** @type {string} a name for the hidden input field for form submission*/ +export let name = '' const dispatch = createEventDispatcher() const labelID = generateRandomID('select-label-') @@ -61,13 +67,32 @@ afterUpdate(() => { }) -
-
+
+ +
+ + + + {label} + + + - + { - - - - {label} - - -
-
-
    +
    +
      {#each options as { id, name } (id)}
    • {name} diff --git a/components/mdc/Select/_index.scss b/components/mdc/Select/_index.scss index 881464a..7ff7969 100644 --- a/components/mdc/Select/_index.scss +++ b/components/mdc/Select/_index.scss @@ -4,6 +4,6 @@ @use '@material/select/styles'; /* MDC select floating label */ -.mdc-select:not(.mdc-select--disabled).mdc-select--focused .mdc-floating-label { +.mdc-select:not(.mdc-select--disabled, .mdc-select--invalid).mdc-select--focused .mdc-floating-label { color: var(--mdc-theme-primary); } diff --git a/index.d.ts b/index.d.ts index 9eaf73b..c35c995 100644 --- a/index.d.ts +++ b/index.d.ts @@ -235,11 +235,14 @@ declare module '@silintl/ui-components' { } interface SelectProps { + disabled?: boolean label?: string + name?: string options?: { name: string; id: string }[] - width?: string - disabled?: boolean + required?: boolean + showError?: boolean selectedID?: string + width?: string class?: string } export class Select extends SvelteComponentTyped {} diff --git a/package-lock.json b/package-lock.json index f1e5f8f..4ac187e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@silintl/ui-components", - "version": "11.2.0", + "version": "11.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@silintl/ui-components", - "version": "11.2.0", + "version": "11.3.0", "license": "MIT", "dependencies": { "material-components-web": "^14.0.0", diff --git a/package.json b/package.json index bd9ce4f..40fbfa9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@silintl/ui-components", - "version": "11.2.0", + "version": "11.3.0", "description": "Reusable Svelte components for some internal applications", "main": "index.mjs", "module": "index.mjs", diff --git a/stories/Select.stories.svelte b/stories/Select.stories.svelte index 8e546bd..7818706 100644 --- a/stories/Select.stories.svelte +++ b/stories/Select.stories.svelte @@ -1,7 +1,8 @@