@govtechsg/sgds-web-component 0.0.8 → 0.0.11

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 (91) hide show
  1. package/Button/index.js +304 -39
  2. package/Button/index.js.map +1 -1
  3. package/Button/sgds-button.d.ts +29 -4
  4. package/Card/index.d.ts +1 -0
  5. package/Card/index.js +6150 -0
  6. package/Card/index.js.map +1 -0
  7. package/Card/package.json +7 -0
  8. package/Card/sgds-action-card.d.ts +20 -0
  9. package/Checkbox/index.d.ts +1 -0
  10. package/Checkbox/index.js +6366 -0
  11. package/Checkbox/index.js.map +1 -0
  12. package/Checkbox/package.json +7 -0
  13. package/Checkbox/sgds-checkbox.d.ts +36 -0
  14. package/Dropdown/index.d.ts +3 -0
  15. package/Dropdown/index.js +13502 -0
  16. package/Dropdown/index.js.map +1 -0
  17. package/Dropdown/package.json +7 -0
  18. package/Dropdown/sgds-dropdown-item.d.ts +7 -0
  19. package/Dropdown/sgds-dropdown.d.ts +7 -0
  20. package/Footer/index.js +111 -95
  21. package/Footer/index.js.map +1 -1
  22. package/Footer/sgds-footer.d.ts +2 -2
  23. package/Input/index.d.ts +1 -0
  24. package/Input/index.js +6656 -0
  25. package/Input/index.js.map +1 -0
  26. package/Input/package.json +7 -0
  27. package/Input/sgds-input.d.ts +42 -0
  28. package/Mainnav/index.d.ts +1 -0
  29. package/Mainnav/index.js +14755 -2188
  30. package/Mainnav/index.js.map +1 -1
  31. package/Mainnav/sgds-mainnav-dropdown.d.ts +5 -0
  32. package/Mainnav/sgds-mainnav-item.d.ts +2 -5
  33. package/Mainnav/sgds-mainnav.d.ts +2 -2
  34. package/Masthead/index.js +140 -114
  35. package/Masthead/index.js.map +1 -1
  36. package/Masthead/sgds-masthead.d.ts +1 -1
  37. package/Modal/index.d.ts +1 -0
  38. package/Modal/index.js +6432 -0
  39. package/Modal/index.js.map +1 -0
  40. package/Modal/package.json +7 -0
  41. package/Modal/sgds-modal.d.ts +28 -0
  42. package/QuantityToggle/index.d.ts +1 -0
  43. package/QuantityToggle/index.js +7049 -0
  44. package/QuantityToggle/index.js.map +1 -0
  45. package/QuantityToggle/package.json +7 -0
  46. package/QuantityToggle/sgds-quantitytoggle.d.ts +30 -0
  47. package/Radio/index.d.ts +2 -0
  48. package/Radio/index.js +12607 -0
  49. package/Radio/index.js.map +1 -0
  50. package/Radio/package.json +7 -0
  51. package/Radio/sgds-radio.d.ts +31 -0
  52. package/Radio/sgds-radiogroup.d.ts +41 -0
  53. package/Sidenav/index.js +2266 -2171
  54. package/Sidenav/index.js.map +1 -1
  55. package/Sidenav/sgds-sidenav-item.d.ts +2 -1
  56. package/Sidenav/sgds-sidenav-link.d.ts +2 -5
  57. package/Sidenav/sgds-sidenav.d.ts +1 -1
  58. package/Tab/index.d.ts +3 -0
  59. package/Tab/index.js +13557 -0
  60. package/Tab/index.js.map +1 -0
  61. package/Tab/package.json +7 -0
  62. package/Tab/sgds-tab.d.ts +26 -0
  63. package/Tab/sgds-tabgroup.d.ts +47 -0
  64. package/Tab/sgds-tabpanel.d.ts +25 -0
  65. package/Textarea/index.d.ts +1 -0
  66. package/Textarea/index.js +6696 -0
  67. package/Textarea/index.js.map +1 -0
  68. package/Textarea/package.json +7 -0
  69. package/Textarea/sgds-textarea.d.ts +53 -0
  70. package/index.d.ts +16 -5
  71. package/index.js +100191 -17701
  72. package/index.js.map +1 -1
  73. package/package.json +2 -4
  74. package/umd/index.js +96696 -14206
  75. package/umd/index.js.map +1 -1
  76. package/utils/animate.d.ts +10 -0
  77. package/utils/animation-registry.d.ts +18 -0
  78. package/utils/card-element.d.ts +11 -0
  79. package/utils/defaultvalue.d.ts +2 -0
  80. package/utils/dropdown-element.d.ts +37 -0
  81. package/utils/event.d.ts +2 -0
  82. package/utils/form.d.ts +38 -0
  83. package/utils/link-element.d.ts +7 -0
  84. package/utils/mergeDeep.d.ts +2 -0
  85. package/utils/modal.d.ts +12 -0
  86. package/utils/object.d.ts +2 -0
  87. package/utils/offset.d.ts +4 -0
  88. package/utils/scroll.d.ts +13 -0
  89. package/utils/slot.d.ts +22 -0
  90. package/utils/tabbable.d.ts +8 -0
  91. package/utils/watch.d.ts +14 -0
