@sebgroup/green-core 3.5.1 → 3.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/checkbox/checkbox.component.js +12 -2
- package/components/form/form-control.d.ts +6 -0
- package/components/form/form-control.js +8 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/input/input.component.d.ts +1 -1
- package/components/input/input.component.js +2 -1
- package/components/switch/index.d.ts +1 -0
- package/components/switch/index.js +1 -0
- package/components/switch/switch.component.d.ts +44 -0
- package/components/switch/switch.component.js +185 -0
- package/components/switch/switch.d.ts +2 -0
- package/components/switch/switch.js +6 -0
- package/components/switch/switch.styles.d.ts +1 -0
- package/components/switch/switch.styles.js +239 -0
- package/custom-elements.json +120645 -119550
- package/gds-element.js +1 -1
- package/generated/mcp/components.json +14 -1
- package/generated/mcp/concepts/scoping.md +16 -1
- package/generated/mcp/guides/migration.md +4 -0
- package/generated/mcp/icons.json +1 -1
- package/generated/mcp/index.json +1 -1
- package/generated/mcp/input/api.md +1 -1
- package/generated/mcp/switch/angular.md +24 -0
- package/generated/mcp/switch/api.md +56 -0
- package/generated/mcp/switch/guidelines.md +35 -0
- package/generated/mcp/switch/index.json +9 -0
- package/generated/mcp/switch/react.md +24 -0
- package/generated/mcp/tokens.json +1 -1
- package/generated/react/index.d.ts +4 -3
- package/generated/react/index.js +4 -3
- package/generated/react/input/index.d.ts +2 -2
- package/generated/react/switch/index.d.ts +701 -0
- package/generated/react/switch/index.js +24 -0
- package/generated/react/textarea/index.d.ts +1 -1
- package/package.json +3 -1
- package/pure.d.ts +1 -0
- package/pure.js +1 -0
- package/utils/helpers/component-meta.d.ts +1 -0
- package/utils/helpers/component-meta.js +5 -4
- package/utils/helpers/custom-element-scoping.js +1 -1
package/gds-element.js
CHANGED
|
@@ -16,7 +16,7 @@ class GdsElement extends LitElement {
|
|
|
16
16
|
/**
|
|
17
17
|
* The semantic version of this element. Can be used for troubleshooting to verify the version being used.
|
|
18
18
|
*/
|
|
19
|
-
this.semanticVersion = "3.
|
|
19
|
+
this.semanticVersion = "3.6.3";
|
|
20
20
|
this.syncFirstRender = false;
|
|
21
21
|
this._isUsingTransitionalStyles = false;
|
|
22
22
|
this._dynamicStylesController = new DynamicStylesController(this);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-04-
|
|
2
|
+
"generatedAt": "2026-04-29T15:59:02.891Z",
|
|
3
3
|
"components": [
|
|
4
4
|
{
|
|
5
5
|
"name": "gds-alert",
|
|
@@ -700,6 +700,19 @@
|
|
|
700
700
|
"react"
|
|
701
701
|
]
|
|
702
702
|
},
|
|
703
|
+
{
|
|
704
|
+
"name": "gds-switch",
|
|
705
|
+
"tagName": "gds-switch",
|
|
706
|
+
"className": "GdsSwitch",
|
|
707
|
+
"description": "",
|
|
708
|
+
"path": "switch/",
|
|
709
|
+
"files": [
|
|
710
|
+
"api",
|
|
711
|
+
"guidelines",
|
|
712
|
+
"angular",
|
|
713
|
+
"react"
|
|
714
|
+
]
|
|
715
|
+
},
|
|
703
716
|
{
|
|
704
717
|
"name": "gds-table",
|
|
705
718
|
"tagName": "gds-table",
|
|
@@ -54,4 +54,19 @@ use the `html` template tag or template tag factory from Green Core.
|
|
|
54
54
|
|
|
55
55
|
At some point in the future, when the scoped custom element registry proposal has been
|
|
56
56
|
implemented in all major browsers, we might remove this custom scoping mechanism and
|
|
57
|
-
switch to using native scoped registries instead.
|
|
57
|
+
switch to using native scoped registries instead.
|
|
58
|
+
|
|
59
|
+
## CSS Variables
|
|
60
|
+
|
|
61
|
+
Shadow DOM encapsulation guards against style leaks in and out of components and custom element scoping ensures
|
|
62
|
+
that multiple versions can coexist. This leaves out CSS variables however. CSS variables, or
|
|
63
|
+
"CSS custom properties" as they are really called, inherit though the DOM, including shadow DOM.
|
|
64
|
+
This means that conflicts *can* still occur here.
|
|
65
|
+
|
|
66
|
+
But Green provides a way to guard against this type of conflict as well: `<gds-theme>`.
|
|
67
|
+
|
|
68
|
+
`<gds-theme>` defines a copy of all the CSS variables on its `:host` selector. This means that
|
|
69
|
+
it will override any same-name variables defined on `:root` or inherited from outside.
|
|
70
|
+
|
|
71
|
+
So by using `<gds-theme>` at the root of your application, you can ensure that all components get
|
|
72
|
+
their variables from the version you expect.
|
|
@@ -6,6 +6,10 @@ If you need to update several versions at once, it is recommended to follow the
|
|
|
6
6
|
|
|
7
7
|
Before you begin, make sure you have the latest feature/patch version of your current major version.
|
|
8
8
|
|
|
9
|
+
## CSS variables
|
|
10
|
+
|
|
11
|
+
Please ensure that you have at least one instance of `gds-theme` at the root of your application. This ensures that all components have the correct variables versions, and guards against conflicts from shell or other MFEs.
|
|
12
|
+
|
|
9
13
|
## Automated migrations
|
|
10
14
|
|
|
11
15
|
Many migrations can be automated using the `green-core-context migrate` command. This will detect and apply code changes for supported automated migrations.
|
package/generated/mcp/icons.json
CHANGED
package/generated/mcp/index.json
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
| `maxlength` | `number` | `-` | The maximum number of characters allowed in the field. |
|
|
35
35
|
| `size` | `'large' \| 'small'` | `-` | Controls the font-size of texts and height of the field. |
|
|
36
36
|
| `plain` | `boolean` | `-` | Hides the header and the footer, while still keeping the accessible label Always set the `label` attribute, and if you need to hide it, add this attribute and keep `label` set. |
|
|
37
|
-
| `type` | `\| 'date' \| 'datetime-local' \| 'email' \| 'number' \| 'password' \| 'search' \| 'tel' \| 'text' \| 'time' \| 'url'` | `-` | The type of input. Works the same as a native `<input>` element, but only a subset of types are supported. Defaults to `text`. |
|
|
37
|
+
| `type` | `\| 'date' \| 'datetime-local' \| 'email' \| 'file' \| 'number' \| 'password' \| 'search' \| 'tel' \| 'text' \| 'time' \| 'url'` | `-` | The type of input. Works the same as a native `<input>` element, but only a subset of types are supported. Defaults to `text`. |
|
|
38
38
|
| `min` | `number \| string \| undefined` | `-` | The input's minimum value. Only applies to date and number input types. |
|
|
39
39
|
| `max` | `number \| string \| undefined` | `-` | The input's maximum value. Only applies to date and number input types. |
|
|
40
40
|
| `step` | `number \| 'any' \| undefined` | `-` | Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is implied, allowing any numeric value. Only applies to date and number input types. |
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# gds-switch - Angular
|
|
2
|
+
|
|
3
|
+
## Import
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import { GdsSwitchComponent } from '@sebgroup/green-core-ng'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Use the component in your Angular templates:
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<gds-switch></gds-switch>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Event Handling
|
|
18
|
+
|
|
19
|
+
Events are emitted using Angular output syntax. Event names are converted from kebab-case to camelCase:
|
|
20
|
+
|
|
21
|
+
| Web Component Event | Angular Output | Handler Example |
|
|
22
|
+
|---------------------|----------------|-----------------|
|
|
23
|
+
| `input` | `input` | `(input)="handler($event)"` |
|
|
24
|
+
| `change` | `change` | `(change)="handler($event)"` |
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# gds-switch
|
|
2
|
+
|
|
3
|
+
**Class**: `GdsSwitch`
|
|
4
|
+
|
|
5
|
+
**Tag**: `<gds-switch>`
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Properties
|
|
9
|
+
|
|
10
|
+
> Some properties accept design token names. Use `get_tokens` with the appropriate category to discover valid token names and their resolved values.
|
|
11
|
+
|
|
12
|
+
| Name | Type | Default | Description |
|
|
13
|
+
|------|------|---------|-------------|
|
|
14
|
+
| `'align-self'` | `string \| undefined` | `-` | Style Expression Property that controls the `align-self` property. Supports all valid CSS `align-self` values. |
|
|
15
|
+
| `'justify-self'` | `string \| undefined` | `-` | Style Expression Property that controls the `justify-self` property. Supports all valid CSS `justify-self` values. |
|
|
16
|
+
| `'place-self'` | `string \| undefined` | `-` | Style Expression Property that controls the `place-self` property. Supports all valid CSS `place-self` values. |
|
|
17
|
+
| `'grid-column'` | `string \| undefined` | `-` | Style Expression Property that controls the `grid-column` property. Supports all valid CSS grid-column values. Documentation: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column |
|
|
18
|
+
| `'grid-row'` | `string \| undefined` | `-` | Style Expression Property that controls the `grid-row` property. Supports all valid CSS `grid-row` values. |
|
|
19
|
+
| `'grid-area'` | `string \| undefined` | `-` | Style Expression Property that controls the `grid-area` property. Supports all valid CSS `grid-area` values. |
|
|
20
|
+
| `flex` | `string \| undefined` | `-` | Style Expression Property that controls the `flex` property. Supports all valid CSS `flex` values. |
|
|
21
|
+
| `order` | `string \| undefined` | `-` | Style Expression Property that controls the `order` property. Supports all valid CSS `order` values. |
|
|
22
|
+
| `margin` | `string \| undefined` | `-` | Style Expression Property that controls the `margin` property. Only accepts space tokens. |
|
|
23
|
+
| `'margin-inline'` | `string \| undefined` | `-` | Style Expression Property that controls the `margin-inline` property. Only accepts space tokens. |
|
|
24
|
+
| `'margin-block'` | `string \| undefined` | `-` | Style Expression Property that controls the `margin-block` property. Only accepts space tokens. |
|
|
25
|
+
| `width` | `string \| undefined` | `-` | Style Expression Property that controls the `width` property. Supports space tokens and all valid CSS `width` values. |
|
|
26
|
+
| `'min-width'` | `string \| undefined` | `-` | Style Expression Property that controls the `min-width` property. Supports space tokens and all valid CSS `min-width` values. |
|
|
27
|
+
| `'max-width'` | `string \| undefined` | `-` | Style Expression Property that controls the `max-width` property. Supports space tokens and all valid CSS `max-width` values. |
|
|
28
|
+
| `'inline-size'` | `string \| undefined` | `-` | Style Expression Property that controls the `inline-size` property. Supports space tokens and all valid CSS `inline-size` values |
|
|
29
|
+
| `'min-inline-size'` | `string \| undefined` | `-` | Style Expression Property that controls the `min-inline-size` property. Supports space tokens and all valid CSS `min-inline-size` values. |
|
|
30
|
+
| `'max-inline-size'` | `string \| undefined` | `-` | Style Expression Property that controls the `max-inline-size` property. Supports space tokens and all valid CSS `max-inline-size` values. |
|
|
31
|
+
| `checked` | `boolean` | `-` | The checked state of the switch. |
|
|
32
|
+
| `controlPlacement` | `'start' \| 'end'` | `-` | Controls where the control is placed relative to the label. |
|
|
33
|
+
| `size` | `'large' \| 'small'` | `-` | Controls text and control sizing. |
|
|
34
|
+
| `'justify-content'` | `string` | `-` | Controls horizontal distribution of label and control. |
|
|
35
|
+
| `value` | `string` | `-` | The value submitted with the form when the switch is checked. Defaults to 'on', matching native checkbox behaviour. |
|
|
36
|
+
| `validator` | `GdsValidator \| undefined` | `-` | A validator that can be used to validate the form control and set an error message. |
|
|
37
|
+
| `required` | `boolean` | `-` | The required attribute can be used to communicate to users of assistive technology that the control is required. Validation still needs to be done in a validator or equivalent. |
|
|
38
|
+
| `errorMessage` | `string` | `-` | This can be used to manually control the error message that will be displayed when the control is invalid. |
|
|
39
|
+
| `invalid` | `any` | `-` | Validation state of the form control. Setting this to true triggers the invalid state of the control. |
|
|
40
|
+
| `label` | `string` | `-` | The label of the form control. |
|
|
41
|
+
| `name` | `string` | `-` | |
|
|
42
|
+
| `disabled` | `boolean` | `-` | If the input is Disabled |
|
|
43
|
+
| `syncFirstRender` | `boolean` | `-` | Force the element to perform a synchronous first render and apply style expression properties in `connectedCallback`. This guarantees that the child DOM always remains projected in DOM, since the element will attach the shadowRoot and run the first render pass in the same event loop cycle, and that declarative layout will be applied once slotted DOM is projected. Note: This will cause the first render pass to be blocking. Use sparingly and only when necessary, such as when the element needs to be measured synchronously after being added to the DOM. |
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Events
|
|
47
|
+
|
|
48
|
+
| Name | Type | Description |
|
|
49
|
+
|------|------|-------------|
|
|
50
|
+
| `input` | `InputEvent` | Dispatched when the checked state changes. |
|
|
51
|
+
| `change` | `Event` | Dispatched when the checked state changes. |
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Form Control
|
|
55
|
+
|
|
56
|
+
This component is a form control and inherits form-related properties and methods.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Switch
|
|
2
|
+
|
|
3
|
+
A toggle lets users switch a setting on or off.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
### Behaviour
|
|
9
|
+
|
|
10
|
+
Changing the toggle updates the state immediately. The current state should always be clear to the user, and the component should provide feedback for different interaction states such as hover, focus, pressed, and disabled.
|
|
11
|
+
|
|
12
|
+
### Size
|
|
13
|
+
|
|
14
|
+
The toggle is available in two sizes: default and small. The small size should only be used in compact views where space is limited, such as dense layouts or smaller components.
|
|
15
|
+
|
|
16
|
+
### Label
|
|
17
|
+
|
|
18
|
+
Labels describe the setting, not the state. They should be short and specific, remain clear in both on and off states, and not require additional context to understand.
|
|
19
|
+
|
|
20
|
+
For example, use labels like “Email notifications”, “Show balance”, or “Enable dark mode”. Avoid labels such as “On / Off”, “Active”, or “Enabled”, as they do not clearly communicate what the toggle controls.
|
|
21
|
+
|
|
22
|
+
### Accessibility
|
|
23
|
+
|
|
24
|
+
A toggle must have a visible and persistent label and communicate its state programmatically as on or off. It should be operable via keyboard and include a visible focus indicator. The state should not rely on color alone to be understood, and the component must meet contrast requirements in all states.
|
|
25
|
+
|
|
26
|
+
### Do's and Don'ts
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## UX Guidelines
|
|
30
|
+
|
|
31
|
+
### Writing UX text for toggle
|
|
32
|
+
|
|
33
|
+
### Keep labels short
|
|
34
|
+
|
|
35
|
+
### Provide context where needed
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# gds-switch - React
|
|
2
|
+
|
|
3
|
+
## Import
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import { GdsSwitch } from '@sebgroup/green-core/react'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Use the component as a React JSX element:
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<GdsSwitch />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Event Handling
|
|
18
|
+
|
|
19
|
+
Events are handled using React event handler props. Event names are converted from kebab-case to camelCase with an "on" prefix:
|
|
20
|
+
|
|
21
|
+
| Web Component Event | React Handler Prop | Handler Example |
|
|
22
|
+
|---------------------|--------------------|-----------------|
|
|
23
|
+
| `input` | `onInput` | `onInput={handler}` |
|
|
24
|
+
| `change` | `onChange` | `onChange={handler}` |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './alert/index.js';
|
|
2
|
-
export * from './blur/index.js';
|
|
3
2
|
export * from './badge/index.js';
|
|
4
3
|
export * from './breadcrumbs/index.js';
|
|
4
|
+
export * from './blur/index.js';
|
|
5
5
|
export * from './button/index.js';
|
|
6
6
|
export * from './calendar/index.js';
|
|
7
7
|
export * from './card/index.js';
|
|
@@ -12,9 +12,9 @@ export * from './context-menu/index.js';
|
|
|
12
12
|
export * from './datepicker/index.js';
|
|
13
13
|
export * from './details/index.js';
|
|
14
14
|
export * from './dialog/index.js';
|
|
15
|
-
export * from './div/index.js';
|
|
16
15
|
export * from './divider/index.js';
|
|
17
16
|
export * from './dropdown/index.js';
|
|
17
|
+
export * from './div/index.js';
|
|
18
18
|
export * from './fab/index.js';
|
|
19
19
|
export * from './filter-chips/index.js';
|
|
20
20
|
export * from './flex/index.js';
|
|
@@ -25,8 +25,8 @@ export * from './list-item/index.js';
|
|
|
25
25
|
export * from './img/index.js';
|
|
26
26
|
export * from './input/index.js';
|
|
27
27
|
export * from './link/index.js';
|
|
28
|
-
export * from './mask/index.js';
|
|
29
28
|
export * from './menu-button/index.js';
|
|
29
|
+
export * from './mask/index.js';
|
|
30
30
|
export * from './pagination/index.js';
|
|
31
31
|
export * from './backdrop/index.js';
|
|
32
32
|
export * from './popover/index.js';
|
|
@@ -36,6 +36,7 @@ export * from './segmented-control/index.js';
|
|
|
36
36
|
export * from './select/index.js';
|
|
37
37
|
export * from './signal/index.js';
|
|
38
38
|
export * from './spinner/index.js';
|
|
39
|
+
export * from './switch/index.js';
|
|
39
40
|
export * from './table/index.js';
|
|
40
41
|
export * from './text/index.js';
|
|
41
42
|
export * from './textarea/index.js';
|
package/generated/react/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./alert/index.js";
|
|
2
|
-
export * from "./blur/index.js";
|
|
3
2
|
export * from "./badge/index.js";
|
|
4
3
|
export * from "./breadcrumbs/index.js";
|
|
4
|
+
export * from "./blur/index.js";
|
|
5
5
|
export * from "./button/index.js";
|
|
6
6
|
export * from "./calendar/index.js";
|
|
7
7
|
export * from "./card/index.js";
|
|
@@ -12,9 +12,9 @@ export * from "./context-menu/index.js";
|
|
|
12
12
|
export * from "./datepicker/index.js";
|
|
13
13
|
export * from "./details/index.js";
|
|
14
14
|
export * from "./dialog/index.js";
|
|
15
|
-
export * from "./div/index.js";
|
|
16
15
|
export * from "./divider/index.js";
|
|
17
16
|
export * from "./dropdown/index.js";
|
|
17
|
+
export * from "./div/index.js";
|
|
18
18
|
export * from "./fab/index.js";
|
|
19
19
|
export * from "./filter-chips/index.js";
|
|
20
20
|
export * from "./flex/index.js";
|
|
@@ -25,8 +25,8 @@ export * from "./list-item/index.js";
|
|
|
25
25
|
export * from "./img/index.js";
|
|
26
26
|
export * from "./input/index.js";
|
|
27
27
|
export * from "./link/index.js";
|
|
28
|
-
export * from "./mask/index.js";
|
|
29
28
|
export * from "./menu-button/index.js";
|
|
29
|
+
export * from "./mask/index.js";
|
|
30
30
|
export * from "./pagination/index.js";
|
|
31
31
|
export * from "./backdrop/index.js";
|
|
32
32
|
export * from "./popover/index.js";
|
|
@@ -36,6 +36,7 @@ export * from "./segmented-control/index.js";
|
|
|
36
36
|
export * from "./select/index.js";
|
|
37
37
|
export * from "./signal/index.js";
|
|
38
38
|
export * from "./spinner/index.js";
|
|
39
|
+
export * from "./switch/index.js";
|
|
39
40
|
export * from "./table/index.js";
|
|
40
41
|
export * from "./text/index.js";
|
|
41
42
|
export * from "./textarea/index.js";
|
|
@@ -39,11 +39,11 @@ export declare const GdsInput: {
|
|
|
39
39
|
maxlength?: number | undefined;
|
|
40
40
|
size?: "small" | "large" | undefined;
|
|
41
41
|
plain?: boolean | undefined;
|
|
42
|
-
type?: "number" | "search" | "time" | "text" | "date" | "email" | "datetime-local" | "password" | "tel" | "url" | undefined;
|
|
42
|
+
type?: "number" | "search" | "time" | "text" | "date" | "email" | "datetime-local" | "file" | "password" | "tel" | "url" | undefined;
|
|
43
43
|
min?: (number | string) | undefined;
|
|
44
44
|
max?: (number | string) | undefined;
|
|
45
45
|
step?: (number | "any") | undefined;
|
|
46
|
-
autocapitalize?: "none" | "
|
|
46
|
+
autocapitalize?: "none" | "on" | "off" | "sentences" | "words" | "characters" | undefined;
|
|
47
47
|
autocorrect?: boolean | undefined;
|
|
48
48
|
autocomplete?: string | undefined;
|
|
49
49
|
autofocus?: boolean | undefined;
|