@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.
Files changed (35) hide show
  1. package/README.md +151 -0
  2. package/components/dropdown/dropdown.d.ts +72 -0
  3. package/components/dropdown/dropdown.styles.d.ts +2 -0
  4. package/components/dropdown/dropdown.trans.styles.d.ts +2 -0
  5. package/components/form-control.d.ts +36 -0
  6. package/components/index.d.ts +2 -0
  7. package/generated/locale-codes.d.ts +13 -0
  8. package/generated/locales/sv.d.ts +5 -0
  9. package/index.d.ts +2 -0
  10. package/index.js +1065 -0
  11. package/localization.d.ts +1 -0
  12. package/localization.js +44 -0
  13. package/package.json +43 -0
  14. package/primitives/listbox/index.d.ts +2 -0
  15. package/primitives/listbox/listbox.d.ts +53 -0
  16. package/primitives/listbox/listbox.styles.d.ts +2 -0
  17. package/primitives/listbox/listbox.trans.styles.d.ts +2 -0
  18. package/primitives/listbox/option.d.ts +59 -0
  19. package/primitives/listbox/option.styles.d.ts +2 -0
  20. package/primitives/popover/index.d.ts +1 -0
  21. package/primitives/popover/popover.d.ts +31 -0
  22. package/primitives/popover/popover.styles.d.ts +2 -0
  23. package/primitives/popover/popover.trans.styles.d.ts +2 -0
  24. package/transitional-styles.d.ts +1 -0
  25. package/transitional-styles.js +5711 -0
  26. package/utils/decorators/index.d.ts +2 -0
  27. package/utils/decorators/observe-light-dom.d.ts +7 -0
  28. package/utils/decorators/watch.d.ts +23 -0
  29. package/utils/helpers/constrain-slots.d.ts +17 -0
  30. package/utils/helpers/custom-element-scoping.d.ts +97 -0
  31. package/utils/helpers/id.d.ts +4 -0
  32. package/utils/helpers/index.d.ts +2 -0
  33. package/utils/helpers/transitional-styles.d.ts +12 -0
  34. package/utils/localization.d.ts +5 -0
  35. package/utils/testing/index.d.ts +30 -0
@@ -0,0 +1 @@
1
+ export * from './utils/localization';
@@ -0,0 +1,44 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // libs/core/src/utils/localization.ts
8
+ import { configureLocalization } from "@lit/localize";
9
+
10
+ // libs/core/src/generated/locale-codes.ts
11
+ var sourceLocale = `en`;
12
+ var targetLocales = [
13
+ `sv`
14
+ ];
15
+
16
+ // libs/core/src/generated/locales/sv.ts
17
+ var sv_exports = {};
18
+ __export(sv_exports, {
19
+ templates: () => templates
20
+ });
21
+ import { str } from "@lit/localize";
22
+ var templates = {
23
+ "s58bfb494feb8eb02": str`${0} valda`,
24
+ "s5d929ff1619ac0c9": `S\xF6k`,
25
+ "sd898d99fd9c13de6": `S\xF6k i listan av val`
26
+ };
27
+
28
+ // libs/core/src/utils/localization.ts
29
+ var localizedTemplates = /* @__PURE__ */ new Map([["sv", sv_exports]]);
30
+ var { getLocale, setLocale } = configureLocalization({
31
+ sourceLocale,
32
+ targetLocales,
33
+ loadLocale: async (locale) => {
34
+ const localModule = localizedTemplates.get(locale);
35
+ if (localModule) {
36
+ return localModule;
37
+ }
38
+ return Promise.reject(new Error(`Locale ${locale} not found`));
39
+ }
40
+ });
41
+ export {
42
+ getLocale,
43
+ setLocale
44
+ };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@sebgroup/green-core",
3
+ "description": "A carefully crafted set of Web Components, laying the foundation of the Green Design System.",
4
+ "version": "1.0.0-beta.10",
5
+ "main": "index.js",
6
+ "module": "index.js",
7
+ "type": "module",
8
+ "author": "SEB Open Source <opensource@seb.se> (https://github.com/sebgroup)",
9
+ "contributors": [],
10
+ "license": "Apache-2.0",
11
+ "bugs": {
12
+ "url": "https://github.com/sebgroup/green/"
13
+ },
14
+ "homepage": "https://sebgroup.github.io/green/latest/core/",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/sebgroup/green.git"
18
+ },
19
+ "publishConfig": {
20
+ "registry": "https://registry.npmjs.org/",
21
+ "access": "public"
22
+ },
23
+ "dependencies": {
24
+ "@floating-ui/dom": "^1.5.3",
25
+ "@lit/localize": "^0.11.4",
26
+ "lit": "^2.8.0",
27
+ "reflect-metadata": "^0.1.13"
28
+ },
29
+ "exports": {
30
+ ".": {
31
+ "types": "./index.d.ts",
32
+ "default": "./index.js"
33
+ },
34
+ "./transitional-styles": {
35
+ "types": "./transitional-styles.d.ts",
36
+ "default": "./transitional-styles.js"
37
+ },
38
+ "./localization": {
39
+ "types": "./localization.d.ts",
40
+ "default": "./localization.js"
41
+ }
42
+ }
43
+ }
@@ -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';