@@ -0,0 +1,10 @@
1
+ export declare function animateTo(el: HTMLElement, keyframes: Keyframe[], options?: KeyframeAnimationOptions): Promise<unknown>;
2
+ export declare function parseDuration(delay: number | string): number;
3
+ export declare function prefersReducedMotion(): boolean;
4
+ export declare function stopAnimations(el: HTMLElement): Promise<unknown[]>;
5
+ export declare function shimKeyframesHeightAuto(keyframes: Keyframe[], calculatedHeight: number): {
6
+ height: string | number;
7
+ composite?: CompositeOperationOrAuto;
8
+ easing?: string;
9
+ offset?: number;
10
+ }[];
@@ -0,0 +1,18 @@
1
+ export interface ElementAnimation {
2
+ keyframes: Keyframe[];
3
+ rtlKeyframes?: Keyframe[];
4
+ options?: KeyframeAnimationOptions;
5
+ }
6
+ export interface ElementAnimationMap {
7
+ [animationName: string]: ElementAnimation;
8
+ }
9
+ export interface GetAnimationOptions {
10
+ /**
11
+ * The component's directionality. When set to "rtl", `rtlKeyframes` will be preferred over `keyframes` where
12
+ * available using getAnimation().
13
+ */
14
+ dir: string;
15
+ }
16
+ export declare function setDefaultAnimation(animationName: string, animation: ElementAnimation | null): void;
17
+ export declare function setAnimation(el: Element, animationName: string, animation: ElementAnimation | null): void;
18
+ export declare function getAnimation(el: Element, animationName: string): ElementAnimation;
@@ -0,0 +1,11 @@
1
+ import SgdsElement from "./sgds-element";
2
+ export type Variant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light" | string;
3
+ export type Color = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light" | "white" | "muted";
4
+ export declare class CardElement extends SgdsElement {
5
+ borderColor?: Variant;
6
+ /** The bg's variant. */
7
+ bgColor?: Variant;
8
+ /** The text's variant. */
9
+ textColor?: Color;
10
+ disabled: boolean;
11
+ }
@@ -0,0 +1,2 @@
1
+ import type { ReactiveElement } from 'lit';
2
+ export declare const defaultValue: (propertyName?: string) => (proto: ReactiveElement, key: string) => void;
@@ -0,0 +1,37 @@
1
+ import { Dropdown } from "bootstrap";
2
+ import * as Popper from "@popperjs/core";
3
+ import type { StrictModifiers } from "@popperjs/core";
4
+ import { Ref } from "lit/directives/ref.js";
5
+ import { SgdsDropdownItem } from "../Dropdown/sgds-dropdown-item";
6
+ import SgdsElement from "./sgds-element";
7
+ export type DropdownButtonVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
8
+ export type DropDirection = "left" | "right" | "up" | "down";
9
+ export declare class DropdownElement extends SgdsElement {
10
+ myDropdown: Ref<HTMLElement>;
11
+ bsDropdown: Dropdown;
12
+ noFlip: boolean;
13
+ menuAlignRight: boolean;
14
+ drop: DropDirection;
15
+ popperOpts: {};
16
+ togglerId: string;
17
+ togglerText: string;
18
+ variant: DropdownButtonVariant;
19
+ menuIsOpen: boolean;
20
+ close: "outside" | "default" | "inside";
21
+ disabled: boolean;
22
+ nextDropdownItemNo: number;
23
+ prevDropdownItemNo: number;
24
+ dropdownConfig: Partial<Popper.Options>;
25
+ modifierOpt: StrictModifiers[];
26
+ firstUpdated(): void;
27
+ showMenu(): void;
28
+ hideMenu(): void;
29
+ _onClickButton(): void;
30
+ _resetMenu(): void;
31
+ _getMenuItems(): SgdsDropdownItem[];
32
+ _getActiveMenuItems(): SgdsDropdownItem[];
33
+ _setMenuItem(currentItemIdx: number, isArrowDown?: boolean): any;
34
+ _handleSelectSlot(e: KeyboardEvent | MouseEvent): void;
35
+ _handleKeyboardEvent(e: KeyboardEvent): any;
36
+ _handleClickOutOfElement(e: MouseEvent, self: DropdownElement): void;
37
+ }
@@ -0,0 +1,2 @@
1
+ /** Waits for a specific event to be emitted from an element. Ignores events that bubble up from child elements. */
2
+ export declare function waitForEvent(el: HTMLElement, eventName: string): Promise<void>;
@@ -0,0 +1,38 @@
1
+ import type SgdsButton from '../Button/sgds-button';
2
+ import type { ReactiveController, ReactiveControllerHost } from 'lit';
3
+ export interface FormSubmitControllerOptions {
4
+ /** A function that returns the form containing the form control. */
5
+ form: (input: unknown) => HTMLFormElement | null;
6
+ /** A function that returns the form control's name, which will be submitted with the form data. */
7
+ name: (input: unknown) => string;
8
+ /** A function that returns the form control's current value. */
9
+ value: (input: unknown) => unknown | unknown[];
10
+ /** A function that returns the form control's default value. */
11
+ defaultValue: (input: unknown) => unknown | unknown[];
12
+ /** A function that returns the form control's current disabled state. If disabled, the value won't be submitted. */
13
+ disabled: (input: unknown) => boolean;
14
+ /**
15
+ * A function that maps to the form control's reportValidity() function. When the control is invalid, this will
16
+ * prevent submission and trigger the browser's constraint violation warning.
17
+ */
18
+ reportValidity: (input: unknown) => boolean;
19
+ /** A function that sets the form control's value */
20
+ setValue: (input: unknown, value: unknown) => void;
21
+ }
22
+ export declare class FormSubmitController implements ReactiveController {
23
+ host?: ReactiveControllerHost & Element;
24
+ form?: HTMLFormElement | null;
25
+ options: FormSubmitControllerOptions;
26
+ constructor(host: ReactiveControllerHost & Element, options?: Partial<FormSubmitControllerOptions>);
27
+ hostConnected(): void;
28
+ hostDisconnected(): void;
29
+ handleFormData(event: FormDataEvent): void;
30
+ handleFormSubmit(event: Event): void;
31
+ handleFormReset(): void;
32
+ reportFormValidity(): boolean;
33
+ doAction(type: 'submit' | 'reset', invoker?: HTMLInputElement | SgdsButton): void;
34
+ /** Resets the form, restoring all the control to their default value */
35
+ reset(invoker?: HTMLInputElement | SgdsButton): void;
36
+ /** Submits the form, triggering validation and form data injection. */
37
+ submit(invoker?: HTMLInputElement | SgdsButton): void;
38
+ }
@@ -0,0 +1,7 @@
1
+ import SgdsElement from "../utils/sgds-element";
2
+ export default class LinkElement extends SgdsElement {
3
+ active: boolean;
4
+ href: string;
5
+ disabled: boolean;
6
+ render(): import("lit").TemplateResult<1>;
7
+ }
@@ -0,0 +1,2 @@
1
+ declare const mergeDeep: (target: any, source: any) => any;
2
+ export default mergeDeep;
@@ -0,0 +1,12 @@
1
+ export default class Modal {
2
+ element: HTMLElement;
3
+ tabDirection: 'forward' | 'backward';
4
+ constructor(element: HTMLElement);
5
+ activate(): void;
6
+ deactivate(): void;
7
+ isActive(): boolean;
8
+ checkFocus(): void;
9
+ handleFocusIn(): void;
10
+ handleKeyDown(event: KeyboardEvent): void;
11
+ handleKeyUp(): void;
12
+ }
@@ -0,0 +1,2 @@
1
+ export declare const assign: (target: any, ...args: any[]) => any;
2
+ export declare const keys: (obj: any) => string[];
@@ -0,0 +1,4 @@
1
+ export declare function getOffset(element: HTMLElement, parent: HTMLElement): {
2
+ top: number;
3
+ left: number;
4
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Prevents body scrolling. Keeps track of which elements requested a lock so multiple levels of locking are possible
3
+ * without premature unlocking.
4
+ */
5
+ export declare function lockBodyScrolling(lockingEl: HTMLElement): void;
6
+ /**
7
+ * Unlocks body scrolling. Scrolling will only be unlocked once all elements that requested a lock call this method.
8
+ */
9
+ export declare function unlockBodyScrolling(lockingEl: HTMLElement): void;
10
+ /**
11
+ * Scrolls an element into view of its container. If the element is already in view, nothing will happen.
12
+ */
13
+ export declare function scrollIntoView(element: HTMLElement, container: HTMLElement, direction?: 'horizontal' | 'vertical' | 'both', behavior?: 'smooth' | 'auto'): void;
@@ -0,0 +1,22 @@
1
+ import type { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ export declare class HasSlotController implements ReactiveController {
3
+ host: ReactiveControllerHost & Element;
4
+ slotNames: string[];
5
+ constructor(host: ReactiveControllerHost & Element, ...slotNames: string[]);
6
+ private hasDefaultSlot;
7
+ private hasNamedSlot;
8
+ test(slotName: string): boolean;
9
+ hostConnected(): void;
10
+ hostDisconnected(): void;
11
+ handleSlotChange(event: Event): void;
12
+ }
13
+ /**
14
+ * Given a slot, this function iterates over all of its assigned element and text nodes and returns the concatenated
15
+ * HTML as a string. This is useful because we can't use slot.innerHTML as an alternative.
16
+ */
17
+ export declare function getInnerHTML(slot: HTMLSlotElement): string;
18
+ /**
19
+ * Given a slot, this function iterates over all of its assigned text nodes and returns the concatenated text as a
20
+ * string. This is useful because we can't use slot.textContent as an alternative.
21
+ */
22
+ export declare function getTextContent(slot: HTMLSlotElement | undefined | null): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns the first and last bounding elements that are tabbable. This is more performant than checking every single
3
+ * element because it short-circuits after finding the first and last ones.
4
+ */
5
+ export declare function getTabbableBoundary(root: HTMLElement | ShadowRoot): {
6
+ start: HTMLElement;
7
+ end: HTMLElement;
8
+ };
@@ -0,0 +1,14 @@
1
+ import type { LitElement } from "lit";
2
+ type UpdateHandler = (prev?: unknown, next?: unknown) => void;
3
+ type NonUndefined<A> = A extends undefined ? never : A;
4
+ type UpdateHandlerFunctionKeys<T extends object> = {
5
+ [K in keyof T]-?: NonUndefined<T[K]> extends UpdateHandler ? K : never;
6
+ }[keyof T];
7
+ interface WatchOptions {
8
+ /**
9
+ * If true, will only start watching after the initial update/render
10
+ */
11
+ waitUntilFirstUpdate?: boolean;
12
+ }
13
+ export declare function watch(propName: string, options?: WatchOptions): <ElemClass extends LitElement>(proto: ElemClass, decoratedFnName: UpdateHandlerFunctionKeys<ElemClass>) => void;
14
+ export {};