@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.
Files changed (338) hide show
  1. package/README.md +102 -10
  2. package/base/card-element.d.ts +12 -0
  3. package/{lib/utils → base}/dropdown-element.d.ts +38 -37
  4. package/{lib/utils → base}/link-element.d.ts +8 -7
  5. package/{lib/utils → base}/sgds-element.d.ts +6 -5
  6. package/components/Accordion/index.d.ts +2 -0
  7. package/components/Accordion/sgds-accordion-item.d.ts +40 -0
  8. package/components/Accordion/sgds-accordion.d.ts +19 -0
  9. package/components/ActionCard/index.d.ts +1 -0
  10. package/{lib/Card → components/ActionCard}/sgds-action-card.d.ts +21 -20
  11. package/components/Alert/index.d.ts +1 -0
  12. package/components/Alert/sgds-alert.d.ts +37 -0
  13. package/components/Badge/index.d.ts +1 -0
  14. package/components/Badge/sgds-badge.d.ts +10 -0
  15. package/components/Breadcrumb/index.d.ts +2 -0
  16. package/components/Breadcrumb/sgds-breadcrumb-item.d.ts +10 -0
  17. package/components/Breadcrumb/sgds-breadcrumb.d.ts +12 -0
  18. package/components/Button/index.d.ts +1 -0
  19. package/{lib → components}/Button/sgds-button.d.ts +55 -48
  20. package/components/Checkbox/index.d.ts +1 -0
  21. package/{lib → components}/Checkbox/sgds-checkbox.d.ts +36 -36
  22. package/components/CloseButton/index.d.ts +1 -0
  23. package/components/CloseButton/sgds-closebutton.d.ts +9 -0
  24. package/components/Dropdown/index.d.ts +3 -0
  25. package/{lib → components}/Dropdown/sgds-dropdown-item.d.ts +8 -7
  26. package/{lib → components}/Dropdown/sgds-dropdown.d.ts +8 -7
  27. package/components/FileUpload/index.d.ts +1 -0
  28. package/components/FileUpload/sgds-fileupload.d.ts +22 -0
  29. package/components/Footer/index.d.ts +1 -0
  30. package/{lib → components}/Footer/sgds-footer.d.ts +27 -23
  31. package/components/Input/index.d.ts +1 -0
  32. package/{lib → components}/Input/sgds-input.d.ts +42 -42
  33. package/components/Mainnav/index.d.ts +3 -0
  34. package/components/Mainnav/sgds-mainnav-dropdown.d.ts +6 -0
  35. package/components/Mainnav/sgds-mainnav-item.d.ts +8 -0
  36. package/{lib → components}/Mainnav/sgds-mainnav.d.ts +26 -22
  37. package/components/Masthead/index.d.ts +1 -0
  38. package/{lib → components}/Masthead/sgds-masthead.d.ts +9 -12
  39. package/components/Modal/index.d.ts +1 -0
  40. package/{lib → components}/Modal/sgds-modal.d.ts +28 -28
  41. package/components/QuantityToggle/index.d.ts +1 -0
  42. package/{lib/QuantityToggle/sgds-quantitytoggle.d.ts → components/QuantityToggle/sgds-quantity-toggle.d.ts} +30 -30
  43. package/components/Radio/index.d.ts +2 -0
  44. package/{lib/Radio/sgds-radiogroup.d.ts → components/Radio/sgds-radio-group.d.ts} +41 -41
  45. package/{lib → components}/Radio/sgds-radio.d.ts +31 -31
  46. package/components/Sidenav/index.d.ts +3 -0
  47. package/{lib → components}/Sidenav/sgds-sidenav-item.d.ts +36 -28
  48. package/components/Sidenav/sgds-sidenav-link.d.ts +8 -0
  49. package/{lib → components}/Sidenav/sgds-sidenav.d.ts +10 -6
  50. package/components/Stepper/index.d.ts +1 -0
  51. package/components/Stepper/sgds-stepper.d.ts +17 -0
  52. package/components/Tab/index.d.ts +3 -0
  53. package/{lib → components}/Tab/sgds-tab.d.ts +27 -26
  54. package/{lib → components}/Tab/sgds-tabgroup.d.ts +48 -47
  55. package/{lib → components}/Tab/sgds-tabpanel.d.ts +26 -25
  56. package/components/Table/index.d.ts +1 -0
  57. package/components/Table/sgds-table.d.ts +26 -0
  58. package/components/Textarea/index.d.ts +1 -0
  59. package/{lib → components}/Textarea/sgds-textarea.d.ts +53 -53
  60. package/components/Toast/index.d.ts +1 -0
  61. package/components/Toast/sgds-toast.d.ts +22 -0
  62. package/components/Tooltip/index.d.ts +1 -0
  63. package/components/Tooltip/sgds-tooltip.d.ts +30 -0
  64. package/index.d.ts +23 -0
  65. package/index.js +11543 -0
  66. package/index.js.map +1 -0
  67. package/main.d.ts +24 -0
  68. package/package.json +23 -65
  69. package/react/accordion/index.d.ts +3 -0
  70. package/react/accordion-item/index.d.ts +8 -0
  71. package/react/action-card/index.d.ts +3 -0
  72. package/react/alert/index.d.ts +3 -0
  73. package/react/badge/index.d.ts +3 -0
  74. package/react/breadcrumb/index.d.ts +3 -0
  75. package/react/breadcrumb-item/index.d.ts +3 -0
  76. package/react/button/index.d.ts +6 -0
  77. package/react/checkbox/index.d.ts +3 -0
  78. package/react/cjs/index.js +12510 -0
  79. package/react/cjs/index.js.map +1 -0
  80. package/react/closebutton/index.d.ts +5 -0
  81. package/react/dropdown/index.d.ts +3 -0
  82. package/react/dropdown-item/index.d.ts +3 -0
  83. package/react/fileupload/index.d.ts +3 -0
  84. package/react/footer/index.d.ts +3 -0
  85. package/react/index.d.ts +34 -0
  86. package/react/index.js +12453 -0
  87. package/react/index.js.map +1 -0
  88. package/react/input/index.d.ts +3 -0
  89. package/react/mainnav/index.d.ts +3 -0
  90. package/react/mainnav-dropdown/index.d.ts +3 -0
  91. package/react/mainnav-item/index.d.ts +3 -0
  92. package/react/masthead/index.d.ts +3 -0
  93. package/react/modal/index.d.ts +3 -0
  94. package/react/package.json +10 -0
  95. package/react/quantity-toggle/index.d.ts +3 -0
  96. package/react/radio/index.d.ts +3 -0
  97. package/react/radio-group/index.d.ts +3 -0
  98. package/react/sidenav/index.d.ts +3 -0
  99. package/react/sidenav-item/index.d.ts +5 -0
  100. package/react/sidenav-link/index.d.ts +3 -0
  101. package/react/stepper/index.d.ts +3 -0
  102. package/react/tab/index.d.ts +3 -0
  103. package/react/tab-group/index.d.ts +3 -0
  104. package/react/tab-panel/index.d.ts +3 -0
  105. package/react/table/index.d.ts +3 -0
  106. package/react/textarea/index.d.ts +3 -0
  107. package/react/toast/index.d.ts +3 -0
  108. package/react/tooltip/index.d.ts +3 -0
  109. package/umd/index.js +11995 -0
  110. package/umd/index.js.map +1 -0
  111. package/{lib/utils → utils}/animate.d.ts +10 -10
  112. package/{lib/utils → utils}/animation-registry.d.ts +18 -18
  113. package/{lib/utils → utils}/breakpoints.d.ts +5 -5
  114. package/{lib/utils → utils}/defaultvalue.d.ts +2 -2
  115. package/{lib/utils → utils}/event.d.ts +2 -2
  116. package/{lib/utils → utils}/form.d.ts +38 -38
  117. package/{lib/utils → utils}/generateId.d.ts +1 -1
  118. package/{lib/utils → utils}/mergeDeep.d.ts +2 -2
  119. package/{lib/utils → utils}/modal.d.ts +12 -12
  120. package/{lib/utils → utils}/object.d.ts +2 -2
  121. package/{lib/utils → utils}/offset.d.ts +4 -4
  122. package/{lib/utils → utils}/scroll.d.ts +13 -13
  123. package/{lib/utils → utils}/slot.d.ts +22 -22
  124. package/{lib/utils → utils}/tabbable.d.ts +8 -8
  125. package/{lib/utils → utils}/watch.d.ts +14 -14
  126. package/.github/workflows/publish-latest.yml +0 -22
  127. package/.github/workflows/publish-pr.yml +0 -28
  128. package/.husky/commit-msg +0 -4
  129. package/.husky/prepare-commit-msg +0 -8
  130. package/.storybook/main.js +0 -16
  131. package/.storybook/preview-head.html +0 -11
  132. package/.storybook/preview.js +0 -9
  133. package/.vscode/settings.json +0 -7
  134. package/CONTRIBUTING.md +0 -56
  135. package/LICENSE +0 -20
  136. package/amplify.yml +0 -22
  137. package/commitlint.config.js +0 -1
  138. package/coverage/lcov-report/base.css +0 -224
  139. package/coverage/lcov-report/block-navigation.js +0 -87
  140. package/coverage/lcov-report/button-element.scss.html +0 -112
  141. package/coverage/lcov-report/button-element.ts.html +0 -145
  142. package/coverage/lcov-report/favicon.png +0 -0
  143. package/coverage/lcov-report/index.html +0 -116
  144. package/coverage/lcov-report/prettify.css +0 -1
  145. package/coverage/lcov-report/prettify.js +0 -2
  146. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  147. package/coverage/lcov-report/sorter.js +0 -196
  148. package/coverage/lcov.info +0 -32
  149. package/index.html +0 -430
  150. package/lib/Button/index.d.ts +0 -1
  151. package/lib/Button/index.js +0 -6634
  152. package/lib/Button/index.js.map +0 -1
  153. package/lib/Button/package.json +0 -7
  154. package/lib/Card/index.d.ts +0 -1
  155. package/lib/Card/index.js +0 -6150
  156. package/lib/Card/index.js.map +0 -1
  157. package/lib/Card/package.json +0 -7
  158. package/lib/Checkbox/index.d.ts +0 -1
  159. package/lib/Checkbox/index.js +0 -6366
  160. package/lib/Checkbox/index.js.map +0 -1
  161. package/lib/Checkbox/package.json +0 -7
  162. package/lib/Dropdown/index.d.ts +0 -3
  163. package/lib/Dropdown/index.js +0 -13502
  164. package/lib/Dropdown/index.js.map +0 -1
  165. package/lib/Dropdown/package.json +0 -7
  166. package/lib/Footer/index.d.ts +0 -2
  167. package/lib/Footer/index.js +0 -7168
  168. package/lib/Footer/index.js.map +0 -1
  169. package/lib/Footer/package.json +0 -7
  170. package/lib/Input/index.d.ts +0 -1
  171. package/lib/Input/index.js +0 -6656
  172. package/lib/Input/index.js.map +0 -1
  173. package/lib/Input/package.json +0 -7
  174. package/lib/Mainnav/index.d.ts +0 -4
  175. package/lib/Mainnav/index.js +0 -32546
  176. package/lib/Mainnav/index.js.map +0 -1
  177. package/lib/Mainnav/package.json +0 -7
  178. package/lib/Mainnav/sgds-mainnav-dropdown.d.ts +0 -5
  179. package/lib/Mainnav/sgds-mainnav-item.d.ts +0 -4
  180. package/lib/Masthead/index.d.ts +0 -1
  181. package/lib/Masthead/index.js +0 -7371
  182. package/lib/Masthead/index.js.map +0 -1
  183. package/lib/Masthead/package.json +0 -7
  184. package/lib/Modal/index.d.ts +0 -1
  185. package/lib/Modal/index.js +0 -6432
  186. package/lib/Modal/index.js.map +0 -1
  187. package/lib/Modal/package.json +0 -7
  188. package/lib/QuantityToggle/index.d.ts +0 -1
  189. package/lib/QuantityToggle/index.js +0 -7049
  190. package/lib/QuantityToggle/index.js.map +0 -1
  191. package/lib/QuantityToggle/package.json +0 -7
  192. package/lib/Radio/index.d.ts +0 -2
  193. package/lib/Radio/index.js +0 -12607
  194. package/lib/Radio/index.js.map +0 -1
  195. package/lib/Radio/package.json +0 -7
  196. package/lib/Sidenav/index.d.ts +0 -3
  197. package/lib/Sidenav/index.js +0 -18739
  198. package/lib/Sidenav/index.js.map +0 -1
  199. package/lib/Sidenav/package.json +0 -7
  200. package/lib/Sidenav/sgds-sidenav-link.d.ts +0 -4
  201. package/lib/Tab/index.d.ts +0 -3
  202. package/lib/Tab/index.js +0 -13557
  203. package/lib/Tab/index.js.map +0 -1
  204. package/lib/Tab/package.json +0 -7
  205. package/lib/Textarea/index.d.ts +0 -1
  206. package/lib/Textarea/index.js +0 -6696
  207. package/lib/Textarea/index.js.map +0 -1
  208. package/lib/Textarea/package.json +0 -7
  209. package/lib/index.d.ts +0 -16
  210. package/lib/index.js +0 -134580
  211. package/lib/index.js.map +0 -1
  212. package/lib/umd/index.js +0 -134587
  213. package/lib/umd/index.js.map +0 -1
  214. package/lib/utils/card-element.d.ts +0 -11
  215. package/mocks/dropdown.d.ts +0 -4
  216. package/mocks/dropdown.ts +0 -27
  217. package/mocks/link.d.ts +0 -3
  218. package/mocks/link.ts +0 -6
  219. package/rollup.config.js +0 -73
  220. package/rollup.test.config.js +0 -42
  221. package/scripts/buildUtils.js +0 -30
  222. package/scripts/frankBuild.js +0 -49
  223. package/src/Button/index.ts +0 -1
  224. package/src/Button/sgds-button.scss +0 -28
  225. package/src/Button/sgds-button.ts +0 -153
  226. package/src/Card/index.ts +0 -1
  227. package/src/Card/sgds-action-card.scss +0 -27
  228. package/src/Card/sgds-action-card.ts +0 -115
  229. package/src/Checkbox/index.ts +0 -1
  230. package/src/Checkbox/sgds-checkbox.scss +0 -4
  231. package/src/Checkbox/sgds-checkbox.ts +0 -149
  232. package/src/Dropdown/index.ts +0 -3
  233. package/src/Dropdown/sgds-dropdown-item.ts +0 -39
  234. package/src/Dropdown/sgds-dropdown.scss +0 -5
  235. package/src/Dropdown/sgds-dropdown.ts +0 -54
  236. package/src/Footer/index.ts +0 -3
  237. package/src/Footer/sgds-footer.scss +0 -5
  238. package/src/Footer/sgds-footer.ts +0 -121
  239. package/src/Input/index.ts +0 -1
  240. package/src/Input/sgds-input.scss +0 -20
  241. package/src/Input/sgds-input.ts +0 -178
  242. package/src/Mainnav/index.ts +0 -4
  243. package/src/Mainnav/sgds-mainnav-dropdown.scss +0 -13
  244. package/src/Mainnav/sgds-mainnav-dropdown.ts +0 -45
  245. package/src/Mainnav/sgds-mainnav-item.scss +0 -24
  246. package/src/Mainnav/sgds-mainnav-item.ts +0 -8
  247. package/src/Mainnav/sgds-mainnav.scss +0 -39
  248. package/src/Mainnav/sgds-mainnav.ts +0 -183
  249. package/src/Masthead/index.ts +0 -1
  250. package/src/Masthead/sgds-masthead.scss +0 -217
  251. package/src/Masthead/sgds-masthead.ts +0 -189
  252. package/src/Modal/index.ts +0 -1
  253. package/src/Modal/sgds-modal.scss +0 -128
  254. package/src/Modal/sgds-modal.ts +0 -309
  255. package/src/QuantityToggle/index.ts +0 -1
  256. package/src/QuantityToggle/sgds-quantitytoggle.scss +0 -10
  257. package/src/QuantityToggle/sgds-quantitytoggle.ts +0 -130
  258. package/src/Radio/index.ts +0 -2
  259. package/src/Radio/sgds-radio.scss +0 -5
  260. package/src/Radio/sgds-radio.ts +0 -120
  261. package/src/Radio/sgds-radiogroup.scss +0 -22
  262. package/src/Radio/sgds-radiogroup.ts +0 -221
  263. package/src/Sidenav/index.ts +0 -4
  264. package/src/Sidenav/sgds-sidenav-item.scss +0 -73
  265. package/src/Sidenav/sgds-sidenav-item.ts +0 -145
  266. package/src/Sidenav/sgds-sidenav-link.scss +0 -25
  267. package/src/Sidenav/sgds-sidenav-link.ts +0 -8
  268. package/src/Sidenav/sgds-sidenav.scss +0 -6
  269. package/src/Sidenav/sgds-sidenav.ts +0 -33
  270. package/src/Tab/index.ts +0 -3
  271. package/src/Tab/sgds-tab.scss +0 -84
  272. package/src/Tab/sgds-tab.ts +0 -87
  273. package/src/Tab/sgds-tabgroup.scss +0 -198
  274. package/src/Tab/sgds-tabgroup.ts +0 -295
  275. package/src/Tab/sgds-tabpanel.scss +0 -12
  276. package/src/Tab/sgds-tabpanel.ts +0 -55
  277. package/src/Textarea/index.ts +0 -1
  278. package/src/Textarea/sgds-textarea.scss +0 -23
  279. package/src/Textarea/sgds-textarea.ts +0 -201
  280. package/src/index.ts +0 -16
  281. package/src/utils/animate.ts +0 -69
  282. package/src/utils/animation-registry.ts +0 -71
  283. package/src/utils/base.scss +0 -14
  284. package/src/utils/breakpoints.ts +0 -5
  285. package/src/utils/card-element.ts +0 -42
  286. package/src/utils/components.style.scss +0 -531
  287. package/src/utils/defaultvalue.ts +0 -51
  288. package/src/utils/dropdown-element.ts +0 -244
  289. package/src/utils/event.ts +0 -13
  290. package/src/utils/form.ts +0 -183
  291. package/src/utils/generateId.ts +0 -4
  292. package/src/utils/link-element.ts +0 -34
  293. package/src/utils/mergeDeep.ts +0 -22
  294. package/src/utils/modal.ts +0 -64
  295. package/src/utils/object.ts +0 -2
  296. package/src/utils/offset.ts +0 -6
  297. package/src/utils/scroll.ts +0 -57
  298. package/src/utils/sgds-element.ts +0 -18
  299. package/src/utils/slot.ts +0 -102
  300. package/src/utils/tabbable.ts +0 -81
  301. package/src/utils/watch.ts +0 -62
  302. package/stories/ActionCard.stories.mdx +0 -199
  303. package/stories/Button.stories.mdx +0 -194
  304. package/stories/Checkbox.stories.mdx +0 -196
  305. package/stories/Dropdown.stories.mdx +0 -152
  306. package/stories/Footer.stories.mdx +0 -261
  307. package/stories/Input.stories.mdx +0 -236
  308. package/stories/MainNav.stories.mdx +0 -169
  309. package/stories/Masthead.stories.mdx +0 -112
  310. package/stories/Modal.stories.mdx +0 -103
  311. package/stories/QuantityToggle.stories.mdx +0 -97
  312. package/stories/Radio.stories.mdx +0 -262
  313. package/stories/Sample.stories.js +0 -29
  314. package/stories/Sample.stories.mdx +0 -33
  315. package/stories/SideNav.stories.mdx +0 -245
  316. package/stories/common.js +0 -185
  317. package/stories/textarea.stories.mdx +0 -253
  318. package/test/button.element.test.ts +0 -185
  319. package/test/checkbox.test.ts +0 -240
  320. package/test/dropdown.test.ts +0 -637
  321. package/test/footer.test.ts +0 -181
  322. package/test/generateId.test.ts +0 -18
  323. package/test/input.element.test.ts +0 -316
  324. package/test/link-element.test.ts +0 -38
  325. package/test/mainnav.test.ts +0 -313
  326. package/test/masthead.test.ts +0 -116
  327. package/test/modal.test.ts +0 -149
  328. package/test/quantitytoggle.test.ts +0 -76
  329. package/test/radio.test.ts +0 -310
  330. package/test/selectable-card.test.ts +0 -159
  331. package/test/sidenav.test.ts +0 -390
  332. package/test/tab.test.ts +0 -76
  333. package/test/textarea.test.ts +0 -126
  334. package/tsconfig.json +0 -26
  335. package/tsconfig.test.json +0 -24
  336. package/typings/scss.d.ts +0 -5
  337. package/web-dev-server.config.mjs +0 -7
  338. package/web-test-runner.config.mjs +0 -47
