@govtechsg/sgds-web-component 0.0.12 → 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.
Files changed (53) hide show
  1. package/base/card-element.d.ts +4 -4
  2. package/base/dropdown-element.d.ts +25 -1
  3. package/base/link-element.d.ts +6 -0
  4. package/components/Accordion/sgds-accordion-item.d.ts +8 -4
  5. package/components/Accordion/sgds-accordion.d.ts +4 -2
  6. package/components/ActionCard/sgds-action-card.d.ts +38 -10
  7. package/components/Button/sgds-button.d.ts +16 -10
  8. package/components/Card/index.d.ts +1 -0
  9. package/components/Card/sgds-card.d.ts +24 -0
  10. package/components/Checkbox/sgds-checkbox.d.ts +26 -7
  11. package/components/FileUpload/index.d.ts +1 -1
  12. package/components/FileUpload/sgds-file-upload.d.ts +44 -0
  13. package/components/Footer/sgds-footer.d.ts +35 -1
  14. package/components/Input/sgds-input.d.ts +46 -13
  15. package/components/Mainnav/sgds-mainnav-item.d.ts +5 -1
  16. package/components/Mainnav/sgds-mainnav.d.ts +20 -5
  17. package/components/Masthead/sgds-masthead.d.ts +17 -0
  18. package/components/QuantityToggle/sgds-quantity-toggle.d.ts +39 -14
  19. package/components/Radio/sgds-radio-group.d.ts +27 -12
  20. package/components/Radio/sgds-radio.d.ts +12 -3
  21. package/components/Sidenav/sgds-sidenav-item.d.ts +27 -6
  22. package/components/Sidenav/sgds-sidenav-link.d.ts +6 -1
  23. package/components/Sidenav/sgds-sidenav.d.ts +8 -1
  24. package/components/Spinner/index.d.ts +1 -0
  25. package/components/Spinner/sgds-spinner.d.ts +11 -0
  26. package/components/Table/sgds-table.d.ts +54 -3
  27. package/components/Textarea/sgds-textarea.d.ts +44 -15
  28. package/index.d.ts +2 -0
  29. package/index.js +910 -530
  30. package/index.js.map +1 -1
  31. package/main.d.ts +1 -0
  32. package/package.json +1 -1
  33. package/react/action-card/index.d.ts +3 -1
  34. package/react/{fileupload → card}/index.d.ts +1 -1
  35. package/react/checkbox/index.d.ts +3 -1
  36. package/react/cjs/index.js +1080 -648
  37. package/react/cjs/index.js.map +1 -1
  38. package/react/dropdown/index.d.ts +6 -1
  39. package/react/file-upload/index.d.ts +5 -0
  40. package/react/index.d.ts +4 -2
  41. package/react/index.js +1052 -622
  42. package/react/index.js.map +1 -1
  43. package/react/input/index.d.ts +6 -1
  44. package/react/mainnav-dropdown/index.d.ts +6 -1
  45. package/react/quantity-toggle/index.d.ts +4 -1
  46. package/react/radio/index.d.ts +4 -1
  47. package/react/radio-group/index.d.ts +3 -1
  48. package/react/spinner/index.d.ts +3 -0
  49. package/react/textarea/index.d.ts +6 -1
  50. package/umd/index.js +838 -529
  51. package/umd/index.js.map +1 -1
  52. package/utils/form.d.ts +16 -0
  53. package/components/FileUpload/sgds-fileupload.d.ts +0 -22
@@ -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,41 +1,56 @@
1
1
  import SgdsElement from "../../base/sgds-element";
2
2
  import { FormSubmitController } from "../../utils/form";
