@govtechsg/sgds-web-component 0.0.10 → 0.0.12
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/README.md +102 -10
- package/base/card-element.d.ts +12 -0
- package/{lib/utils → base}/dropdown-element.d.ts +38 -37
- package/{lib/utils → base}/link-element.d.ts +8 -7
- package/{lib/utils → base}/sgds-element.d.ts +6 -5
- package/components/Accordion/index.d.ts +2 -0
- package/components/Accordion/sgds-accordion-item.d.ts +40 -0
- package/components/Accordion/sgds-accordion.d.ts +19 -0
- package/components/ActionCard/index.d.ts +1 -0
- package/{lib/Card → components/ActionCard}/sgds-action-card.d.ts +21 -20
- package/components/Alert/index.d.ts +1 -0
- package/components/Alert/sgds-alert.d.ts +37 -0
- package/components/Badge/index.d.ts +1 -0
- package/components/Badge/sgds-badge.d.ts +10 -0
- package/components/Breadcrumb/index.d.ts +2 -0
- package/components/Breadcrumb/sgds-breadcrumb-item.d.ts +10 -0
- package/components/Breadcrumb/sgds-breadcrumb.d.ts +12 -0
- package/components/Button/index.d.ts +1 -0
- package/{lib → components}/Button/sgds-button.d.ts +55 -48
- package/components/Checkbox/index.d.ts +1 -0
- package/{lib → components}/Checkbox/sgds-checkbox.d.ts +36 -36
- package/components/CloseButton/index.d.ts +1 -0
- package/components/CloseButton/sgds-closebutton.d.ts +9 -0
- package/components/Dropdown/index.d.ts +3 -0
- package/{lib → components}/Dropdown/sgds-dropdown-item.d.ts +8 -7
- package/{lib → components}/Dropdown/sgds-dropdown.d.ts +8 -7
- package/components/FileUpload/index.d.ts +1 -0
- package/components/FileUpload/sgds-fileupload.d.ts +22 -0
- package/components/Footer/index.d.ts +1 -0
- package/{lib → components}/Footer/sgds-footer.d.ts +27 -23
- package/components/Input/index.d.ts +1 -0
- package/{lib → components}/Input/sgds-input.d.ts +42 -42
- package/components/Mainnav/index.d.ts +3 -0
- package/components/Mainnav/sgds-mainnav-dropdown.d.ts +6 -0
- package/components/Mainnav/sgds-mainnav-item.d.ts +8 -0
- package/{lib → components}/Mainnav/sgds-mainnav.d.ts +26 -22
- package/components/Masthead/index.d.ts +1 -0
- package/{lib → components}/Masthead/sgds-masthead.d.ts +9 -12
- package/components/Modal/index.d.ts +1 -0
- package/{lib → components}/Modal/sgds-modal.d.ts +28 -28
- package/components/QuantityToggle/index.d.ts +1 -0
- package/{lib/QuantityToggle/sgds-quantitytoggle.d.ts → components/QuantityToggle/sgds-quantity-toggle.d.ts} +30 -30
- package/components/Radio/index.d.ts +2 -0
- package/{lib/Radio/sgds-radiogroup.d.ts → components/Radio/sgds-radio-group.d.ts} +41 -41
- package/{lib → components}/Radio/sgds-radio.d.ts +31 -31
- package/components/Sidenav/index.d.ts +3 -0
- package/{lib → components}/Sidenav/sgds-sidenav-item.d.ts +36 -28
- package/components/Sidenav/sgds-sidenav-link.d.ts +8 -0
- package/{lib → components}/Sidenav/sgds-sidenav.d.ts +10 -6
- package/components/Stepper/index.d.ts +1 -0
- package/components/Stepper/sgds-stepper.d.ts +17 -0
- package/components/Tab/index.d.ts +3 -0
- package/{lib → components}/Tab/sgds-tab.d.ts +27 -26
- package/{lib → components}/Tab/sgds-tabgroup.d.ts +48 -47
- package/{lib → components}/Tab/sgds-tabpanel.d.ts +26 -25
- package/components/Table/index.d.ts +1 -0
- package/components/Table/sgds-table.d.ts +26 -0
- package/components/Textarea/index.d.ts +1 -0
- package/{lib → components}/Textarea/sgds-textarea.d.ts +53 -53
- package/components/Toast/index.d.ts +1 -0
- package/components/Toast/sgds-toast.d.ts +22 -0
- package/components/Tooltip/index.d.ts +1 -0
- package/components/Tooltip/sgds-tooltip.d.ts +30 -0
- package/index.d.ts +23 -0
- package/index.js +11543 -0
- package/index.js.map +1 -0
- package/main.d.ts +24 -0
- package/package.json +23 -65
- package/react/accordion/index.d.ts +3 -0
- package/react/accordion-item/index.d.ts +8 -0
- package/react/action-card/index.d.ts +3 -0
- package/react/alert/index.d.ts +3 -0
- package/react/badge/index.d.ts +3 -0
- package/react/breadcrumb/index.d.ts +3 -0
- package/react/breadcrumb-item/index.d.ts +3 -0
- package/react/button/index.d.ts +6 -0
- package/react/checkbox/index.d.ts +3 -0
- package/react/cjs/index.js +12510 -0
- package/react/cjs/index.js.map +1 -0
- package/react/closebutton/index.d.ts +5 -0
- package/react/dropdown/index.d.ts +3 -0
- package/react/dropdown-item/index.d.ts +3 -0
- package/react/fileupload/index.d.ts +3 -0
- package/react/footer/index.d.ts +3 -0
- package/react/index.d.ts +34 -0
- package/react/index.js +12453 -0
- package/react/index.js.map +1 -0
- package/react/input/index.d.ts +3 -0
- package/react/mainnav/index.d.ts +3 -0
- package/react/mainnav-dropdown/index.d.ts +3 -0
- package/react/mainnav-item/index.d.ts +3 -0
- package/react/masthead/index.d.ts +3 -0
- package/react/modal/index.d.ts +3 -0
- package/react/package.json +10 -0
- package/react/quantity-toggle/index.d.ts +3 -0
- package/react/radio/index.d.ts +3 -0
- package/react/radio-group/index.d.ts +3 -0
- package/react/sidenav/index.d.ts +3 -0
- package/react/sidenav-item/index.d.ts +5 -0
- package/react/sidenav-link/index.d.ts +3 -0
- package/react/stepper/index.d.ts +3 -0
- package/react/tab/index.d.ts +3 -0
- package/react/tab-group/index.d.ts +3 -0
- package/react/tab-panel/index.d.ts +3 -0
- package/react/table/index.d.ts +3 -0
- package/react/textarea/index.d.ts +3 -0
- package/react/toast/index.d.ts +3 -0
- package/react/tooltip/index.d.ts +3 -0
- package/umd/index.js +11995 -0
- package/umd/index.js.map +1 -0
- package/{lib/utils → utils}/animate.d.ts +10 -10
- package/{lib/utils → utils}/animation-registry.d.ts +18 -18
- package/{lib/utils → utils}/breakpoints.d.ts +5 -5
- package/{lib/utils → utils}/defaultvalue.d.ts +2 -2
- package/{lib/utils → utils}/event.d.ts +2 -2
- package/{lib/utils → utils}/form.d.ts +38 -38
- package/{lib/utils → utils}/generateId.d.ts +1 -1
- package/{lib/utils → utils}/mergeDeep.d.ts +2 -2
- package/{lib/utils → utils}/modal.d.ts +12 -12
- package/{lib/utils → utils}/object.d.ts +2 -2
- package/{lib/utils → utils}/offset.d.ts +4 -4
- package/{lib/utils → utils}/scroll.d.ts +13 -13
- package/{lib/utils → utils}/slot.d.ts +22 -22
- package/{lib/utils → utils}/tabbable.d.ts +8 -8
- package/{lib/utils → utils}/watch.d.ts +14 -14
- package/.github/workflows/publish-latest.yml +0 -22
- package/.github/workflows/publish-pr.yml +0 -28
- package/.husky/commit-msg +0 -4
- package/.husky/prepare-commit-msg +0 -8
- package/.storybook/main.js +0 -16
- package/.storybook/preview-head.html +0 -11
- package/.storybook/preview.js +0 -9
- package/.vscode/settings.json +0 -7
- package/CONTRIBUTING.md +0 -56
- package/LICENSE +0 -20
- package/amplify.yml +0 -22
- package/commitlint.config.js +0 -1
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/button-element.scss.html +0 -112
- package/coverage/lcov-report/button-element.ts.html +0 -145
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -116
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -32
- package/index.html +0 -430
- package/lib/Button/index.d.ts +0 -1
- package/lib/Button/index.js +0 -6634
- package/lib/Button/index.js.map +0 -1
- package/lib/Button/package.json +0 -7
- package/lib/Card/index.d.ts +0 -1
- package/lib/Card/index.js +0 -6150
- package/lib/Card/index.js.map +0 -1
- package/lib/Card/package.json +0 -7
- package/lib/Checkbox/index.d.ts +0 -1
- package/lib/Checkbox/index.js +0 -6366
- package/lib/Checkbox/index.js.map +0 -1
- package/lib/Checkbox/package.json +0 -7
- package/lib/Dropdown/index.d.ts +0 -3
- package/lib/Dropdown/index.js +0 -13502
- package/lib/Dropdown/index.js.map +0 -1
- package/lib/Dropdown/package.json +0 -7
- package/lib/Footer/index.d.ts +0 -2
- package/lib/Footer/index.js +0 -7168
- package/lib/Footer/index.js.map +0 -1
- package/lib/Footer/package.json +0 -7
- package/lib/Input/index.d.ts +0 -1
- package/lib/Input/index.js +0 -6656
- package/lib/Input/index.js.map +0 -1
- package/lib/Input/package.json +0 -7
- package/lib/Mainnav/index.d.ts +0 -4
- package/lib/Mainnav/index.js +0 -32546
- package/lib/Mainnav/index.js.map +0 -1
- package/lib/Mainnav/package.json +0 -7
- package/lib/Mainnav/sgds-mainnav-dropdown.d.ts +0 -5
- package/lib/Mainnav/sgds-mainnav-item.d.ts +0 -4
- package/lib/Masthead/index.d.ts +0 -1
- package/lib/Masthead/index.js +0 -7371
- package/lib/Masthead/index.js.map +0 -1
- package/lib/Masthead/package.json +0 -7
- package/lib/Modal/index.d.ts +0 -1
- package/lib/Modal/index.js +0 -6432
- package/lib/Modal/index.js.map +0 -1
- package/lib/Modal/package.json +0 -7
- package/lib/QuantityToggle/index.d.ts +0 -1
- package/lib/QuantityToggle/index.js +0 -7049
- package/lib/QuantityToggle/index.js.map +0 -1
- package/lib/QuantityToggle/package.json +0 -7
- package/lib/Radio/index.d.ts +0 -2
- package/lib/Radio/index.js +0 -12607
- package/lib/Radio/index.js.map +0 -1
- package/lib/Radio/package.json +0 -7
- package/lib/Sidenav/index.d.ts +0 -3
- package/lib/Sidenav/index.js +0 -18739
- package/lib/Sidenav/index.js.map +0 -1
- package/lib/Sidenav/package.json +0 -7
- package/lib/Sidenav/sgds-sidenav-link.d.ts +0 -4
- package/lib/Tab/index.d.ts +0 -3
- package/lib/Tab/index.js +0 -13557
- package/lib/Tab/index.js.map +0 -1
- package/lib/Tab/package.json +0 -7
- package/lib/Textarea/index.d.ts +0 -1
- package/lib/Textarea/index.js +0 -6696
- package/lib/Textarea/index.js.map +0 -1
- package/lib/Textarea/package.json +0 -7
- package/lib/index.d.ts +0 -16
- package/lib/index.js +0 -134580
- package/lib/index.js.map +0 -1
- package/lib/umd/index.js +0 -134587
- package/lib/umd/index.js.map +0 -1
- package/lib/utils/card-element.d.ts +0 -11
- package/mocks/dropdown.d.ts +0 -4
- package/mocks/dropdown.ts +0 -27
- package/mocks/link.d.ts +0 -3
- package/mocks/link.ts +0 -6
- package/rollup.config.js +0 -73
- package/rollup.test.config.js +0 -42
- package/scripts/buildUtils.js +0 -30
- package/scripts/frankBuild.js +0 -49
- package/src/Button/index.ts +0 -1
- package/src/Button/sgds-button.scss +0 -28
- package/src/Button/sgds-button.ts +0 -153
- package/src/Card/index.ts +0 -1
- package/src/Card/sgds-action-card.scss +0 -27
- package/src/Card/sgds-action-card.ts +0 -115
- package/src/Checkbox/index.ts +0 -1
- package/src/Checkbox/sgds-checkbox.scss +0 -4
- package/src/Checkbox/sgds-checkbox.ts +0 -149
- package/src/Dropdown/index.ts +0 -3
- package/src/Dropdown/sgds-dropdown-item.ts +0 -39
- package/src/Dropdown/sgds-dropdown.scss +0 -5
- package/src/Dropdown/sgds-dropdown.ts +0 -54
- package/src/Footer/index.ts +0 -3
- package/src/Footer/sgds-footer.scss +0 -5
- package/src/Footer/sgds-footer.ts +0 -121
- package/src/Input/index.ts +0 -1
- package/src/Input/sgds-input.scss +0 -20
- package/src/Input/sgds-input.ts +0 -178
- package/src/Mainnav/index.ts +0 -4
- package/src/Mainnav/sgds-mainnav-dropdown.scss +0 -13
- package/src/Mainnav/sgds-mainnav-dropdown.ts +0 -45
- package/src/Mainnav/sgds-mainnav-item.scss +0 -24
- package/src/Mainnav/sgds-mainnav-item.ts +0 -8
- package/src/Mainnav/sgds-mainnav.scss +0 -39
- package/src/Mainnav/sgds-mainnav.ts +0 -183
- package/src/Masthead/index.ts +0 -1
- package/src/Masthead/sgds-masthead.scss +0 -217
- package/src/Masthead/sgds-masthead.ts +0 -189
- package/src/Modal/index.ts +0 -1
- package/src/Modal/sgds-modal.scss +0 -128
- package/src/Modal/sgds-modal.ts +0 -309
- package/src/QuantityToggle/index.ts +0 -1
- package/src/QuantityToggle/sgds-quantitytoggle.scss +0 -10
- package/src/QuantityToggle/sgds-quantitytoggle.ts +0 -130
- package/src/Radio/index.ts +0 -2
- package/src/Radio/sgds-radio.scss +0 -5
- package/src/Radio/sgds-radio.ts +0 -120
- package/src/Radio/sgds-radiogroup.scss +0 -22
- package/src/Radio/sgds-radiogroup.ts +0 -221
- package/src/Sidenav/index.ts +0 -4
- package/src/Sidenav/sgds-sidenav-item.scss +0 -73
- package/src/Sidenav/sgds-sidenav-item.ts +0 -145
- package/src/Sidenav/sgds-sidenav-link.scss +0 -25
- package/src/Sidenav/sgds-sidenav-link.ts +0 -8
- package/src/Sidenav/sgds-sidenav.scss +0 -6
- package/src/Sidenav/sgds-sidenav.ts +0 -33
- package/src/Tab/index.ts +0 -3
- package/src/Tab/sgds-tab.scss +0 -84
- package/src/Tab/sgds-tab.ts +0 -87
- package/src/Tab/sgds-tabgroup.scss +0 -198
- package/src/Tab/sgds-tabgroup.ts +0 -295
- package/src/Tab/sgds-tabpanel.scss +0 -12
- package/src/Tab/sgds-tabpanel.ts +0 -55
- package/src/Textarea/index.ts +0 -1
- package/src/Textarea/sgds-textarea.scss +0 -23
- package/src/Textarea/sgds-textarea.ts +0 -201
- package/src/index.ts +0 -16
- package/src/utils/animate.ts +0 -69
- package/src/utils/animation-registry.ts +0 -71
- package/src/utils/base.scss +0 -14
- package/src/utils/breakpoints.ts +0 -5
- package/src/utils/card-element.ts +0 -42
- package/src/utils/components.style.scss +0 -531
- package/src/utils/defaultvalue.ts +0 -51
- package/src/utils/dropdown-element.ts +0 -244
- package/src/utils/event.ts +0 -13
- package/src/utils/form.ts +0 -183
- package/src/utils/generateId.ts +0 -4
- package/src/utils/link-element.ts +0 -34
- package/src/utils/mergeDeep.ts +0 -22
- package/src/utils/modal.ts +0 -64
- package/src/utils/object.ts +0 -2
- package/src/utils/offset.ts +0 -6
- package/src/utils/scroll.ts +0 -57
- package/src/utils/sgds-element.ts +0 -18
- package/src/utils/slot.ts +0 -102
- package/src/utils/tabbable.ts +0 -81
- package/src/utils/watch.ts +0 -62
- package/stories/ActionCard.stories.mdx +0 -199
- package/stories/Button.stories.mdx +0 -194
- package/stories/Checkbox.stories.mdx +0 -196
- package/stories/Dropdown.stories.mdx +0 -152
- package/stories/Footer.stories.mdx +0 -261
- package/stories/Input.stories.mdx +0 -236
- package/stories/MainNav.stories.mdx +0 -169
- package/stories/Masthead.stories.mdx +0 -112
- package/stories/Modal.stories.mdx +0 -103
- package/stories/QuantityToggle.stories.mdx +0 -97
- package/stories/Radio.stories.mdx +0 -262
- package/stories/Sample.stories.js +0 -29
- package/stories/Sample.stories.mdx +0 -33
- package/stories/SideNav.stories.mdx +0 -245
- package/stories/common.js +0 -185
- package/stories/textarea.stories.mdx +0 -253
- package/test/button.element.test.ts +0 -185
- package/test/checkbox.test.ts +0 -240
- package/test/dropdown.test.ts +0 -637
- package/test/footer.test.ts +0 -181
- package/test/generateId.test.ts +0 -18
- package/test/input.element.test.ts +0 -316
- package/test/link-element.test.ts +0 -38
- package/test/mainnav.test.ts +0 -313
- package/test/masthead.test.ts +0 -116
- package/test/modal.test.ts +0 -149
- package/test/quantitytoggle.test.ts +0 -76
- package/test/radio.test.ts +0 -310
- package/test/selectable-card.test.ts +0 -159
- package/test/sidenav.test.ts +0 -390
- package/test/tab.test.ts +0 -76
- package/test/textarea.test.ts +0 -126
- package/tsconfig.json +0 -26
- package/tsconfig.test.json +0 -24
- package/typings/scss.d.ts +0 -5
- package/web-dev-server.config.mjs +0 -7
- package/web-test-runner.config.mjs +0 -47
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|
package/mocks/dropdown.d.ts
DELETED
package/mocks/dropdown.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
DELETED
package/mocks/link.ts
DELETED
package/rollup.config.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
];
|
package/rollup.test.config.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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
|
-
];
|
package/scripts/buildUtils.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
};
|
package/scripts/frankBuild.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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();
|
package/src/Button/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SgdsButton } from "./sgds-button";
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { customElement, property, state, query} from "lit/decorators.js";
|
|
2
|
-
import { html, literal } from 'lit/static-html.js';
|
|
3
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
|
-
import {classMap} from 'lit/directives/class-map.js';
|
|
5
|
-
import { FormSubmitController } from "../utils/form";
|
|
6
|
-
import SgdsElement from "../utils/sgds-element";
|
|
7
|
-
import styles from "./sgds-button.scss";
|
|
8
|
-
|
|
9
|
-
export type ButtonVariant =
|
|
10
|
-
"primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark" | "link" | "icon" |
|
|
11
|
-
"outline-primary" | "outline-secondary" | "outline-success" | "outline-danger" | "outline-warning" | "outline-info" | "outline-light" | "outline-dark"
|
|
12
|
-
|
|
13
|
-
@customElement("sgds-button")
|
|
14
|
-
export class SgdsButton extends SgdsElement {
|
|
15
|
-
static styles = styles;
|
|
16
|
-
|
|
17
|
-
@query('.btn') button: HTMLButtonElement | HTMLLinkElement;
|
|
18
|
-
|
|
19
|
-
private readonly formSubmitController = new FormSubmitController(this, {
|
|
20
|
-
form: (input: HTMLInputElement) => {
|
|
21
|
-
// Buttons support a form attribute that points to an arbitrary form, so if this attribute it set we need to query
|
|
22
|
-
// the form from the same root using its id
|
|
23
|
-
if (input.hasAttribute('form')) {
|
|
24
|
-
const doc = input.getRootNode() as Document | ShadowRoot;
|
|
25
|
-
const formId = input.getAttribute('form')!;
|
|
26
|
-
return doc.getElementById(formId) as HTMLFormElement;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Fall back to the closest containing form
|
|
30
|
-
return input.closest('form');
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
@state() private hasFocus = false;
|
|
35
|
-
|
|
36
|
-
/** The button's variant. */
|
|
37
|
-
@property({ reflect: true }) variant: ButtonVariant = "primary";
|
|
38
|
-
|
|
39
|
-
@property({ reflect: true }) buttonClasses? : string;
|
|
40
|
-
|
|
41
|
-
/** Button sizes */
|
|
42
|
-
@property({ reflect: true }) size : 'sm' | 'lg' ;
|
|
43
|
-
|
|
44
|
-
/** Button active state */
|
|
45
|
-
@property({ type: Boolean, reflect: true }) active = false ;
|
|
46
|
-
|
|
47
|
-
/** Button disabled state */
|
|
48
|
-
@property({ type: Boolean, reflect: true }) disabled = false ;
|
|
49
|
-
|
|
50
|
-
@property() type: 'button' | 'submit' | 'reset' = 'button' ;
|
|
51
|
-
|
|
52
|
-
/** When set, the underlying button will be rendered as an `<a>` with this `href` instead of a `<button>`. */
|
|
53
|
-
@property() href?: string;
|
|
54
|
-
|
|
55
|
-
/** Tells the browser where to open the link. Only used when `href` is set. */
|
|
56
|
-
@property() target?: '_blank' | '_parent' | '_self' | '_top';
|
|
57
|
-
|
|
58
|
-
/** Tells the browser to download the linked file as this filename. Only used when `href` is set. */
|
|
59
|
-
@property({ reflect: true }) download?: string;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The "form owner" to associate the button with. If omitted, the closest containing form will be used instead. The
|
|
63
|
-
* value of this attribute must be an id of a form in the same document or shadow root as the button.
|
|
64
|
-
*/
|
|
65
|
-
@property() form: string;
|
|
66
|
-
|
|
67
|
-
/** Used to override the form owner's `action` attribute. */
|
|
68
|
-
@property({ attribute: 'formaction' }) formAction: string;
|
|
69
|
-
|
|
70
|
-
/** Used to override the form owner's `method` attribute. */
|
|
71
|
-
@property({ attribute: 'formmethod' }) formMethod: 'post' | 'get';
|
|
72
|
-
|
|
73
|
-
/** Used to override the form owner's `novalidate` attribute. */
|
|
74
|
-
@property({ attribute: 'formnovalidate', type: Boolean }) formNoValidate: boolean;
|
|
75
|
-
|
|
76
|
-
/** Used to override the form owner's `target` attribute. */
|
|
77
|
-
@property({ attribute: 'formtarget' }) formTarget: '_self' | '_blank' | '_parent' | '_top' | string;
|
|
78
|
-
|
|
79
|
-
/** Sets focus on the button. */
|
|
80
|
-
focus(options?: FocusOptions) {
|
|
81
|
-
this.button.focus(options);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** Simulates a click on the button. */
|
|
85
|
-
click() {
|
|
86
|
-
this.button.click();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** Removes focus from the button. */
|
|
90
|
-
blur() {
|
|
91
|
-
this.button.blur();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
handleBlur() {
|
|
95
|
-
this.hasFocus = false;
|
|
96
|
-
this.emit('sgds-blur');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
handleFocus() {
|
|
100
|
-
this.hasFocus = true;
|
|
101
|
-
this.emit('sgds-focus');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
handleClick(event: MouseEvent) {
|
|
105
|
-
if (this.disabled) {
|
|
106
|
-
event.preventDefault();
|
|
107
|
-
event.stopPropagation();
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (this.type === 'submit') {
|
|
112
|
-
this.formSubmitController.submit(this);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (this.type === 'reset') {
|
|
116
|
-
this.formSubmitController.reset(this);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
render() {
|
|
121
|
-
const isLink = this.href;
|
|
122
|
-
const tag = isLink ? literal`a` : literal`button`;
|
|
123
|
-
return html`
|
|
124
|
-
<${tag}
|
|
125
|
-
class="sgds btn ${classMap(
|
|
126
|
-
{
|
|
127
|
-
'disabled': isLink && this.disabled,
|
|
128
|
-
'active': this.active,
|
|
129
|
-
[`btn-${this.variant}`]: this.variant,
|
|
130
|
-
[`btn-${this.size}`]: this.size,
|
|
131
|
-
[`${this.buttonClasses}`]: this.buttonClasses
|
|
132
|
-
}
|
|
133
|
-
)}"
|
|
134
|
-
?disabled=${ifDefined(isLink ? undefined : this.disabled)}
|
|
135
|
-
type=${ifDefined(isLink ? undefined : this.type)}
|
|
136
|
-
href=${ifDefined(isLink ? this.href : undefined)}
|
|
137
|
-
target=${ifDefined(isLink ? this.target : undefined)}
|
|
138
|
-
download=${ifDefined(isLink ? this.download : undefined)}
|
|
139
|
-
rel=${ifDefined(isLink && this.target === "_blank" ? 'noreferrer noopener' : undefined)}
|
|
140
|
-
role=${ifDefined(isLink ? 'button': undefined )}
|
|
141
|
-
aria-disabled=${this.disabled ? 'true' : 'false'}
|
|
142
|
-
tabindex=${this.disabled ? '-1' : '0'}
|
|
143
|
-
@click=${this.handleClick}
|
|
144
|
-
@focus=${this.handleFocus}
|
|
145
|
-
@blur=${this.handleBlur}
|
|
146
|
-
>
|
|
147
|
-
<slot></slot>
|
|
148
|
-
</${tag}>
|
|
149
|
-
`;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export default SgdsButton;
|
package/src/Card/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SgdsActionCard } from "./sgds-action-card";
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
@import "../utils/base.scss";
|
|
2
|
-
@import "~@govtechsg/sgds/sass/card/";
|
|
3
|
-
|
|
4
|
-
:host {
|
|
5
|
-
.sgds {
|
|
6
|
-
&.card {
|
|
7
|
-
&[variant*="card-action"] {
|
|
8
|
-
.card-body {
|
|
9
|
-
sl-icon {
|
|
10
|
-
font-size: 1.5rem;
|
|
11
|
-
margin-right: 1rem;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
@each $color, $value in $theme-colors {
|
|
17
|
-
&.text-#{$color} {
|
|
18
|
-
color: $value !important;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
@each $color, $value in $theme-colors {
|
|
22
|
-
&.bg-#{$color} {
|
|
23
|
-
background-color: $value !important;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { customElement, property, state, query } from "lit/decorators.js";
|
|
2
|
-
import { html, literal } from "lit/static-html.js";
|
|
3
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
4
|
-
import styles from "./sgds-action-card.scss";
|
|
5
|
-
import { CardElement } from "../utils/card-element";
|
|
6
|
-
import { ref, createRef, Ref } from "lit/directives/ref.js";
|
|
7
|
-
|
|
8
|
-
export type CardVariant = "card-action" | "card-action-quantity-toggle";
|
|
9
|
-
|
|
10
|
-
export type TypeVariant = "checkbox" | "radio";
|
|
11
|
-
|
|
12
|
-
@customElement("sgds-action-card")
|
|
13
|
-
export class SgdsActionCard extends CardElement {
|
|
14
|
-
static styles = styles;
|
|
15
|
-
|
|
16
|
-
// @query("sgds-checkbox") // Define the query
|
|
17
|
-
// inputEl!: HTMLInputElement; // Declare the prop
|
|
18
|
-
|
|
19
|
-
inputRef: Ref<HTMLInputElement> = createRef();
|
|
20
|
-
|
|
21
|
-
@property({ type: String, reflect: true }) type?: TypeVariant = "checkbox";
|
|
22
|
-
|
|
23
|
-
/** Use on actionable cards like SelectableCard and Quantity Toggle Card' */
|
|
24
|
-
@property({ reflect: true }) variant?: CardVariant = "card-action";
|
|
25
|
-
|
|
26
|
-
/** The card's subtitle iconName. */
|
|
27
|
-
@property({ reflect: true }) iconName?: string;
|
|
28
|
-
|
|
29
|
-
/** The input's id. */
|
|
30
|
-
@property({ reflect: true }) inputId?: string;
|
|
31
|
-
|
|
32
|
-
@property({ reflect: true, type: Boolean })
|
|
33
|
-
active = false;
|
|
34
|
-
|
|
35
|
-
// Declare the click event listener
|
|
36
|
-
onInputChange() {
|
|
37
|
-
this.inputRef.value.click();
|
|
38
|
-
if (this.inputRef.value.checked && (!this.inputRef.value.disabled)) this.active = true;
|
|
39
|
-
else if (!this.inputRef.value.checked) {
|
|
40
|
-
this.active = false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
handleKeyDown(event: KeyboardEvent) {
|
|
45
|
-
const hasModifier =
|
|
46
|
-
event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
47
|
-
if (event.key === "Enter" && !hasModifier) {
|
|
48
|
-
this.onInputChange();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// handleChange(event: string){
|
|
52
|
-
// this.checked = this.inputRef.value.checked;
|
|
53
|
-
// this.emit(event);
|
|
54
|
-
// }
|
|
55
|
-
|
|
56
|
-
render() {
|
|
57
|
-
const checkbox = html`<sgds-checkbox
|
|
58
|
-
${ref(this.inputRef)}
|
|
59
|
-
?disabled=${this.disabled}
|
|
60
|
-
checkboxId=${this.inputId}
|
|
61
|
-
@click=${this.onInputChange}
|
|
62
|
-
@keydown=${this.handleKeyDown}
|
|
63
|
-
></sgds-checkbox>`;
|
|
64
|
-
|
|
65
|
-
const radio = html`<sgds-radio
|
|
66
|
-
${ref(this.inputRef)}
|
|
67
|
-
?disabled=${this.disabled}
|
|
68
|
-
radioId=${this.inputId}
|
|
69
|
-
@click=${this.onInputChange}
|
|
70
|
-
@keydown=${this.handleKeyDown}
|
|
71
|
-
></sgds-radio>`;
|
|
72
|
-
|
|
73
|
-
const icon = html`<sl-icon name="${this.iconName}"></sl-icon>`;
|
|
74
|
-
|
|
75
|
-
return html`
|
|
76
|
-
<div
|
|
77
|
-
tabindex=${this.disabled ? "-1" : "0"}
|
|
78
|
-
@click=${this.onInputChange}
|
|
79
|
-
@keydown=${this.handleKeyDown}
|
|
80
|
-
|
|
81
|
-
variant="card-action"
|
|
82
|
-
class="sgds card
|
|
83
|
-
${classMap({
|
|
84
|
-
[`text-${this.textColor}`]: this.textColor,
|
|
85
|
-
[`bg-${this.bgColor}`]: this.bgColor,
|
|
86
|
-
[`border-${this.borderColor}`]: this.borderColor,
|
|
87
|
-
["is-active"]: this.active,
|
|
88
|
-
})}
|
|
89
|
-
"
|
|
90
|
-
>
|
|
91
|
-
<div class="card-body">
|
|
92
|
-
<h6 class="text-muted card-subtitle">
|
|
93
|
-
<div>
|
|
94
|
-
${this.iconName == undefined ? undefined : icon}
|
|
95
|
-
<slot name="card-subtitle"></slot></slot>
|
|
96
|
-
</div>
|
|
97
|
-
<div class="card-input">
|
|
98
|
-
${
|
|
99
|
-
this.type == "checkbox" && this.variant == "card-action"
|
|
100
|
-
? checkbox
|
|
101
|
-
: this.type == "radio" && this.variant == "card-action"
|
|
102
|
-
? radio
|
|
103
|
-
: undefined
|
|
104
|
-
}
|
|
105
|
-
</div>
|
|
106
|
-
</h6>
|
|
107
|
-
<h5 class="card-title"><slot name="card-title"></slot></h5>
|
|
108
|
-
<p class="card-text"><slot name="card-text"></slot></p>
|
|
109
|
-
</div>
|
|
110
|
-
</div>
|
|
111
|
-
`;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export default SgdsActionCard;
|
package/src/Checkbox/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {SgdsCheckbox} from './sgds-checkbox';
|