package/README.md CHANGED
@@ -1,21 +1,113 @@
1
- # sgds-web-component
1
+ <img src="https://img.shields.io/badge/lit-324FFF?style=for-the-badge&logo=lit&logoColor=white" /> &nbsp;
2
+ <img src="https://img.shields.io/badge/Sass-CC6699?style=for-the-badge&logo=sass&logoColor=white" /> &nbsp;
3
+ <img src="https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white" />&nbsp;
2
4
 
3
- This project uses Lit 2.0 + SASS + TS and bundled with rollup.
5
+ # sgds-web-component
4
6
 
5
7
  Project is still in development works. See https://master.d1yxrtldqtp3a0.amplifyapp.com/ for the progress of the components
6
8
 
7
- ## Get Started
9
+ # Installation Guide
10
+
11
+ You can load SGDS's web components via CDN or by installing it locally.
12
+ <!-- <s>If you're using a framework, make sure to check out the pages for React, Vue, and Angular for additional information.</s> -->
13
+
14
+ ## CDN
15
+
16
+ The CDN loader registers all SGDS elements up front. Note that, if you're only using a handful of components. You can also cherry pick components via local imports if you want to load specific ones up front.
17
+
18
+ ```js
19
+
20
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@govtechsg/sgds-web-component"></script>
21
+
22
+ //cherry picked
23
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@govtechsg/sgds-web-component/${Component}/index.js"></script>
24
+
25
+
26
+ ```
27
+
28
+ ## Local Installation
29
+
30
+ You can also install SGDS web components locally with the following command
31
+
32
+ ```js
33
+
34
+ npm install @govtechsg/sgds-web-component
35
+
36
+ ```
37
+
38
+ and import the library once in your entry point
39
+
40
+ ```js
41
+
42
+ import "@govtechsg/sgds-web-component";
43
+
44
+ ```
45
+
46
+
47
+ # Usage Guide
48
+
49
+ ## Cherry Picking
50
+
51
+ We recommend cherry picking your web components whenever to limit the number of files that the browser has to load. Note that the component folder should start with capital letter
52
+
53
+ ```js
54
+
55
+ import "@govtechsg/sgds-web-component/Button";
56
+ //cdn way
57
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@govtechsg/sgds-web-component/Button/index.js"></script>
8
58
 
9
- Clone the repo. Then install.
10
59
 
11
- ```bash
12
- npm install
13
60
  ```
14
61
 
15
- Then start the dev server and rollup watchers
62
+ ## Component dependency
63
+
64
+ Complex components depends on one or more other components under its hood. E.g. Dropdown and Modal component uses Button component
65
+ For such components, you will have to import all of its dependency. The component's dependency will be specified in the Component documentation under Dependency section
66
+
67
+ ```js
68
+ // When using Dropdown component, import both Dropdown and Button
69
+ import "@govtechsg/sgds-web-component/Dropdown";
70
+ import "@govtechsg/sgds-web-component/Button";
16
71
 
