@sebgroup/green-core 1.0.0-beta.10
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 +151 -0
- package/components/dropdown/dropdown.d.ts +72 -0
- package/components/dropdown/dropdown.styles.d.ts +2 -0
- package/components/dropdown/dropdown.trans.styles.d.ts +2 -0
- package/components/form-control.d.ts +36 -0
- package/components/index.d.ts +2 -0
- package/generated/locale-codes.d.ts +13 -0
- package/generated/locales/sv.d.ts +5 -0
- package/index.d.ts +2 -0
- package/index.js +1065 -0
- package/localization.d.ts +1 -0
- package/localization.js +44 -0
- package/package.json +43 -0
- package/primitives/listbox/index.d.ts +2 -0
- package/primitives/listbox/listbox.d.ts +53 -0
- package/primitives/listbox/listbox.styles.d.ts +2 -0
- package/primitives/listbox/listbox.trans.styles.d.ts +2 -0
- package/primitives/listbox/option.d.ts +59 -0
- package/primitives/listbox/option.styles.d.ts +2 -0
- package/primitives/popover/index.d.ts +1 -0
- package/primitives/popover/popover.d.ts +31 -0
- package/primitives/popover/popover.styles.d.ts +2 -0
- package/primitives/popover/popover.trans.styles.d.ts +2 -0
- package/transitional-styles.d.ts +1 -0
- package/transitional-styles.js +5711 -0
- package/utils/decorators/index.d.ts +2 -0
- package/utils/decorators/observe-light-dom.d.ts +7 -0
- package/utils/decorators/watch.d.ts +23 -0
- package/utils/helpers/constrain-slots.d.ts +17 -0
- package/utils/helpers/custom-element-scoping.d.ts +97 -0
- package/utils/helpers/id.d.ts +4 -0
- package/utils/helpers/index.d.ts +2 -0
- package/utils/helpers/transitional-styles.d.ts +12 -0
- package/utils/localization.d.ts +5 -0
- package/utils/testing/index.d.ts +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#  green
|
|
2
|
+
|
|
3
|
+
Green is an opinionated design system for building content and functionality for SEB. It builds on a set of principles and techniques aimed at maximizing code quality, code reuse, consistency and collaboration.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## View
|
|
7
|
+
|
|
8
|
+
View the components in our [Storybook](https://sebgroup.github.io/green/latest/chlorophyll/)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Philosophy
|
|
12
|
+
|
|
13
|
+
Dream big! Start small! Learn fast!
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### We only build what we need
|
|
17
|
+
|
|
18
|
+
If no-one needs a component, we will not build it. If someone needs a component, we will build it. This means that some things in Design Library might not make it into Green. It all depends on what gets used.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Ease of use, not ease of build
|
|
22
|
+
|
|
23
|
+
The components of Green will be used more times than one. This puts a multiplier on the value of every hour spent improving ease of use.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Minimum possible flexibility, but _not_ less
|
|
27
|
+
|
|
28
|
+
Flexibility means decisions must be made. This puts strain on every user of a system. Green goes the other way: Minimum flexibility, maximum clarity. If our users cannot do what they need, we solve that specific problem in a generalized way - no more, no less. Remember: The most flexible system possible is your terminal.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### We don't solve problems we do not have
|
|
32
|
+
|
|
33
|
+
If something _might_ be a performance problem, that is ok. If something _might_ give a to large payload, that is ok. When we suspect a problem, we measure it. If it _is_ a problem, we fix it. See [premature optimization](https://xkcd.com/1691/)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### We work from right to left
|
|
37
|
+
|
|
38
|
+
If something can be deployed, we deploy. Then, if a PR needs a review, we review. Then, and only then, if something can be built, we build. Flow is more important than speed.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## The design process
|
|
42
|
+
|
|
43
|
+
Green is tightly integrated with the design process. The design responsible are part of the team so that decisions can be made effectively and by those most suited.
|
|
44
|
+
|
|
45
|
+
For the most part we follow the existing design. When changes have to be made for practical reasons, clarity, uniformity, accessibility or any other reason, the design responsible make the call and the change is integrated.
|
|
46
|
+
|
|
47
|
+
This can, and will, lead to minor inconsistencies in different parts of our offering, especially as Green is not yet (even close to) at 100% adoption. This is fine. Far larger inconsistencies already exist in our current, digital ecosystem. We therefore prioritise the ability to keep moving forward and improve our customers' experience over delaying for the sake of consistency.
|
|
48
|
+
|
|
49
|
+
In the long run, consistency will be achieved by automating the roll-out of changes, be they visual, functional or qualitative, to keep all parts of our offering on the latest version. When we go Green, we stay green.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Develop
|
|
53
|
+
|
|
54
|
+
### Yarn
|
|
55
|
+
|
|
56
|
+
This mono repo is based on `nx` and uses `yarn` instead of `npm`. If you are unused to yarn, see the following instructions:
|
|
57
|
+
|
|
58
|
+
#### Install yarn
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install yarn -g
|
|
62
|
+
```
|
|
63
|
+
Use the -g flag to install it globally on your computer.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
#### Install dependencies
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
yarn
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Add a dependency to a workspace
|
|
73
|
+
|
|
74
|
+
All projects use a common set of dependencies so if you want to add `leftpad` to the chlorophyll project, just run:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
yarn add leftpad
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Run a command in `package.json`
|
|
81
|
+
|
|
82
|
+
Unlike `npm`, `yarn` doesn't require the `run` command. So if you want to run `lint` in your package or in the project root, simply type:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
yarn lint
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### How to contribute?
|
|
89
|
+
|
|
90
|
+
- Clone the project locally from GitHub - `git clone https://github.com/sebgroup/green.git`.
|
|
91
|
+
- Create a new branch each time - `git checkout -b "DESCRIPTIVE NAME"`.
|
|
92
|
+
- Commit with the Semantic everything inscructions underneath.
|
|
93
|
+
- Pull the latest - `git pull`.
|
|
94
|
+
- Push eveything - `git push`.
|
|
95
|
+
- Make a pull request in GitHub - `https://github.com/sebgroup/green/compare`.
|
|
96
|
+
|
|
97
|
+
### Semantic everything
|
|
98
|
+
|
|
99
|
+
All projects in Green use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) to power [semantic releases](https://semantic-release.gitbook.io/semantic-release/). In order to simplify using this format, install:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm install git-cz -g
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
To commit, just run `git-cz` in the terminal. Always try to add reference to an issue in the longer description with # and the issue number. Eg `#1337`.
|
|
106
|
+
|
|
107
|
+
### Start Storybook
|
|
108
|
+
|
|
109
|
+
You start the common storybooks with these commands:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
npx nx run chlorophyll:storybook
|
|
113
|
+
npx nx run react:storybook
|
|
114
|
+
npx nx run angular:storybook
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Or the general `npx nx run [PROJECT]:storybook` where you replace `[PROJECT]` with a folder name from `green\libs`.
|
|
118
|
+
|
|
119
|
+
If you install nx globally you can omit the npx above.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm install nx -g
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### Build
|
|
126
|
+
|
|
127
|
+
If you want to build the files to see how the output looks use `build-storybook`:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npx nx run chlorophyll:build-storybook
|
|
131
|
+
npx nx run react:build-storybook
|
|
132
|
+
npx nx run angular:build-storybook
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### On SEB Windows computer
|
|
136
|
+
|
|
137
|
+
For the moment, `yarn` is difficult to use within the SEB environment, so instead you can install the dependencies using `npm`:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
$ npm i --force
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The `--force` flag is necessary in this case to convince `npm` that sub-dependency conflicts are OK.
|
|
144
|
+
|
|
145
|
+
Don't commit the generated `package-lock.json` file, since we already have a `yarn.lock` file.
|
|
146
|
+
|
|
147
|
+
If you need to add a new dependency, the `yarn.lock` file needs to be updated, and in that case you still need to use `yarn`. You can do this by temporarily disconnecting from the SEB network, or by using a non-SEB computer.
|
|
148
|
+
|
|
149
|
+
## Git
|
|
150
|
+
|
|
151
|
+
We reccommend using [GitHub Desktop](https://desktop.github.com/), as it will work smoothly with both on-prem GitHub and external GitHub without any manual configuration of proxies and certificates. Ask for help on Teams if you need assistance!
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import 'primitives/listbox';
|
|
3
|
+
import type { GdsOption, OptionsContainer } from 'primitives/listbox';
|
|
4
|
+
import 'primitives/popover';
|
|
5
|
+
import { GdsFormControlElement } from '../form-control';
|
|
6
|
+
/**
|
|
7
|
+
* @element gds-dropdown
|
|
8
|
+
* A dropdown consist of a trigger button and a list of selectable options. It is used to select a single value from a list of options.
|
|
9
|
+
*
|
|
10
|
+
* @status beta
|
|
11
|
+
*
|
|
12
|
+
* @slot - Options for the dropdown. Accepts `gds-option` elements.
|
|
13
|
+
* @slot button - The trigger button for the dropdown. Custom content for the button can be assigned through this slot.
|
|
14
|
+
* @slot sub-label - Renders between the label and the trigger button.
|
|
15
|
+
* @slot message - Renders below the trigger button. Will be red if there is a validation error.
|
|
16
|
+
*
|
|
17
|
+
* @event change - Fired when the value of the dropdown is changed through user interaction (not when value prop is set programatically).
|
|
18
|
+
* @event gds-ui-state - Fired when the dropdown is opened or closed.
|
|
19
|
+
*/
|
|
20
|
+
export declare class GdsDropdown<ValueT = any> extends GdsFormControlElement<ValueT | ValueT[]> implements OptionsContainer {
|
|
21
|
+
#private;
|
|
22
|
+
static styles: import("lit").CSSResult;
|
|
23
|
+
static shadowRootOptions: ShadowRootInit;
|
|
24
|
+
/**
|
|
25
|
+
* The label of the dropdown.
|
|
26
|
+
* Will only render if this property is set to a non-empty string.
|
|
27
|
+
*/
|
|
28
|
+
label: string;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the open state of the dropdown.
|
|
31
|
+
*/
|
|
32
|
+
open: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the dropdown should be searchable.
|
|
35
|
+
*/
|
|
36
|
+
searchable: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Wheter the dropdown should support multiple selections.
|
|
39
|
+
* When set to true, the dropdown will render a checkbox next to each option.
|
|
40
|
+
* The value of the dropdown will be an array of the selected values.
|
|
41
|
+
*/
|
|
42
|
+
multiple: boolean;
|
|
43
|
+
constructor();
|
|
44
|
+
connectedCallback(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Get the options of the dropdown.
|
|
47
|
+
*/
|
|
48
|
+
get options(): GdsOption[];
|
|
49
|
+
/**
|
|
50
|
+
* Return the first option with a isPlaceholder attribute.
|
|
51
|
+
* If no placeholder is found, this will be undefined.
|
|
52
|
+
*/
|
|
53
|
+
get placeholder(): GdsOption | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the display value as a string.
|
|
56
|
+
* If the dropdown is in multiple mode, this will be a comma separated list of the selected values.
|
|
57
|
+
*/
|
|
58
|
+
get displayValue(): string;
|
|
59
|
+
render(): any;
|
|
60
|
+
/**
|
|
61
|
+
* Update value assignment and request update when the light DOM changes.
|
|
62
|
+
*/
|
|
63
|
+
private _handleLightDOMChange;
|
|
64
|
+
/**
|
|
65
|
+
* Called whenever the `value` property changes
|
|
66
|
+
*/
|
|
67
|
+
private _handleValueChange;
|
|
68
|
+
/**
|
|
69
|
+
* Emits `gds-ui-state`event and does some other house-keeping when the open state changes.
|
|
70
|
+
*/
|
|
71
|
+
private _onOpenChange;
|
|
72
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for Green Core form controls.
|
|
4
|
+
*
|
|
5
|
+
* This class sets up the form-associated custom element API, along with some
|
|
6
|
+
* other common form control functionality that all Green Core form controls share.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class GdsFormControlElement<ValueT = any> extends LitElement implements Partial<Omit<HTMLInputElement, 'value'>> {
|
|
11
|
+
#private;
|
|
12
|
+
static formAssociated: boolean;
|
|
13
|
+
constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Validation state of the form control. Setting this to true triggers the invalid state of the control.
|
|
16
|
+
*
|
|
17
|
+
* @attr aria-invalid
|
|
18
|
+
*/
|
|
19
|
+
invalid: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get or set the value of the form control.
|
|
22
|
+
*/
|
|
23
|
+
value: ValueT | undefined;
|
|
24
|
+
name: string;
|
|
25
|
+
get form(): HTMLFormElement | null;
|
|
26
|
+
get type(): string;
|
|
27
|
+
get validity(): ValidityState;
|
|
28
|
+
get validationMessage(): string;
|
|
29
|
+
get willValidate(): boolean;
|
|
30
|
+
checkValidity(): boolean;
|
|
31
|
+
reportValidity(): boolean;
|
|
32
|
+
connectedCallback(): void;
|
|
33
|
+
disconnectedCallback(): void;
|
|
34
|
+
private __handleValidityChange;
|
|
35
|
+
private __handleValueChange;
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The locale code that templates in this source code are written in.
|
|
3
|
+
*/
|
|
4
|
+
export declare const sourceLocale = "en";
|
|
5
|
+
/**
|
|
6
|
+
* The other locale codes that this application is localized into. Sorted
|
|
7
|
+
* lexicographically.
|
|
8
|
+
*/
|
|
9
|
+
export declare const targetLocales: readonly ["sv"];
|
|
10
|
+
/**
|
|
11
|
+
* All valid project locale codes. Sorted lexicographically.
|
|
12
|
+
*/
|
|
13
|
+
export declare const allLocales: readonly ["en", "sv"];
|
package/index.d.ts
ADDED