@korzun/design 0.0.0-stage → 0.0.2

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 (608) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +73 -2
  3. package/dist/component/card/index.d.ts +15 -0
  4. package/dist/component/card/index.d.ts.map +1 -0
  5. package/dist/component/card/index.js +34 -0
  6. package/dist/component/card/index.js.map +1 -0
  7. package/dist/component/card/style.d.ts +5 -0
  8. package/dist/component/card/style.d.ts.map +1 -0
  9. package/dist/component/card/style.js +69 -0
  10. package/dist/component/card/style.js.map +1 -0
  11. package/dist/component/card-divider/index.d.ts +10 -0
  12. package/dist/component/card-divider/index.d.ts.map +1 -0
  13. package/dist/component/card-divider/index.js +23 -0
  14. package/dist/component/card-divider/index.js.map +1 -0
  15. package/dist/component/card-divider/style.d.ts +5 -0
  16. package/dist/component/card-divider/style.d.ts.map +1 -0
  17. package/dist/component/card-divider/style.js +48 -0
  18. package/dist/component/card-divider/style.js.map +1 -0
  19. package/dist/component/card-row/index.d.ts +6 -0
  20. package/dist/component/card-row/index.d.ts.map +1 -0
  21. package/dist/component/card-row/index.js +16 -0
  22. package/dist/component/card-row/index.js.map +1 -0
  23. package/dist/component/card-row/style.d.ts +5 -0
  24. package/dist/component/card-row/style.d.ts.map +1 -0
  25. package/dist/component/card-row/style.js +13 -0
  26. package/dist/component/card-row/style.js.map +1 -0
  27. package/dist/component/collapsible-section/index.d.ts +11 -0
  28. package/dist/component/collapsible-section/index.d.ts.map +1 -0
  29. package/dist/component/collapsible-section/index.js +20 -0
  30. package/dist/component/collapsible-section/index.js.map +1 -0
  31. package/dist/component/collapsible-section/style.d.ts +5 -0
  32. package/dist/component/collapsible-section/style.d.ts.map +1 -0
  33. package/dist/component/collapsible-section/style.js +36 -0
  34. package/dist/component/collapsible-section/style.js.map +1 -0
  35. package/dist/component/empty-state/index.d.ts +22 -0
  36. package/dist/component/empty-state/index.d.ts.map +1 -0
  37. package/dist/component/empty-state/index.js +19 -0
  38. package/dist/component/empty-state/index.js.map +1 -0
  39. package/dist/component/empty-state/style.d.ts +5 -0
  40. package/dist/component/empty-state/style.d.ts.map +1 -0
  41. package/dist/component/empty-state/style.js +30 -0
  42. package/dist/component/empty-state/style.js.map +1 -0
  43. package/dist/component/index.d.ts +16 -0
  44. package/dist/component/index.d.ts.map +1 -0
  45. package/dist/component/index.js +15 -0
  46. package/dist/component/index.js.map +1 -0
  47. package/dist/component/meta-line/index.d.ts +21 -0
  48. package/dist/component/meta-line/index.d.ts.map +1 -0
  49. package/dist/component/meta-line/index.js +24 -0
  50. package/dist/component/meta-line/index.js.map +1 -0
  51. package/dist/component/meta-line/style.d.ts +5 -0
  52. package/dist/component/meta-line/style.d.ts.map +1 -0
  53. package/dist/component/meta-line/style.js +35 -0
  54. package/dist/component/meta-line/style.js.map +1 -0
  55. package/dist/component/metadata/index.d.ts +6 -0
  56. package/dist/component/metadata/index.d.ts.map +1 -0
  57. package/dist/component/metadata/index.js +7 -0
  58. package/dist/component/metadata/index.js.map +1 -0
  59. package/dist/component/metadata/style.d.ts +5 -0
  60. package/dist/component/metadata/style.d.ts.map +1 -0
  61. package/dist/component/metadata/style.js +20 -0
  62. package/dist/component/metadata/style.js.map +1 -0
  63. package/dist/component/metadata-list/index.d.ts +10 -0
  64. package/dist/component/metadata-list/index.d.ts.map +1 -0
  65. package/dist/component/metadata-list/index.js +9 -0
  66. package/dist/component/metadata-list/index.js.map +1 -0
  67. package/dist/component/metadata-list/style.d.ts +5 -0
  68. package/dist/component/metadata-list/style.d.ts.map +1 -0
  69. package/dist/component/metadata-list/style.js +10 -0
  70. package/dist/component/metadata-list/style.js.map +1 -0
  71. package/dist/component/nav-desktop/index.d.ts +6 -0
  72. package/dist/component/nav-desktop/index.d.ts.map +1 -0
  73. package/dist/component/nav-desktop/index.js +11 -0
  74. package/dist/component/nav-desktop/index.js.map +1 -0
  75. package/dist/component/nav-desktop/style.d.ts +5 -0
  76. package/dist/component/nav-desktop/style.d.ts.map +1 -0
  77. package/dist/component/nav-desktop/style.js +94 -0
  78. package/dist/component/nav-desktop/style.js.map +1 -0
  79. package/dist/component/nav-mobile/index.d.ts +25 -0
  80. package/dist/component/nav-mobile/index.d.ts.map +1 -0
  81. package/dist/component/nav-mobile/index.js +153 -0
  82. package/dist/component/nav-mobile/index.js.map +1 -0
  83. package/dist/component/nav-mobile/style.d.ts +5 -0
  84. package/dist/component/nav-mobile/style.d.ts.map +1 -0
  85. package/dist/component/nav-mobile/style.js +347 -0
  86. package/dist/component/nav-mobile/style.js.map +1 -0
  87. package/dist/component/nav-types.d.ts +12 -0
  88. package/dist/component/nav-types.d.ts.map +1 -0
  89. package/dist/component/nav-types.js +2 -0
  90. package/dist/component/nav-types.js.map +1 -0
  91. package/dist/component/page/index.d.ts +33 -0
  92. package/dist/component/page/index.d.ts.map +1 -0
  93. package/dist/component/page/index.js +20 -0
  94. package/dist/component/page/index.js.map +1 -0
  95. package/dist/component/page/style.d.ts +10 -0
  96. package/dist/component/page/style.d.ts.map +1 -0
  97. package/dist/component/page/style.js +132 -0
  98. package/dist/component/page/style.js.map +1 -0
  99. package/dist/component/progress-indicator/index.d.ts +17 -0
  100. package/dist/component/progress-indicator/index.d.ts.map +1 -0
  101. package/dist/component/progress-indicator/index.js +19 -0
  102. package/dist/component/progress-indicator/index.js.map +1 -0
  103. package/dist/component/progress-indicator/style.d.ts +5 -0
  104. package/dist/component/progress-indicator/style.d.ts.map +1 -0
  105. package/dist/component/progress-indicator/style.js +24 -0
  106. package/dist/component/progress-indicator/style.js.map +1 -0
  107. package/dist/component/tag/index.d.ts +9 -0
  108. package/dist/component/tag/index.d.ts.map +1 -0
  109. package/dist/component/tag/index.js +15 -0
  110. package/dist/component/tag/index.js.map +1 -0
  111. package/dist/component/tag/style.d.ts +5 -0
  112. package/dist/component/tag/style.d.ts.map +1 -0
  113. package/dist/component/tag/style.js +28 -0
  114. package/dist/component/tag/style.js.map +1 -0
  115. package/dist/component/theme-setting/index.d.ts +2 -0
  116. package/dist/component/theme-setting/index.d.ts.map +1 -0
  117. package/dist/component/theme-setting/index.js +14 -0
  118. package/dist/component/theme-setting/index.js.map +1 -0
  119. package/dist/component/top-fade/index.d.ts +2 -0
  120. package/dist/component/top-fade/index.d.ts.map +1 -0
  121. package/dist/component/top-fade/index.js +9 -0
  122. package/dist/component/top-fade/index.js.map +1 -0
  123. package/dist/component/top-fade/style.d.ts +5 -0
  124. package/dist/component/top-fade/style.d.ts.map +1 -0
  125. package/dist/component/top-fade/style.js +57 -0
  126. package/dist/component/top-fade/style.js.map +1 -0
  127. package/dist/control/action-menu-list/index.d.ts +44 -0
  128. package/dist/control/action-menu-list/index.d.ts.map +1 -0
  129. package/dist/control/action-menu-list/index.js +9 -0
  130. package/dist/control/action-menu-list/index.js.map +1 -0
  131. package/dist/control/action-menu-list/style.d.ts +5 -0
  132. package/dist/control/action-menu-list/style.d.ts.map +1 -0
  133. package/dist/control/action-menu-list/style.js +51 -0
  134. package/dist/control/action-menu-list/style.js.map +1 -0
  135. package/dist/control/action-menu-list/use-dismiss.d.ts +3 -0
  136. package/dist/control/action-menu-list/use-dismiss.d.ts.map +1 -0
  137. package/dist/control/action-menu-list/use-dismiss.js +25 -0
  138. package/dist/control/action-menu-list/use-dismiss.js.map +1 -0
  139. package/dist/control/back-button/index.d.ts +6 -0
  140. package/dist/control/back-button/index.d.ts.map +1 -0
  141. package/dist/control/back-button/index.js +20 -0
  142. package/dist/control/back-button/index.js.map +1 -0
  143. package/dist/control/back-button/style.d.ts +5 -0
  144. package/dist/control/back-button/style.d.ts.map +1 -0
  145. package/dist/control/back-button/style.js +26 -0
  146. package/dist/control/back-button/style.js.map +1 -0
  147. package/dist/control/button/index.d.ts +36 -0
  148. package/dist/control/button/index.d.ts.map +1 -0
  149. package/dist/control/button/index.js +39 -0
  150. package/dist/control/button/index.js.map +1 -0
  151. package/dist/control/button/style.d.ts +24 -0
  152. package/dist/control/button/style.d.ts.map +1 -0
  153. package/dist/control/button/style.js +370 -0
  154. package/dist/control/button/style.js.map +1 -0
  155. package/dist/control/chips-input/index.d.ts +17 -0
  156. package/dist/control/chips-input/index.d.ts.map +1 -0
  157. package/dist/control/chips-input/index.js +77 -0
  158. package/dist/control/chips-input/index.js.map +1 -0
  159. package/dist/control/chips-input/style.d.ts +10 -0
  160. package/dist/control/chips-input/style.d.ts.map +1 -0
  161. package/dist/control/chips-input/style.js +152 -0
  162. package/dist/control/chips-input/style.js.map +1 -0
  163. package/dist/control/confirm-modal/index.d.ts +17 -0
  164. package/dist/control/confirm-modal/index.d.ts.map +1 -0
  165. package/dist/control/confirm-modal/index.js +22 -0
  166. package/dist/control/confirm-modal/index.js.map +1 -0
  167. package/dist/control/confirm-modal/style.d.ts +5 -0
  168. package/dist/control/confirm-modal/style.d.ts.map +1 -0
  169. package/dist/control/confirm-modal/style.js +33 -0
  170. package/dist/control/confirm-modal/style.js.map +1 -0
  171. package/dist/control/date-time-input/index.d.ts +21 -0
  172. package/dist/control/date-time-input/index.d.ts.map +1 -0
  173. package/dist/control/date-time-input/index.js +35 -0
  174. package/dist/control/date-time-input/index.js.map +1 -0
  175. package/dist/control/date-time-input/iso-date.d.ts +25 -0
  176. package/dist/control/date-time-input/iso-date.d.ts.map +1 -0
  177. package/dist/control/date-time-input/iso-date.js +51 -0
  178. package/dist/control/date-time-input/iso-date.js.map +1 -0
  179. package/dist/control/date-time-input/style.d.ts +5 -0
  180. package/dist/control/date-time-input/style.d.ts.map +1 -0
  181. package/dist/control/date-time-input/style.js +72 -0
  182. package/dist/control/date-time-input/style.js.map +1 -0
  183. package/dist/control/field-list/index.d.ts +26 -0
  184. package/dist/control/field-list/index.d.ts.map +1 -0
  185. package/dist/control/field-list/index.js +11 -0
  186. package/dist/control/field-list/index.js.map +1 -0
  187. package/dist/control/field-list/style.d.ts +5 -0
  188. package/dist/control/field-list/style.d.ts.map +1 -0
  189. package/dist/control/field-list/style.js +43 -0
  190. package/dist/control/field-list/style.js.map +1 -0
  191. package/dist/control/index.d.ts +23 -0
  192. package/dist/control/index.d.ts.map +1 -0
  193. package/dist/control/index.js +18 -0
  194. package/dist/control/index.js.map +1 -0
  195. package/dist/control/number-input/index.d.ts +12 -0
  196. package/dist/control/number-input/index.d.ts.map +1 -0
  197. package/dist/control/number-input/index.js +34 -0
  198. package/dist/control/number-input/index.js.map +1 -0
  199. package/dist/control/number-input/style.d.ts +5 -0
  200. package/dist/control/number-input/style.d.ts.map +1 -0
  201. package/dist/control/number-input/style.js +50 -0
  202. package/dist/control/number-input/style.js.map +1 -0
  203. package/dist/control/page-actions-bar/index.d.ts +11 -0
  204. package/dist/control/page-actions-bar/index.d.ts.map +1 -0
  205. package/dist/control/page-actions-bar/index.js +26 -0
  206. package/dist/control/page-actions-bar/index.js.map +1 -0
  207. package/dist/control/page-actions-bar/style.d.ts +5 -0
  208. package/dist/control/page-actions-bar/style.d.ts.map +1 -0
  209. package/dist/control/page-actions-bar/style.js +63 -0
  210. package/dist/control/page-actions-bar/style.js.map +1 -0
  211. package/dist/control/page-actions-menu/index.d.ts +7 -0
  212. package/dist/control/page-actions-menu/index.d.ts.map +1 -0
  213. package/dist/control/page-actions-menu/index.js +19 -0
  214. package/dist/control/page-actions-menu/index.js.map +1 -0
  215. package/dist/control/page-actions-menu/style.d.ts +5 -0
  216. package/dist/control/page-actions-menu/style.d.ts.map +1 -0
  217. package/dist/control/page-actions-menu/style.js +33 -0
  218. package/dist/control/page-actions-menu/style.js.map +1 -0
  219. package/dist/control/page-footer-actions/index.d.ts +17 -0
  220. package/dist/control/page-footer-actions/index.d.ts.map +1 -0
  221. package/dist/control/page-footer-actions/index.js +14 -0
  222. package/dist/control/page-footer-actions/index.js.map +1 -0
  223. package/dist/control/page-footer-actions/style.d.ts +5 -0
  224. package/dist/control/page-footer-actions/style.d.ts.map +1 -0
  225. package/dist/control/page-footer-actions/style.js +12 -0
  226. package/dist/control/page-footer-actions/style.js.map +1 -0
  227. package/dist/control/popover/index.d.ts +27 -0
  228. package/dist/control/popover/index.d.ts.map +1 -0
  229. package/dist/control/popover/index.js +58 -0
  230. package/dist/control/popover/index.js.map +1 -0
  231. package/dist/control/popover/style.d.ts +5 -0
  232. package/dist/control/popover/style.d.ts.map +1 -0
  233. package/dist/control/popover/style.js +8 -0
  234. package/dist/control/popover/style.js.map +1 -0
  235. package/dist/control/segmented-control/index.d.ts +55 -0
  236. package/dist/control/segmented-control/index.d.ts.map +1 -0
  237. package/dist/control/segmented-control/index.js +107 -0
  238. package/dist/control/segmented-control/index.js.map +1 -0
  239. package/dist/control/segmented-control/style.d.ts +5 -0
  240. package/dist/control/segmented-control/style.d.ts.map +1 -0
  241. package/dist/control/segmented-control/style.js +149 -0
  242. package/dist/control/segmented-control/style.js.map +1 -0
  243. package/dist/control/select/index.d.ts +37 -0
  244. package/dist/control/select/index.d.ts.map +1 -0
  245. package/dist/control/select/index.js +138 -0
  246. package/dist/control/select/index.js.map +1 -0
  247. package/dist/control/select/style.d.ts +5 -0
  248. package/dist/control/select/style.d.ts.map +1 -0
  249. package/dist/control/select/style.js +192 -0
  250. package/dist/control/select/style.js.map +1 -0
  251. package/dist/control/switch/index.d.ts +39 -0
  252. package/dist/control/switch/index.d.ts.map +1 -0
  253. package/dist/control/switch/index.js +94 -0
  254. package/dist/control/switch/index.js.map +1 -0
  255. package/dist/control/switch/style.d.ts +36 -0
  256. package/dist/control/switch/style.d.ts.map +1 -0
  257. package/dist/control/switch/style.js +159 -0
  258. package/dist/control/switch/style.js.map +1 -0
  259. package/dist/control/text-area/index.d.ts +15 -0
  260. package/dist/control/text-area/index.d.ts.map +1 -0
  261. package/dist/control/text-area/index.js +44 -0
  262. package/dist/control/text-area/index.js.map +1 -0
  263. package/dist/control/text-area/style.d.ts +5 -0
  264. package/dist/control/text-area/style.d.ts.map +1 -0
  265. package/dist/control/text-area/style.js +85 -0
  266. package/dist/control/text-area/style.js.map +1 -0
  267. package/dist/control/text-input/index.d.ts +25 -0
  268. package/dist/control/text-input/index.d.ts.map +1 -0
  269. package/dist/control/text-input/index.js +43 -0
  270. package/dist/control/text-input/index.js.map +1 -0
  271. package/dist/control/text-input/style.d.ts +5 -0
  272. package/dist/control/text-input/style.d.ts.map +1 -0
  273. package/dist/control/text-input/style.js +80 -0
  274. package/dist/control/text-input/style.js.map +1 -0
  275. package/dist/control/use-modal-dialog/index.d.ts +24 -0
  276. package/dist/control/use-modal-dialog/index.d.ts.map +1 -0
  277. package/dist/control/use-modal-dialog/index.js +73 -0
  278. package/dist/control/use-modal-dialog/index.js.map +1 -0
  279. package/dist/hooks/index.d.ts +6 -0
  280. package/dist/hooks/index.d.ts.map +1 -0
  281. package/dist/hooks/index.js +4 -0
  282. package/dist/hooks/index.js.map +1 -0
  283. package/dist/hooks/is-standalone.d.ts +2 -0
  284. package/dist/hooks/is-standalone.d.ts.map +1 -0
  285. package/dist/hooks/is-standalone.js +10 -0
  286. package/dist/hooks/is-standalone.js.map +1 -0
  287. package/dist/hooks/use-minimize-on-scroll.d.ts +48 -0
  288. package/dist/hooks/use-minimize-on-scroll.d.ts.map +1 -0
  289. package/dist/hooks/use-minimize-on-scroll.js +123 -0
  290. package/dist/hooks/use-minimize-on-scroll.js.map +1 -0
  291. package/dist/hooks/use-pull-to-refresh.d.ts +37 -0
  292. package/dist/hooks/use-pull-to-refresh.d.ts.map +1 -0
  293. package/dist/hooks/use-pull-to-refresh.js +116 -0
  294. package/dist/hooks/use-pull-to-refresh.js.map +1 -0
  295. package/dist/icon/adjustments-horizontal.d.ts +3 -0
  296. package/dist/icon/adjustments-horizontal.d.ts.map +1 -0
  297. package/dist/icon/adjustments-horizontal.js +11 -0
  298. package/dist/icon/adjustments-horizontal.js.map +1 -0
  299. package/dist/icon/alert-octagon.d.ts +3 -0
  300. package/dist/icon/alert-octagon.d.ts.map +1 -0
  301. package/dist/icon/alert-octagon.js +8 -0
  302. package/dist/icon/alert-octagon.js.map +1 -0
  303. package/dist/icon/book.d.ts +3 -0
  304. package/dist/icon/book.d.ts.map +1 -0
  305. package/dist/icon/book.js +11 -0
  306. package/dist/icon/book.js.map +1 -0
  307. package/dist/icon/books.d.ts +3 -0
  308. package/dist/icon/books.d.ts.map +1 -0
  309. package/dist/icon/books.js +11 -0
  310. package/dist/icon/books.js.map +1 -0
  311. package/dist/icon/check.d.ts +3 -0
  312. package/dist/icon/check.d.ts.map +1 -0
  313. package/dist/icon/check.js +8 -0
  314. package/dist/icon/check.js.map +1 -0
  315. package/dist/icon/chevron-circle.d.ts +3 -0
  316. package/dist/icon/chevron-circle.d.ts.map +1 -0
  317. package/dist/icon/chevron-circle.js +11 -0
  318. package/dist/icon/chevron-circle.js.map +1 -0
  319. package/dist/icon/chevron.d.ts +3 -0
  320. package/dist/icon/chevron.d.ts.map +1 -0
  321. package/dist/icon/chevron.js +11 -0
  322. package/dist/icon/chevron.js.map +1 -0
  323. package/dist/icon/circle-x.d.ts +3 -0
  324. package/dist/icon/circle-x.d.ts.map +1 -0
  325. package/dist/icon/circle-x.js +8 -0
  326. package/dist/icon/circle-x.js.map +1 -0
  327. package/dist/icon/clock.d.ts +3 -0
  328. package/dist/icon/clock.d.ts.map +1 -0
  329. package/dist/icon/clock.js +11 -0
  330. package/dist/icon/clock.js.map +1 -0
  331. package/dist/icon/device.d.ts +3 -0
  332. package/dist/icon/device.d.ts.map +1 -0
  333. package/dist/icon/device.js +11 -0
  334. package/dist/icon/device.js.map +1 -0
  335. package/dist/icon/emoji.d.ts +20 -0
  336. package/dist/icon/emoji.d.ts.map +1 -0
  337. package/dist/icon/emoji.js +21 -0
  338. package/dist/icon/emoji.js.map +1 -0
  339. package/dist/icon/hand-love-you.d.ts +3 -0
  340. package/dist/icon/hand-love-you.d.ts.map +1 -0
  341. package/dist/icon/hand-love-you.js +5 -0
  342. package/dist/icon/hand-love-you.js.map +1 -0
  343. package/dist/icon/hand-ok.d.ts +3 -0
  344. package/dist/icon/hand-ok.d.ts.map +1 -0
  345. package/dist/icon/hand-ok.js +5 -0
  346. package/dist/icon/hand-ok.js.map +1 -0
  347. package/dist/icon/hand-peace.d.ts +3 -0
  348. package/dist/icon/hand-peace.d.ts.map +1 -0
  349. package/dist/icon/hand-peace.js +5 -0
  350. package/dist/icon/hand-peace.js.map +1 -0
  351. package/dist/icon/hands-clap.d.ts +3 -0
  352. package/dist/icon/hands-clap.d.ts.map +1 -0
  353. package/dist/icon/hands-clap.js +5 -0
  354. package/dist/icon/hands-clap.js.map +1 -0
  355. package/dist/icon/home.d.ts +3 -0
  356. package/dist/icon/home.d.ts.map +1 -0
  357. package/dist/icon/home.js +11 -0
  358. package/dist/icon/home.js.map +1 -0
  359. package/dist/icon/index.d.ts +31 -0
  360. package/dist/icon/index.d.ts.map +1 -0
  361. package/dist/icon/index.js +30 -0
  362. package/dist/icon/index.js.map +1 -0
  363. package/dist/icon/info-circle.d.ts +3 -0
  364. package/dist/icon/info-circle.d.ts.map +1 -0
  365. package/dist/icon/info-circle.js +8 -0
  366. package/dist/icon/info-circle.js.map +1 -0
  367. package/dist/icon/key.d.ts +3 -0
  368. package/dist/icon/key.d.ts.map +1 -0
  369. package/dist/icon/key.js +8 -0
  370. package/dist/icon/key.js.map +1 -0
  371. package/dist/icon/list-check.d.ts +3 -0
  372. package/dist/icon/list-check.d.ts.map +1 -0
  373. package/dist/icon/list-check.js +11 -0
  374. package/dist/icon/list-check.js.map +1 -0
  375. package/dist/icon/more.d.ts +3 -0
  376. package/dist/icon/more.d.ts.map +1 -0
  377. package/dist/icon/more.js +11 -0
  378. package/dist/icon/more.js.map +1 -0
  379. package/dist/icon/props.d.ts +26 -0
  380. package/dist/icon/props.d.ts.map +1 -0
  381. package/dist/icon/props.js +16 -0
  382. package/dist/icon/props.js.map +1 -0
  383. package/dist/icon/row-remove.d.ts +3 -0
  384. package/dist/icon/row-remove.d.ts.map +1 -0
  385. package/dist/icon/row-remove.js +11 -0
  386. package/dist/icon/row-remove.js.map +1 -0
  387. package/dist/icon/search.d.ts +3 -0
  388. package/dist/icon/search.d.ts.map +1 -0
  389. package/dist/icon/search.js +11 -0
  390. package/dist/icon/search.js.map +1 -0
  391. package/dist/icon/settings.d.ts +3 -0
  392. package/dist/icon/settings.d.ts.map +1 -0
  393. package/dist/icon/settings.js +11 -0
  394. package/dist/icon/settings.js.map +1 -0
  395. package/dist/icon/spinner.d.ts +3 -0
  396. package/dist/icon/spinner.d.ts.map +1 -0
  397. package/dist/icon/spinner.js +10 -0
  398. package/dist/icon/spinner.js.map +1 -0
  399. package/dist/icon/thumb-down.d.ts +3 -0
  400. package/dist/icon/thumb-down.d.ts.map +1 -0
  401. package/dist/icon/thumb-down.js +5 -0
  402. package/dist/icon/thumb-down.js.map +1 -0
  403. package/dist/icon/upload.d.ts +3 -0
  404. package/dist/icon/upload.d.ts.map +1 -0
  405. package/dist/icon/upload.js +11 -0
  406. package/dist/icon/upload.js.map +1 -0
  407. package/dist/icon/user.d.ts +3 -0
  408. package/dist/icon/user.d.ts.map +1 -0
  409. package/dist/icon/user.js +11 -0
  410. package/dist/icon/user.js.map +1 -0
  411. package/dist/icon/users.d.ts +3 -0
  412. package/dist/icon/users.d.ts.map +1 -0
  413. package/dist/icon/users.js +11 -0
  414. package/dist/icon/users.js.map +1 -0
  415. package/dist/icon/x.d.ts +3 -0
  416. package/dist/icon/x.d.ts.map +1 -0
  417. package/dist/icon/x.js +11 -0
  418. package/dist/icon/x.js.map +1 -0
  419. package/dist/index.d.ts +10 -0
  420. package/dist/index.d.ts.map +1 -0
  421. package/dist/index.js +12 -0
  422. package/dist/index.js.map +1 -0
  423. package/dist/theme/context.d.ts +11 -0
  424. package/dist/theme/context.d.ts.map +1 -0
  425. package/dist/theme/context.js +7 -0
  426. package/dist/theme/context.js.map +1 -0
  427. package/dist/theme/global-styles.d.ts +3 -0
  428. package/dist/theme/global-styles.d.ts.map +1 -0
  429. package/dist/theme/global-styles.js +67 -0
  430. package/dist/theme/global-styles.js.map +1 -0
  431. package/dist/theme/index.d.ts +11 -0
  432. package/dist/theme/index.d.ts.map +1 -0
  433. package/dist/theme/index.js +7 -0
  434. package/dist/theme/index.js.map +1 -0
  435. package/dist/theme/provider.d.ts +7 -0
  436. package/dist/theme/provider.d.ts.map +1 -0
  437. package/dist/theme/provider.js +49 -0
  438. package/dist/theme/provider.js.map +1 -0
  439. package/dist/theme/theme.d.ts +262 -0
  440. package/dist/theme/theme.d.ts.map +1 -0
  441. package/dist/theme/theme.js +481 -0
  442. package/dist/theme/theme.js.map +1 -0
  443. package/dist/theme/use-theme-setting.d.ts +4 -0
  444. package/dist/theme/use-theme-setting.d.ts.map +1 -0
  445. package/dist/theme/use-theme-setting.js +7 -0
  446. package/dist/theme/use-theme-setting.js.map +1 -0
  447. package/dist/theme/use-theme.d.ts +3 -0
  448. package/dist/theme/use-theme.d.ts.map +1 -0
  449. package/dist/theme/use-theme.js +5 -0
  450. package/dist/theme/use-theme.js.map +1 -0
  451. package/dist/toast/context.d.ts +5 -0
  452. package/dist/toast/context.d.ts.map +1 -0
  453. package/dist/toast/context.js +5 -0
  454. package/dist/toast/context.js.map +1 -0
  455. package/dist/toast/hook/index.d.ts +2 -0
  456. package/dist/toast/hook/index.d.ts.map +1 -0
  457. package/dist/toast/hook/index.js +2 -0
  458. package/dist/toast/hook/index.js.map +1 -0
  459. package/dist/toast/hook/use-toast.d.ts +2 -0
  460. package/dist/toast/hook/use-toast.d.ts.map +1 -0
  461. package/dist/toast/hook/use-toast.js +7 -0
  462. package/dist/toast/hook/use-toast.js.map +1 -0
  463. package/dist/toast/index.d.ts +3 -0
  464. package/dist/toast/index.d.ts.map +1 -0
  465. package/dist/toast/index.js +3 -0
  466. package/dist/toast/index.js.map +1 -0
  467. package/dist/toast/provider.d.ts +8 -0
  468. package/dist/toast/provider.d.ts.map +1 -0
  469. package/dist/toast/provider.js +57 -0
  470. package/dist/toast/provider.js.map +1 -0
  471. package/dist/toast/reducer.d.ts +21 -0
  472. package/dist/toast/reducer.d.ts.map +1 -0
  473. package/dist/toast/reducer.js +24 -0
  474. package/dist/toast/reducer.js.map +1 -0
  475. package/dist/toast/style.d.ts +5 -0
  476. package/dist/toast/style.d.ts.map +1 -0
  477. package/dist/toast/style.js +63 -0
  478. package/dist/toast/style.js.map +1 -0
  479. package/dist/toast/toast.d.ts +12 -0
  480. package/dist/toast/toast.d.ts.map +1 -0
  481. package/dist/toast/toast.js +17 -0
  482. package/dist/toast/toast.js.map +1 -0
  483. package/dist/utils.d.ts +3 -0
  484. package/dist/utils.d.ts.map +1 -0
  485. package/dist/utils.js +38 -0
  486. package/dist/utils.js.map +1 -0
  487. package/package.json +93 -4
  488. package/src/component/card/index.tsx +123 -0
  489. package/src/component/card/style.ts +69 -0
  490. package/src/component/card-divider/index.tsx +74 -0
  491. package/src/component/card-divider/style.ts +48 -0
  492. package/src/component/card-row/index.tsx +32 -0
  493. package/src/component/card-row/style.ts +13 -0
  494. package/src/component/collapsible-section/index.tsx +58 -0
  495. package/src/component/collapsible-section/style.ts +36 -0
  496. package/src/component/empty-state/index.tsx +35 -0
  497. package/src/component/empty-state/style.ts +30 -0
  498. package/src/component/index.ts +15 -0
  499. package/src/component/meta-line/index.tsx +42 -0
  500. package/src/component/meta-line/style.ts +36 -0
  501. package/src/component/metadata/index.tsx +15 -0
  502. package/src/component/metadata/style.ts +20 -0
  503. package/src/component/metadata-list/index.tsx +15 -0
  504. package/src/component/metadata-list/style.ts +10 -0
  505. package/src/component/nav-desktop/index.tsx +43 -0
  506. package/src/component/nav-desktop/style.ts +94 -0
  507. package/src/component/nav-mobile/index.tsx +358 -0
  508. package/src/component/nav-mobile/style.ts +354 -0
  509. package/src/component/nav-types.ts +13 -0
  510. package/src/component/page/index.tsx +87 -0
  511. package/src/component/page/style.ts +133 -0
  512. package/src/component/progress-indicator/index.tsx +58 -0
  513. package/src/component/progress-indicator/style.ts +24 -0
  514. package/src/component/tag/index.tsx +38 -0
  515. package/src/component/tag/style.ts +28 -0
  516. package/src/component/theme-setting/index.tsx +24 -0
  517. package/src/component/top-fade/index.tsx +8 -0
  518. package/src/component/top-fade/style.ts +58 -0
  519. package/src/control/action-menu-list/index.tsx +75 -0
  520. package/src/control/action-menu-list/style.ts +51 -0
  521. package/src/control/action-menu-list/use-dismiss.ts +29 -0
  522. package/src/control/back-button/index.tsx +44 -0
  523. package/src/control/back-button/style.ts +26 -0
  524. package/src/control/button/index.tsx +148 -0
  525. package/src/control/button/style.ts +389 -0
  526. package/src/control/chips-input/index.tsx +168 -0
  527. package/src/control/chips-input/style.ts +158 -0
  528. package/src/control/confirm-modal/index.tsx +79 -0
  529. package/src/control/confirm-modal/style.ts +33 -0
  530. package/src/control/date-time-input/index.tsx +95 -0
  531. package/src/control/date-time-input/iso-date.ts +61 -0
  532. package/src/control/date-time-input/style.ts +72 -0
  533. package/src/control/field-list/index.tsx +78 -0
  534. package/src/control/field-list/style.ts +43 -0
  535. package/src/control/index.ts +23 -0
  536. package/src/control/number-input/index.tsx +75 -0
  537. package/src/control/number-input/style.ts +50 -0
  538. package/src/control/page-actions-bar/index.tsx +68 -0
  539. package/src/control/page-actions-bar/style.ts +63 -0
  540. package/src/control/page-actions-menu/index.tsx +49 -0
  541. package/src/control/page-actions-menu/style.ts +33 -0
  542. package/src/control/page-footer-actions/index.tsx +50 -0
  543. package/src/control/page-footer-actions/style.ts +12 -0
  544. package/src/control/popover/index.tsx +102 -0
  545. package/src/control/popover/style.ts +8 -0
  546. package/src/control/segmented-control/index.tsx +193 -0
  547. package/src/control/segmented-control/style.ts +150 -0
  548. package/src/control/select/index.tsx +326 -0
  549. package/src/control/select/style.ts +192 -0
  550. package/src/control/switch/index.tsx +189 -0
  551. package/src/control/switch/style.ts +172 -0
  552. package/src/control/text-area/index.tsx +106 -0
  553. package/src/control/text-area/style.ts +85 -0
  554. package/src/control/text-input/index.tsx +124 -0
  555. package/src/control/text-input/style.ts +80 -0
  556. package/src/control/use-modal-dialog/index.ts +75 -0
  557. package/src/hooks/index.ts +5 -0
  558. package/src/hooks/is-standalone.ts +11 -0
  559. package/src/hooks/use-minimize-on-scroll.ts +137 -0
  560. package/src/hooks/use-pull-to-refresh.ts +133 -0
  561. package/src/icon/adjustments-horizontal.tsx +48 -0
  562. package/src/icon/alert-octagon.tsx +31 -0
  563. package/src/icon/book.tsx +42 -0
  564. package/src/icon/books.tsx +46 -0
  565. package/src/icon/check.tsx +31 -0
  566. package/src/icon/chevron-circle.tsx +40 -0
  567. package/src/icon/chevron.tsx +39 -0
  568. package/src/icon/circle-x.tsx +30 -0
  569. package/src/icon/clock.tsx +41 -0
  570. package/src/icon/device.tsx +41 -0
  571. package/src/icon/emoji.tsx +70 -0
  572. package/src/icon/hand-love-you.tsx +5 -0
  573. package/src/icon/hand-ok.tsx +5 -0
  574. package/src/icon/hand-peace.tsx +7 -0
  575. package/src/icon/hands-clap.tsx +5 -0
  576. package/src/icon/home.tsx +42 -0
  577. package/src/icon/index.ts +31 -0
  578. package/src/icon/info-circle.tsx +30 -0
  579. package/src/icon/key.tsx +38 -0
  580. package/src/icon/list-check.tsx +44 -0
  581. package/src/icon/more.tsx +41 -0
  582. package/src/icon/props.ts +29 -0
  583. package/src/icon/row-remove.tsx +41 -0
  584. package/src/icon/search.tsx +41 -0
  585. package/src/icon/settings.tsx +41 -0
  586. package/src/icon/spinner.tsx +36 -0
  587. package/src/icon/thumb-down.tsx +5 -0
  588. package/src/icon/upload.tsx +42 -0
  589. package/src/icon/user.tsx +41 -0
  590. package/src/icon/users.tsx +43 -0
  591. package/src/icon/x.tsx +41 -0
  592. package/src/index.ts +12 -0
  593. package/src/theme/context.ts +19 -0
  594. package/src/theme/global-styles.ts +71 -0
  595. package/src/theme/index.ts +11 -0
  596. package/src/theme/provider.tsx +74 -0
  597. package/src/theme/theme.ts +672 -0
  598. package/src/theme/use-theme-setting.ts +10 -0
  599. package/src/theme/use-theme.tsx +7 -0
  600. package/src/toast/context.ts +9 -0
  601. package/src/toast/hook/index.ts +1 -0
  602. package/src/toast/hook/use-toast.ts +8 -0
  603. package/src/toast/index.ts +2 -0
  604. package/src/toast/provider.tsx +90 -0
  605. package/src/toast/reducer.ts +41 -0
  606. package/src/toast/style.ts +63 -0
  607. package/src/toast/toast.tsx +51 -0
  608. package/src/utils.ts +47 -0
