@sebgroup/green-core 1.0.0-beta.4 → 1.0.0-beta.8

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 ADDED
@@ -0,0 +1,151 @@
1
+ # ![image](https://user-images.githubusercontent.com/11420341/121186039-f6eeda00-c866-11eb-9d80-21d01d065f0a.png) 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,2 @@
1
+ declare const style: import("lit").CSSResult;
2
+ export default style;
@@ -0,0 +1,2 @@
1
+ export declare function register(): void;
2
+ export default register;
@@ -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,2 @@
1
+ export * from './dropdown/dropdown';
2
+ export * from '../primitives/listbox/option';
@@ -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"];
@@ -0,0 +1,5 @@
1
+ export declare const templates: {
2
+ s58bfb494feb8eb02: import("@lit/localize").StrResult;
3
+ s5d929ff1619ac0c9: string;
4
+ sd898d99fd9c13de6: string;
5
+ };
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './utils/helpers/custom-element-scoping';
package/index.js CHANGED
@@ -122,7 +122,7 @@ function observeLightDOM() {
122
122
  // libs/core/src/utils/helpers/custom-element-scoping.ts
123
123
  import { html as litHtml } from "lit";
124
124
  import { customElement } from "lit/decorators.js";
125
- var VER_SUFFIX = "-gdsvsuffix";
125
+ var VER_SUFFIX = "-00499f";
126
126
  var elementLookupTable = /* @__PURE__ */ new Map();
127
127
  var gdsCustomElement = (tagName) => {
128
128
  if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
@@ -0,0 +1 @@
1
+ export * from './utils/localization';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sebgroup/green-core",
3
3
  "description": "A carefully crafted set of Web Components, laying the foundation of the Green Design System.",
4
- "version": "1.0.0-beta.4",
4
+ "version": "1.0.0-beta.8",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
7
7
  "type": "module",
@@ -0,0 +1,2 @@
1
+ export * from './listbox';
2
+ export * from './option';
@@ -0,0 +1,53 @@
1
+ import { LitElement } from 'lit';
2
+ import { GdsOption, OptionsContainer } from './option';
3
+ import 'reflect-metadata';
4
+ /**
5
+ * @element gds-listbox
6
+ * @internal
7
+ *
8
+ * A listbox is a widget that allows the user to select one or more items from a list of choices.
9
+ * This primitive corresponds to the aria listbox role: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role
10
+ *
11
+ * The listbox handles keyboard navigation and manages focus and selection of options.
12
+ *
13
+ * Can be used together with the `gds-option` primitive.
14
+ *
15
+ * @slot - The default slot. Only `gds-option` elements should be used here.
16
+ */
17
+ export declare class GdsListbox extends LitElement implements OptionsContainer {
18
+ #private;
19
+ static styles: import("lit").CSSResult;
20
+ /**
21
+ * Controls whether the listbox allows multiple selection or not.
22
+ */
23
+ multiple: boolean;
24
+ constructor();
25
+ /**
26
+ * Returns a list of all `gds-option` elements in the listbox.
27
+ */
28
+ get options(): GdsOption[];
29
+ /**
30
+ * Returns a list of all visible `gds-option` elements in the listbox.
31
+ */
32
+ get visibleOptionElements(): GdsOption[];
33
+ /**
34
+ * Returns a list of all visible `gds-option` elements in the listbox.
35
+ */
36
+ get visibleSelectedOptionElements(): GdsOption[];
37
+ /**
38
+ * Returns a list of all selected `gds-option` elements in the listbox.
39
+ */
40
+ get selection(): GdsOption[];
41
+ set selection(values: GdsOption[] | any[]);
42
+ connectedCallback(): void;
43
+ /**
44
+ * Focuses the first selected option in the listbox.
45
+ * If no option is selected, the first visible option is focused.
46
+ */
47
+ focus(): void;
48
+ render(): any;
49
+ /**
50
+ * Re-renders all options in the listbox when the `multiple` property changes.
51
+ */
52
+ private _rerenderOptions;
53
+ }
@@ -0,0 +1,2 @@
1
+ declare const style: import("lit").CSSResult;
2
+ export default style;
@@ -0,0 +1,2 @@
1
+ export declare function register(): void;
2
+ export default register;
@@ -0,0 +1,59 @@
1
+ import { LitElement } from 'lit';
2
+ import 'reflect-metadata';
3
+ export interface OptionsContainer extends HTMLElement {
4
+ options: GdsOption[];
5
+ multiple: boolean;
6
+ }
7
+ /**
8
+ * @element gds-option
9
+ * @internal
10
+ *
11
+ * A listbox option is an option in a listbox widget.
12
+ * This primitive corresponds to the aria `option` role: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/option_role
13
+ *
14
+ * Can be used together with the `gds-listbox` primitive.
15
+ *
16
+ * @slot - The default slot. Custom content can be used to display the option.
17
+ *
18
+ * @event gds-select - Fired when the option is selected.
19
+ * @event gds-blur - Fired when the option loses focus.
20
+ * @event gds-focus - Fired when the option gains focus.
21
+ */
22
+ export declare class GdsOption extends LitElement {
23
+ #private;
24
+ static styles: import("lit").CSSResult;
25
+ /**
26
+ * The value of the option.
27
+ */
28
+ value: any;
29
+ /**
30
+ * Controls whether the option is visible or not.
31
+ */
32
+ get hidden(): boolean;
33
+ set hidden(value: string | boolean);
34
+ /**
35
+ * Returns true if the option is selected.
36
+ * Setting this property will select or unselect the option.
37
+ */
38
+ selected: boolean;
39
+ /**
40
+ * Sets this option as a placeholder.
41
+ * A placehodler option does not have a value and will act as the default option.
42
+ *
43
+ * In a multiple select listbox, placeholder options will not be rendered in the list.
44
+ */
45
+ isPlaceholder: boolean;
46
+ constructor();
47
+ connectedCallback(): void;
48
+ get parentElement(): OptionsContainer;
49
+ handlePlaceholderStatusChange(): void;
50
+ /**
51
+ * Focuses the option.
52
+ *
53
+ * @param options - Focus options
54
+ */
55
+ focus(options?: FocusOptions | undefined): void;
56
+ onblur: (e: FocusEvent) => void;
57
+ onfocus: (e: FocusEvent) => void;
58
+ render(): import("lit-html").TemplateResult<1>;
59
+ }
@@ -0,0 +1,2 @@
1
+ declare const style: import("lit").CSSResult;
2
+ export default style;
@@ -0,0 +1 @@
1
+ export * from './popover';
@@ -0,0 +1,31 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * @element gds-popover
4
+ * @internal
5
+ *
6
+ * A popover is a transient view that appears above other content. It is used by components such as dropdowns.
7
+ *
8
+ * GdsPopover can be supplied with a trigger through the `trigger` property. If a trigger is specified, the popover will
9
+ * register a keydown listener on the trigger and listen to `ArrowDown` key presses. When the trigger is focused and
10
+ * `ArrowDown` is pressed, the popover will open and focus the first slotted child.
11
+ *
12
+ * @slot - Content of the popover
13
+ * @fires gds-ui-state - Fired when the popover is opened or closed
14
+ */
15
+ export declare class GdsPopover extends LitElement {
16
+ #private;
17
+ static styles: import("lit").CSSResult;
18
+ /**
19
+ * Whether the popover is open.
20
+ */
21
+ open: boolean;
22
+ /**
23
+ * Optional trigger element for the popover.
24
+ */
25
+ trigger: HTMLElement | undefined;
26
+ private _handleTriggerChanged;
27
+ connectedCallback(): void;
28
+ disconnectedCallback(): void;
29
+ render(): import("lit-html").TemplateResult<1>;
30
+ private _updateHidden;
31
+ }
@@ -0,0 +1,2 @@
1
+ declare const style: import("lit").CSSResult;
2
+ export default style;
@@ -0,0 +1,2 @@
1
+ export declare function register(): void;
2
+ export default register;
@@ -0,0 +1 @@
1
+ export * from './utils/helpers/transitional-styles';
@@ -0,0 +1,2 @@
1
+ export * from './watch';
2
+ export * from './observe-light-dom';
@@ -0,0 +1,7 @@
1
+ import type { LitElement } from 'lit';
2
+ declare type Handler = () => void;
3
+ /**
4
+ * Runs when the light DOM children of the component changes.
5
+ */
6
+ export declare function observeLightDOM(): <ElemClass extends LitElement>(proto: ElemClass, _propertyKey: string, descriptor: TypedPropertyDescriptor<Handler>) => void;
7
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { LitElement } from 'lit';
2
+ declare type UpdateHandler = (prev?: unknown, next?: unknown) => void;
3
+ interface WatchOptions {
4
+ /**
5
+ * If true, will only start watching after the initial update/render
6
+ */
7
+ waitUntilFirstUpdate?: boolean;
8
+ }
9
+ /**
10
+ * Runs when observed properties change, e.g. @property or @state, but before the component updates. To wait for an
11
+ * update to complete after a change occurs, use `await this.updateComplete` in the handler. To start watching after the
12
+ * initial update/render, use `{ waitUntilFirstUpdate: true }` or `this.hasUpdated` in the handler.
13
+ *
14
+ * Usage:
15
+ * ```javascript
16
+ * \@watch('propName')
17
+ * handlePropChange(oldValue, newValue) {
18
+ * ...
19
+ * }
20
+ * ```
21
+ */
22
+ export declare function watch(propertyName: string | string[], options?: WatchOptions): <ElemClass extends LitElement>(proto: ElemClass, propertyKey: string, descriptor: TypedPropertyDescriptor<UpdateHandler>) => void;
23
+ export {};
@@ -0,0 +1,17 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * This function is used to constrain the slots of a component to only allow
4
+ * certain types of slotted elements. Add the `gds-allow` attribute to the slot
5
+ * element and specify the allowed elements as a space-separated list. Slots
6
+ * without the `gds-allow` attribute will not be constrained.
7
+ *
8
+ * Example:
9
+ * ```html
10
+ * <slot gds-allow="span p"></slot>
11
+ * ```
12
+ * This will only allow `span` and `p` elements to be slotted into this slot. Any other
13
+ * elements will be removed from the shadow DOM.
14
+ *
15
+ * @param self The element to apply the slot constraints to
16
+ */
17
+ export declare function constrainSlots(self: LitElement): void;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * # Custom element scoping
3
+ *
4
+ * One problem with the current state of the Custom Elements standard is that there is
5
+ * only a single, global, `CustomElementRegistry`. This means that if you have two different
6
+ * libraries, or two different versions of the same library, that both define a custom
7
+ * element with the same name, only one of them will be registered, and the other will
8
+ * throw an error.
9
+ *
10
+ * This is a problem for Green, because we need it to work well in a microfrontend
11
+ * architecture, where multiple apps can be loaded on the same page, and each app can
12
+ * potentially have its own version of Green.
13
+ *
14
+ * There is a (proposal)[https://github.com/WICG/webcomponents/blob/gh-pages/proposals/Scoped-Custom-Element-Registries.md]
15
+ * for enabling user instantiated CustomElementRegistry scoped to a ShodowRoot, but as of
16
+ * mid 2023 this is still only available in Chrome canary behind experimental flags.
17
+ *
18
+ * ## Solution
19
+ *
20
+ * To get around the problem we define our own scoping mechanism. It will works like this:
21
+ *
22
+ * * Green Core has its own lookup table of custom elements, and a suffix is added to the
23
+ * name of each custom element. For example, `gds-popover` becomes `gds-popover-<versionstring>`.
24
+ * The version string is deterministically generated based on the version of the Green
25
+ * Core package.
26
+ *
27
+ * * We also define a new `customElement` decorator that will be used to register custom
28
+ * elements. `@gdsCustomElement` will automatically add the version suffix to the name of
29
+ * the custom element, and register it in the lookup table. If the custom element is already
30
+ * registered, it will abort silently, with the assumption that the custom element was
31
+ * already registered by the same version of Green Core and is therefor compatible.
32
+ *
33
+ * * There is also a custom `html` template tag that will automatically rewrite all custom
34
+ * element names from the lookup table to include the version suffix, before passing the
35
+ * template on to the Lit `html` tag. Alternatively, a templte tag factory can be used
36
+ * to create a custom `html` tag, if Lit is not used by the consumer
37
+ *
38
+ * ## Caveats
39
+ *
40
+ * Consumers using top-level components from Green Core will have to add the version suffix
41
+ * in some way. The React and Angular wrappers takes care of this automatically. Another way
42
+ * is to use the `html` template tag or template tag factory from Green Core, but it will only
43
+ * work if the consumer is using javascript template literals.
44
+ *
45
+ * If the consumer is using hard coded HTML, or a templating language that does not support
46
+ * template tags, the consumer will have to manually add the version suffix to the custom
47
+ * element names, which would be cumbersome. In this edge-case, the scoping feature can be disabled,
48
+ * and the consumer will have to make sure that only a single version of Green Core is used
49
+ * on the page.
50
+ *
51
+ * The recommendation is to only consume Green Core though the React or Angular wrappers, or to
52
+ * use the `html` template tag or template tag factory from Green Core.
53
+ *
54
+ * At some point in the future, when the scoped custom element registry proposal has been
55
+ * implemented in all major browsers, we might remove this custom scoping mechanism and
56
+ * switch to using native scoped registries instead.
57
+ */
58
+ /**
59
+ * Class decorator factory that defines the decorated class as a custom element, and registers
60
+ * it with the custom element registry under a versioned name.
61
+ *
62
+ * ```js
63
+ * @gdsCustomElement('my-element')
64
+ * class MyElement extends LitElement {
65
+ * render() {
66
+ * return html``;
67
+ * }
68
+ * }
69
+ * ```
70
+ * @category Decorator
71
+ * @param tagName The tag name of the custom element to define.
72
+ */
73
+ export declare const gdsCustomElement: (tagName: string) => (classOrDescriptor: {
74
+ prototype: HTMLElement;
75
+ } | import("@lit/reactive-element/decorators/base").ClassDescriptor) => any;
76
+ /**
77
+ * Template tag factory that creates a new template tag, which rewrites all custom element names from the
78
+ * lookup table to include the version suffix, and then passes the template on to the provided template tag.
79
+ */
80
+ export declare function htmlTemplateTagFactory(extendedTag: (strings: TemplateStringsArray, ...values: any[]) => any): (strings: TemplateStringsArray, ...values: any[]) => any;
81
+ /**
82
+ * Template tag that rewrites all custom element names from the lookup table to include the
83
+ * version suffix, before passing the template on to the Lit `html` tag.
84
+ */
85
+ export declare const html: (strings: TemplateStringsArray, ...values: any[]) => any;
86
+ /**
87
+ * Returns the correctly scoped tag name for the given tag.
88
+ * @param tagName The tag name to scope
89
+ */
90
+ export declare function getScopedTagName(tagName: string): string;
91
+ /**
92
+ * Returns the unscoped tag name for the given scoped tag.
93
+ * @param tagName The scoped tag name to unscope
94
+ */
95
+ export declare function getUnscopedTagName(tagName: string): string | undefined;
96
+ declare const _default: {};
97
+ export default _default;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Generate a random id with `gds-` prefix
3
+ */
4
+ export declare const randomId: () => string;
@@ -0,0 +1,2 @@
1
+ export * from './constrain-slots';
2
+ export * from './id';
@@ -0,0 +1,12 @@
1
+ export declare const registerTransitionalStyles: () => void;
2
+ declare global {
3
+ var __gdsTransitionalStyles: TransitionalStyles;
4
+ }
5
+ export declare class TransitionalStyles {
6
+ static get instance(): TransitionalStyles;
7
+ private sheets;
8
+ private elements;
9
+ apply(element: HTMLElement, styleKey: string): void;
10
+ applyToElement(styleKey: string, sheet: CSSStyleSheet): void;
11
+ register(name: string, styles: string): void;
12
+ }
@@ -0,0 +1,5 @@
1
+ export declare const getLocale: (() => string) & {
2
+ _LIT_LOCALIZE_GET_LOCALE_?: undefined;
3
+ }, setLocale: ((newLocale: string) => Promise<void>) & {
4
+ _LIT_LOCALIZE_SET_LOCALE_?: undefined;
5
+ };
@@ -0,0 +1,30 @@
1
+ /** A testing utility that measures an element's position and clicks on it. */
2
+ export declare function clickOnElement(
3
+ /** The element to click */
4
+ el: Element,
5
+ /** The location of the element to click */
6
+ position?: 'top' | 'right' | 'bottom' | 'left' | 'center',
7
+ /** The horizontal offset to apply to the position when clicking */
8
+ offsetX?: number,
9
+ /** The vertical offset to apply to the position when clicking */
10
+ offsetY?: number): Promise<void>;
11
+ /** A testing utility that moves the mouse onto an element. */
12
+ export declare function moveMouseOnElement(
13
+ /** The element to click */
14
+ el: Element,
15
+ /** The location of the element to click */
16
+ position?: 'top' | 'right' | 'bottom' | 'left' | 'center',
17
+ /** The horizontal offset to apply to the position when clicking */
18
+ offsetX?: number,
19
+ /** The vertical offset to apply to the position when clicking */
20
+ offsetY?: number): Promise<void>;
21
+ /** A testing utility that drags an element with the mouse. */
22
+ export declare function dragElement(
23
+ /** The element to drag */
24
+ el: Element,
25
+ /** The horizontal distance to drag in pixels */
26
+ deltaX?: number,
27
+ /** The vertical distance to drag in pixels */
28
+ deltaY?: number): Promise<void>;
29
+ /** A testing utility that waits for a specified amount of time. */
30
+ export declare function timeout(ms: number): Promise<unknown>;