@govtechsg/sgds-web-component 0.0.7 → 0.0.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/.github/workflows/publish-latest.yml +22 -0
- package/.github/workflows/publish-pr.yml +28 -0
- package/.husky/commit-msg +4 -0
- package/.husky/prepare-commit-msg +8 -0
- package/.storybook/main.js +16 -0
- package/.storybook/preview-head.html +11 -0
- package/.storybook/preview.js +9 -0
- package/.vscode/settings.json +7 -0
- package/CONTRIBUTING.md +56 -0
- package/LICENSE +20 -0
- package/amplify.yml +22 -0
- package/commitlint.config.js +1 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/button-element.scss.html +112 -0
- package/coverage/lcov-report/button-element.ts.html +145 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +116 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +32 -0
- package/index.html +430 -0
- package/{Button → lib/Button}/index.d.ts +0 -0
- package/{Button → lib/Button}/index.js +304 -39
- package/lib/Button/index.js.map +1 -0
- package/{Button → lib/Button}/package.json +0 -0
- package/lib/Button/sgds-button.d.ts +48 -0
- package/lib/Card/index.d.ts +1 -0
- package/lib/Card/index.js +6150 -0
- package/lib/Card/index.js.map +1 -0
- package/lib/Card/package.json +7 -0
- package/lib/Card/sgds-action-card.d.ts +20 -0
- package/lib/Checkbox/index.d.ts +1 -0
- package/lib/Checkbox/index.js +6366 -0
- package/lib/Checkbox/index.js.map +1 -0
- package/lib/Checkbox/package.json +7 -0
- package/lib/Checkbox/sgds-checkbox.d.ts +36 -0
- package/lib/Dropdown/index.d.ts +3 -0
- package/{Mainnav → lib/Dropdown}/index.js +2786 -9258
- package/lib/Dropdown/index.js.map +1 -0
- package/lib/Dropdown/package.json +7 -0
- package/lib/Dropdown/sgds-dropdown-item.d.ts +7 -0
- package/lib/Dropdown/sgds-dropdown.d.ts +7 -0
- package/{Footer → lib/Footer}/index.d.ts +0 -0
- package/{Footer → lib/Footer}/index.js +111 -95
- package/lib/Footer/index.js.map +1 -0
- package/{Footer → lib/Footer}/package.json +0 -0
- package/{Footer → lib/Footer}/sgds-footer.d.ts +2 -2
- package/lib/Input/index.d.ts +1 -0
- package/lib/Input/index.js +6656 -0
- package/lib/Input/index.js.map +1 -0
- package/lib/Input/package.json +7 -0
- package/lib/Input/sgds-input.d.ts +42 -0
- package/{Mainnav → lib/Mainnav}/index.d.ts +1 -0
- package/{index.js → lib/Mainnav/index.js} +3876 -23415
- package/lib/Mainnav/index.js.map +1 -0
- package/{Mainnav → lib/Mainnav}/package.json +0 -0
- package/lib/Mainnav/sgds-mainnav-dropdown.d.ts +5 -0
- package/lib/Mainnav/sgds-mainnav-item.d.ts +4 -0
- package/{Mainnav → lib/Mainnav}/sgds-mainnav.d.ts +3 -2
- package/{Masthead → lib/Masthead}/index.d.ts +0 -0
- package/{Masthead → lib/Masthead}/index.js +140 -114
- package/lib/Masthead/index.js.map +1 -0
- package/{Masthead → lib/Masthead}/package.json +0 -0
- package/{Masthead → lib/Masthead}/sgds-masthead.d.ts +1 -1
- package/lib/Modal/index.d.ts +1 -0
- package/lib/Modal/index.js +6432 -0
- package/lib/Modal/index.js.map +1 -0
- package/lib/Modal/package.json +7 -0
- package/lib/Modal/sgds-modal.d.ts +28 -0
- package/lib/QuantityToggle/index.d.ts +1 -0
- package/lib/QuantityToggle/index.js +7049 -0
- package/lib/QuantityToggle/index.js.map +1 -0
- package/lib/QuantityToggle/package.json +7 -0
- package/lib/QuantityToggle/sgds-quantitytoggle.d.ts +30 -0
- package/lib/Radio/index.d.ts +2 -0
- package/lib/Radio/index.js +12607 -0
- package/lib/Radio/index.js.map +1 -0
- package/lib/Radio/package.json +7 -0
- package/lib/Radio/sgds-radio.d.ts +31 -0
- package/lib/Radio/sgds-radiogroup.d.ts +41 -0
- package/{Sidenav → lib/Sidenav}/index.d.ts +0 -0
- package/{Sidenav → lib/Sidenav}/index.js +2266 -2171
- package/lib/Sidenav/index.js.map +1 -0
- package/{Sidenav → lib/Sidenav}/package.json +0 -0
- package/{Sidenav → lib/Sidenav}/sgds-sidenav-item.d.ts +2 -1
- package/lib/Sidenav/sgds-sidenav-link.d.ts +4 -0
- package/{Sidenav → lib/Sidenav}/sgds-sidenav.d.ts +1 -1
- package/lib/Tab/index.d.ts +3 -0
- package/lib/Tab/index.js +13557 -0
- package/lib/Tab/index.js.map +1 -0
- package/lib/Tab/package.json +7 -0
- package/lib/Tab/sgds-tab.d.ts +26 -0
- package/lib/Tab/sgds-tabgroup.d.ts +47 -0
- package/lib/Tab/sgds-tabpanel.d.ts +25 -0
- package/lib/Textarea/index.d.ts +1 -0
- package/lib/Textarea/index.js +6696 -0
- package/lib/Textarea/index.js.map +1 -0
- package/lib/Textarea/package.json +7 -0
- package/lib/Textarea/sgds-textarea.d.ts +53 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +134580 -0
- package/lib/index.js.map +1 -0
- package/lib/umd/index.js +134587 -0
- package/lib/umd/index.js.map +1 -0
- package/lib/utils/animate.d.ts +10 -0
- package/lib/utils/animation-registry.d.ts +18 -0
- package/{utils → lib/utils}/breakpoints.d.ts +0 -0
- package/lib/utils/card-element.d.ts +11 -0
- package/lib/utils/defaultvalue.d.ts +2 -0
- package/lib/utils/dropdown-element.d.ts +37 -0
- package/lib/utils/event.d.ts +2 -0
- package/lib/utils/form.d.ts +38 -0
- package/{utils → lib/utils}/generateId.d.ts +0 -0
- package/lib/utils/link-element.d.ts +7 -0
- package/lib/utils/mergeDeep.d.ts +2 -0
- package/lib/utils/modal.d.ts +12 -0
- package/lib/utils/object.d.ts +2 -0
- package/lib/utils/offset.d.ts +4 -0
- package/lib/utils/scroll.d.ts +13 -0
- package/{utils → lib/utils}/sgds-element.d.ts +0 -0
- package/lib/utils/slot.d.ts +22 -0
- package/lib/utils/tabbable.d.ts +8 -0
- package/lib/utils/watch.d.ts +14 -0
- package/mocks/dropdown.d.ts +4 -0
- package/mocks/dropdown.ts +27 -0
- package/mocks/link.d.ts +3 -0
- package/mocks/link.ts +6 -0
- package/package.json +65 -10
- package/rollup.config.js +73 -0
- package/rollup.test.config.js +42 -0
- package/scripts/buildUtils.js +30 -0
- package/scripts/frankBuild.js +49 -0
- package/src/Button/index.ts +1 -0
- package/src/Button/sgds-button.scss +28 -0
- package/src/Button/sgds-button.ts +153 -0
- package/src/Card/index.ts +1 -0
- package/src/Card/sgds-action-card.scss +27 -0
- package/src/Card/sgds-action-card.ts +115 -0
- package/src/Checkbox/index.ts +1 -0
- package/src/Checkbox/sgds-checkbox.scss +4 -0
- package/src/Checkbox/sgds-checkbox.ts +149 -0
- package/src/Dropdown/index.ts +3 -0
- package/src/Dropdown/sgds-dropdown-item.ts +39 -0
- package/src/Dropdown/sgds-dropdown.scss +5 -0
- package/src/Dropdown/sgds-dropdown.ts +54 -0
- package/src/Footer/index.ts +3 -0
- package/src/Footer/sgds-footer.scss +5 -0
- package/src/Footer/sgds-footer.ts +121 -0
- package/src/Input/index.ts +1 -0
- package/src/Input/sgds-input.scss +20 -0
- package/src/Input/sgds-input.ts +178 -0
- package/src/Mainnav/index.ts +4 -0
- package/src/Mainnav/sgds-mainnav-dropdown.scss +13 -0
- package/src/Mainnav/sgds-mainnav-dropdown.ts +45 -0
- package/src/Mainnav/sgds-mainnav-item.scss +24 -0
- package/src/Mainnav/sgds-mainnav-item.ts +8 -0
- package/src/Mainnav/sgds-mainnav.scss +39 -0
- package/src/Mainnav/sgds-mainnav.ts +183 -0
- package/src/Masthead/index.ts +1 -0
- package/src/Masthead/sgds-masthead.scss +217 -0
- package/src/Masthead/sgds-masthead.ts +189 -0
- package/src/Modal/index.ts +1 -0
- package/src/Modal/sgds-modal.scss +128 -0
- package/src/Modal/sgds-modal.ts +309 -0
- package/src/QuantityToggle/index.ts +1 -0
- package/src/QuantityToggle/sgds-quantitytoggle.scss +10 -0
- package/src/QuantityToggle/sgds-quantitytoggle.ts +130 -0
- package/src/Radio/index.ts +2 -0
- package/src/Radio/sgds-radio.scss +5 -0
- package/src/Radio/sgds-radio.ts +120 -0
- package/src/Radio/sgds-radiogroup.scss +22 -0
- package/src/Radio/sgds-radiogroup.ts +221 -0
- package/src/Sidenav/index.ts +4 -0
- package/src/Sidenav/sgds-sidenav-item.scss +73 -0
- package/src/Sidenav/sgds-sidenav-item.ts +145 -0
- package/src/Sidenav/sgds-sidenav-link.scss +25 -0
- package/src/Sidenav/sgds-sidenav-link.ts +8 -0
- package/src/Sidenav/sgds-sidenav.scss +6 -0
- package/src/Sidenav/sgds-sidenav.ts +33 -0
- package/src/Tab/index.ts +3 -0
- package/src/Tab/sgds-tab.scss +84 -0
- package/src/Tab/sgds-tab.ts +87 -0
- package/src/Tab/sgds-tabgroup.scss +198 -0
- package/src/Tab/sgds-tabgroup.ts +295 -0
- package/src/Tab/sgds-tabpanel.scss +12 -0
- package/src/Tab/sgds-tabpanel.ts +55 -0
- package/src/Textarea/index.ts +1 -0
- package/src/Textarea/sgds-textarea.scss +23 -0
- package/src/Textarea/sgds-textarea.ts +201 -0
- package/src/index.ts +16 -0
- package/src/utils/animate.ts +69 -0
- package/src/utils/animation-registry.ts +71 -0
- package/src/utils/base.scss +14 -0
- package/src/utils/breakpoints.ts +5 -0
- package/src/utils/card-element.ts +42 -0
- package/src/utils/components.style.scss +531 -0
- package/src/utils/defaultvalue.ts +51 -0
- package/src/utils/dropdown-element.ts +244 -0
- package/src/utils/event.ts +13 -0
- package/src/utils/form.ts +183 -0
- package/src/utils/generateId.ts +4 -0
- package/src/utils/link-element.ts +34 -0
- package/src/utils/mergeDeep.ts +22 -0
- package/src/utils/modal.ts +64 -0
- package/src/utils/object.ts +2 -0
- package/src/utils/offset.ts +6 -0
- package/src/utils/scroll.ts +57 -0
- package/src/utils/sgds-element.ts +18 -0
- package/src/utils/slot.ts +102 -0
- package/src/utils/tabbable.ts +81 -0
- package/src/utils/watch.ts +62 -0
- package/stories/ActionCard.stories.mdx +199 -0
- package/stories/Button.stories.mdx +194 -0
- package/stories/Checkbox.stories.mdx +196 -0
- package/stories/Dropdown.stories.mdx +152 -0
- package/stories/Footer.stories.mdx +261 -0
- package/stories/Input.stories.mdx +236 -0
- package/stories/MainNav.stories.mdx +169 -0
- package/stories/Masthead.stories.mdx +112 -0
- package/stories/Modal.stories.mdx +103 -0
- package/stories/QuantityToggle.stories.mdx +97 -0
- package/stories/Radio.stories.mdx +262 -0
- package/stories/Sample.stories.js +29 -0
- package/stories/Sample.stories.mdx +33 -0
- package/stories/SideNav.stories.mdx +245 -0
- package/stories/common.js +185 -0
- package/stories/textarea.stories.mdx +253 -0
- package/test/button.element.test.ts +185 -0
- package/test/checkbox.test.ts +240 -0
- package/test/dropdown.test.ts +637 -0
- package/test/footer.test.ts +181 -0
- package/test/generateId.test.ts +18 -0
- package/test/input.element.test.ts +316 -0
- package/test/link-element.test.ts +38 -0
- package/test/mainnav.test.ts +313 -0
- package/test/masthead.test.ts +116 -0
- package/test/modal.test.ts +149 -0
- package/test/quantitytoggle.test.ts +76 -0
- package/test/radio.test.ts +310 -0
- package/test/selectable-card.test.ts +159 -0
- package/test/sidenav.test.ts +390 -0
- package/test/tab.test.ts +76 -0
- package/test/textarea.test.ts +126 -0
- package/tsconfig.json +26 -0
- package/tsconfig.test.json +24 -0
- package/typings/scss.d.ts +5 -0
- package/web-dev-server.config.mjs +7 -0
- package/web-test-runner.config.mjs +47 -0
- package/Button/index.js.map +0 -1
- package/Button/sgds-button.d.ts +0 -23
- package/Footer/index.js.map +0 -1
- package/Mainnav/index.js.map +0 -1
- package/Mainnav/sgds-mainnav-item.d.ts +0 -7
- package/Masthead/index.js.map +0 -1
- package/Sidenav/index.js.map +0 -1
- package/Sidenav/sgds-sidenav-link.d.ts +0 -7
- package/index.d.ts +0 -5
- package/index.js.map +0 -1
- package/umd/index.js +0 -52092
- package/umd/index.js.map +0 -1
|
@@ -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;
|
|
File without changes
|
|
@@ -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,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,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
|
+
}
|
|
File without changes
|
|
@@ -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,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;
|
|
File without changes
|
|
@@ -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 {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
import { customElement } from "lit/decorators.js";
|
|
3
|
+
import { ref } from "lit/directives/ref.js";
|
|
4
|
+
import { DropdownElement } from "../src/utils/dropdown-element";
|
|
5
|
+
|
|
6
|
+
@customElement("mock-dropdown")
|
|
7
|
+
export class MockDropdown extends DropdownElement {
|
|
8
|
+
render() {
|
|
9
|
+
return html`
|
|
10
|
+
<div>
|
|
11
|
+
<button
|
|
12
|
+
variant="outline-${this.variant}"
|
|
13
|
+
?disabled=${this.disabled}
|
|
14
|
+
aria-expanded="${this.menuIsOpen}"
|
|
15
|
+
${ref(this.myDropdown)}
|
|
16
|
+
@click=${() => this._onClickButton()}
|
|
17
|
+
id=${this.togglerId}
|
|
18
|
+
>
|
|
19
|
+
Mock Dropdown
|
|
20
|
+
</button>
|
|
21
|
+
<ul class="dropdown-menu" role="menu" part="menu">
|
|
22
|
+
<slot @click=${this._handleSelectSlot}></slot>
|
|
23
|
+
</ul>
|
|
24
|
+
</div>
|
|
25
|
+
`;
|
|
26
|
+
}
|
|
27
|
+
}
|
package/mocks/link.d.ts
ADDED
package/mocks/link.ts
ADDED
package/package.json
CHANGED
|
@@ -1,23 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@govtechsg/sgds-web-component",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "
|
|
7
|
-
"typings": "
|
|
5
|
+
"main": "lib/umd/index.js",
|
|
6
|
+
"module": "lib/index.js",
|
|
7
|
+
"typings": "lib/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "rm -rf lib && rollup --config rollup.config.js",
|
|
10
|
+
"post:build": "node ./scripts/frankBuild.js",
|
|
11
|
+
"build:lib": "npm run build && npm run post:build",
|
|
12
|
+
"build:watch": "npm run build -- --watch",
|
|
13
|
+
"dev": "npm run build:watch & npm run serve",
|
|
14
|
+
"serve": "wds --watch --open",
|
|
15
|
+
"test": "rm -rf test-outdir && rollup --config rollup.test.config.js && web-test-runner",
|
|
16
|
+
"storybook": "npm run build && start-storybook -p 6006",
|
|
17
|
+
"build-storybook": "rm -rf lib && npm run build && build-storybook",
|
|
18
|
+
"prepare": "husky install"
|
|
19
|
+
},
|
|
8
20
|
"author": "",
|
|
9
21
|
"license": "MIT",
|
|
10
22
|
"dependencies": {
|
|
11
|
-
"@govtechsg/sgds": "^2.1.
|
|
23
|
+
"@govtechsg/sgds": "^2.1.1",
|
|
12
24
|
"bootstrap": "^5.1.3",
|
|
13
|
-
"bootstrap-icons": "^1.9.1",
|
|
14
|
-
"clk-styletest": "^2.0.9",
|
|
15
25
|
"lit": "^2.3.1"
|
|
16
26
|
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@babel/core": "^7.18.13",
|
|
29
|
+
"@commitlint/cli": "^17.1.2",
|
|
30
|
+
"@commitlint/config-conventional": "^17.1.0",
|
|
31
|
+
"@esm-bundle/chai": "^4.3.4-fix.0",
|
|
32
|
+
"@open-wc/storybook": "^0.2.8",
|
|
33
|
+
"@open-wc/testing": "^3.0.0-next.5",
|
|
34
|
+
"@playwright/test": "^1.27.0",
|
|
35
|
+
"@rollup/plugin-node-resolve": "^11.2.1",
|
|
36
|
+
"@rollup/plugin-replace": "^5.0.0",
|
|
37
|
+
"@shoelace-style/shoelace": "^2.0.0-beta.83",
|
|
38
|
+
"@storybook/addon-actions": "^6.5.16",
|
|
39
|
+
"@storybook/addon-docs": "^6.5.16",
|
|
40
|
+
"@storybook/addon-essentials": "^6.5.16",
|
|
41
|
+
"@storybook/addon-controls": "^6.5.16",
|
|
42
|
+
"@storybook/addon-links": "^6.5.16",
|
|
43
|
+
"@storybook/builder-webpack5": "^6.5.16",
|
|
44
|
+
"@storybook/manager-webpack5": "^6.5.16",
|
|
45
|
+
"@storybook/preset-scss": "^1.0.3",
|
|
46
|
+
"@storybook/web-components": "^6.5.16",
|
|
47
|
+
"@types/bootstrap": "^5.2.4",
|
|
48
|
+
"@web/dev-server": "^0.1.17",
|
|
49
|
+
"@web/dev-server-esbuild": "^0.3.2",
|
|
50
|
+
"@web/dev-server-rollup": "^0.3.19",
|
|
51
|
+
"@web/dev-server-storybook": "^0.5.4",
|
|
52
|
+
"@web/test-runner": "^0.14.0",
|
|
53
|
+
"@web/test-runner-commands": "^0.6.5",
|
|
54
|
+
"@web/test-runner-playwright": "^0.8.10",
|
|
55
|
+
"autoprefixer": "^10.4.8",
|
|
56
|
+
"babel-loader": "^8.2.5",
|
|
57
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
58
|
+
"esbuild-sass-plugin": "^2.3.2",
|
|
59
|
+
"husky": "^8.0.0",
|
|
60
|
+
"postcss": "^8.2.13",
|
|
61
|
+
"rollup": "^2.46.0",
|
|
62
|
+
"rollup-plugin-generate-package-json": "^3.2.0",
|
|
63
|
+
"rollup-plugin-postcss": "^4.0.0",
|
|
64
|
+
"rollup-plugin-postcss-lit": "^1.0.1",
|
|
65
|
+
"rollup-plugin-typescript2": "^0.33.0",
|
|
66
|
+
"sass": "^1.54.4",
|
|
67
|
+
"sass-loader": "^13.0.2",
|
|
68
|
+
"sinon": "^14.0.0",
|
|
69
|
+
"storybook-addon-web-components-knobs": "^0.3.20",
|
|
70
|
+
"tslib": "^2.4.0",
|
|
71
|
+
"typescript": "^4.2.4"
|
|
72
|
+
},
|
|
17
73
|
"config": {
|
|
18
74
|
"commitizen": {
|
|
19
75
|
"path": "./node_modules/cz-conventional-changelog"
|
|
20
76
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
}
|
|
77
|
+
}
|
|
78
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import typescript from "rollup-plugin-typescript2";
|
|
2
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
3
|
+
import postcss from "rollup-plugin-postcss";
|
|
4
|
+
import litcss from "rollup-plugin-postcss-lit";
|
|
5
|
+
const packageJson = require("./package.json");
|
|
6
|
+
import { getFolders } from './scripts/buildUtils';
|
|
7
|
+
import generatePackageJson from 'rollup-plugin-generate-package-json';
|
|
8
|
+
import replace from '@rollup/plugin-replace';
|
|
9
|
+
|
|
10
|
+
const plugins = [
|
|
11
|
+
resolve({
|
|
12
|
+
browser: true,
|
|
13
|
+
}),
|
|
14
|
+
replace({
|
|
15
|
+
'process.env.NODE_ENV': JSON.stringify("production"),
|
|
16
|
+
preventAssignment: true
|
|
17
|
+
}),
|
|
18
|
+
postcss({
|
|
19
|
+
minimize: false,
|
|
20
|
+
inject: false,
|
|
21
|
+
}),
|
|
22
|
+
litcss(),
|
|
23
|
+
typescript({
|
|
24
|
+
useTsconfigDeclarationDir: true,
|
|
25
|
+
}),
|
|
26
|
+
]
|
|
27
|
+
const subfolderPlugins = (folderName) => [
|
|
28
|
+
...plugins,
|
|
29
|
+
generatePackageJson({
|
|
30
|
+
baseContents: {
|
|
31
|
+
name: `${packageJson.name}/${folderName}`,
|
|
32
|
+
private: true,
|
|
33
|
+
main: '../umd/index.js',
|
|
34
|
+
module: './index.js',
|
|
35
|
+
types: './index.d.ts',
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
];
|
|
39
|
+
const folderBuilds = getFolders('./src').map((folder) => {
|
|
40
|
+
return {
|
|
41
|
+
input: `src/${folder}/index.ts`,
|
|
42
|
+
output: [
|
|
43
|
+
{
|
|
44
|
+
file: `lib/${folder}/index.js`,
|
|
45
|
+
sourcemap: true,
|
|
46
|
+
exports: 'named',
|
|
47
|
+
format: 'esm',
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
plugins: subfolderPlugins(folder),
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export default [
|
|
55
|
+
{
|
|
56
|
+
input: "src/index.ts",
|
|
57
|
+
output: [
|
|
58
|
+
{
|
|
59
|
+
file: packageJson.module,
|
|
60
|
+
format: "esm",
|
|
61
|
+
sourcemap: true,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
file: packageJson.main,
|
|
65
|
+
format: "umd",
|
|
66
|
+
sourcemap: true,
|
|
67
|
+
name: "index"
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
plugins
|
|
71
|
+
},
|
|
72
|
+
...folderBuilds
|
|
73
|
+
];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import typescript from "rollup-plugin-typescript2";
|
|
2
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
3
|
+
import postcss from "rollup-plugin-postcss";
|
|
4
|
+
import litcss from "rollup-plugin-postcss-lit";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import replace from '@rollup/plugin-replace';
|
|
7
|
+
const packageJson = require("./package.json");
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
|
|
10
|
+
export const getFiles = (entry, extensions = [], excludeExtensions = []) => {
|
|
11
|
+
const files = fs.readdirSync(entry);
|
|
12
|
+
const filePaths = files.map(fileName => path.join(entry, fileName))
|
|
13
|
+
return filePaths
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default [
|
|
17
|
+
{
|
|
18
|
+
input: getFiles('./test'),
|
|
19
|
+
output: [
|
|
20
|
+
{
|
|
21
|
+
dir: "test-outdir",
|
|
22
|
+
format: 'es'
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
plugins: [
|
|
26
|
+
resolve({
|
|
27
|
+
browser: true,
|
|
28
|
+
}),
|
|
29
|
+
replace({
|
|
30
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
31
|
+
}),
|
|
32
|
+
typescript({
|
|
33
|
+
tsconfig: './tsconfig.test.json'
|
|
34
|
+
}),
|
|
35
|
+
postcss({ // process .scss files
|
|
36
|
+
minimize: false,
|
|
37
|
+
inject: false,
|
|
38
|
+
}),
|
|
39
|
+
litcss(), // process adoptedStylesheets for lit
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
export const getFolders = (entry) => {
|
|
3
|
+
const dirs = fs.readdirSync(entry)
|
|
4
|
+
const dirsWithoutIndex = dirs.filter(name => name !== 'index.ts').filter(name => name !== 'utils')
|
|
5
|
+
return dirsWithoutIndex
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const getFiles = (entry, extensions = [], excludeExtensions = []) => {
|
|
9
|
+
let fileNames = [];
|
|
10
|
+
const dirs = fs.readdirSync(entry);
|
|
11
|
+
dirs.forEach((dir) => {
|
|
12
|
+
const path = `${entry}/${dir}`;
|
|
13
|
+
|
|
14
|
+
if (fs.lstatSync(path).isDirectory()) {
|
|
15
|
+
fileNames = [
|
|
16
|
+
...fileNames,
|
|
17
|
+
...getFiles(path, extensions, excludeExtensions),
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!excludeExtensions.some((exclude) => dir.endsWith(exclude))
|
|
24
|
+
&& extensions.some((ext) => dir.endsWith(ext))
|
|
25
|
+
) {
|
|
26
|
+
fileNames.push(path);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return fileNames;
|
|
30
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
const { resolve, join, basename } = require('path');
|
|
3
|
+
const { readFile, writeFile, copy } = require('fs-extra');
|
|
4
|
+
const packagePath = process.cwd();
|
|
5
|
+
const distPath = join(packagePath, './lib');
|
|
6
|
+
|
|
7
|
+
const writeJson = (targetPath, obj) =>
|
|
8
|
+
writeFile(targetPath, JSON.stringify(obj, null, 2), 'utf8');
|
|
9
|
+
|
|
10
|
+
async function createPackageFile() {
|
|
11
|
+
const packageData = await readFile(
|
|
12
|
+
resolve(packagePath, './package.json'),
|
|
13
|
+
'utf8'
|
|
14
|
+
);
|
|
15
|
+
const { scripts, devDependencies, ...packageOthers } =
|
|
16
|
+
JSON.parse(packageData);
|
|
17
|
+
const newPackageData = {
|
|
18
|
+
...packageOthers,
|
|
19
|
+
private: false,
|
|
20
|
+
typings: './index.d.ts',
|
|
21
|
+
main: './umd/index.js',
|
|
22
|
+
module: './index.js',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const targetPath = resolve(distPath, './package.json');
|
|
26
|
+
|
|
27
|
+
await writeJson(targetPath, newPackageData);
|
|
28
|
+
console.log(`Created package.json in ${targetPath}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function includeFileInBuild(file) {
|
|
32
|
+
const sourcePath = resolve(packagePath, file);
|
|
33
|
+
const targetPath = resolve(distPath, basename(file));
|
|
34
|
+
await copy(sourcePath, targetPath);
|
|
35
|
+
console.log(`Copied ${sourcePath} to ${targetPath}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function run() {
|
|
39
|
+
try {
|
|
40
|
+
await createPackageFile();
|
|
41
|
+
await includeFileInBuild('./README.md');
|
|
42
|
+
// await includeFileInBuild('../../LICENSE');
|
|
43
|
+
} catch (err) {
|
|
44
|
+
console.error(err);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
run();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SgdsButton } from "./sgds-button";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
@import '../utils/base.scss';
|
|
3
|
+
@import "~@govtechsg/sgds/sass/buttons";
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: inline-block;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.btn-icon{
|
|
10
|
+
background: transparent;
|
|
11
|
+
border: 0;
|
|
12
|
+
&:hover{
|
|
13
|
+
background: transparent;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
:host(.button-group_button-first){
|
|
17
|
+
.btn{
|
|
18
|
+
border-start-end-radius: 0;
|
|
19
|
+
border-end-end-radius: 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host(.button-group_button-last){
|
|
24
|
+
.btn{
|
|
25
|
+
border-start-start-radius: 0;
|
|
26
|
+
border-end-start-radius: 0;
|
|
27
|
+
}
|
|
28
|
+
}
|