17
- ```bash
18
- npm run dev
19
72
  ```
20
73
 
21
- A browser window should open and rollup will watch your files for changes.
74
+ <!-- ## Shoelace Icons
75
+
76
+ SGDS depends on 3rd party library [Shoelace](https://shoelace.style/components/icon) for our icons. We recommend using Shoelace's default icon library which are Bootstrap icons
77
+
78
+ ````js
79
+ // data-shoelace attribute points to the assets folder, where the bootstrap icons are located. If you are copying out the assets folder to your own directory, change the value of data-shoelace to your assets folder
80
+ <script type="module" data-shoelace="node_modules/@shoelace-style/shoelace/dist">
81
+ import '@shoelace-style/shoelace/dist/components/icon/icon.js';
82
+ //<sl-icon> is ready to use!
83
+ </script>
84
+
85
+ ````
86
+
87
+ You can also use the utility `setBasePath` from Shoelace to set the based path of the asset folder
88
+
89
+ ```js
90
+
91
+ import { setBasePath } from '@shoelace-style/shoelace/dist/utilities/base-path.js';
92
+ // Set the base path to the folder you copied Shoelace's assets
93
+ setBasePath('/path/to/shoelace/dist');
94
+
95
+ import '@shoelace-style/shoelace/dist/components/icon/icon.js'
96
+ //<sl-icon> is ready to use!
97
+
98
+ ```
99
+
100
+ Please refer to [Shoelace documentation](https://shoelace.style/getting-started/installation?id=setting-the-base-path) for more information -->
101
+
102
+ ## Stylings
103
+
104
+ ### Component Styles
105
+
106
+ SGDS web component library is shipped with SGDS v2 stylings and does not require you to configure or install any other styling files.
107
+ The styles of components are built in and can be modified via props, cssparts and css custom properties whenever we specify for such styling modificiations. This information will be specified under API section for each component
108
+
109
+ You will require some knowledge of web components and css to do so and the information can be readily available online like mdn web docs for [web components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) and [css](https://developer.mozilla.org/en-US/docs/Web/CSS)
110
+
111
+ ### External stylings
112
+
113
+ Any external stylings done on our web components like positioning needs to be done on your end. You can use [SGDS v2 library](https://designsystem.tech.gov.sg/get-started/)to leverage on the position stylings we provide e.g. ms-auto, flexbox, grids
@@ -0,0 +1,12 @@
1
+ import SgdsElement from "./sgds-element";
2
+ export type CardBorderVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light";
3
+ export type CardTextVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark" | "light" | "white" | "muted";
4
+ export declare class CardElement extends SgdsElement {
5
+ static styles: import("lit").CSSResultGroup;
6
+ borderColor?: CardBorderVariant;
7
+ /** The bg's variant. */
8
+ bgColor?: CardBorderVariant;
9
+ /** The text's variant. */
10
+ textColor?: CardTextVariant;
11
+ disabled: boolean;
12
+ }
@@ -1,37 +1,38 @@
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
- }
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 "../components/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
+ static styles: import("lit").CSSResultGroup;
11
+ myDropdown: Ref<HTMLElement>;
12
+ bsDropdown: Dropdown;
13
+ noFlip: boolean;
14
+ menuAlignRight: boolean;
15
+ drop: DropDirection;
16
+ popperOpts: {};
17
+ togglerId: string;
18
+ togglerText: string;
19
+ variant: DropdownButtonVariant;
20
+ menuIsOpen: boolean;
21
+ close: "outside" | "default" | "inside";
22
+ disabled: boolean;
23
+ nextDropdownItemNo: number;
24
+ prevDropdownItemNo: number;
25
+ dropdownConfig: Partial<Popper.Options>;
26
+ modifierOpt: StrictModifiers[];
27
+ firstUpdated(): void;
28
+ showMenu(): void;
29
+ hideMenu(): void;
30
+ _onClickButton(): void;
31
+ _resetMenu(): void;
32
+ _getMenuItems(): SgdsDropdownItem[];
33
+ _getActiveMenuItems(): SgdsDropdownItem[];
34
+ _setMenuItem(currentItemIdx: number, isArrowDown?: boolean): any;
35
+ _handleSelectSlot(e: KeyboardEvent | MouseEvent): void;
36
+ _handleKeyboardEvent(e: KeyboardEvent): any;
37
+ _handleClickOutOfElement(e: MouseEvent, self: DropdownElement): void;
38
+ }
@@ -1,7 +1,8 @@
1
- import SgdsElement from "../utils/sgds-element";
2
- export default class LinkElement extends SgdsElement {
3
- active: boolean;
4
- href: string;
5
- disabled: boolean;
6
- render(): import("lit").TemplateResult<1>;
7
- }
1
+ import SgdsElement from "./sgds-element";
2
+ export default class LinkElement extends SgdsElement {
3
+ static styles: import("lit").CSSResultGroup;
4
+ active: boolean;
5
+ href: string;
6
+ disabled: boolean;
7
+ render(): import("lit").TemplateResult<1>;
8
+ }
@@ -1,5 +1,6 @@
1
- import { LitElement } from 'lit';
2
- export default class SgdsElement extends LitElement {
3
- /** Emits a custom event with more convenient defaults. */
4
- emit(name: string, options?: CustomEventInit): CustomEvent<any>;
5
- }
1
+ import { LitElement } from "lit";
2
+ export default class SgdsElement extends LitElement {
3
+ static styles: import("lit").CSSResultGroup;
4
+ /** Emits a custom event with more convenient defaults. */
5
+ emit(name: string, options?: CustomEventInit): CustomEvent<any>;
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./sgds-accordion";
2
+ export * from "./sgds-accordion-item";
@@ -0,0 +1,40 @@
1
+ import SgdsElement from "../../base/sgds-element";
2
+ /**
3
+ * @slot default - content of the accordion item
4
+ *
5
+ * @event sgds-show - Emitted on show.
6
+ * @event sgds-after-show - Emitted on show after animation has completed.
7
+ * @event sgds-hide - Emitted on hide.
8
+ * @event sgds-after-hide - Emitted on hide after animation has completed.
9
+ *
10
+ * @csspart base - The accordion-item base wrapper
11
+ * @csspart header - The accordion-item button header
12
+ * @csspart content - The accordion-item content
13
+ */
14
+ export declare class SgdsAccordionItem extends SgdsElement {
15
+ static styles: import("lit").CSSResultGroup[];
16
+ /** @internal */
17
+ accordion: HTMLElement;
18
+ /** @internal */
19
+ header: HTMLElement;
20
+ /** @internal */
21
+ body: HTMLElement;
22
+ /** Controls whether accordion-item is open or close */
23
+ open: boolean;
24
+ /** Title of the accordion */
25
+ summary: string;
26
+ /** Disables the accordion-item. When true, accordion-item cannot open */
27
+ disabled: boolean;
28
+ /** Optional for accordion item. Can be used to insert any utility classes such as `me-auto` */
29
+ accordionItemClasses?: string;
30
+ firstUpdated(): void;
31
+ private handleSummaryClick;
32
+ private handleSummaryKeyDown;
33
+ handleOpenChange(): Promise<void>;
34
+ /** Shows the accordion. */
35
+ show(): Promise<void>;
36
+ /** Hide the accordion */
37
+ hide(): Promise<void>;
38
+ render(): import("lit").TemplateResult<1>;
39
+ }
40
+ export default SgdsAccordionItem;
@@ -0,0 +1,19 @@
1
+ import SgdsElement from "../../base/sgds-element";
2
+ import type SgdsAccordionItem from "./sgds-accordion-item";
3
+ /**
4
+ * @summary A dropdown mechanism that allow users to either show or hide related content.
5
+ * @slot default - slot for accordion-item
6
+ */
7
+ export declare class SgdsAccordion extends SgdsElement {
8
+ static styles: import("lit").CSSResultGroup[];
9
+ allowMultiple: boolean;
10
+ accordionClasses?: string;
11
+ /** @internal */
12
+ private defaultNodes;
13
+ /** @internal */
14
+ get items(): SgdsAccordionItem[];
15
+ firstUpdated(): void;
16
+ onToggle(event: Event): Promise<void>;
17
+ render(): import("lit").TemplateResult<1>;
18
+ }
19
+ export default SgdsAccordion;
@@ -0,0 +1 @@
1
+ export * from "./sgds-action-card";
@@ -1,20 +1,21 @@
1
- import { CardElement } from "../utils/card-element";
2
- import { Ref } from "lit/directives/ref.js";
3
- export type CardVariant = "card-action" | "card-action-quantity-toggle";
4
- export type TypeVariant = "checkbox" | "radio";
5
- export declare class SgdsActionCard extends CardElement {
6
- static styles: import("lit").CSSResultGroup;
7
- inputRef: Ref<HTMLInputElement>;
8
- type?: TypeVariant;
9
- /** Use on actionable cards like SelectableCard and Quantity Toggle Card' */
10
- variant?: CardVariant;
11
- /** The card's subtitle iconName. */
12
- iconName?: string;
13
- /** The input's id. */
14
- inputId?: string;
15
- active: boolean;
16
- onInputChange(): void;
17
- handleKeyDown(event: KeyboardEvent): void;
18
- render(): import("lit").TemplateResult<1 | 2>;
19
- }
20
- export default SgdsActionCard;
1
+ import { Ref } from "lit/directives/ref.js";
2
+ import { CardElement } from "../../base/card-element";
3
+ export type CardVariant = "card-action" | "card-action-quantity-toggle";
4
+ export type TypeVariant = "checkbox" | "radio";
5
+ export declare class SgdsActionCard extends CardElement {
6
+ static styles: import("lit").CSSResultGroup[];
7
+ /** @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;
16
+ active: boolean;
17
+ onInputChange(): void;
18
+ handleKeyDown(event: KeyboardEvent): void;
19
+ render(): import("lit").TemplateResult;
20
+ }
21
+ export default SgdsActionCard;
@@ -0,0 +1 @@
1
+ export * from "./sgds-alert";
@@ -0,0 +1,37 @@
1
+ import SgdsElement from "../../base/sgds-element";
2
+ /**
3
+ *
4
+ * @dependency sl-icon-button
5
+ *
6
+ * @slot - The alert's main content.
7
+ * @slot icon - An icon to show in the alert. Works best with `<sl-icon>`.
8
+ *
9
+ * @event sl-show - Emitted when the alert opens.
10
+ * @event sl-after-show - Emitted after the alert opens and all animations are complete.
11
+ * @event sl-hide - Emitted when the alert closes.
12
+ * @event sl-after-hide - Emitted after the alert closes and all animations are complete.
13
+ *
14
+ * @csspart base - The component's base wrapper.
15
+ * @csspart icon - The container that wraps the optional icon.
16
+ * @csspart message - The container that wraps the alert's main content.
17
+ * @csspart close-button - The close button, an `<sl-icon-button>`.
18
+ * @csspart close-button__base - The close button's exported `base` part.
19
+ *
20
+ * @animation alert.show - The animation to use when showing the alert.
21
+ * @animation alert.hide - The animation to use when hiding the alert.
22
+ */
23
+ export type AlertVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light";
24
+ export declare class SgdsAlert extends SgdsElement {
25
+ static styles: import("lit").CSSResultGroup[];
26
+ show: boolean;
27
+ /** Enables a close button that allows the user to dismiss the alert. */
28
+ dismissible?: boolean;
29
+ /** The alert's theme variant. */
30
+ variant: AlertVariant;
31
+ closeLabel?: string;
32
+ alertClasses?: string;
33
+ toggleShow(): void;
34
+ handleCloseClick(): void;
35
+ render(): import("lit").TemplateResult;
36
+ }
37
+ export default SgdsAlert;
@@ -0,0 +1 @@
1
+ export { SgdsBadge } from "./sgds-badge";
@@ -0,0 +1,10 @@
1
+ import SgdsElement from "../../base/sgds-element";
2
+ export type BadgeVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
3
+ export declare class SgdsBadge extends SgdsElement {
4
+ static styles: import("lit").CSSResultGroup[];
5
+ variant: BadgeVariant;
6
+ isLight: any;
7
+ roundedPill: any;
8
+ render(): import("lit").TemplateResult<1>;
9
+ }
10
+ export default SgdsBadge;
@@ -0,0 +1,2 @@
1
+ export { SgdsBreadcrumb } from "./sgds-breadcrumb";
2
+ export { SgdsBreadcrumbItem } from "./sgds-breadcrumb-item";
@@ -0,0 +1,10 @@
1
+ import SgdsElement from "../../base/sgds-element";
2
+ export declare class SgdsBreadcrumbItem extends SgdsElement {
3
+ static styles: import("lit").CSSResultGroup[];
4
+ currentPage: any;
5
+ href: any;
6
+ target?: "_blank" | "_parent" | "_self" | "_top";
7
+ rel: string;
8
+ render(): import("lit").TemplateResult<1>;
9
+ }
10
+ export default SgdsBreadcrumbItem;
@@ -0,0 +1,12 @@
1
+ import SgdsElement from "../../base/sgds-element";
2
+ export declare class SgdsBreadcrumb extends SgdsElement {
3
+ static styles: import("lit").CSSResultGroup[];
4
+ ariaLabel: string;
5
+ breadcrumbClasses?: string;
6
+ defaultSlot: HTMLSlotElement;
7
+ separatorSlot: HTMLSlotElement;
8
+ private getSeparator;
9
+ private handleSlotChange;
10
+ render(): import("lit").TemplateResult;
11
+ }
12
+ export default SgdsBreadcrumb;
@@ -0,0 +1 @@
1
+ export * from "./sgds-button";
@@ -1,48 +1,55 @@
1
- import SgdsElement from "../utils/sgds-element";
2
- export type ButtonVariant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark" | "link" | "icon" | "outline-primary" | "outline-secondary" | "outline-success" | "outline-danger" | "outline-warning" | "outline-info" | "outline-light" | "outline-dark";
3
- export declare class SgdsButton extends SgdsElement {
4
- static styles: import("lit").CSSResultGroup;
5
- button: HTMLButtonElement | HTMLLinkElement;
6
- private readonly formSubmitController;
7
- private hasFocus;
8
- /** The button's variant. */
9
- variant: ButtonVariant;
10
- buttonClasses?: string;
11
- /** Button sizes */
12
- size: 'sm' | 'lg';
13
- /** Button active state */
14
- active: boolean;
15
- /** Button disabled state */
16
- disabled: boolean;
17
- type: 'button' | 'submit' | 'reset';
18
- /** When set, the underlying button will be rendered as an `<a>` with this `href` instead of a `<button>`. */
19
- href?: string;
20
- /** Tells the browser where to open the link. Only used when `href` is set. */
21
- target?: '_blank' | '_parent' | '_self' | '_top';
22
- /** Tells the browser to download the linked file as this filename. Only used when `href` is set. */
23
- download?: string;
24
- /**
25
- * The "form owner" to associate the button with. If omitted, the closest containing form will be used instead. The
26
- * value of this attribute must be an id of a form in the same document or shadow root as the button.
27
- */
28
- form: string;
29
- /** Used to override the form owner's `action` attribute. */
30
- formAction: string;
31
- /** Used to override the form owner's `method` attribute. */
32
- formMethod: 'post' | 'get';
33
- /** Used to override the form owner's `novalidate` attribute. */
34
- formNoValidate: boolean;
35
- /** Used to override the form owner's `target` attribute. */
36
- formTarget: '_self' | '_blank' | '_parent' | '_top' | string;
37
- /** Sets focus on the button. */
38
- focus(options?: FocusOptions): void;
39
- /** Simulates a click on the button. */
40
- click(): void;
41
- /** Removes focus from the button. */
42
- blur(): void;
43
- handleBlur(): void;
44
- handleFocus(): void;
45
- handleClick(event: MouseEvent): void;
46
- render(): import("lit").TemplateResult<1 | 2>;
47
- }
48
- export default SgdsButton;
1
+ import SgdsElement from "../../base/sgds-element";
2
+ export type ButtonVariant = "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
+ * @slot - The button's label.
5
+ *
6
+ * @event sgds-blur - Emitted when the button is not focused.
7
+ * @event sgds-focus - Emitted when the button is focused.
8
+ */
9
+ export declare class SgdsButton extends SgdsElement {
10
+ static styles: import("lit").CSSResultGroup[];
11
+ button: HTMLButtonElement | HTMLLinkElement;
12
+ private readonly formSubmitController;
13
+ private hasFocus;
14
+ /** The button's variant. */
15
+ variant: ButtonVariant;
16
+ buttonClasses?: string;
17
+ /** Button sizes */
18
+ size: "sm" | "lg";
19
+ /** Button active state */
20
+ active: boolean;
21
+ /** Button disabled state */
22
+ disabled: boolean;
23
+ type: "button" | "submit" | "reset";
24
+ /** When set, the underlying button will be rendered as an `<a>` with this `href` instead of a `<button>`. */
25
+ href?: string;
26
+ /** Tells the browser where to open the link. Only used when `href` is set. */
27
+ target?: "_blank" | "_parent" | "_self" | "_top";
28
+ /** Tells the browser to download the linked file as this filename. Only used when `href` is set. */
29
+ download?: string;
30
+ /**
31
+ * The "form owner" to associate the button with. If omitted, the closest containing form will be used instead. The
32
+ * value of this attribute must be an id of a form in the same document or shadow root as the button.
33
+ */
34
+ form: string;
35
+ /** Used to override the form owner's `action` attribute. */
36
+ formAction: string;
37
+ /** Used to override the form owner's `method` attribute. */
38
+ formMethod: "post" | "get";
39
+ /** Used to override the form owner's `novalidate` attribute. */
40
+ formNoValidate: boolean;
41
+ /** Used to override the form owner's `target` attribute. */
42
+ formTarget: "_self" | "_blank" | "_parent" | "_top" | string;
43
+ /** Sets focus on the button. */
44
+ focus(options?: FocusOptions): void;
45
+ /** Simulates a click on the button. */
46
+ click(): void;
47
+ /** Removes focus from the button. */
48
+ blur(): void;
49
+ handleBlur(): void;
50
+ handleFocus(): void;
51
+ handleClick(event: MouseEvent): void;
52
+ clickHandler: () => void;
53
+ render(): import("lit").TemplateResult;
54
+ }
55
+ export default SgdsButton;
@@ -0,0 +1 @@
1
+ export * from "./sgds-checkbox";
@@ -1,36 +1,36 @@
1
- import SgdsElement from "../utils/sgds-element";
2
- export declare class SgdsCheckbox extends SgdsElement {
3
- static styles: import("lit").CSSResultGroup;
4
- input: HTMLInputElement;
5
- private readonly formSubmitController;
6
- /** Name of the HTML form control. Submitted with the form as part of a name/value pair. */
7
- name: string;
8
- /** For Id/For pair of the HTML form control. */
9
- checkboxId: string;
10
- /** For aria-label when there is no appropriate text label visible */
11
- ariaLabel: string;
12
- /** Manually style the input as valid */
13
- valid: boolean;
14
- /** Manually style the input as invalid */
15
- invalid: boolean;
16
- /** Value of the HTML form control. Primarily used to differentiate a list of related checkboxes that have the same name. */
17
- value: string;
18
- /** Makes the checkbox a required field. */
19
- required: boolean;
20
- /** Draws the checkbox in a checked state. */
21
- checked: boolean;
22
- /** Disables the checkbox (so the user can't check / uncheck it). */
23
- disabled: boolean;
24
- /** 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. */
25
- defaultChecked: boolean;
26
- /** Simulates a click on the checkbox. */
27
- click(): void;
28
- /** Checks for validity and shows the browser's validation message if the control is invalid. */
29
- reportValidity(): boolean;
30
- handleChange(): void;
31
- handleKeyDown(event: KeyboardEvent): void;
32
- handleDisabledChange(): void;
33
- handleStateChange(): void;
34
- render(): import("lit").TemplateResult<1>;
35
- }
36
- export default SgdsCheckbox;
1
+ import SgdsElement from "../../base/sgds-element";
2
+ export declare class SgdsCheckbox extends SgdsElement {
3
+ static styles: import("lit").CSSResultGroup[];
4
+ input: HTMLInputElement;
5
+ private readonly formSubmitController;
6
+ /** Name of the HTML form control. Submitted with the form as part of a name/value pair. */
7
+ name: string;
8
+ /** For Id/For pair of the HTML form control. */
9
+ checkboxId: string;
10
+ /** For aria-label when there is no appropriate text label visible */
11
+ ariaLabel: string;
12
+ /** Manually style the input as valid */
13
+ valid: boolean;
14
+ /** Manually style the input as invalid */
15
+ invalid: boolean;
16
+ /** Value of the HTML form control. Primarily used to differentiate a list of related checkboxes that have the same name. */
17
+ value: string;
18
+ /** Makes the checkbox a required field. */
19
+ required: boolean;
20
+ /** Draws the checkbox in a checked state. */
21
+ checked: boolean;
22
+ /** Disables the checkbox (so the user can't check / uncheck it). */
23
+ disabled: boolean;
24
+ /** 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. */
25
+ defaultChecked: boolean;
26
+ /** Simulates a click on the checkbox. */
27
+ click(): void;
28
+ /** Checks for validity and shows the browser's validation message if the control is invalid. */
29
+ reportValidity(): boolean;
30
+ handleChange(): void;
31
+ handleKeyDown(event: KeyboardEvent): void;
32
+ handleDisabledChange(): void;
33
+ handleStateChange(): void;
34
+ render(): import("lit").TemplateResult<1>;
35
+ }
36
+ export default SgdsCheckbox;
@@ -0,0 +1 @@
1
+ export { SgdsCloseButton } from "./sgds-closebutton";