3
+ /**
4
+ * @summary RadioGroup group multiple radios so they function as a single form control.
5
+ *
6
+ * @slot default - The default slot where sgds-radio are placed.
7
+ *
8
+ * @event sgds-change - Emitted when the radio group's selected value changes.
9
+ */
3
10
  export declare class SgdsRadioGroup extends SgdsElement {
4
11
  static styles: import("lit").CSSResultGroup[];
12
+ /**@internal */
5
13
  protected readonly formSubmitController: FormSubmitController;
14
+ /**@internal */
6
15
  defaultSlot: HTMLSlotElement;
16
+ /**@internal */
7
17
  input: HTMLInputElement;
8
- private defaultValue;
18
+ /**@internal */
19
+ defaultValue: string;
20
+ /**@internal */
9
21
  private customErrorMessage;
10
- /**
11
- * The radio group label. Required for proper accessibility. If you need to display HTML, you can use the `label` slot
12
- * instead.
13
- */
14
- label: string;
22
+ /** @internal This will be true when the control is in an invalid state. */
23
+ invalid: boolean;
15
24
  /** The selected value of the control. */
16
25
  value: string;
17
26
  /** The name assigned to the radio controls. */
18
27
  name: string;
19
28
  /** Ensures a child radio is checked before allowing the containing form to submit. */
20
29
  required: boolean;
21
- /**
22
- * This will be true when the control is in an invalid state.
23
- */
24
- invalid: boolean;
30
+ /**Feedback text for error state when validated */
25
31
  invalidFeedback: string;
32
+ /** Allows invalidFeedback, invalid and valid styles to be visible with the input */
33
+ hasFeedback: boolean;
26
34
  handleValueChange(): void;
27
35
  connectedCallback(): void;
36
+ /** Gets and return the ValidityState object. */
28
37
  get validity(): ValidityState;
29
38
  /** Checks for validity and shows the browser's validation message if the control is invalid. */
30
39
  reportValidity(): boolean;
31
- private getAllRadios;
40
+ /**@internal */
41
+ private _radios;
32
42
  handleRadioClick(event: MouseEvent): void;
33
43
  handleKeyDown(event: KeyboardEvent): void;
34
44
  handleLabelClick(): void;
35
45
  handleSlotChange(): void;
36
- handleInvalid(): void;
46
+ handleInvalid(e: Event): void;
37
47
  showNativeErrorMessage(): void;
38
48
  updateCheckedRadio(): void;
39
49
  render(): import("lit").TemplateResult<1>;
40
50
  }
51
+ declare global {
52
+ interface HTMLElementTagNameMap {
53
+ "sgds-radio-group": SgdsRadioGroup;
54
+ }
55
+ }
41
56
  export default SgdsRadioGroup;
@@ -1,18 +1,27 @@
1
1
  import SgdsElement from "../../base/sgds-element";
