@sebgroup/green-core 1.12.0 → 1.14.0

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/README.md CHANGED
@@ -1,90 +1,33 @@
1
- <h1 align="center">
2
- <a href="https://seb.io">
3
- <img src="https://github.com/sebgroup/green/assets/11420341/2fc122ba-54fc-4f22-b96d-d405079d6e50">
4
- </a>
5
- <br/>
6
- <br/>
7
- Green Design System
8
- </h1>
1
+ <div align="center">
2
+ <img width="600" alt="green-core" src="https://github.com/sebgroup/green/assets/11420341/5d4b25fd-0633-498c-b50f-70f07c01ac16">
3
+ <h1>@sebgroup/green-core</h1>
4
+ <p>Green Core is a carefully crafted set of Web Components that lays the foundation for the Green Design System.</p>
5
+ </div>
9
6
 
10
- <p align="center">Green is an open-source design system built by SEB.<p>
11
- <p align="center"><a href="https://github.com/sebgroup/green/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache2.0-005FAC"/></a> <a href="https://semver.org/"><img src="https://img.shields.io/badge/semantic%20versioning-006D31"/></a> <a href="https://nx.dev/"><img src="https://img.shields.io/badge/maintained%20with-nx-006D31"/></a> <a href="https://github.com/sebgroup/green/blob/main/CONTRIBUTING.md"><img src="https://img.shields.io/badge/PRs-welcome-006D31"/></a></p>
12
-
13
- ## Getting started
14
-
15
- If you are new to Green, checkout [@sebgroup/green-core](https://github.com/sebgroup/green/tree/main/libs/core).
16
-
17
- We also provide components for the following technologies:
18
-
19
- - [React](https://github.com/sebgroup/green/tree/main/libs/react)
20
- - [Angular](https://github.com/sebgroup/green/tree/main/libs/angular)
21
-
22
- If you're trying to find something specific, here's a full list of packages that we support!
23
-
24
- | Package name | Description |
25
- | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
26
- | [@sebgroup/green-core](https://github.com/sebgroup/green/tree/main/libs/core) | Webcomponent library built with [Lit](https://lit.dev) |
27
- | [@sebgroup/green-react](https://github.com/sebgroup/green/tree/main/libs/react) | React component library |
28
- | [@sebgroup/green-angular](https://github.com/sebgroup/green/tree/main/libs/angular) | Angular component library |
29
- | [@sebgroup/chlorophyll](https://github.com/sebgroup/green/tree/main/libs/chlorophyll) | Styling framework |
30
- | [@sebgroup/green-tokens](https://github.com/sebgroup/green/tree/main/libs/tokens) | Design Tokens package |
31
- | [@sebgroup/green-charts](https://github.com/sebgroup/green/tree/main/libs/charts) | An SEB wrapper of [Billboard.js](https://naver.github.io/billboard.js/) |
32
- | [@sebgroup/green-react-charts](https://github.com/sebgroup/green/tree/main/libs/react-charts) | A React version of the charts wrapper |
33
- | [@sebgroup/green-angular-charts](https://github.com/sebgroup/green/tree/main/libs/angular-charts) | An Angular version of the charts wrapper |
34
-
35
- ## 📋 Table of content
36
-
37
- - [Documentation](https://github.com/sebgroup/green/tree/main?tab=readme-ov-file#documentation)
38
- - [Working from SEB](https://github.com/sebgroup/green/tree/main?tab=readme-ov-file#working-from-seb)
39
- - [Contribute](https://github.com/sebgroup/green/tree/main?tab=readme-ov-file#contribute)
40
- - [Working locally with this repo](https://github.com/sebgroup/green/tree/main?tab=readme-ov-file#working-locally-with-this-repo)
41
-
42
- ## 📚 Documentation
43
-
44
- Documentation currently resides in a few different locations:
45
-
46
- - [User Interface Guidelines (Design Library)](https://designlibrary.sebgroup.com/)
47
- - [Storybook (@sebgroup/chlorophyll)](https://sebgroup.github.io/green/latest/chlorophyll/)
48
- - [Storybook (@sebgroup/green-core)](https://sebgroup.github.io/green/latest/core/)
49
- - [Storybook (@sebgroup/green-react)](https://sebgroup.github.io/green/latest/react/)
50
- - [Storybook (@sebgroup/green-angular)](https://sebgroup.github.io/green/latest/angular/)
51
-
52
- ## 🏦 Working from SEB
53
-
54
- Working from SEB and on SEB machines you need to setup things in a specific way for everything to work smooth. Checkout our [Developer Guidelines](https://github.sebank.se/pages/seb-common/Developer-garden/detail_pages/green.html) over at Developer Garden.
55
-
56
- ## 🎉 Contribute
57
-
58
- We're always looking for contributors to help us fix bugs, build new features, or help us improve the project documentation. If you're interested, definitely check out our [Contributing Guide](https://github.com/sebgroup/green/blob/main/CONTRIBUTING.md)! 👀
59
-
60
- ## 🔨 Working locally with this repo
61
-
62
- ### Start Storybook locally
63
-
64
- To start Storybooks locally on your machine you run the following command:
7
+ ## Install
65
8
 
66
9
  ```bash
67
- npx nx run [PROJECT]:storybook
10
+ yarn install @sebgroup/green-core
11
+
12
+ # or use npm
13
+ npm install @sebgroup/green-core
68
14
  ```
69
15
 
70
- Where you replace `[PROJECT]` with a folder name from `green\libs`.
16
+ ## Use
71
17
 
72
- So to start Storybook for each component library run:
18
+ ```js
19
+ import { GdsButton } from '@sebgroup/green-core'
20
+ import { transitionalStyles } from '@sebgroup/green-core/transitional-styles'
73
21
 
74
- ```bash
75
- npx nx run chlorophyll:storybook
76
- npx nx run react:storybook
77
- npx nx run angular:storybook
22
+ //register transitional styles to get SEB's current visual design
23
+ transitionalStyles()
78
24
  ```
79
25
 
80
- If you install nx globally you can omit the npx above.
26
+ ```html
27
+ <!-- Then use the component in your html -->
28
+ <gds-button>Click me</gds-button>
29
+ ```
81
30
 
82
- ```bash
83
- # Install nx globally
84
- npm install nx -g
31
+ ## Documentation
85
32
 
86
- # And start the storybooks
87
- nx run chlorophyll:storybook
88
- nx run react:storybook
89
- nx run angular:storybook
90
- ```
33
+ Check out the [Storybook (@sebgroup/core)](https://sebgroup.github.io/green/latest/core/) for components and documentation.
@@ -0,0 +1,43 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ *
4
+ * @element gds-badge
5
+ * @summary A component that displays a badge with different variants and types.
6
+ * @documentation https://seb.io/docs/component/badge
7
+ * @status beta
8
+ * @since 1.0.0
9
+ *
10
+ * @cssprop --gds-badge-background-color - The background color of the badge.
11
+ * @cssprop --gds-badge-color - The text color of the badge.
12
+ * @cssprop --gds-badge-font-size - The font size of the badge.
13
+ * @cssprop --gds-badge-height - The height of the badge.
14
+ * @cssprop --gds-badge-width - The width of the badge.
15
+ *
16
+ * @variant Information - A badge with an information icon and blue background color.
17
+ * @variant Success - A badge with a checkmark icon and green background color.
18
+ * @variant Warning - A badge with an exclamation mark icon and yellow background color.
19
+ * @variant Error - A badge with a cross icon and red background color.
20
+ *
21
+ * @type Status - A badge that displays a status.
22
+ * @type Counter - A badge that displays a count.
23
+ * @type Indicator - A badge that displays an icon and percentage.
24
+ *
25
+ * @example
26
+ * <gds-badge variant="Information" type="Status">Pending</gds-badge>
27
+ * <gds-badge variant="Success" type="Counter">10</gds-badge>
28
+ * <gds-badge variant="Warning" type="Indicator" icon="warning" percentage="50">50%</gds-badge>
29
+ * <gds-badge variant="Error" type="Status">Failed</gds-badge>
30
+ *
31
+ */
32
+ export declare class GdsBadge extends LitElement {
33
+ #private;
34
+ static styles: import("lit").CSSResult;
35
+ static shadowRootOptions: ShadowRootInit;
36
+ constructor();
37
+ variant: string;
38
+ type: string;
39
+ icon: string;
40
+ slotIcon(): import("lit").TemplateResult<1>;
41
+ slotLabel(): "" | import("lit").TemplateResult<1>;
42
+ render(): import("lit").TemplateResult<1>;
43
+ }
@@ -0,0 +1,46 @@
1
+ import '../icon/icon';
2
+ import '../../primitives/ripple/ripple';
3
+ import { GdsFormControlElement } from '../../components/form-control';
4
+ /**
5
+ * @element gds-button
6
+ * @summary A custom button element that can display a label, lead and trail icons, and a ripple effect on click.
7
+ * @status beta
8
+ *
9
+ * @slot - Content to be displayed as the button label.
10
+ * @slot lead - An optional slot that allows a `gds-icon` element to be placed before the label.
11
+ * @slot trail - An optional slot that allows a `gds-icon` element to be placed after the label.
12
+ *
13
+ * @event click - Fired when the button is clicked.
14
+ */
15
+ export declare class GdsButton<ValueT = any> extends GdsFormControlElement<ValueT> {
16
+ #private;
17
+ static styles: (import("lit").CSSResult | import("lit").CSSResult[])[];
18
+ static shadowRootOptions: ShadowRootInit;
19
+ /**
20
+ * Whether the button is disabled.
21
+ */
22
+ disabled: boolean;
23
+ /**
24
+ * The type of the button.
25
+ */
26
+ type?: HTMLButtonElement['type'];
27
+ /**
28
+ * The variant of the button. Defaults to "primary".
29
+ */
30
+ variant: 'primary' | 'secondary' | 'tertiary';
31
+ /**
32
+ * Defines which set the button belongs to. Defaults to "neutral".
33
+ */
34
+ set: 'neutral' | 'positive' | 'negative';
35
+ /**
36
+ * Sets the size of the button. Defaults to "small".
37
+ */
38
+ size: 'small' | 'medium' | 'large';
39
+ /**
40
+ * The label of the button. Use this to add an accessible label to the button when no text is provided in the default slot.
41
+ */
42
+ label: string;
43
+ private _mainSlot?;
44
+ constructor();
45
+ render(): any;
46
+ }
@@ -0,0 +1,12 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class GdsCheckbox extends LitElement {
3
+ #private;
4
+ static styles: import("lit").CSSResult;
5
+ static shadowRootOptions: ShadowRootInit;
6
+ constructor();
7
+ private inputElement;
8
+ private exludeAttr;
9
+ private reflectAttributesToInput;
10
+ update(changedProperties: Map<PropertyKey, unknown>): void;
11
+ render(): import("lit").TemplateResult<1>;
12
+ }
@@ -18,6 +18,7 @@ export declare class GdsDatepicker extends GdsFormControlElement<Date> {
18
18
  #private;
19
19
  static styles: import("lit").CSSResult[];
20
20
  static shadowRootOptions: ShadowRootInit;
21
+ get type(): string;
21
22
  /**
22
23
  * The Date value of the datepicker. This can be set to undefined to clear the datepicker.
23
24
  * This can be a string if set via the value attribute in markup, or via the setAttribute DOM API.
@@ -21,6 +21,7 @@ export declare class GdsDropdown<ValueT = any> extends GdsFormControlElement<Val
21
21
  #private;
22
22
  static styles: import("lit").CSSResult;
23
23
  static shadowRootOptions: ShadowRootInit;
24
+ get type(): string;
24
25
  /**
25
26
  * The label of the dropdown.
26
27
  * Will only render if this property is set to a non-empty string.
@@ -23,7 +23,6 @@ export declare abstract class GdsFormControlElement<ValueT = any> extends GdsEle
23
23
  value?: ValueT;
24
24
  name: string;
25
25
  get form(): HTMLFormElement | null;
26
- get type(): string;
27
26
  get validity(): ValidityState;
28
27
  get validationMessage(): string;
29
28
  get willValidate(): boolean;
@@ -0,0 +1,16 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class GdsIcon extends LitElement {
3
+ static get styles(): import("lit").CSSResult;
4
+ open: boolean;
5
+ name: string;
6
+ static properties: {
7
+ open: {
8
+ type: StringConstructor;
9
+ reflect: boolean;
10
+ };
11
+ name: {
12
+ type: StringConstructor;
13
+ };
14
+ };
15
+ render(): import("lit").TemplateResult<1>;
16
+ }
@@ -6,3 +6,5 @@ export * from '../primitives/menu/menu-item';
6
6
  export * from './datepicker/datepicker';
7
7
  export * from './grid/grid';
8
8
  export * from './grouped-list/grouped-list';
9
+ export * from './segmented-control/segmented-control';
10
+ export * from './icon/icon';
@@ -0,0 +1,69 @@
1
+ import { GdsFormControlElement } from '../form-control';
2
+ /**
3
+ * @summary A custom input element that can be used in forms.
4
+ * @status beta
5
+ *
6
+ * @element gds-input
7
+ *.
8
+ * @slot lead - Accepts `gds-icon`. Use this to place an icon in the start of the field.
9
+ * @slot trail - Accepts `gds-badge`. Use this to place a badge in the field, for displaying currency for example.
10
+ * @slot extended-supporting-text - A longer supporting text can be placed here. It will be
11
+ * displayed in a panel when the user clicks the info button.
12
+ */
13
+ export declare class GdsInput extends GdsFormControlElement<string> {
14
+ #private;
15
+ static shadowRootOptions: {
16
+ delegatesFocus: boolean;
17
+ mode: ShadowRootMode;
18
+ slotAssignment?: SlotAssignmentMode | undefined;
19
+ };
20
+ static styles: (import("lit").CSSResult | import("lit").CSSResult[])[];
21
+ value: string;
22
+ /**
23
+ * The label displayed above the field
24
+ */
25
+ label: string;
26
+ /**
27
+ * The supporting text displayed between the label and the field itself
28
+ */
29
+ supportingText: string;
30
+ /**
31
+ * Whether the supporting text should be displayed or not.
32
+ */
33
+ showExtendedSupportingText: boolean;
34
+ /**
35
+ * Whether the field should be clearable or not. Clearable fields will display a clear button when
36
+ * the field has a value.
37
+ */
38
+ clearable: boolean;
39
+ /**
40
+ * The maximum number of characters allowed in the field.
41
+ */
42
+ maxlength: number;
43
+ /**
44
+ * The variant of the input field. The default variant displays a label, supporting text, and
45
+ * extended supporting text. The simplified variant only displays the field itself and the
46
+ * supporting text below.
47
+ *
48
+ * The simplified variant should only be used in specific cases, for example when the input field
49
+ * is placed inside a table cell or in a space-constrained layout.
50
+ *
51
+ * A typical form should use the default variant.
52
+ */
53
+ variant: 'default' | 'simplified';
54
+ /**
55
+ * Whether the input field should be multiline or not. Multiline fields will render a textarea
56
+ * internally instead of an input.
57
+ */
58
+ multiline: boolean;
59
+ private elInput;
60
+ private elExtendedSupportingTextSlot;
61
+ constructor();
62
+ connectedCallback(): void;
63
+ render(): any;
64
+ private _setAutoHeight;
65
+ /**
66
+ * Event handler for the form reset event.
67
+ */
68
+ _handleFormReset: () => void;
69
+ }
@@ -0,0 +1,13 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class GdsRadioGroup extends LitElement {
3
+ #private;
4
+ static shadowRootOptions: ShadowRootInit;
5
+ selectedValue: any;
6
+ constructor();
7
+ label: string;
8
+ private inputElement;
9
+ private exludeAttr;
10
+ private reflectAttributesToInput;
11
+ update(changedProperties: Map<PropertyKey, unknown>): void;
12
+ render(): import("lit").TemplateResult<1>;
13
+ }
@@ -0,0 +1,14 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class GdsRadio extends LitElement {
3
+ #private;
4
+ static styles: import("lit").CSSResult;
5
+ static shadowRootOptions: ShadowRootInit;
6
+ value: any;
7
+ constructor();
8
+ private inputElement;
9
+ private exludeAttr;
10
+ private reflectAttributesToInput;
11
+ update(changedProperties: Map<PropertyKey, unknown>): void;
12
+ handleClick(): void;
13
+ render(): import("lit").TemplateResult<1>;
14
+ }
@@ -0,0 +1,19 @@
1
+ import { GdsElement } from '../../../gds-element';
2
+ /**
3
+ * @element gds-segment
4
+ */
5
+ export declare class GdsSegment<ValueT = any> extends GdsElement {
6
+ static styles: import("lit").CSSResult[];
7
+ /**
8
+ * Whether the segment is selected
9
+ * @attr selected
10
+ */
11
+ selected: boolean;
12
+ /**
13
+ * Value can be used to tie arbitrary data to the segment.
14
+ * @attr value
15
+ */
16
+ value?: ValueT;
17
+ connectedCallback(): void;
18
+ render(): any;
19
+ }
@@ -0,0 +1,2 @@
1
+ export declare function register(): void;
2
+ export default register;
@@ -0,0 +1,50 @@
1
+ import { GdsElement } from '../../gds-element';
2
+ import { GdsSegment } from './segment/segment';
3
+ /**
4
+ * @element gds-segmented-control
5
+ * A segmented control is a group of 2-5 buttons that lets the user switch views or sort elements.
6
+ *
7
+ * @status beta
8
+ *
9
+ * @slot - Segments to display in the control
10
+ *
11
+ * @event changed - Fires when the selected segment is changed
12
+ */
13
+ export declare class GdsSegmentedControl<ValueT = any> extends GdsElement {
14
+ #private;
15
+ static styles: (import("lit").CSSResult | import("lit").CSSResult[])[];
16
+ /**
17
+ * Minimum width of each segment. Used for calculating the number of visible
18
+ * segments that can fit based on the available space.
19
+ * @attr seg-min-width
20
+ */
21
+ segMinWidth: number;
22
+ /**
23
+ * Size of the segmented control
24
+ * @attr size
25
+ */
26
+ size: 'small' | 'medium';
27
+ /**
28
+ * The value of the currently selected segment. Setting this property will
29
+ * select the segment with the matching value.
30
+ * @attr value
31
+ */
32
+ get value(): ValueT | undefined;
33
+ set value(val: ValueT | undefined);
34
+ /**
35
+ * Returns the segments in the control
36
+ * @readonly
37
+ */
38
+ get segments(): GdsSegment<any>[];
39
+ private _tStyles?;
40
+ private _elSlot;
41
+ private _elIndicator;
42
+ private _elTrack;
43
+ private _elSegments;
44
+ private _showPrevButton;
45
+ private _showNextButton;
46
+ connectedCallback(): void;
47
+ disconnectedCallback(): void;
48
+ render(): any;
49
+ private _recalculateMinWidth;
50
+ }
@@ -0,0 +1,2 @@
1
+ export declare function register(): void;
2
+ export default register;
@@ -0,0 +1,12 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class GdsSwitch extends LitElement {
3
+ #private;
4
+ static styles: import("lit").CSSResult;
5
+ static shadowRootOptions: ShadowRootInit;
6
+ constructor();
7
+ private inputElement;
8
+ private exludeAttr;
9
+ private reflectAttributesToInput;
10
+ update(changedProperties: Map<PropertyKey, unknown>): void;
11
+ render(): import("lit").TemplateResult<1>;
12
+ }
@@ -0,0 +1,14 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * @element gds-tooltip
4
+ *
5
+ * @status beta
6
+ */
7
+ export declare class GdsTooltip extends LitElement {
8
+ static styles: import("lit").CSSResult;
9
+ static shadowRootOptions: ShadowRootInit;
10
+ open: boolean;
11
+ content: null;
12
+ position: null;
13
+ render(): import("lit").TemplateResult<1>;
14
+ }
package/gds-element.d.ts CHANGED
@@ -4,5 +4,6 @@ export declare class GdsElement extends LitElement {
4
4
  * The unscoped name of this element.
5
5
  */
6
6
  gdsElementName: string;
7
+ isUsingTransitionalStyles: boolean;
7
8
  connectedCallback(): void;
8
9
  }
@@ -30,6 +30,8 @@ export declare const templates: {
30
30
  sbc083a1dbee9af73: string;
31
31
  scb6b9cb49cf93277: string;
32
32
  sd898d99fd9c13de6: string;
33
+ sdc27791837e94961: string;
34
+ sdc42f1da42d6411a: string;
33
35
  se0955919920ee87d: string;
34
36
  se4129fd6b9d7b4c2: string;
35
37
  sf295af199c723ec8: string;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * This config can be used when using jest for testing an application that directly or
3
+ * indirectly (through green-react or green-angular) use the Green Core web components.
4
+ *
5
+ * The config includes the following:
6
+ * - `transformIgnorePatterns` to ignore transforming certain Green and Lit files
7
+ * - `setupFilesAfterEnv` that mocks some browser APIs that are used by the web components
8
+ */
9
+
10
+ module.exports = {
11
+ apply: (config) => {
12
+ config.transformIgnorePatterns = [
13
+ ...(config.transformIgnorePatterns || []),
14
+ 'node_modules/(?!.*.mjs$|@sebgroup/green-react|@sebgroup/extract|@sebgroup/green-core|lit-element|lit-html|lit|@lit|@lit-labs/)',
15
+ ]
16
+
17
+ config.setupFilesAfterEnv = [
18
+ ...(config.setupFilesAfterEnv || []),
19
+ __dirname + '/setup-jest.js',
20
+ ]
21
+
22
+ return config
23
+ },
24
+ }