@govtechsg/sgds-web-component 0.0.13 → 1.0.0-rc.0

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.
@@ -3,10 +3,10 @@ export type CardBorderVariant = "primary" | "secondary" | "success" | "danger" |
3
3
  export type CardTextVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light" | "white" | "muted";
4
4
  export declare class CardElement extends SgdsElement {
5
5
  static styles: import("lit").CSSResultGroup;
6
- borderColor?: CardBorderVariant;
6
+ /** The border's variant. */
7
+ borderColor: CardBorderVariant;
7
8
  /** The bg's variant. */
8
- bgColor?: CardBorderVariant;
9
+ bgColor: CardBorderVariant;
9
10
  /** The text's variant. */
10
- textColor?: CardTextVariant;
11
- disabled: boolean;
11
+ textColor: CardTextVariant;
12
12
  }
@@ -26,8 +26,8 @@ export declare class DropdownElement extends SgdsElement {
26
26
  drop: DropDirection;
27
27
  /** Additional configuration to pass to Popper.js. See https://popper.js.org/ for config opts */
28
28
  popperOpts: {};
29
- /** Forwards value to id attribute of toggle button of Dropdown. An unique id generated by default */
30
- togglerId: string;
29
+ /** @internal Forwards value to id attribute of toggle button of Dropdown. An unique id generated by default */
30
+ protected togglerId: string;
31
31
  /** Sets the text content of Dropdown button */
32
32
  togglerText: string;
33
33
  /** Sets color of Dropdown button */
@@ -1,20 +1,48 @@
1
1
  import { Ref } from "lit/directives/ref.js";
2
2
  import { CardElement } from "../../base/card-element";
3
- export type CardVariant = "card-action" | "card-action-quantity-toggle";
3
+ import { SgdsCheckbox } from "../Checkbox";
4
+ import { SgdsRadio } from "../Radio";
4
5
  export type TypeVariant = "checkbox" | "radio";
6
+ /**
7
+ * @summary Action Card are cards with built in checkbox or radio components. The ref of input is extended to the Card's body.
8
+ * @slot icon - Icon content in the card-subtitile
9
+ * @slot card-subtitle - The subtitle of the card
10
+ * @slot card-title - The title of the card
11
+ * @slot card-text - The paragrapher text of the card
12
+ *
13
+ * @event sgds-change - Emitted when the checked state of card's checkbox changes or when the selected card's radio has changed
14
+ *
15
+ * @csspart base - The action card base wrapper
16
+ * @csspart body - The action card body
17
+ * @csspart subtitle - The action card subtitle
18
+ * @csspart title - The action card title
19
+ * @csspart text - The action card text
20
+ *
21
+ */
5
22
  export declare class SgdsActionCard extends CardElement {
6
23
  static styles: import("lit").CSSResultGroup[];
7
24
  /** @internal */
8
- inputRef: Ref<HTMLInputElement>;
9
- type?: TypeVariant;
10
- /** Use on actionable cards like SelectableCard and Quantity Toggle Card' */
11
- variant: CardVariant;
12
- /** The card's subtitle iconName. */
13
- iconName?: string;
14
- /** The input's id. */
15
- inputId?: string;
25
+ inputRef: Ref<SgdsCheckbox | SgdsRadio>;
26
+ /** Name of the HTML form control. Submitted with the form as part of a name/value pair. */
27
+ name: string;
28
+ /** Value of the HTML form control. Primarily used to differentiate a list of related checkboxes that have the same name. */
29
+ value: string;
30
+ /** Disables the input (so the user can't check / uncheck it). */
31
+ disabled: boolean;
32
+ /** Draws the input in a checked state. */
33
+ checked: boolean;
34
+ /** The type of input of the action card */
35
+ type: TypeVariant;
36
+ /** Controls the active styling of the action card */
16
37
  active: boolean;
17
- onInputChange(): void;
38
+ /** Simulates a click on the input control*/
39
+ click(): void;
40
+ /** @internal Declare the click event listener*/
41
+ handleInputChange(): Promise<void>;
42
+ /** @internal The input's id. */
43
+ private inputId;
44
+ handleRadioCheckedChange(): Promise<void>;
45
+ handleDisabledChange(): Promise<void>;
18
46
  handleKeyDown(event: KeyboardEvent): void;
19
47
  render(): import("lit").TemplateResult;
20
48
  }
@@ -0,0 +1 @@
1
+ export * from "./sgds-card";
@@ -0,0 +1,24 @@
1
+ import { CardElement } from "../../base/card-element";
2
+ /**
3
+ * @summary Cards can be used for headers and footers, a wide variety of content, contain contextual background colors and images.
4
+ * @slot card-title - The title of the card
5
+ * @slot card-text - The paragrapher text of the card
6
+ * @slot card-image - Accepts an image or svg element of the card. Only a single element is allowed to be passed in.
7
+ * @slot card-link - Accepts an anchor element. Only a single element is allowed to be passed in.
8
+ *
9
+ *
10
+ * @csspart base - The card base wrapper
11
+ * @csspart body - The card body
12
+ * @csspart title - The card title
13
+ * @csspart text - The card text
14
+ *
15
+ */
16
+ export declare class SgdsCard extends CardElement {
17
+ static styles: import("lit").CSSResultGroup;
18
+ /** Extends the link passed in slot[name="link"] to the entire card */
19
+ stretchedLink: boolean;
20
+ handleLinkSlotChange(e: Event): void;
21
+ handleImgSlotChange(e: Event): void;
22
+ render(): import("lit").TemplateResult<1>;
23
+ }
24
+ export default SgdsCard;
@@ -5,7 +5,7 @@ import { SgdsFormControl } from "../../utils/form";
5
5
  *
6
6
  * @slot default - The label of checkbox.
7
7
  *
8
- * @event sgds-change - Emitted when the radio group's selected value changes.
8
+ * @event sgds-change - Emitted when the checked state changes.
9
9
  */
10
10
  export declare class SgdsCheckbox extends SgdsElement implements SgdsFormControl {
11
11
  static styles: import("lit").CSSResultGroup[];
@@ -15,8 +15,6 @@ export declare class SgdsCheckbox extends SgdsElement implements SgdsFormControl
15
15
  private readonly formSubmitController;
16
16
  /** Name of the HTML form control. Submitted with the form as part of a name/value pair. */
17
17
  name: string;
18
- /** For Id/For pair of the HTML form control and label. */
19
- checkboxId: string;
20
18
  /** For aria-label when there is no appropriate text label visible */
21
19
  ariaLabel: string;
22
20
  /** Value of the HTML form control. Primarily used to differentiate a list of related checkboxes that have the same name. */
@@ -37,6 +35,8 @@ export declare class SgdsCheckbox extends SgdsElement implements SgdsFormControl
37
35
  valid: boolean;
38
36
  /** @internal */
39
37
  invalid: boolean;
38
+ /** @internal For Id/For pair of the HTML form control and label. */
39
+ private inputId;
40
40
  /** Simulates a click on the checkbox. */
41
41
  click(): void;
42
42
  /** Sets focus on the checkbox. */
@@ -1 +1 @@
1
- export { SgdsFileUpload } from "./sgds-fileupload";
1
+ export { SgdsFileUpload } from "./sgds-file-upload";
@@ -0,0 +1,44 @@
1
+ import SgdsElement from "../../base/sgds-element";
2
+ export type FileUploadButtonVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark" | "link" | "outline-primary" | "outline-secondary" | "outline-success" | "outline-danger" | "outline-warning" | "outline-info" | "outline-light" | "outline-dark";
3
+ /**
4
+ * @summary Allows users to upload files of various sizes and formats
5
+ * @slot default - Label for file upload button
6
+ *
7
+ * @event sgds-files-selected - Emitted when files are selected for uploading
8
+ *
9
+ * @cssproperty --fileupload-file-icon-fill - Left icon fill color
10
+ * @cssproperty --fileupload-remove-icon-fill - Remove icon fill color
11
+ * @cssproperty --fileupload-remove-icon-hover-fill - Remove icon mouse over fill color
12
+ *
13
+ */
14
+ export declare class SgdsFileUpload extends SgdsElement {
15
+ static styles: import("lit").CSSResultGroup[];
16
+ /** The button's variant. */
17
+ variant: FileUploadButtonVariant;
18
+ disabled: boolean;
19
+ /** Allows multiple files to be listed for uploading */
20
+ multiple: boolean;
21
+ /** Specify the acceptable file type */
22
+ accept: string;
23
+ /** Specifies a large or small button */
24
+ size: "sm" | "lg";
25
+ /** Customize the check icon with SVG */
26
+ checkedIcon: string;
27
+ /** Customize the cancel icon with SVG */
28
+ cancelIcon: string;
29
+ /** @internal */
30
+ private files;
31
+ /** @internal */
32
+ private selectedFiles;
33
+ setFileList(files: FileList): void;
34
+ /** @internal */
35
+ private inputRef;
36
+ /** @internal */
37
+ private handleClick;
38
+ /** @internal */
39
+ private handleInputChange;
40
+ /** @internal */
41
+ removeFileHandler(index: number): void;
42
+ render(): import("lit").TemplateResult<1>;
43
+ }
44
+ export default SgdsFileUpload;
@@ -21,8 +21,6 @@ export declare class SgdsInput extends SgdsElement implements SgdsFormControl {
21
21
  label: string;
22
22
  /** The input's hint text below the label */
23
23
  hintText: string;
24
- /**The input's id. This value gets forwarded into the HTMLInputElement of the component. Defaults to a unique value */
25
- inputId: string;
26
24
  /**The input's name attribute */
27
25
  name: string;
28
26
  /**Forwards classes to the native HTMLInputElement of the component. Can be used to insert any classes from bootstrap such as mt-2 */
@@ -57,6 +55,8 @@ export declare class SgdsInput extends SgdsElement implements SgdsFormControl {
57
55
  invalid: boolean;
58
56
  /**@internal */
59
57
  valid: boolean;
58
+ /**@internal */
59
+ private inputId;
60
60
  /** Sets focus on the input. */
61
61
  focus(options?: FocusOptions): void;
62
62
  /** Sets blur on the input. */
@@ -26,8 +26,7 @@ export declare class SgdsMainnav extends SgdsElement {
26
26
  private _onClickButton;
27
27
  /** The href link for brand logo */
28
28
  brandHref: string;
29
- /** Forwards to id attribute of div.collapse and aria-controls attribute of toggler button in SgdsMainnav. By default, SgdsMainnav auto-generates a unique id. Override the default id by specifiying your own */
30
- collapseId: string;
29
+ private collapseId;
31
30
  /** The breakpoint, below which, the Navbar will collapse. When always the Navbar will always be expanded regardless of screen size. When never, the Navbar will always be collapsed */
32
31
  expand: MainnavExpandSize;
33
32
  /** @internal */
@@ -1,28 +1,53 @@
1
- import { SgdsButton } from "../Button";
1
+ import { ButtonVariant } from "../Button";
2
2
  import SgdsElement from "../../base/sgds-element";
3
- export declare class SgdsQuantityToggle extends SgdsElement {
4
- input: HTMLInputElement;
5
- leftBtn: SgdsButton;
6
- lastBtn: SgdsButton;
3
+ import { SgdsFormControl } from "../../utils/form";
4
+ /**
5
+ * @summary The quantity toggle component is used to increase or decrease an incremental venue, best used when the user needs to enter or adjust the quantity of a selected item.
6
+ *
7
+ * @csspart base - The base wrapper of the quantity toggle component.
8
+ * @csspart button - The plus and minus button of quantity toggle
9
+ *
10
+ * @event sgds-change - Emitted when an alteration to the control's value is committed by the user.
11
+ * @event sgds-input - Emitted when the control receives input and its value changes.
12
+ *
13
+ */
14
+ export declare class SgdsQuantityToggle extends SgdsElement implements SgdsFormControl {
15
+ /**@internal */
16
+ private input;
17
+ /**@internal */
18
+ private plusBtn;
19
+ /**@internal */
20
+ private minusBtn;
7
21
  static styles: import("lit").CSSResultGroup[];
8
- quantToggleId: string;
22
+ /**@internal */
23
+ private readonly formSubmitController;
24
+ /** The name of the input */
9
25
  name: string;
10
26
  /** The input's minimum value. */
11
- min: number | string;
27
+ min: number;
12
28
  /** The input's maximum value. */
13
- max: number | string;
14
- size: "sm" | "lg" | "default";
15
- count: number;
29
+ max: number;
30
+ /**Controls the size of the quantity toggle */
31
+ size: "sm" | "lg";
32
+ /**The input's value. Set to 0 by default */
33
+ value: number;
34
+ /** Disables the entire quantity toggle */
16
35
  disabled: boolean;
17
- quantityToggleClasses?: string;
36
+ /** The quantity toggle's button variants */
37
+ buttonVariant: ButtonVariant;
18
38
  /**
19
- * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is
20
- * implied, allowing any numeric value.
39
+ * Controls the incremental / decremental value of the input
21
40
  */
22
41
  step: number;
23
42
  /** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */
24
- defaultValue: string;
43
+ defaultValue: number;
44
+ /** @internal The id forwarded to input element */
45
+ private inputId;
25
46
  handleChange(event: string): void;
47
+ /** Simulates a click on the plus button */
48
+ plus(): void;
49
+ /** Simulates a click on the minus button */
50
+ minus(): void;
26
51
  onPlus(event: MouseEvent): void;
27
52
  onMinus(event: MouseEvent): void;
28
53
  render(): import("lit").TemplateResult;
@@ -1,6 +1,5 @@
1
1
  import SgdsElement from "../../base/sgds-element";
2
2
  import { FormSubmitController } from "../../utils/form";
3
- import { SgdsFormControl } from "../../utils/form";
4
3
  /**
5
4
  * @summary RadioGroup group multiple radios so they function as a single form control.
6
5
  *
@@ -8,7 +7,7 @@ import { SgdsFormControl } from "../../utils/form";
8
7
  *
9
8
  * @event sgds-change - Emitted when the radio group's selected value changes.
10
9
  */
11
- export declare class SgdsRadioGroup extends SgdsElement implements SgdsFormControl {
10
+ export declare class SgdsRadioGroup extends SgdsElement {
12
11
  static styles: import("lit").CSSResultGroup[];
13
12
  /**@internal */
14
13
  protected readonly formSubmitController: FormSubmitController;
@@ -38,7 +37,8 @@ export declare class SgdsRadioGroup extends SgdsElement implements SgdsFormContr
38
37
  get validity(): ValidityState;
39
38
  /** Checks for validity and shows the browser's validation message if the control is invalid. */
40
39
  reportValidity(): boolean;
41
- private getAllRadios;
40
+ /**@internal */
41
+ private _radios;
42
42
  handleRadioClick(event: MouseEvent): void;
43
43
  handleKeyDown(event: KeyboardEvent): void;
44
44
  handleLabelClick(): void;
@@ -9,18 +9,19 @@ import SgdsElement from "../../base/sgds-element";
9
9
  */
10
10
  export declare class SgdsRadio extends SgdsElement {
11
11
  static styles: import("lit").CSSResultGroup[];
12
- /**@internal */
12
+ /**
13
+ * Draws the radio in a checked state
14
+ */
13
15
  checked: boolean;
14
16
  /** The radio's value attribute. */
15
17
  value: string;
16
- /** For id/for pair of the HTML form control and label. */
17
- radioId: string;
18
18
  /** Disables the radio. */
19
19
  disabled: boolean;
20
20
  /** Aligns the radios horizontally */
21
21
  isInline: boolean;
22
22
  /** For aria-label */
23
23
  ariaLabel: string;
24
+ private radioId;
24
25
  connectedCallback(): void;
25
26
  handleCheckedChange(): void;
26
27
  handleDisabledChange(): void;
@@ -23,21 +23,21 @@ export declare class SgdsSidenavItem extends SgdsElement {
23
23
  */
24
24
  active: boolean;
25
25
  /**
26
- * When defined, converts SgdsSidenavItem from a button element to an Anchor element
26
+ * When defined, converts SgdsSidenavItem from a button element to an Anchor element. In this case, only one level of navigation is allowed
27
27
  */
28
28
  href: string;
29
29
  /**
30
- * Forwards to id attribute of div.collapse and aria-controls attribute of button in SgdsSidenavItem. By default, SgdsSidenavItem auto-generates a unique id. Override the default id by specifiying your own
30
+ * Disables the SgdsSidenavItem
31
31
  */
32
- collapseId: string;
32
+ disabled: boolean;
33
33
  /**
34
- * Forwards to id attribute of button and aria-labelledby attribute of ul.sidenav-list in SgdsSidenavItem. By default, SgdsSidenavItem auto-generates a unique id. Override the default id by specifiying your own
34
+ * @internal Forwards to id attribute of div.collapse and aria-controls attribute of button in SgdsSidenavItem. By default, SgdsSidenavItem auto-generates a unique id. Override the default id by specifiying your own
35
35
  */
36
- buttonId: string;
36
+ private collapseId;
37
37
  /**
38
- * Disables the SgdsSidenavItem
38
+ * @internal Forwards to id attribute of button and aria-labelledby attribute of ul.sidenav-list in SgdsSidenavItem. By default, SgdsSidenavItem auto-generates a unique id. Override the default id by specifiying your own
39
39
  */
40
- disabled: boolean;
40
+ private buttonId;
41
41
  /** @internal */
42
42
  private index;
43
43
  private _onClick;
@@ -1,6 +1,6 @@
1
1
  import LinkElement from "../../base/link-element";
2
2
  /**
3
- * @slot - default slot for label of anchor tag.
3
+ * @slot default - slot for label of anchor tag.
4
4
  *
5
5
  * @cssproperty --sidenav-link-font-size - sidenav link font size, default to `--sgds-body-font-size`
6
6
  * @cssproperty --sidenav-link-padding-x - sidenav link padding left and right
@@ -1,7 +1,10 @@
1
1
  import SgdsElement from "../../base/sgds-element";
2
2
  /**
3
- * @summary The side navigation is used to display a list of links to move between pages within a related category. It is used as a secondary form of navigation where the primary navigation is located hierachically above the page frame.
4
- * @slot - default slot for SgdsSidenavItem element.
3
+ * @summary The side navigation is used to display a list of links to move between pages within a related category.
4
+ * It is used as a secondary form of navigation where the primary navigation is located hierachically above the page frame.
5
+ * Maximum two levels of navigations are allowed.
6
+ *
7
+ * @slot default - Default slot for SgdsSidenavItem element.
5
8
  *
6
9
  * @cssproperty --sidenav-theme-color - overall sidenav theme color
7
10
  */
@@ -18,8 +18,6 @@ export declare class SgdsTextarea extends SgdsElement implements SgdsFormControl
18
18
  private resizeObserver;
19
19
  /**The textarea's label */
20
20
  label: string;
21
- /**The textarea's unique id */
22
- textareaId: string;
23
21
  /**The textarea's name attribute */
24
22
  name: string;
25
23
  /**Forwarded to the HTML native textarea element. Can be used to insert any bootstrap classes such as mt-2 */
@@ -60,6 +58,8 @@ export declare class SgdsTextarea extends SgdsElement implements SgdsFormControl
60
58
  invalid: boolean;
61
59
  /**@internal */
62
60
  valid: boolean;
61
+ /** @internal The textarea's unique id */
62
+ private textareaId;
63
63
  connectedCallback(): void;
64
64
  disconnectedCallback(): void;
65
65
  /** Sets focus on the textarea. */
package/index.d.ts CHANGED
@@ -22,3 +22,4 @@ export * from "./components/FileUpload";
22
22
  export * from "./components/Accordion";
23
23
  export * from "./components/Tooltip";
24
24
  export * from "./components/Spinner";
25
+ export * from "./components/Card";