@@ -0,0 +1,192 @@
1
+ import { createUseStyles, type Theme } from '../../theme/index.js';
2
+
3
+ export const useStyle = createUseStyles((theme: Theme) => ({
4
+ root: {
5
+ // The outer panel, which carries a `bg.cardHeader` background in the
6
+ // `horizontal`/`vertical` layouts. With no label it is EXACTLY coincident
7
+ // with the trigger (`triggerWrapper` has `flexGrow: 1`), so its corners are
8
+ // what shows if they are rounder or squarer than the trigger's — rounding
9
+ // only the trigger left this poking out at the ends, reading as a shadow
10
+ // that had not followed the corners. Both take the surface modifier.
11
+ borderRadius: theme.radius.md,
12
+ '&$page': { borderRadius: theme.radius.lg },
13
+ '&$horizontal': {
14
+ display: 'flex',
15
+ flexDirection: 'row',
16
+ alignItems: 'start',
17
+ gap: theme.space.md,
18
+ backgroundColor: theme.color.bg.cardHeader,
19
+ '& $label': {
20
+ marginTop: theme.space.md,
21
+ marginLeft: theme.space.sm,
22
+ minWidth: '6rem',
23
+ textAlign: 'left',
24
+ },
25
+ '& $triggerWrapper': { flexGrow: 1 },
26
+ },
27
+ '&$vertical': {
28
+ display: 'flex',
29
+ flexDirection: 'column',
30
+ gap: theme.space.xs,
31
+ backgroundColor: theme.color.bg.cardHeader,
32
+ '& $label': {
33
+ marginTop: theme.space.xs,
34
+ marginLeft: theme.space.md,
35
+ },
36
+ '& $triggerWrapper': { flexGrow: 1 },
37
+ },
38
+ '&$inline': {
39
+ display: 'inline-flex',
40
+ alignItems: 'baseline',
41
+ gap: theme.space.md,
42
+ },
43
+ },
44
+ label: { ...theme.recipe.label },
45
+ triggerWrapper: {
46
+ position: 'relative',
47
+ },
48
+ // The two surfaces. `card` is the default and adds nothing — the control as
49
+ // it has always looked. `page` makes the select match `recipe.card.shell`
50
+ // (`radius.lg` + `shadow.cardStack`), so a select sitting directly on the
51
+ // page carries the same elevation as the cards beside it.
52
+ //
53
+ // BOTH `root` and `trigger` take the radius. `root` is exactly coincident
54
+ // with the trigger when there is no label (`triggerWrapper` has `flexGrow:1`),
55
+ // so leaving `root` at `radius.md` left its squarer corners poking out past
56
+ // the trigger's rounder ones — which reads as a shadow that has not followed
57
+ // the corners.
58
+ card: {},
59
+ page: {},
60
+ trigger: {
61
+ ...theme.recipe.input,
62
+ '&$page': {
63
+ borderRadius: theme.radius.lg,
64
+ boxShadow: theme.shadow.cardStack,
65
+ },
66
+ // Shared single-line control height so inputs/select/chips line up on one row.
67
+ height: theme.layout.controlHeight,
68
+ display: 'flex',
69
+ alignItems: 'center',
70
+ gap: theme.space.md,
71
+ cursor: 'pointer',
72
+ userSelect: 'none',
73
+ '-webkit-user-select': 'none',
74
+ '&:focus, &:focus-within': { borderColor: theme.color.border.focus },
75
+ '&$loading': {
76
+ cursor: 'default',
77
+ borderColor: theme.color.border.light,
78
+ color: theme.color.text.muted,
79
+ '&:hover': { borderColor: theme.color.border.light },
80
+ '&:focus, &:focus-within': { borderColor: theme.color.border.light },
81
+ },
82
+ '&$disabled': {
83
+ cursor: 'not-allowed',
84
+ '&:hover': { borderColor: theme.color.border.default },
85
+ '&:focus, &:focus-within': { borderColor: theme.color.border.default },
86
+ },
87
+ },
88
+ triggerText: {
89
+ flex: 1,
90
+ overflow: 'hidden',
91
+ textOverflow: 'ellipsis',
92
+ whiteSpace: 'nowrap',
93
+ fontSize: '0.80rem',
94
+ color: theme.color.text.primary,
95
+ '&$placeholder': { color: theme.color.text.faint },
96
+ },
97
+ searchInput: {
98
+ border: 'none',
99
+ outline: 'none',
100
+ background: 'transparent',
101
+ fontFamily: theme.fontFamily.body,
102
+ fontSize: '0.80rem',
103
+ color: theme.color.text.primary,
104
+ flex: 1,
105
+ minWidth: 0,
106
+ padding: 0,
107
+ '&::placeholder': { color: theme.color.text.faint },
108
+ [theme.breakpoint.mobile]: { fontSize: '1rem' },
109
+ },
110
+ clearButton: {
111
+ display: 'flex',
112
+ alignItems: 'center',
113
+ fontSize: '0.80rem',
114
+ lineHeight: 1,
115
+ color: theme.color.text.faint,
116
+ cursor: 'pointer',
117
+ flexShrink: 0,
118
+ '&:hover': { color: theme.color.text.primary },
119
+ },
120
+ chevron: {
121
+ display: 'flex',
122
+ alignItems: 'center',
123
+ flexShrink: 0,
124
+ color: theme.color.text.faint,
125
+ // Optical nudge down so the caret reads as vertically centered.
126
+ position: 'relative',
127
+ top: '1px',
128
+ transform: 'rotate(90deg)',
129
+ transition: `transform ${theme.transition.fast}`,
130
+ '&$open': { transform: 'rotate(-90deg)' },
131
+ },
132
+ dropdown: {
133
+ border: `1px solid ${theme.color.border.strong}`,
134
+ borderRadius: theme.radius.md,
135
+ backgroundColor: theme.color.bg.card,
136
+ boxShadow: theme.shadow.hoverLift,
137
+ overflow: 'hidden',
138
+ },
139
+ optionList: {
140
+ listStyle: 'none',
141
+ margin: 0,
142
+ padding: `${theme.space.xs} 0`,
143
+ maxHeight: '12.5rem',
144
+ overflowY: 'auto',
145
+ },
146
+ option: {
147
+ fontFamily: theme.fontFamily.body,
148
+ fontSize: '0.80rem',
149
+ padding: `${theme.space.md} ${theme.space.xxl}`,
150
+ cursor: 'pointer',
151
+ color: theme.color.text.primary,
152
+ '&:hover': { backgroundColor: theme.color.bg.cardHeader },
153
+ '&$highlighted': { backgroundColor: theme.color.brand.light },
154
+ '&$selected': { fontWeight: theme.fontWeight.semibold },
155
+ '&$emptyOption': {
156
+ color: theme.color.text.faint,
157
+ fontStyle: 'italic',
158
+ cursor: 'default',
159
+ '&:hover': { backgroundColor: 'transparent' },
160
+ },
161
+ },
162
+ optionDescription: {
163
+ marginTop: theme.space.xxs,
164
+ fontSize: theme.fontSize.sm,
165
+ fontWeight: 400,
166
+ color: theme.color.text.faint,
167
+ whiteSpace: 'normal',
168
+ },
169
+ matchHighlight: {
170
+ backgroundColor: theme.color.bg.selected,
171
+ borderRadius: theme.radius.sm,
172
+ padding: '0 1px',
173
+ },
174
+ createOption: {
175
+ color: theme.color.brand.default,
176
+ fontStyle: 'italic',
177
+ },
178
+ spinner: { ...theme.recipe.spinner },
179
+ // Empty modifier classes — referenced as $name in compound selectors above
180
+ danger: {},
181
+ loading: {},
182
+ disabled: { opacity: 0.5 },
183
+ open: {},
184
+ placeholder: {},
185
+ highlighted: {},
186
+ selected: {},
187
+ emptyOption: {},
188
+ // Layout variant classes
189
+ horizontal: {},
190
+ vertical: {},
191
+ inline: {},
192
+ }));
@@ -0,0 +1,189 @@
1
+ import cx from 'classnames';
2
+ import { ReactNode, useCallback, useEffect, useId, useState } from 'react';
3
+
4
+ import { SpinnerIcon } from '../../icon/index.js';
5
+ import { SwitchRadius, SwitchRadiusValue, useStyle } from './style.js';
6
+
7
+ /**
8
+ * How long a save may run before the switch admits to it.
9
+ *
10
+ * Every mutation behind a switch in this app is local — a preference row, a
11
+ * push subscription — and normally settles in well under this. Showing the
12
+ * spinner the instant a click fires would therefore flash it for two or three
13
+ * frames on nearly every interaction, which reads as a glitch rather than as
14
+ * feedback. Waiting means the common path shows nothing at all, and only a
15
+ * genuinely slow save (a busy server, a dropped connection) ever draws one.
16
+ */
17
+ const SPINNER_DELAY_MS = 150;
18
+
19
+ /**
20
+ * True once `active` has been continuously true for `delayMs`, false the
21
+ * moment it clears.
22
+ *
23
+ * The delay is PURELY VISUAL. Both the click guard and `aria-busy` below read
24
+ * the undelayed prop instead, because suppressing the spinner for 150ms must
25
+ * not also open a 150ms window in which a second click fires a second
26
+ * mutation, nor hide the state from a screen reader that has no flicker to be
27
+ * spared.
28
+ */
29
+ function useDelayedFlag(active: boolean, delayMs: number): boolean {
30
+ const [elapsed, setElapsed] = useState(false);
31
+ useEffect(() => {
32
+ if (!active) {
33
+ setElapsed(false);
34
+ return;
35
+ }
36
+ const timer = setTimeout(() => setElapsed(true), delayMs);
37
+ return () => clearTimeout(timer);
38
+ }, [active, delayMs]);
39
+ return elapsed;
40
+ }
41
+
42
+ type SwitchProps = {
43
+ /**
44
+ * Accessible name when the visible `label` is absent because something
45
+ * OUTSIDE the switch already carries it — a grid's row and column headers,
46
+ * say. Without it such a switch falls back to announcing `name`, which is a
47
+ * machine key (`BOOK_REQUEST_FULFILLED:EMAIL`), not a name.
48
+ */
49
+ ariaLabel?: string;
50
+ checked: boolean;
51
+ description?: ReactNode;
52
+ disabled?: boolean;
53
+ label?: string;
54
+ layout?: 'default' | 'horizontal';
55
+ /**
56
+ * A save driven by this switch is in flight. The thumb becomes a spinner
57
+ * (after a short delay — see `SPINNER_DELAY_MS`) and further clicks are
58
+ * ignored until it clears.
59
+ *
60
+ * Distinct from `disabled`, which means "you may not change this" and fades
61
+ * the whole control. A loading switch keeps its colour and shows the
62
+ * position it is SAVING, not the one it came from, so the reader can see
63
+ * where the click is taking it.
64
+ */
65
+ loading?: boolean;
66
+ name: string;
67
+ onChange: (checked: boolean) => void;
68
+ /**
69
+ * The corner shape of the track, named for what the switch sits in. Defaults
70
+ * to `inset` — concentric with the shaded input row every switch in this app
71
+ * currently sits in. Pass `pill` for the classic capsule on an unshaded
72
+ * surface.
73
+ */
74
+ radius?: SwitchRadiusValue;
75
+ };
76
+
77
+ export const Switch = ({
78
+ ariaLabel,
79
+ checked,
80
+ description,
81
+ disabled = false,
82
+ label,
83
+ layout = 'default',
84
+ loading = false,
85
+ name,
86
+ onChange,
87
+ radius = SwitchRadius.Inset as SwitchRadiusValue,
88
+ }: SwitchProps) => {
89
+ const style = useStyle();
90
+ const showSpinner = useDelayedFlag(loading, SPINNER_DELAY_MS);
91
+ // Per-instance id so the description's aria target stays unique even when two
92
+ // switches sharing a `name` mount at once (e.g. the device create + edit forms).
93
+ const generatedId = useId();
94
+ const descriptionId = description ? generatedId : undefined;
95
+
96
+ const handleClick = useCallback(
97
+ (event: React.MouseEvent) => {
98
+ event.stopPropagation();
99
+ if (!disabled && !loading) onChange(!checked);
100
+ },
101
+ [checked, disabled, loading, onChange]
102
+ );
103
+
104
+ const handleKeyDown = useCallback(
105
+ (event: React.KeyboardEvent) => {
106
+ if (event.key === 'Enter' || event.key === ' ') {
107
+ event.preventDefault();
108
+ event.stopPropagation();
109
+ if (!disabled && !loading) onChange(!checked);
110
+ }
111
+ },
112
+ [checked, disabled, loading, onChange]
113
+ );
114
+
115
+ // The description is helper text, not a toggle target — clicking it should
116
+ // not flip the switch.
117
+ const handleDescriptionClick = useCallback((event: React.MouseEvent) => {
118
+ event.stopPropagation();
119
+ }, []);
120
+
121
+ // The radius class lands on the track rather than the root because it styles
122
+ // the track and its thumb, and the track is the one element both layouts
123
+ // below render identically.
124
+ const track = (
125
+ <div
126
+ className={cx(style.track, style[radius], {
127
+ [style.checked]: checked,
128
+ [style.disabled]: disabled,
129
+ [style.loading]: showSpinner,
130
+ })}
131
+ >
132
+ {showSpinner ? (
133
+ // `aria-hidden` because `aria-busy` on the switch itself already
134
+ // carries this to assistive tech, and from the undelayed prop.
135
+ <SpinnerIcon aria-hidden={true} className={style.spinner} />
136
+ ) : (
137
+ <div className={style.thumb} />
138
+ )}
139
+ </div>
140
+ );
141
+
142
+ const descriptionEl = description ? (
143
+ <div
144
+ id={descriptionId}
145
+ className={style.description}
146
+ // In the horizontal layout the whole shaded row is a toggle target, so let
147
+ // description clicks bubble up. Elsewhere the description stays inert helper text.
148
+ onClick={layout === 'horizontal' ? undefined : handleDescriptionClick}
149
+ >
150
+ {description}
151
+ </div>
152
+ ) : null;
153
+
154
+ const commonProps = {
155
+ role: 'switch' as const,
156
+ 'aria-checked': checked,
157
+ 'aria-label': ariaLabel ?? label ?? name,
158
+ 'aria-describedby': descriptionId,
159
+ 'aria-disabled': disabled,
160
+ 'aria-busy': loading,
161
+ tabIndex: disabled ? -1 : 0,
162
+ onClick: handleClick,
163
+ onKeyDown: handleKeyDown,
164
+ };
165
+
166
+ // Horizontal keeps the toggle in its own right-hand column so the description,
167
+ // stacked under the label in the content column, never runs beneath it.
168
+ if (layout === 'horizontal') {
169
+ return (
170
+ <div {...commonProps} className={cx(style.root, style.horizontal)}>
171
+ <div className={style.content}>
172
+ {label && <span className={style.label}>{label}</span>}
173
+ {descriptionEl}
174
+ </div>
175
+ {track}
176
+ </div>
177
+ );
178
+ }
179
+
180
+ return (
181
+ <div {...commonProps} className={style.root}>
182
+ <div className={style.row}>
183
+ {track}
184
+ {label && <span className={style.label}>{label}</span>}
185
+ </div>
186
+ {descriptionEl}
187
+ </div>
188
+ );
189
+ };
@@ -0,0 +1,172 @@
1
+ import { createUseStyles, type Theme } from '../../theme/index.js';
2
+
3
+ /**
4
+ * Named for what the switch SITS IN rather than for a size, matching
5
+ * `ButtonRadius`: a caller knows its own surroundings, not which step of the
6
+ * radius scale suits a 16px-tall track.
7
+ *
8
+ * Deliberately two values, where `ButtonRadius` has four. A switch's track is
9
+ * 16px tall, so any radius of 8px or more clamps to a full pill — `card`
10
+ * (`radius.md`) and `pill` would be the same shape, named twice, and could
11
+ * never diverge while the track keeps that height.
12
+ */
13
+ export type SwitchRadiusValue = 'inset' | 'pill';
14
+ export enum SwitchRadius {
15
+ /**
16
+ * Concentric with the shaded input row the switch sits in: 16px card, 8px
17
+ * row, 4px track, 2px thumb. The default, because that row is where every
18
+ * switch in this app currently lives.
19
+ */
20
+ Inset = 'inset',
21
+ /**
22
+ * The classic capsule, and the rule for a switch in a CARD HEADER.
23
+ *
24
+ * Not about shading — a card header is painted `bg.cardHeader`, the same
25
+ * colour as the input row. It is about whether there is anything nearby to
26
+ * be concentric WITH. An input row is a small rounded rectangle wrapping the
27
+ * switch, so a 4px track echoes its 8px corner a few pixels away. A card
28
+ * header is a full-width bar whose only corners are the card's own, far off
29
+ * at either end: nothing for the track to relate to, so it reads better as a
30
+ * self-contained control than as a square-ish chip floating in a bar.
31
+ */
32
+ Pill = 'pill',
33
+ }
34
+
35
+ export const useStyle = createUseStyles((theme: Theme) => ({
36
+ root: {
37
+ display: 'inline-flex',
38
+ flexDirection: 'column',
39
+ alignItems: 'flex-start',
40
+ gap: theme.space.xs,
41
+ cursor: 'pointer',
42
+ userSelect: 'none',
43
+ '-webkit-user-select': 'none',
44
+ },
45
+ row: {
46
+ display: 'flex',
47
+ alignItems: 'center',
48
+ gap: theme.space.md,
49
+ },
50
+ description: {
51
+ // Indent under the label (past the 28px track + row gap) so it reads as
52
+ // helper text for this toggle rather than a separate row.
53
+ marginLeft: `calc(28px + ${theme.space.md})`,
54
+ fontSize: theme.fontSize.sm,
55
+ // Dedicated description colour — darker than faint for readable helper text,
56
+ // especially on the shaded background of the horizontal layout.
57
+ color: theme.color.text.description,
58
+ cursor: 'auto',
59
+ },
60
+ track: {
61
+ position: 'relative',
62
+ width: '28px',
63
+ height: '16px',
64
+ backgroundColor: theme.color.border.default,
65
+ ...theme.recipe.focusRing,
66
+ transitionProperty: 'background-color, outline-color',
67
+ transitionDuration: '0.1s',
68
+ transitionTimingFunction: 'ease-in',
69
+ '$root:hover &': { outlineColor: theme.color.brand.outline },
70
+ '$root:focus &': { outlineColor: theme.color.brand.outline },
71
+ '&$checked': { backgroundColor: theme.color.brand.default },
72
+ '&$disabled': { opacity: 0.4, cursor: 'not-allowed' },
73
+ },
74
+ thumb: {
75
+ position: 'absolute',
76
+ top: '2px',
77
+ left: '2px',
78
+ width: '12px',
79
+ height: '12px',
80
+ backgroundColor: theme.color.bg.input,
81
+ transitionProperty: 'left',
82
+ transitionDuration: '0.1s',
83
+ transitionTimingFunction: 'ease-in',
84
+ '$checked &': { left: '14px' },
85
+ },
86
+ /**
87
+ * Each value sets the track AND its thumb together, because the two are not
88
+ * independent: the thumb is inset 2px on every side, so a concentric thumb
89
+ * is always the track's radius less that inset. Splitting them into two
90
+ * props would let a caller produce a square thumb in a capsule track.
91
+ */
92
+ [SwitchRadius.Inset]: {
93
+ borderRadius: theme.radius.sm,
94
+ // Arithmetic rather than a token so it follows the track automatically if
95
+ // that radius ever changes — and because the scale has no 2px step.
96
+ '& $thumb': { borderRadius: `calc(${theme.radius.sm} - 2px)` },
97
+ },
98
+ [SwitchRadius.Pill]: {
99
+ borderRadius: theme.radius.pill,
100
+ '& $thumb': { borderRadius: theme.radius.circle },
101
+ },
102
+
103
+ /**
104
+ * Replaces the thumb while a save is in flight. Sized to the thumb it
105
+ * stands in for, and inheriting `currentColor` from `$track` below so it
106
+ * stays legible against both track colours.
107
+ */
108
+ spinner: {
109
+ ...theme.recipe.spinner,
110
+ position: 'absolute',
111
+ top: '2px',
112
+ width: '12px',
113
+ height: '12px',
114
+ // Matches the thumb's own transition, so a click that both moves the
115
+ // switch AND starts a save does not animate the two at different speeds.
116
+ transitionProperty: 'left',
117
+ transitionDuration: '0.1s',
118
+ transitionTimingFunction: 'ease-in',
119
+ left: '2px',
120
+ '$checked &': { left: '14px' },
121
+ },
122
+ loading: {
123
+ // The track keeps its colour — this is "working", not "unavailable",
124
+ // which `disabled` already says by fading to 40%. Only the cursor and the
125
+ // thumb change.
126
+ cursor: 'progress',
127
+ // `currentColor` for the spinner: muted against the pale unchecked track,
128
+ // white against the saturated checked one. A single colour would vanish
129
+ // into one of the two.
130
+ color: theme.color.text.muted,
131
+ '&$checked': { color: theme.color.bg.input },
132
+ },
133
+
134
+ label: {
135
+ ...theme.recipe.label,
136
+ },
137
+ content: {},
138
+ horizontal: {
139
+ // Two columns: content (label + description) on the left, toggle on the right.
140
+ display: 'flex',
141
+ flexDirection: 'row',
142
+ alignItems: 'center',
143
+ gap: theme.space.md,
144
+ width: '100%',
145
+ backgroundColor: theme.color.bg.cardHeader,
146
+ borderRadius: theme.radius.md,
147
+ padding: `${theme.space.md} ${theme.space.lg} ${theme.space.md} ${theme.space.sm}`,
148
+ '& $content': {
149
+ display: 'flex',
150
+ flexDirection: 'column',
151
+ gap: theme.space.xs,
152
+ flexGrow: 1,
153
+ minWidth: 0,
154
+ },
155
+ '& $label': {
156
+ // Left-aligned to the same edge as the other fields' labels.
157
+ textAlign: 'left',
158
+ },
159
+ '& $description': {
160
+ margin: 0,
161
+ // The whole shaded row toggles, so the description shows the toggle cursor too.
162
+ cursor: 'pointer',
163
+ },
164
+ '& $track': {
165
+ // Kept in its own column so the description never runs beneath it.
166
+ flexShrink: 0,
167
+ },
168
+ },
169
+ checked: {},
170
+ disabled: {},
171
+ danger: {},
172
+ }));
@@ -0,0 +1,106 @@
1
+ import cx from 'classnames';
2
+ import { useCallback, useEffect, useRef, useState } from 'react';
3
+
4
+ import { useStyle } from './style.js';
5
+
6
+ export type TextAreaProps = {
7
+ autoResize?: boolean;
8
+ label?: string;
9
+ layout?: 'horizontal' | 'vertical' | 'inline';
10
+ maxLength?: number;
11
+ name: string;
12
+ onChange?: (newValue: string | undefined) => void;
13
+ onValidChange?: (fieldName: string, newValid: boolean) => void;
14
+ placeholder?: string;
15
+ validate?: (newValue: string) => boolean;
16
+ value: string | undefined;
17
+ variant?: 'outlined' | 'borderless';
18
+ };
19
+
20
+ export const TextArea = ({
21
+ autoResize = false,
22
+ label,
23
+ layout = 'horizontal',
24
+ maxLength,
25
+ name,
26
+ onChange = () => {},
27
+ onValidChange = () => {},
28
+ placeholder,
29
+ validate = () => true,
30
+ value = '',
31
+ variant = 'outlined',
32
+ }: TextAreaProps) => {
33
+ const style = useStyle();
34
+ const ref = useRef<HTMLTextAreaElement>(null);
35
+
36
+ const [isValid, setIsValid] = useState<boolean>(true);
37
+ const [internalValue, setInternalValue] = useState<string | undefined>(value);
38
+ const [prevValue, setPrevValue] = useState<string | undefined>(value);
39
+
40
+ const handleValueChange = useCallback(
41
+ (event: React.ChangeEvent<HTMLTextAreaElement>) => {
42
+ const newValue = event.target.value;
43
+ setInternalValue(newValue);
44
+ if (validate(newValue)) {
45
+ if (isValid === false) {
46
+ setIsValid(true);
47
+ onValidChange(name, true);
48
+ }
49
+ onChange(newValue === '' ? undefined : newValue);
50
+ } else {
51
+ if (isValid === true) {
52
+ setIsValid(false);
53
+ onValidChange(name, false);
54
+ }
55
+ }
56
+ },
57
+ [isValid, name, onChange, onValidChange, validate]
58
+ );
59
+
60
+ if (value !== prevValue) {
61
+ setPrevValue(value);
62
+ setInternalValue(value);
63
+ }
64
+
65
+ useEffect(() => {
66
+ if (!autoResize || !ref.current) return;
67
+ const el = ref.current;
68
+ el.style.height = 'auto';
69
+ el.style.height = `${el.scrollHeight}px`;
70
+ }, [autoResize, internalValue]);
71
+
72
+ const currentLength = (internalValue ?? '').length;
73
+ const remaining = maxLength !== undefined ? maxLength - currentLength : undefined;
74
+ const showCounter =
75
+ remaining !== undefined && remaining <= Math.max(Math.floor((maxLength ?? 0) * 0.1), 50);
76
+
77
+ return (
78
+ <div className={cx(style.root, style[layout])}>
79
+ {label && (
80
+ <label className={cx(style.label, { [`${style.danger}`]: !isValid })}>{label}</label>
81
+ )}
82
+ <div className={style.textareaWrapper}>
83
+ <textarea
84
+ className={cx(style.input, style[variant], { [style.autoResize]: autoResize })}
85
+ maxLength={maxLength}
86
+ name={name}
87
+ onChange={handleValueChange}
88
+ placeholder={placeholder}
89
+ ref={ref}
90
+ style={{ minHeight: autoResize ? '7rem' : '10rem' }}
91
+ value={internalValue}
92
+ />
93
+ {showCounter && (
94
+ <span
95
+ className={cx(
96
+ style.counter,
97
+ remaining !== undefined && remaining <= 0 && style.counterDanger
98
+ )}
99
+ >
100
+ {currentLength}/{maxLength}
101
+ </span>
102
+ )}
103
+ </div>
104
+ </div>
105
+ );
106
+ };