2
+ /**
3
+ * @summary Radio allows the user to select one option from a set while seeing all available options.
4
+ *
5
+ * @slot default - The label of the radio button
6
+ *
7
+ * @event sgds-focus - Emitted when the control gains focus.
8
+ * @event sgds-blur - Emitted when the control loses focus.
9
+ */
2
10
  export declare class SgdsRadio extends SgdsElement {
3
11
  static styles: import("lit").CSSResultGroup[];
12
+ /**
13
+ * Draws the radio in a checked state
14
+ */
4
15
  checked: boolean;
5
- protected hasFocus: boolean;
6
16
  /** The radio's value attribute. */
7
17
  value: string;
8
- /** For id/for pair of the HTML form control. */
9
- radioId: string;
10
18
  /** Disables the radio. */
11
19
  disabled: boolean;
12
20
  /** Aligns the radios horizontally */
13
21
  isInline: boolean;
14
22
  /** For aria-label */
15
23
  ariaLabel: string;
24
+ private radioId;
16
25
  connectedCallback(): void;
17
26
  handleCheckedChange(): void;
18
27
  handleDisabledChange(): void;
@@ -5,29 +5,50 @@ import SgdsElement from "../../base/sgds-element";
5
5
  *
6
6
  * @slot - default slot for SgdsSidenavLink element.
7
7
  * @slot title - title slot for the content of SgdsSidenavItem's button / anchor element.
8
+ * @slot icon - icon slot for the content of SgdsSidenavItem's button / anchor element.
9
+ *
10
+ * @cssproperty --sidenav-item-button-border-left-width - sidenav item left border width
11
+ * @cssproperty --sidenav-item-padding-x - sidenav item padding left and right
12
+ * @cssproperty --sidenav-item-padding-y - sidenav item padding top and bottom
13
+ * @cssproperty --sidenav-item-icon-title-gap - the flex gap between sidenav item icon and title
8
14
  */
9
15
  export declare class SgdsSidenavItem extends SgdsElement {
10
16
  static styles: import("lit").CSSResultGroup[];
17
+ /** @internal */
11
18
  private myCollapse;
19
+ /** @internal */
12
20
  private bsCollapse;
13
- /** when true, toggles the sidenav-item to open on first load and
14
- * set the active stylings.
21
+ /**
22
+ * when true, toggles the sidenav-item to open on first load and set the active stylings.
15
23
  */
16
24
  active: boolean;
25
+ /**
26
+ * When defined, converts SgdsSidenavItem from a button element to an Anchor element. In this case, only one level of navigation is allowed
27
+ */
17
28
  href: string;
18
- collapseId: string;
19
- buttonId: string;
29
+ /**
30
+ * Disables the SgdsSidenavItem
31
+ */
20
32
  disabled: boolean;
33
+ /**
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
+ */
36
+ private collapseId;
37
+ /**
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
+ */
40
+ private buttonId;
41
+ /** @internal */
21
42
  private index;
22
43
  private _onClick;
23
44
  private _onClickButton;
24
45
  private _onClickLink;
25
46
  /**
26
- * closeItem - closes sidenav and inactivates it
47
+ * When invoked, closes the SgdsSidenavItem
27
48
  */
28
49
  closeItem(): void;
29
50
  /**
30
- * openItem
51
+ * When invoked, opens the SgdsSidenavItem
31
52
  */
32
53
  openItem(): void;
33
54
  firstUpdated(): void;
@@ -1,6 +1,11 @@
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
+ *
5
+ * @cssproperty --sidenav-link-font-size - sidenav link font size, default to `--sgds-body-font-size`
6
+ * @cssproperty --sidenav-link-padding-x - sidenav link padding left and right
7
+ * @cssproperty --sidenav-link-padding-y - sidenav link padding top and bottom
8
+ * @cssproperty --sidenav-link-disabled-color - sidenav link disabled color, default to `--sgds-gray-600`
4
9
  */
5
10
  export declare class SgdsSidenavLink extends LinkElement {
6
11
  static styles: import("lit").CSSResultGroup;
@@ -1,9 +1,16 @@
1
1
  import SgdsElement from "../../base/sgds-element";
2
2
  /**
3
- * @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.
8
+ *
9
+ * @cssproperty --sidenav-theme-color - overall sidenav theme color
4
10
  */
5
11
  export declare class SgdsSidenav extends SgdsElement {
6
12
  static styles: import("lit").CSSResultGroup;
13
+ /** Allow sidenav items to stay open when another item is opened */
7
14
  alwaysOpen: boolean;
8
15
  render(): import("lit").TemplateResult<1>;
9
16
  }
@@ -0,0 +1 @@
1
+ export { SgdsSpinner } from "./sgds-spinner";
@@ -0,0 +1,11 @@
1
+ import SgdsElement from "../../base/sgds-element";
2
+ export type Type = "border" | "grow";
3
+ export type Color = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
4
+ export declare class SgdsSpinner extends SgdsElement {
5
+ static styles: import("lit").CSSResultGroup[];
6
+ type: Type;
7
+ color: Color;
8
+ spinnerClasses?: string;
9
+ render(): import("lit").TemplateResult;
10
+ }
11
+ export default SgdsSpinner;
@@ -1,22 +1,73 @@
1
1
  import SgdsElement from "../../base/sgds-element";
2
+ /**
3
+ * @summary The use of a table is to organise a collections of data into readable rows
4
+ *
5
+ * @cssproperty --sgds-table-bg - Table's background color
6
+ * @cssproperty --sgds-table-accent-bg - Table's accent background color
7
+ * @cssproperty --sgds-table-striped-color - Text color for striped table
8
+ * @cssproperty --sgds-table-striped-bg - Background color for striped table
9
+ * @cssproperty --sgds-table-active-color - Active text color for hovered row
10
+ * @cssproperty --sgds-table-active-bg - Active background color for hovered row
11
+ * @cssproperty --sgds-table-hover-color - Hovered text color for hover table
12
+ * @cssproperty --sgds-table-hover-bg - Hovered background color for hover table
13
+ */
2
14
  export declare class SgdsTable extends SgdsElement {
3
15
  static styles: import("lit").CSSResultGroup[];
16
+ /**
17
+ * Adds zebra-striping using striped to table row within the <tbody>
18
+ */
4
19
  striped: boolean;
20
+ /**
21
+ * Add borders to all sides of table and cells
22
+ */
5
23
  bordered: boolean;
24
+ /**
25
+ * Remove all borders to table and cells
26
+ */
6
27
  borderless: boolean;
28
+ /**
29
+ * Add hoverable state on table rows
30
+ */
7
31
  hover: boolean;
8
- size?: string;
9
- variant?: string;
32
+ /**
33
+ * Add <code>.table-sm</code> to make table more compact
34
+ */
35
+ size: string;
36
+ /**
37
+ * Use contextual classes to add colors to table
38
+ */
39
+ variant: string;
40
+ /**
41
+ * Sorting on a column is enabled by adding the sort property. The sorting algorithm is based on javascript array.sort() method. In ascending order from bottom, alphabets come first, followed by numbers, and then symbols. Similarly, in descending order from bottom, symbols come first, followed by numbers, and then alphabets.
42
+ */
10
43
  sort: boolean;
44
+ /**
45
+ * When removableSort is present, the third click removes the sorting from the column.
46
+ */
11
47
  removableSort: boolean;
12
- responsive?: "sm" | "md" | "lg" | "xl";
48
+ /**
49
+ * Use responsive="sm", responsive="md" , responsive="lg", or responsive="xl" as needed to create responsive tables up to a particular breakpoint. From that breakpoint and up, the table will behave normally and not scroll horizontally. Use reponsive="always" to let table be always responsive
50
+ */
51
+ responsive: "sm" | "md" | "lg" | "xl" | "always";
52
+ /**
53
+ * Populate header cells using Arrays
54
+ */
13
55
  tableHeaders: any[];
56
+ /**
57
+ * Populate data cells using Arrays
58
+ */
14
59
  tableData: any[];
60
+ /** @internal */
15
61
  sortColumn: number | null;
62
+ /** @internal */
16
63
  sortAsc: boolean;
64
+ /** @internal */
17
65
  activeColumn: number | null;
66
+ /** @internal */
18
67
  sortClickCount: number;
68
+ /** @internal */
19
69
  clickCount: number;
70
+ /** @internal */
20
71
  originalTableData: Array<string[]>;
21
72
  connectedCallback(): void;
22
73
  handleHeaderClick(columnIndex: number): void;
@@ -1,48 +1,77 @@
1
1
  import SgdsElement from "../../base/sgds-element";
2
- export declare class SgdsTextArea extends SgdsElement {
2
+ import { SgdsFormControl } from "../../utils/form";
3
+ /**
4
+ * @summary Text areas allow for the collection of input longer than a single line.
5
+ *
6
+ * @event sgds-change - Emitted when an alteration to the control's value is committed by the user.
7
+ * @event sgds-input - Emitted when the control receives input and its value changes.
8
+ * @event sgds-focus - Emitted when textarea is in focus.
9
+ * @event sgds-blur - Emitted when textarea loses focus.
10
+ */
11
+ export declare class SgdsTextarea extends SgdsElement implements SgdsFormControl {
3
12
  static styles: import("lit").CSSResultGroup[];
13
+ /**@internal */
4
14
  textarea: HTMLTextAreaElement;
5
- private hasFocus;
15
+ /**@internal */
6
16
  private readonly formSubmitController;
17
+ /**@internal */
7
18
  private resizeObserver;
19
+ /**The textarea's label */
8
20
  label: string;
9
- textareaId: string;
10
- name: any;
11
- textareaClasses?: any;
21
+ /**The textarea's name attribute */
22
+ name: string;
23
+ /**Forwarded to the HTML native textarea element. Can be used to insert any bootstrap classes such as mt-2 */
24
+ textareaClasses?: string;
25
+ /**The textarea's value attribute. */
12
26
  value: string;
13
- minlength: any;
14
- maxlength: any;
27
+ /**Sets the minimum length of the textarea */
28
+ minlength: number;
29
+ /**Sets the maximum length of the textarea */
30
+ maxlength: number;
31
+ /**Enables spell checking on the textarea */
15
32
  spellcheck: boolean;
16
33
  /** The number of rows to display by default. */
17
34
  rows: number;
35
+ /**The textarea's placeholder text. */
18
36
  placeholder: string;
37
+ /**Feedback text for error state when validated */
19
38
  invalidFeedback: string;
39
+ /**Autofocus the textarea */
20
40
  autofocus: boolean;
41
+ /**Disables the textarea. */
21
42
  disabled: boolean;
43
+ /**Makes the textarea a required field. */
22
44
  required: boolean;
23
- /** Makes the input readonly. */
45
+ /** Makes the textarea readonly. */
24
46
  readonly: boolean;
25
- invalid: boolean;
26
- valid: boolean;
27
47
  /** Controls how the textarea can be resized. */
28
48
  resize: "none" | "vertical" | "auto";
29
- /** The textarea's inputmode attribute. */
49
+ /** The native textarea's inputmode attribute. It hints at the type of data that might be entered by the user while editing the element or its contents. This allows a browser to display an appropriate virtual keyboard. */
30
50
  inputmode: "none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url";
51
+ /** The native textarea's autocorrect attribute. */
31
52
  autocorrect: string;
32
53
  /** 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. */
33
54
  defaultValue: string;
55
+ /** Allows invalidFeedback, invalid and valid styles to be visible with the input */
56
+ hasFeedback: boolean;
57
+ /**@internal */
58
+ invalid: boolean;
59
+ /**@internal */
60
+ valid: boolean;
61
+ /** @internal The textarea's unique id */
62
+ private textareaId;
34
63
  connectedCallback(): void;
35
64
  disconnectedCallback(): void;
36
65
  /** Sets focus on the textarea. */
37
66
  focus(options?: FocusOptions): void;
38
67
  /** Checks for validity and shows the browser's validation message if the control is invalid. */
39
68
  reportValidity(): boolean;
40
- handleInvalid(): void;
69
+ /** Selects all the text in the textarea. */
70
+ select(): void;
71
+ handleInvalid(e: Event): void;
41
72
  handleChange(event: string): void;
42
73
  handleFocus(): void;
43
74
  handleBlur(): void;
44
- /** Selects all the text in the textarea. */
45
- select(): void;
46
75
  handleKeyDown(event: KeyboardEvent): void;
47
76
  handleRowsChange(): void;
48
77
  setTextareaHeight(): void;
@@ -50,4 +79,4 @@ export declare class SgdsTextArea extends SgdsElement {
50
79
  handleValueChange(): void;
51
80
  render(): import("lit").TemplateResult;
52
81
  }
53
- export default SgdsTextArea;
82
+ export default SgdsTextarea;
package/index.d.ts CHANGED
@@ -21,3 +21,5 @@ export * from "./components/Toast";
21
21
  export * from "./components/FileUpload";
22
22
  export * from "./components/Accordion";
23
23
  export * from "./components/Tooltip";
24
+ export * from "./components/Spinner";
25
+ export * from "./components/Card";