@seanyeh77/ui 0.45.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/dist/bundle.js +19 -19
  2. package/dist/components/Alert/Alert.d.ts +2 -1
  3. package/dist/components/Alert/Alert.js +15 -17
  4. package/dist/components/Alert/Alert.js.map +1 -1
  5. package/dist/components/AppShell/AppShell.d.ts +3 -3
  6. package/dist/components/AppShell/AppShell.js +9 -10
  7. package/dist/components/AppShell/AppShell.js.map +1 -1
  8. package/dist/components/Badge/Badge.d.ts +4 -4
  9. package/dist/components/Badge/Badge.js +7 -1
  10. package/dist/components/Badge/Badge.js.map +1 -1
  11. package/dist/components/Breadcrumb/Breadcrumb.js +1 -0
  12. package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -1
  13. package/dist/components/Calendar/Calendar.js +6 -2
  14. package/dist/components/Calendar/Calendar.js.map +1 -1
  15. package/dist/components/ConsoleLayout/ConsoleLayout.js +15 -12
  16. package/dist/components/ConsoleLayout/ConsoleLayout.js.map +1 -1
  17. package/dist/components/DataTable/DataTable.d.ts +8 -0
  18. package/dist/components/DataTable/DataTable.js +188 -34
  19. package/dist/components/DataTable/DataTable.js.map +1 -1
  20. package/dist/components/DataTable/filters.js +10 -4
  21. package/dist/components/DataTable/filters.js.map +1 -1
  22. package/dist/components/DatePicker/DatePicker.js +1 -0
  23. package/dist/components/DatePicker/DatePicker.js.map +1 -1
  24. package/dist/components/DateRangePicker/DateRangePicker.js +1 -0
  25. package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
  26. package/dist/components/DetailList/DetailList.d.ts +8 -1
  27. package/dist/components/DetailList/DetailList.js +16 -2
  28. package/dist/components/DetailList/DetailList.js.map +1 -1
  29. package/dist/components/EmptyState/EmptyState.js +19 -1
  30. package/dist/components/EmptyState/EmptyState.js.map +1 -1
  31. package/dist/components/EventTimeline/EventTimeline.js +6 -3
  32. package/dist/components/EventTimeline/EventTimeline.js.map +1 -1
  33. package/dist/components/FileUpload/FileUpload.js +2 -2
  34. package/dist/components/FileUpload/FileUpload.js.map +1 -1
  35. package/dist/components/Grid/Grid.d.ts +5 -2
  36. package/dist/components/Grid/Grid.js +4 -3
  37. package/dist/components/Grid/Grid.js.map +1 -1
  38. package/dist/components/InlineCode/InlineCode.js +7 -6
  39. package/dist/components/InlineCode/InlineCode.js.map +1 -1
  40. package/dist/components/KpiCard/KpiCard.d.ts +6 -4
  41. package/dist/components/KpiCard/KpiCard.js +6 -12
  42. package/dist/components/KpiCard/KpiCard.js.map +1 -1
  43. package/dist/components/LayerGraph/LayerGraph.js +47 -13
  44. package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
  45. package/dist/components/MultiSelect/MultiSelect.js +73 -45
  46. package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
  47. package/dist/components/NotificationBell/NotificationBell.d.ts +6 -3
  48. package/dist/components/NotificationBell/NotificationBell.js +14 -3
  49. package/dist/components/NotificationBell/NotificationBell.js.map +1 -1
  50. package/dist/components/PageHeader/PageHeader.d.ts +3 -2
  51. package/dist/components/PageHeader/PageHeader.js +10 -1
  52. package/dist/components/PageHeader/PageHeader.js.map +1 -1
  53. package/dist/components/RelativeTime/RelativeTime.js +4 -3
  54. package/dist/components/RelativeTime/RelativeTime.js.map +1 -1
  55. package/dist/components/Select/Select.js +1 -1
  56. package/dist/components/Select/Select.js.map +1 -1
  57. package/dist/components/SettingsLayout/SettingsLayout.d.ts +6 -4
  58. package/dist/components/SettingsLayout/SettingsLayout.js +38 -11
  59. package/dist/components/SettingsLayout/SettingsLayout.js.map +1 -1
  60. package/dist/components/SideNav/SideNav.d.ts +10 -5
  61. package/dist/components/SideNav/SideNav.js +10 -6
  62. package/dist/components/SideNav/SideNav.js.map +1 -1
  63. package/dist/components/SplitPane/SplitPane.d.ts +2 -2
  64. package/dist/components/SplitPane/SplitPane.js +29 -9
  65. package/dist/components/SplitPane/SplitPane.js.map +1 -1
  66. package/dist/components/TextField/TextField.d.ts +8 -2
  67. package/dist/components/TextField/TextField.js +59 -13
  68. package/dist/components/TextField/TextField.js.map +1 -1
  69. package/dist/components/TopBar/TopBar.d.ts +2 -2
  70. package/dist/components/TopBar/TopBar.js.map +1 -1
  71. package/dist/components/Workbench/Workbench.d.ts +8 -5
  72. package/dist/components/Workbench/Workbench.js +184 -157
  73. package/dist/components/Workbench/Workbench.js.map +1 -1
  74. package/dist/components/ZoneMap/ZoneMap.js +4 -4
  75. package/dist/components/ZoneMap/ZoneMap.js.map +1 -1
  76. package/dist/components/useFormErrors/useFormErrors.d.ts +5 -2
  77. package/dist/components/useFormErrors/useFormErrors.js +10 -4
  78. package/dist/components/useFormErrors/useFormErrors.js.map +1 -1
  79. package/dist/css/AccentPicker.css +19 -0
  80. package/dist/css/Alert.css +30 -7
  81. package/dist/css/AppShell.css +12 -0
  82. package/dist/css/Calendar.css +7 -0
  83. package/dist/css/ConsoleLayout.css +3 -0
  84. package/dist/css/DataTable.css +70 -8
  85. package/dist/css/DetailList.css +11 -0
  86. package/dist/css/EmptyState.css +8 -0
  87. package/dist/css/EventTimeline.css +11 -4
  88. package/dist/css/Grid.css +15 -0
  89. package/dist/css/KpiCard.css +1 -0
  90. package/dist/css/LayerGraph.css +1 -1
  91. package/dist/css/LoadingBar.css +4 -1
  92. package/dist/css/LoginCard.css +1 -1
  93. package/dist/css/MobileTabBar.css +6 -4
  94. package/dist/css/MultiSelect.css +23 -3
  95. package/dist/css/Select.css +9 -0
  96. package/dist/css/SettingsLayout.css +29 -14
  97. package/dist/css/Tabs.css +36 -17
  98. package/dist/css/Toast.css +7 -0
  99. package/dist/css/TopBar.css +6 -3
  100. package/dist/css/Workbench.css +10 -5
  101. package/dist/css/base.css +90 -3
  102. package/dist/css/end.css +5 -2
  103. package/dist/fonts-latin.css +2 -0
  104. package/dist/fonts-tc.css +2 -0
  105. package/dist/format.d.ts +4 -3
  106. package/dist/format.js +13 -12
  107. package/dist/format.js.map +1 -1
  108. package/dist/i18n.js +17 -6
  109. package/dist/i18n.js.map +1 -1
  110. package/dist/icons/Icon.d.ts +2 -1
  111. package/dist/icons/Icon.js +4 -3
  112. package/dist/icons/Icon.js.map +1 -1
  113. package/dist/icons/all.js +23 -1
  114. package/dist/icons/all.js.map +1 -1
  115. package/dist/icons/names.d.ts +22 -0
  116. package/dist/icons/names.js +11 -0
  117. package/dist/icons/names.js.map +1 -1
  118. package/dist/icons/ph/credit-card.d.ts +10 -0
  119. package/dist/icons/ph/credit-card.js +11 -0
  120. package/dist/icons/ph/credit-card.js.map +1 -0
  121. package/dist/icons/ph/map-pin.d.ts +10 -0
  122. package/dist/icons/ph/map-pin.js +11 -0
  123. package/dist/icons/ph/map-pin.js.map +1 -0
  124. package/dist/icons/ph/package.d.ts +10 -0
  125. package/dist/icons/ph/package.js +11 -0
  126. package/dist/icons/ph/package.js.map +1 -0
  127. package/dist/icons/ph/pause.d.ts +10 -0
  128. package/dist/icons/ph/pause.js +11 -0
  129. package/dist/icons/ph/pause.js.map +1 -0
  130. package/dist/icons/ph/phone.d.ts +10 -0
  131. package/dist/icons/ph/phone.js +11 -0
  132. package/dist/icons/ph/phone.js.map +1 -0
  133. package/dist/icons/ph/play.d.ts +10 -0
  134. package/dist/icons/ph/play.js +11 -0
  135. package/dist/icons/ph/play.js.map +1 -0
  136. package/dist/icons/ph/prohibit.d.ts +10 -0
  137. package/dist/icons/ph/prohibit.js +11 -0
  138. package/dist/icons/ph/prohibit.js.map +1 -0
  139. package/dist/icons/ph/receipt.d.ts +10 -0
  140. package/dist/icons/ph/receipt.js +11 -0
  141. package/dist/icons/ph/receipt.js.map +1 -0
  142. package/dist/icons/ph/shopping-cart.d.ts +10 -0
  143. package/dist/icons/ph/shopping-cart.js +11 -0
  144. package/dist/icons/ph/shopping-cart.js.map +1 -0
  145. package/dist/icons/ph/storefront.d.ts +10 -0
  146. package/dist/icons/ph/storefront.js +11 -0
  147. package/dist/icons/ph/storefront.js.map +1 -0
  148. package/dist/icons/ph/truck.d.ts +10 -0
  149. package/dist/icons/ph/truck.js +11 -0
  150. package/dist/icons/ph/truck.js.map +1 -0
  151. package/dist/icons/store.d.ts +3 -1
  152. package/dist/icons/store.js +17 -12
  153. package/dist/icons/store.js.map +1 -1
  154. package/dist/index.d.ts +2 -2
  155. package/dist/index.js +2 -2
  156. package/dist/internal/FloatingPanel.js +5 -2
  157. package/dist/internal/FloatingPanel.js.map +1 -1
  158. package/dist/internal/clickSteps.js +11 -0
  159. package/dist/internal/clickSteps.js.map +1 -0
  160. package/dist/internal/util.js +7 -1
  161. package/dist/internal/util.js.map +1 -1
  162. package/dist/styles.css +499 -162
  163. package/dist/theme.d.ts +7 -0
  164. package/dist/theme.js +39 -15
  165. package/dist/theme.js.map +1 -1
  166. package/docs/Alert.md +1 -1
  167. package/docs/AppShell.md +4 -4
  168. package/docs/Badge.md +2 -1
  169. package/docs/BarChart.md +1 -1
  170. package/docs/Checkbox.md +2 -2
  171. package/docs/CodeView.md +12 -22
  172. package/docs/ConsoleLayout.md +1 -0
  173. package/docs/DataTable.md +16 -11
  174. package/docs/DatePicker.md +1 -1
  175. package/docs/DateRangePicker.md +1 -0
  176. package/docs/DetailList.md +12 -1
  177. package/docs/Drawer.md +1 -1
  178. package/docs/EmptyState.md +1 -0
  179. package/docs/EventTimeline.md +1 -1
  180. package/docs/Format.md +2 -1
  181. package/docs/Graph.md +1 -0
  182. package/docs/Grid.md +9 -0
  183. package/docs/KpiCard.md +5 -4
  184. package/docs/LoadingBar.md +1 -1
  185. package/docs/LoginCard.md +1 -1
  186. package/docs/Markdown.md +4 -37
  187. package/docs/MobileTabBar.md +1 -1
  188. package/docs/MultiSelect.md +3 -2
  189. package/docs/NotificationBell.md +2 -2
  190. package/docs/PageHeader.md +2 -1
  191. package/docs/RadioGroup.md +1 -1
  192. package/docs/RelativeTime.md +2 -2
  193. package/docs/SettingsLayout.md +5 -4
  194. package/docs/SideNav.md +2 -1
  195. package/docs/Skeleton.md +2 -2
  196. package/docs/SplitPane.md +3 -9
  197. package/docs/Tabs.md +14 -11
  198. package/docs/Tag.md +4 -3
  199. package/docs/TextField.md +2 -0
  200. package/docs/Toast.md +1 -1
  201. package/docs/TopBar.md +2 -2
  202. package/docs/Workbench.md +9 -6
  203. package/docs/agents.md +13 -13
  204. package/docs/data.md +2 -1
  205. package/docs/guidelines.md +4 -4
  206. package/docs/icons.md +2 -2
  207. package/docs/layout.md +3 -3
  208. package/docs/theme.md +6 -3
  209. package/docs/useFormErrors.md +2 -1
  210. package/package.json +4 -2
@@ -16,5 +16,6 @@ export interface AlertProps {
16
16
  /** Extra class on the root element. */
17
17
  className?: string;
18
18
  }
19
- /** A message inside the page: a card with the tone's icon, a title, a sentence and an optional action under it. */
19
+ /** A message inside the page: a card with the tone's icon, a title, a sentence and an optional action at the right end
20
+ * of the text (under it when the alert is narrower than 480 px). */
20
21
  export declare function Alert({ tone, title, children, actionLabel, onAction, onDismiss, className }: AlertProps): React.JSX.Element;
@@ -14,7 +14,8 @@ const ALERT_ICONS = {
14
14
  warning: "M12 4l9 16H3zM12 10v4M12 17v.5",
15
15
  danger: "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 8v5M12 16.5v.5"
16
16
  };
17
- /** A message inside the page: a card with the tone's icon, a title, a sentence and an optional action under it. */
17
+ /** A message inside the page: a card with the tone's icon, a title, a sentence and an optional action at the right end
18
+ * of the text (under it when the alert is narrower than 480 px). */
18
19
  function Alert({ tone = "info", title, children, actionLabel, onAction, onDismiss, className }) {
19
20
  const t = ALERT_ICONS[tone] ? tone : "info";
20
21
  const canClose = (t === "info" || t === "success") && onDismiss;
@@ -28,23 +29,20 @@ function Alert({ tone = "info", title, children, actionLabel, onAction, onDismis
28
29
  }),
29
30
  /* @__PURE__ */ jsxs("div", {
30
31
  className: "ui-alert-content",
31
- children: [
32
- title ? /* @__PURE__ */ jsx("div", {
33
- className: "ui-alert-title",
34
- children: title
35
- }) : null,
36
- children ? /* @__PURE__ */ jsx("div", {
37
- className: "ui-alert-body",
38
- children: codeText(children)
39
- }) : null,
40
- actionLabel ? /* @__PURE__ */ jsx("button", {
41
- type: "button",
42
- className: "ui-btn ui-btn-secondary ui-alert-action",
43
- onClick: onAction,
44
- children: actionLabel
45
- }) : null
46
- ]
32
+ children: [title ? /* @__PURE__ */ jsx("div", {
33
+ className: "ui-alert-title",
34
+ children: title
35
+ }) : null, children ? /* @__PURE__ */ jsx("div", {
36
+ className: "ui-alert-body",
37
+ children: codeText(children)
38
+ }) : null]
47
39
  }),
40
+ actionLabel ? /* @__PURE__ */ jsx("button", {
41
+ type: "button",
42
+ className: "ui-btn ui-btn-secondary ui-alert-action",
43
+ onClick: onAction,
44
+ children: actionLabel
45
+ }) : null,
48
46
  canClose ? /* @__PURE__ */ jsx("button", {
49
47
  type: "button",
50
48
  className: "ui-alert-close",
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.js","names":["phX"],"sources":["../../../src/components/Alert/Alert.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon, type CustomIcon } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { includeIcons } from '../../icons/store';\nimport phX from '../../icons/ph/x';\nimport { codeText } from '../InlineCode/InlineCode';\n\nincludeIcons(phX);\n\nexport type AlertTone = 'info' | 'success' | 'warning' | 'danger';\n\nconst ALERT_ICONS: Record<AlertTone, CustomIcon> = {\n info: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 11v5M12 7.5v.5',\n success: 'M5 12.5l4.5 4.5L19 7',\n warning: 'M12 4l9 16H3zM12 10v4M12 17v.5',\n danger: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 8v5M12 16.5v.5',\n};\n\nexport interface AlertProps {\n /** Default 'info'. danger is announced at once (role alert). */\n tone?: AlertTone;\n /** One short line, bold. */\n title?: string;\n /** The cause and the fix, at most 2 short sentences; in a string, `backticks` are code. */\n children?: React.ReactNode;\n /** A verb, such as 重試: an outline button under the text. */\n actionLabel?: string;\n /** Runs when the action button is pressed. */\n onAction?: () => void;\n /** Adds × for info and success; warning and danger stay until the problem is solved. */\n onDismiss?: () => void;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** A message inside the page: a card with the tone's icon, a title, a sentence and an optional action under it. */\nexport function Alert({ tone = 'info', title, children, actionLabel, onAction, onDismiss, className }: AlertProps) {\n const t = ALERT_ICONS[tone] ? tone : 'info';\n const canClose = (t === 'info' || t === 'success') && onDismiss;\n return (\n <div className={cx('ui-alert', 'ui-alert-' + t, className)} role={t === 'danger' ? 'alert' : 'status'}>\n <Icon d={ALERT_ICONS[t]} className=\"ui-alert-icon\" />\n <div className=\"ui-alert-content\">\n {title ? <div className=\"ui-alert-title\">{title}</div> : null}\n {children ? <div className=\"ui-alert-body\">{codeText(children)}</div> : null}\n {/* Under the text, not at the right end: with or without ✕ every action starts at the same place. */}\n {actionLabel ? (\n <button type=\"button\" className=\"ui-btn ui-btn-secondary ui-alert-action\" onClick={onAction}>\n {actionLabel}\n </button>\n ) : null}\n </div>\n {canClose ? (\n <button type=\"button\" className=\"ui-alert-close\" aria-label={tr('關閉提示')} onClick={onDismiss}>\n <Icon name=\"x\" size={16} />\n </button>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAQA,aAAaA,SAAG;AAIhB,MAAM,cAA6C;CACjD,MAAM;CACN,SAAS;CACT,SAAS;CACT,QAAQ;AACV;;AAoBA,SAAgB,MAAM,EAAE,OAAO,QAAQ,OAAO,UAAU,aAAa,UAAU,WAAW,aAAyB;CACjH,MAAM,IAAI,YAAY,QAAQ,OAAO;CACrC,MAAM,YAAY,MAAM,UAAU,MAAM,cAAc;CACtD,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,cAAc,GAAG,SAAS;EAAG,MAAM,MAAM,WAAW,UAAU;EAA7F,UAAA;GACE,oBAAC,MAAD;IAAM,GAAG,YAAY;IAAI,WAAU;GAAiB,CAAA;GACpD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACG,QAAQ,oBAAC,OAAD;MAAK,WAAU;MAAkB,UAAA;KAAW,CAAA,IAAI;KACxD,WAAW,oBAAC,OAAD;MAAK,WAAU;MAAiB,UAAA,SAAS,QAAQ;KAAO,CAAA,IAAI;KAEvE,cACC,oBAAC,UAAD;MAAQ,MAAK;MAAS,WAAU;MAA0C,SAAS;MAChF,UAAA;KACK,CAAA,IACN;IACD;;GACJ,WACC,oBAAC,UAAD;IAAQ,MAAK;IAAS,WAAU;IAAiB,cAAY,GAAG,MAAM;IAAG,SAAS;IAChF,UAAA,oBAAC,MAAD;KAAM,MAAK;KAAI,MAAM;IAAK,CAAA;GACpB,CAAA,IACN;EACD;;AAET"}
1
+ {"version":3,"file":"Alert.js","names":["phX"],"sources":["../../../src/components/Alert/Alert.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon, type CustomIcon } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { includeIcons } from '../../icons/store';\nimport phX from '../../icons/ph/x';\nimport { codeText } from '../InlineCode/InlineCode';\n\nincludeIcons(phX);\n\nexport type AlertTone = 'info' | 'success' | 'warning' | 'danger';\n\nconst ALERT_ICONS: Record<AlertTone, CustomIcon> = {\n info: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 11v5M12 7.5v.5',\n success: 'M5 12.5l4.5 4.5L19 7',\n warning: 'M12 4l9 16H3zM12 10v4M12 17v.5',\n danger: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 8v5M12 16.5v.5',\n};\n\nexport interface AlertProps {\n /** Default 'info'. danger is announced at once (role alert). */\n tone?: AlertTone;\n /** One short line, bold. */\n title?: string;\n /** The cause and the fix, at most 2 short sentences; in a string, `backticks` are code. */\n children?: React.ReactNode;\n /** A verb, such as 重試: an outline button under the text. */\n actionLabel?: string;\n /** Runs when the action button is pressed. */\n onAction?: () => void;\n /** Adds × for info and success; warning and danger stay until the problem is solved. */\n onDismiss?: () => void;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** A message inside the page: a card with the tone's icon, a title, a sentence and an optional action at the right end\n * of the text (under it when the alert is narrower than 480 px). */\nexport function Alert({ tone = 'info', title, children, actionLabel, onAction, onDismiss, className }: AlertProps) {\n const t = ALERT_ICONS[tone] ? tone : 'info';\n const canClose = (t === 'info' || t === 'success') && onDismiss;\n return (\n <div className={cx('ui-alert', 'ui-alert-' + t, className)} role={t === 'danger' ? 'alert' : 'status'}>\n <Icon d={ALERT_ICONS[t]} className=\"ui-alert-icon\" />\n <div className=\"ui-alert-content\">\n {title ? <div className=\"ui-alert-title\">{title}</div> : null}\n {children ? <div className=\"ui-alert-body\">{codeText(children)}</div> : null}\n </div>\n {/* At the right end of the text, so the alert is no taller than its text; under it on a narrow alert. */}\n {actionLabel ? (\n <button type=\"button\" className=\"ui-btn ui-btn-secondary ui-alert-action\" onClick={onAction}>\n {actionLabel}\n </button>\n ) : null}\n {canClose ? (\n <button type=\"button\" className=\"ui-alert-close\" aria-label={tr('關閉提示')} onClick={onDismiss}>\n <Icon name=\"x\" size={16} />\n </button>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAQA,aAAaA,SAAG;AAIhB,MAAM,cAA6C;CACjD,MAAM;CACN,SAAS;CACT,SAAS;CACT,QAAQ;AACV;;;AAqBA,SAAgB,MAAM,EAAE,OAAO,QAAQ,OAAO,UAAU,aAAa,UAAU,WAAW,aAAyB;CACjH,MAAM,IAAI,YAAY,QAAQ,OAAO;CACrC,MAAM,YAAY,MAAM,UAAU,MAAM,cAAc;CACtD,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,cAAc,GAAG,SAAS;EAAG,MAAM,MAAM,WAAW,UAAU;EAA7F,UAAA;GACE,oBAAC,MAAD;IAAM,GAAG,YAAY;IAAI,WAAU;GAAiB,CAAA;GACpD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,QAAQ,oBAAC,OAAD;KAAK,WAAU;KAAkB,UAAA;IAAW,CAAA,IAAI,MACxD,WAAW,oBAAC,OAAD;KAAK,WAAU;KAAiB,UAAA,SAAS,QAAQ;IAAO,CAAA,IAAI,IACrE;;GAEJ,cACC,oBAAC,UAAD;IAAQ,MAAK;IAAS,WAAU;IAA0C,SAAS;IAChF,UAAA;GACK,CAAA,IACN;GACH,WACC,oBAAC,UAAD;IAAQ,MAAK;IAAS,WAAU;IAAiB,cAAY,GAAG,MAAM;IAAG,SAAS;IAChF,UAAA,oBAAC,MAAD;KAAM,MAAK;KAAI,MAAM;IAAK,CAAA;GACpB,CAAA,IACN;EACD;;AAET"}
@@ -16,7 +16,7 @@ export interface AppShellProps {
16
16
  /** The page title, shown once in the top bar. Leave it out when the page has its own title (PageHeader with
17
17
  * `title` on a detail page); never both. */
18
18
  title?: string;
19
- /** Right after the title in the top bar, e.g. a Tag 「示範資料」 with the info icon. */
19
+ /** Right after the title in the top bar, small and muted (12 px, ink-muted), e.g. a Tag 「示範資料」 with the info icon. */
20
20
  tags?: React.ReactNode;
21
21
  /** @deprecated A breadcrumb goes at the top of the content: put `<Breadcrumb items={…} />` first in the page. */
22
22
  breadcrumb?: BreadcrumbItem[];
@@ -35,8 +35,8 @@ export interface AppShellProps {
35
35
  /** Extra class on the root element. */
36
36
  className?: string;
37
37
  }
38
- /** The dashboard frame: sidebar (240 px, 72 px collapsed) from 1024 px, a drawer from the top bar's menu button from
39
- * 600 to 1023 px, and bottom tabs on phones.
38
+ /** The dashboard frame: sidebar (240 px, 72 px collapsed) above 1024 px, a drawer from the top bar's menu button from
39
+ * 600 to 1024 px, and bottom tabs on phones.
40
40
  * The top bar hides while scrolling down and returns when scrolling up. */
41
41
  export declare function AppShell({ nav, value, onNavigate, brand, title, tags, breadcrumb, onSearch, actions, children, tabLabels, defaultPinned, className }: AppShellProps): React.JSX.Element;
42
42
  export { focusMain };
@@ -24,13 +24,13 @@ const OPEN_DELAY = 100;
24
24
  /** Pointer away this long before it hides again (a slip off the edge does not). */
25
25
  const CLOSE_DELAY = 300;
26
26
  const MORE = "\0more";
27
- /** The dashboard frame: sidebar (240 px, 72 px collapsed) from 1024 px, a drawer from the top bar's menu button from
28
- * 600 to 1023 px, and bottom tabs on phones.
27
+ /** The dashboard frame: sidebar (240 px, 72 px collapsed) above 1024 px, a drawer from the top bar's menu button from
28
+ * 600 to 1024 px, and bottom tabs on phones.
29
29
  * The top bar hides while scrolling down and returns when scrolling up. */
30
30
  function AppShell({ nav, value, onNavigate, brand, title, tags, breadcrumb, onSearch, actions, children, tabLabels, defaultPinned = false, className }) {
31
31
  devWarn(breadcrumb, "AppShell", "`breadcrumb` is deprecated: in the top bar it repeats the page title. Put <Breadcrumb items={…} /> first in the page content instead.");
32
32
  const phone = useNarrow();
33
- const tablet = useMedia("(min-width: 600px) and (max-width: 1023px)");
33
+ const tablet = useMedia("(min-width: 600px) and (max-width: 1024px)");
34
34
  const [storedCollapsed, setStoredCollapsed] = useStored(COLLAPSE_KEY, asText, null);
35
35
  const [storedPin, setStoredPin] = useStored(PIN_KEY, asText, null);
36
36
  const userCollapsed = storedCollapsed === "1";
@@ -100,8 +100,9 @@ function AppShell({ nav, value, onNavigate, brand, title, tags, breadcrumb, onSe
100
100
  inShell: true,
101
101
  title: !!title
102
102
  }), [title]);
103
+ const bare = !title && !tags && !actions && !onSearch && !breadcrumb?.length && !tablet;
103
104
  return /* @__PURE__ */ jsxs("div", {
104
- className: cx("ui-shell", phone && "is-phone", className),
105
+ className: cx("ui-shell", phone && "is-phone", bare && "is-bare", className),
105
106
  children: [
106
107
  /* @__PURE__ */ jsx("a", {
107
108
  className: "ui-skip",
@@ -119,10 +120,8 @@ function AppShell({ nav, value, onNavigate, brand, title, tags, breadcrumb, onSe
119
120
  brand,
120
121
  collapsed,
121
122
  pinned: true,
122
- onPin: togglePin,
123
- onToggle: () => {
124
- setStoredCollapsed(userCollapsed ? "0" : "1");
125
- }
123
+ onPinnedChange: togglePin,
124
+ onCollapsedChange: (c) => setStoredCollapsed(c ? "1" : "0")
126
125
  }) : /* @__PURE__ */ jsx("div", {
127
126
  className: cx("ui-shell-rail", open && "is-open"),
128
127
  onPointerEnter: (e) => e.pointerType === "mouse" && later(true),
@@ -151,13 +150,13 @@ function AppShell({ nav, value, onNavigate, brand, title, tags, breadcrumb, onSe
151
150
  },
152
151
  brand,
153
152
  collapsed,
154
- onPin: togglePin
153
+ onPinnedChange: togglePin
155
154
  })
156
155
  }),
157
156
  /* @__PURE__ */ jsxs("div", {
158
157
  className: "ui-shell-body",
159
158
  children: [
160
- /* @__PURE__ */ jsx(TopBar, {
159
+ bare ? null : /* @__PURE__ */ jsx(TopBar, {
161
160
  className: cx("ui-shell-top", hidden && "is-hidden"),
162
161
  title,
163
162
  tags,
@@ -1 +1 @@
1
- {"version":3,"file":"AppShell.js","names":["phDotsThree"],"sources":["../../../src/components/AppShell/AppShell.tsx"],"sourcesContent":["import * as React from 'react';\nimport { SideNav, type NavBrand, type NavItem, type NavSection } from '../SideNav/SideNav';\nimport { TopBar } from '../TopBar/TopBar';\nimport { MobileTabBar, type MobileTab } from '../MobileTabBar/MobileTabBar';\nimport { Drawer } from '../Drawer/Drawer';\nimport { AutoToaster } from '../Toast/Toast';\nimport { tr } from '../../i18n';\nimport type { BreadcrumbItem } from '../Breadcrumb/Breadcrumb';\nimport { cx, useMedia, useNarrow } from '../../internal/util';\nimport { asText, useStored } from '../../internal/stored';\nimport { devWarn } from '../../internal/dev';\nimport { ensureAnnouncer } from '../../announce';\nimport { focusMain, installFocusMain } from '../../internal/focusMain';\nimport { ShellTitle } from '../../internal/shell';\nimport { includeIcons } from '../../icons/store';\nimport phDotsThree from '../../icons/ph/dots-three';\n\nincludeIcons(phDotsThree);\n\nexport interface AppShellProps {\n /** Sidebar groups. On phones, top-level items with an icon become bottom tabs; pages they cannot reach go under 「更多」. */\n nav: NavSection[];\n /** Id of the current page. */\n value: string;\n /** Called with the id of the nav item the person picks. */\n onNavigate: (id: string) => void;\n /** The product at the top of the sidebar: { mark, name, href } (see SideNav's NavBrand). Collapsed it shows the mark\n * alone, a link named by `name`; open or pinned, the name fades in beside it. Plain text gets its first character as\n * the mark. */\n brand?: React.ReactNode | NavBrand;\n /** The page title, shown once in the top bar. Leave it out when the page has its own title (PageHeader with\n * `title` on a detail page); never both. */\n title?: string;\n /** Right after the title in the top bar, e.g. a Tag 「示範資料」 with the info icon. */\n tags?: React.ReactNode;\n /** @deprecated A breadcrumb goes at the top of the content: put `<Breadcrumb items={…} />` first in the page. */\n breadcrumb?: BreadcrumbItem[];\n /** Opens search (CommandPalette). */\n onSearch?: () => void;\n /** Right side of the top bar: NotificationBell, ProjectSwitcher, the account menu. */\n actions?: React.ReactNode;\n /** The page: Cards and sections, 32 px apart. */\n children: React.ReactNode;\n /** Labels under the phone tab bar's icons (MobileTabBar labels). Default true. */\n tabLabels?: boolean;\n /** Desktop: whether the sidebar starts pinned (240 px, or 72 px collapsed, beside the content) until the reader\n * pins or unpins it; their choice is kept in the browser. Default false: a 72 px strip of icons that opens to\n * 240 px over the content while the pointer or the keyboard focus is on it. */\n defaultPinned?: boolean;\n /** Extra class on the root element. */\n className?: string;\n}\n\nconst COLLAPSE_KEY = 'ui-nav-collapsed';\nconst PIN_KEY = 'ui-nav-pinned';\n/** Pointer on the strip this long before it opens (passing over it on the way to the browser's edge does not). */\nconst OPEN_DELAY = 100;\n/** Pointer away this long before it hides again (a slip off the edge does not). */\nconst CLOSE_DELAY = 300;\n\nexport { focusMain };\nconst MORE = '\\u0000more';\n\n/** The dashboard frame: sidebar (240 px, 72 px collapsed) from 1024 px, a drawer from the top bar's menu button from\n * 600 to 1023 px, and bottom tabs on phones.\n * The top bar hides while scrolling down and returns when scrolling up. */\nexport function AppShell({\n nav,\n value,\n onNavigate,\n brand,\n title,\n tags,\n breadcrumb,\n onSearch,\n actions,\n children,\n tabLabels,\n defaultPinned = false,\n className,\n}: AppShellProps) {\n devWarn(\n breadcrumb,\n 'AppShell',\n '`breadcrumb` is deprecated: in the top bar it repeats the page title. Put <Breadcrumb items={…} /> first in the page content instead.',\n );\n const phone = useNarrow();\n // 600 to 1023 px (tablets, narrow windows): no sidebar; the top bar's menu button opens the whole nav in a drawer.\n // 1024 px is the navigation's own edge, separate from the page-layout breakpoint bp-desktop (960 px).\n const tablet = useMedia('(min-width: 600px) and (max-width: 1023px)');\n // Stored choices: the same on the server and the first render in the browser (none stored), then the stored ones.\n const [storedCollapsed, setStoredCollapsed] = useStored<string | null>(COLLAPSE_KEY, asText, null);\n const [storedPin, setStoredPin] = useStored<string | null>(PIN_KEY, asText, null);\n const userCollapsed = storedCollapsed === '1';\n // Pinned: the sidebar sits beside the content as before (240 px, or 72 px collapsed). Not pinned: a 72 px strip of\n // icons that opens over the content. Someone who already chose collapsed or expanded keeps a pinned sidebar.\n const pinned = storedPin != null ? storedPin === '1' : storedCollapsed != null || defaultPinned;\n React.useEffect(installFocusMain, []);\n const [open, setOpen] = React.useState(false);\n const openTimer = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n const closeTimer = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n const later = (show: boolean) => {\n clearTimeout(openTimer.current);\n clearTimeout(closeTimer.current);\n if (show) openTimer.current = setTimeout(() => setOpen(true), OPEN_DELAY);\n else closeTimer.current = setTimeout(() => setOpen(false), CLOSE_DELAY);\n };\n React.useEffect(\n () => () => {\n clearTimeout(openTimer.current);\n clearTimeout(closeTimer.current);\n },\n [],\n );\n const collapsed = pinned ? userCollapsed : !open;\n const togglePin = () => {\n setStoredPin(pinned ? '0' : '1');\n setOpen(false);\n };\n const top = nav.flatMap((s) => s.items);\n const parentOf = (id: string) => top.find((it) => it.children?.some((c) => c.id === id));\n // Phones: top-level items with an icon become tabs (a group opens its first page).\n // When some page is not reachable that way, the last tab becomes 「更多」 and opens the whole nav.\n const withIcon = top.filter((it): it is NavItem & { icon: NonNullable<NavItem['icon']> } => !!it.icon);\n const unreachable = top.some((it) => !it.icon || (it.children?.length ?? 0) > 1) || withIcon.length > 5;\n const tabs: MobileTab[] = withIcon.slice(0, unreachable ? 4 : 5).map((it) => ({ id: it.id, label: it.label, icon: it.icon }));\n if (unreachable) tabs.push({ id: MORE, label: tr('更多'), icon: 'dots-three' });\n const [moreOpen, setMoreOpen] = React.useState(false);\n // Widened past the drawer's layouts (to a desktop with the sidebar): closed, so it does not pop up again when the\n // window narrows later.\n if (moreOpen && !phone && !tablet) setMoreOpen(false);\n devWarn(phone && withIcon.length < 2, 'AppShell', 'phones show the top-level nav items as bottom tabs; give at least 2 of them an icon.');\n const current = parentOf(value)?.id ?? value;\n const tabValue = tabs.some((t) => t.id === current) ? current : MORE;\n const onTab = (id: string) => {\n if (id === MORE) return setMoreOpen(true);\n if (id === current) return;\n const item = top.find((it) => it.id === id);\n onNavigate(item?.children?.[0]?.id ?? id);\n };\n\n // Hide the top bar while scrolling down, show it again on the way up.\n const main = React.useRef<HTMLElement>(null);\n const [hidden, setHidden] = React.useState(false);\n React.useEffect(() => {\n const el = main.current;\n if (!el) return;\n let last = el.scrollTop;\n const onScroll = () => {\n const y = el.scrollTop;\n if (Math.abs(y - last) < 8) return;\n setHidden(y > last && y > 64);\n last = y;\n };\n el.addEventListener('scroll', onScroll, { passive: true });\n return () => el.removeEventListener('scroll', onScroll);\n }, []);\n\n React.useEffect(() => {\n ensureAnnouncer();\n }, []);\n const shellTitle = React.useMemo(() => ({ inShell: true, title: !!title }), [title]);\n return (\n <div className={cx('ui-shell', phone && 'is-phone', className)}>\n {/* First stop for the keyboard: skips the navigation. */}\n <a\n className=\"ui-skip\"\n href=\"#main\"\n onClick={(e) => {\n e.preventDefault();\n focusMain();\n }}\n >\n {tr('跳到主要內容')}\n </a>\n {phone || tablet ? null : pinned ? (\n <SideNav\n sections={nav}\n value={value}\n onChange={onNavigate}\n brand={brand}\n collapsed={collapsed}\n pinned\n onPin={togglePin}\n onToggle={() => {\n setStoredCollapsed(userCollapsed ? '0' : '1');\n }}\n />\n ) : (\n // Not pinned: the strip keeps its 72 px in the layout; the sidebar inside opens over the content and closes\n // again when the pointer and the focus have left it, after a page is chosen, or on Esc.\n <div\n className={cx('ui-shell-rail', open && 'is-open')}\n onPointerEnter={(e) => e.pointerType === 'mouse' && later(true)}\n onPointerLeave={(e) => e.pointerType === 'mouse' && later(false)}\n onFocus={(e) => {\n if (!(e.target as Element).matches(':focus-visible')) return;\n clearTimeout(closeTimer.current);\n setOpen(true);\n }}\n onBlur={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setOpen(false);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && open) {\n e.stopPropagation();\n setOpen(false);\n }\n }}\n >\n <SideNav\n sections={nav}\n value={value}\n onChange={(id) => {\n clearTimeout(openTimer.current);\n setOpen(false);\n onNavigate(id);\n }}\n brand={brand}\n collapsed={collapsed}\n onPin={togglePin}\n />\n </div>\n )}\n <div className=\"ui-shell-body\">\n <TopBar\n className={cx('ui-shell-top', hidden && 'is-hidden')}\n title={title}\n tags={tags}\n breadcrumb={breadcrumb}\n onSearch={onSearch ?? false}\n onMenu={tablet ? () => setMoreOpen(true) : undefined}\n >\n {actions}\n </TopBar>\n <main ref={main} id=\"main\" className=\"ui-shell-main\" tabIndex={-1}>\n <ShellTitle.Provider value={shellTitle}>{children}</ShellTitle.Provider>\n </main>\n {phone && tabs.length ? <MobileTabBar items={tabs} value={tabValue} onChange={onTab} labels={tabLabels} /> : null}\n {phone || tablet ? (\n <Drawer open={moreOpen} onOpenChange={setMoreOpen} title={tr('全部頁面')} side={tablet ? 'left' : 'right'} width={tablet ? 300 : undefined}>\n <SideNav\n className=\"ui-shell-allnav\"\n sections={nav}\n value={value}\n onChange={(id) => {\n setMoreOpen(false);\n onNavigate(id);\n }}\n />\n </Drawer>\n ) : null}\n {/* toast() works on every AppShell page without setup; a page's own <Toaster /> takes over. */}\n <AutoToaster />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,aAAaA,kBA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AEP,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,oBAAC,QAAD;MACE,WAAW,GAAG,gBAAgB,UAAU,WAAW;MAC5C;MACD;MACM;MACZ,UAAU,YAAY;MACtB,QAAQ,eAAe,YAAY,IAAI,IAAI,KAAA;MAE1C,UAAA;KACK,CAAA;KACR,oBAAC,QAAD;MAAM,KAAK;MAAM,IAAG;MAAO,WAAU;MAAgB,UAAU;MAC7D,UAAA,oBAAC,WAAW,UAAZ;OAAqB,OAAO;OAAa;MAA8B,CAAA;KACnE,CAAA;KACL,SAAS,KAAK,SAAS,oBAAC,cAAD;MAAc,OAAO;MAAM,OAAO;MAAU,UAAU;MAAO,QAAQ;KAAY,CAAA,IAAI;KAC5G,SAAS,SACR,oBAAC,QAAD;MAAQ,MAAM;MAAU,cAAc;MAAa,OAAO,GAAG,MAAM;MAAG,MAAM,SAAS,SAAS;MAAS,OAAO,SAAS,MAAM,KAAA;MAC3H,UAAA,oBAAC,SAAD;OACE,WAAU;OACV,UAAU;OACH;OACP,WAAW,OAAO;QAChB,YAAY,KAAK;QACjB,WAAW,EAAE;OACf;MACD,CAAA;KACK,CAAA,IACN;KAEJ,oBAAC,aAAD,CAAc,CAAA;IACX;;EACF;;AAET"}
1
+ {"version":3,"file":"AppShell.js","names":["phDotsThree"],"sources":["../../../src/components/AppShell/AppShell.tsx"],"sourcesContent":["import * as React from 'react';\nimport { SideNav, type NavBrand, type NavItem, type NavSection } from '../SideNav/SideNav';\nimport { TopBar } from '../TopBar/TopBar';\nimport { MobileTabBar, type MobileTab } from '../MobileTabBar/MobileTabBar';\nimport { Drawer } from '../Drawer/Drawer';\nimport { AutoToaster } from '../Toast/Toast';\nimport { tr } from '../../i18n';\nimport type { BreadcrumbItem } from '../Breadcrumb/Breadcrumb';\nimport { cx, useMedia, useNarrow } from '../../internal/util';\nimport { asText, useStored } from '../../internal/stored';\nimport { devWarn } from '../../internal/dev';\nimport { ensureAnnouncer } from '../../announce';\nimport { focusMain, installFocusMain } from '../../internal/focusMain';\nimport { ShellTitle } from '../../internal/shell';\nimport { includeIcons } from '../../icons/store';\nimport phDotsThree from '../../icons/ph/dots-three';\n\nincludeIcons(phDotsThree);\n\nexport interface AppShellProps {\n /** Sidebar groups. On phones, top-level items with an icon become bottom tabs; pages they cannot reach go under 「更多」. */\n nav: NavSection[];\n /** Id of the current page. */\n value: string;\n /** Called with the id of the nav item the person picks. */\n onNavigate: (id: string) => void;\n /** The product at the top of the sidebar: { mark, name, href } (see SideNav's NavBrand). Collapsed it shows the mark\n * alone, a link named by `name`; open or pinned, the name fades in beside it. Plain text gets its first character as\n * the mark. */\n brand?: React.ReactNode | NavBrand;\n /** The page title, shown once in the top bar. Leave it out when the page has its own title (PageHeader with\n * `title` on a detail page); never both. */\n title?: string;\n /** Right after the title in the top bar, small and muted (12 px, ink-muted), e.g. a Tag 「示範資料」 with the info icon. */\n tags?: React.ReactNode;\n /** @deprecated A breadcrumb goes at the top of the content: put `<Breadcrumb items={…} />` first in the page. */\n breadcrumb?: BreadcrumbItem[];\n /** Opens search (CommandPalette). */\n onSearch?: () => void;\n /** Right side of the top bar: NotificationBell, ProjectSwitcher, the account menu. */\n actions?: React.ReactNode;\n /** The page: Cards and sections, 32 px apart. */\n children: React.ReactNode;\n /** Labels under the phone tab bar's icons (MobileTabBar labels). Default true. */\n tabLabels?: boolean;\n /** Desktop: whether the sidebar starts pinned (240 px, or 72 px collapsed, beside the content) until the reader\n * pins or unpins it; their choice is kept in the browser. Default false: a 72 px strip of icons that opens to\n * 240 px over the content while the pointer or the keyboard focus is on it. */\n defaultPinned?: boolean;\n /** Extra class on the root element. */\n className?: string;\n}\n\nconst COLLAPSE_KEY = 'ui-nav-collapsed';\nconst PIN_KEY = 'ui-nav-pinned';\n/** Pointer on the strip this long before it opens (passing over it on the way to the browser's edge does not). */\nconst OPEN_DELAY = 100;\n/** Pointer away this long before it hides again (a slip off the edge does not). */\nconst CLOSE_DELAY = 300;\n\nexport { focusMain };\nconst MORE = '\\u0000more';\n\n/** The dashboard frame: sidebar (240 px, 72 px collapsed) above 1024 px, a drawer from the top bar's menu button from\n * 600 to 1024 px, and bottom tabs on phones.\n * The top bar hides while scrolling down and returns when scrolling up. */\nexport function AppShell({\n nav,\n value,\n onNavigate,\n brand,\n title,\n tags,\n breadcrumb,\n onSearch,\n actions,\n children,\n tabLabels,\n defaultPinned = false,\n className,\n}: AppShellProps) {\n devWarn(\n breadcrumb,\n 'AppShell',\n '`breadcrumb` is deprecated: in the top bar it repeats the page title. Put <Breadcrumb items={…} /> first in the page content instead.',\n );\n const phone = useNarrow();\n // 600 to 1024 px (tablets, narrow windows, a 1024 px tablet in landscape included): no sidebar; the top bar's menu\n // button opens the whole nav in a drawer. 1024 px is the navigation's own edge, separate from the page-layout\n // breakpoint bp-desktop (960 px).\n const tablet = useMedia('(min-width: 600px) and (max-width: 1024px)');\n // Stored choices: the same on the server and the first render in the browser (none stored), then the stored ones.\n const [storedCollapsed, setStoredCollapsed] = useStored<string | null>(COLLAPSE_KEY, asText, null);\n const [storedPin, setStoredPin] = useStored<string | null>(PIN_KEY, asText, null);\n const userCollapsed = storedCollapsed === '1';\n // Pinned: the sidebar sits beside the content as before (240 px, or 72 px collapsed). Not pinned: a 72 px strip of\n // icons that opens over the content. Someone who already chose collapsed or expanded keeps a pinned sidebar.\n const pinned = storedPin != null ? storedPin === '1' : storedCollapsed != null || defaultPinned;\n React.useEffect(installFocusMain, []);\n const [open, setOpen] = React.useState(false);\n const openTimer = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n const closeTimer = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n const later = (show: boolean) => {\n clearTimeout(openTimer.current);\n clearTimeout(closeTimer.current);\n if (show) openTimer.current = setTimeout(() => setOpen(true), OPEN_DELAY);\n else closeTimer.current = setTimeout(() => setOpen(false), CLOSE_DELAY);\n };\n React.useEffect(\n () => () => {\n clearTimeout(openTimer.current);\n clearTimeout(closeTimer.current);\n },\n [],\n );\n const collapsed = pinned ? userCollapsed : !open;\n const togglePin = () => {\n setStoredPin(pinned ? '0' : '1');\n setOpen(false);\n };\n const top = nav.flatMap((s) => s.items);\n const parentOf = (id: string) => top.find((it) => it.children?.some((c) => c.id === id));\n // Phones: top-level items with an icon become tabs (a group opens its first page).\n // When some page is not reachable that way, the last tab becomes 「更多」 and opens the whole nav.\n const withIcon = top.filter((it): it is NavItem & { icon: NonNullable<NavItem['icon']> } => !!it.icon);\n const unreachable = top.some((it) => !it.icon || (it.children?.length ?? 0) > 1) || withIcon.length > 5;\n const tabs: MobileTab[] = withIcon.slice(0, unreachable ? 4 : 5).map((it) => ({ id: it.id, label: it.label, icon: it.icon }));\n if (unreachable) tabs.push({ id: MORE, label: tr('更多'), icon: 'dots-three' });\n const [moreOpen, setMoreOpen] = React.useState(false);\n // Widened past the drawer's layouts (to a desktop with the sidebar): closed, so it does not pop up again when the\n // window narrows later.\n if (moreOpen && !phone && !tablet) setMoreOpen(false);\n devWarn(phone && withIcon.length < 2, 'AppShell', 'phones show the top-level nav items as bottom tabs; give at least 2 of them an icon.');\n const current = parentOf(value)?.id ?? value;\n const tabValue = tabs.some((t) => t.id === current) ? current : MORE;\n const onTab = (id: string) => {\n if (id === MORE) return setMoreOpen(true);\n if (id === current) return;\n const item = top.find((it) => it.id === id);\n onNavigate(item?.children?.[0]?.id ?? id);\n };\n\n // Hide the top bar while scrolling down, show it again on the way up.\n const main = React.useRef<HTMLElement>(null);\n const [hidden, setHidden] = React.useState(false);\n React.useEffect(() => {\n const el = main.current;\n if (!el) return;\n let last = el.scrollTop;\n const onScroll = () => {\n const y = el.scrollTop;\n if (Math.abs(y - last) < 8) return;\n setHidden(y > last && y > 64);\n last = y;\n };\n el.addEventListener('scroll', onScroll, { passive: true });\n return () => el.removeEventListener('scroll', onScroll);\n }, []);\n\n React.useEffect(() => {\n ensureAnnouncer();\n }, []);\n const shellTitle = React.useMemo(() => ({ inShell: true, title: !!title }), [title]);\n // A page with its own title (PageHeader) and nothing else for the top bar: no empty 64 px strip. The bar stays\n // whenever it holds something (actions, search, tags, the tablet's menu button).\n const bare = !title && !tags && !actions && !onSearch && !breadcrumb?.length && !tablet;\n return (\n <div className={cx('ui-shell', phone && 'is-phone', bare && 'is-bare', className)}>\n {/* First stop for the keyboard: skips the navigation. */}\n <a\n className=\"ui-skip\"\n href=\"#main\"\n onClick={(e) => {\n e.preventDefault();\n focusMain();\n }}\n >\n {tr('跳到主要內容')}\n </a>\n {phone || tablet ? null : pinned ? (\n <SideNav\n sections={nav}\n value={value}\n onChange={onNavigate}\n brand={brand}\n collapsed={collapsed}\n pinned\n onPinnedChange={togglePin}\n onCollapsedChange={(c) => setStoredCollapsed(c ? '1' : '0')}\n />\n ) : (\n // Not pinned: the strip keeps its 72 px in the layout; the sidebar inside opens over the content and closes\n // again when the pointer and the focus have left it, after a page is chosen, or on Esc.\n <div\n className={cx('ui-shell-rail', open && 'is-open')}\n onPointerEnter={(e) => e.pointerType === 'mouse' && later(true)}\n onPointerLeave={(e) => e.pointerType === 'mouse' && later(false)}\n onFocus={(e) => {\n if (!(e.target as Element).matches(':focus-visible')) return;\n clearTimeout(closeTimer.current);\n setOpen(true);\n }}\n onBlur={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setOpen(false);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && open) {\n e.stopPropagation();\n setOpen(false);\n }\n }}\n >\n <SideNav\n sections={nav}\n value={value}\n onChange={(id) => {\n clearTimeout(openTimer.current);\n setOpen(false);\n onNavigate(id);\n }}\n brand={brand}\n collapsed={collapsed}\n onPinnedChange={togglePin}\n />\n </div>\n )}\n <div className=\"ui-shell-body\">\n {bare ? null : (\n <TopBar\n className={cx('ui-shell-top', hidden && 'is-hidden')}\n title={title}\n tags={tags}\n breadcrumb={breadcrumb}\n onSearch={onSearch ?? false}\n onMenu={tablet ? () => setMoreOpen(true) : undefined}\n >\n {actions}\n </TopBar>\n )}\n <main ref={main} id=\"main\" className=\"ui-shell-main\" tabIndex={-1}>\n <ShellTitle.Provider value={shellTitle}>{children}</ShellTitle.Provider>\n </main>\n {phone && tabs.length ? <MobileTabBar items={tabs} value={tabValue} onChange={onTab} labels={tabLabels} /> : null}\n {phone || tablet ? (\n <Drawer open={moreOpen} onOpenChange={setMoreOpen} title={tr('全部頁面')} side={tablet ? 'left' : 'right'} width={tablet ? 300 : undefined}>\n <SideNav\n className=\"ui-shell-allnav\"\n sections={nav}\n value={value}\n onChange={(id) => {\n setMoreOpen(false);\n onNavigate(id);\n }}\n />\n </Drawer>\n ) : null}\n {/* toast() works on every AppShell page without setup; a page's own <Toaster /> takes over. */}\n <AutoToaster />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,aAAaA,kBAAW;AAoCxB,MAAM,eAAe;AACrB,MAAM,UAAU;;AAEhB,MAAM,aAAa;;AAEnB,MAAM,cAAc;AAGpB,MAAM,OAAO;;;;AAKb,SAAgB,SAAS,EACvB,KACA,OACA,YACA,OACA,OACA,MACA,YACA,UACA,SACA,UACA,WACA,gBAAgB,OAChB,aACgB;CAChB,QACE,YACA,YACA,uIACF;CACA,MAAM,QAAQ,UAAU;CAIxB,MAAM,SAAS,SAAS,4CAA4C;CAEpE,MAAM,CAAC,iBAAiB,sBAAsB,UAAyB,cAAc,QAAQ,IAAI;CACjG,MAAM,CAAC,WAAW,gBAAgB,UAAyB,SAAS,QAAQ,IAAI;CAChF,MAAM,gBAAgB,oBAAoB;CAG1C,MAAM,SAAS,aAAa,OAAO,cAAc,MAAM,mBAAmB,QAAQ;CAClF,MAAM,UAAU,kBAAkB,CAAC,CAAC;CACpC,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAC5C,MAAM,YAAY,MAAM,OAAsC,KAAA,CAAS;CACvE,MAAM,aAAa,MAAM,OAAsC,KAAA,CAAS;CACxE,MAAM,SAAS,SAAkB;EAC/B,aAAa,UAAU,OAAO;EAC9B,aAAa,WAAW,OAAO;EAC/B,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OACP,WAAW,OAAO;QAChB,YAAY,KAAK;QACjB,WAAW,EAAE;OACf;MACD,CAAA;KACK,CAAA,IACN;KAEJ,oBAAC,aAAD,CAAc,CAAA;IACX;;EACF;;AAET"}
@@ -3,9 +3,9 @@ import * as React from "react";
3
3
  export type BadgeTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';
4
4
  /** The five work states: draft, doing, review, done and fail. */
5
5
  export type BadgeStatus = 'draft' | 'doing' | 'review' | 'done' | 'fail';
6
- /** Every preset: the work states, closed for a state that ended without a result (已取消, 已停用), and online and
7
- * offline for monitoring. */
8
- export type BadgePreset = BadgeStatus | 'closed' | 'online' | 'offline';
6
+ /** Every preset: the work states, closed for a state that ended without a result (已取消, 已停用), paused for one on
7
+ * hold that can resume (已暫停, 已停權), and online and offline for monitoring. */
8
+ export type BadgePreset = BadgeStatus | 'closed' | 'paused' | 'online' | 'offline';
9
9
  interface BadgeBase {
10
10
  /** Colour of the mark (and of the text for warning and danger). Default: the preset's, or 'neutral'. */
11
11
  tone?: BadgeTone;
@@ -17,7 +17,7 @@ interface BadgeBase {
17
17
  export type BadgeProps = BadgeBase & ({
18
18
  /** A preset: its name, tone and mark. */
19
19
  status: BadgePreset;
20
- /** Default: the preset's name (草稿, 進行中, 審核中, 完成, 失敗, 已關閉, 在線, 離線). */
20
+ /** Default: the preset's name (草稿, 進行中, 審核中, 完成, 失敗, 已關閉, 已暫停, 在線, 離線). */
21
21
  children?: React.ReactNode;
22
22
  } | {
23
23
  status?: undefined;
@@ -35,6 +35,11 @@ const STATUS = {
35
35
  tone: "neutral",
36
36
  mark: "dash"
37
37
  },
38
+ paused: {
39
+ label: "已暫停",
40
+ tone: "warning",
41
+ mark: "pause"
42
+ },
38
43
  online: {
39
44
  label: "在線",
40
45
  tone: "success",
@@ -64,7 +69,8 @@ const STROKE = {
64
69
  bang: "M12 7.5v5.5M12 16.4v.2",
65
70
  cross: "M9 9l6 6M15 9l-6 6",
66
71
  dash: "M8.5 12h7",
67
- slash: "M6.5 17.5l11-11"
72
+ slash: "M6.5 17.5l11-11",
73
+ pause: "M10 8.5v7M14 8.5v7"
68
74
  };
69
75
  /** The status of an item: a mark and text, no chip. The mark's shape carries the meaning too, never colour alone. */
70
76
  function Badge({ status, tone, variant, children, className }) {
@@ -1 +1 @@
1
- {"version":3,"file":"Badge.js","names":[],"sources":["../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\n\n/** The meaning of a status: its colour, and its mark's shape when no preset gives one. */\nexport type BadgeTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';\n\n/** The five work states: draft, doing, review, done and fail. */\nexport type BadgeStatus = 'draft' | 'doing' | 'review' | 'done' | 'fail';\n/** Every preset: the work states, closed for a state that ended without a result (已取消, 已停用), and online and\n * offline for monitoring. */\nexport type BadgePreset = BadgeStatus | 'closed' | 'online' | 'offline';\n\ntype Mark = 'ring' | 'half' | 'quarter' | 'full' | 'bang' | 'cross' | 'dash' | 'slash';\n\nconst STATUS: Record<BadgePreset, { label: string; tone: BadgeTone; mark: Mark }> = {\n draft: { label: '草稿', tone: 'neutral', mark: 'ring' },\n doing: { label: '進行中', tone: 'info', mark: 'half' },\n review: { label: '審核中', tone: 'warning', mark: 'quarter' },\n done: { label: '完成', tone: 'success', mark: 'full' },\n fail: { label: '失敗', tone: 'danger', mark: 'cross' },\n closed: { label: '已關閉', tone: 'neutral', mark: 'dash' },\n online: { label: '在線', tone: 'success', mark: 'full' },\n offline: { label: '離線', tone: 'neutral', mark: 'slash' },\n};\n\n/** The mark of a tone without a preset: the shape tells the meaning too, never colour alone. */\nconst TONE_MARK: Record<BadgeTone, Mark> = { neutral: 'ring', info: 'half', success: 'full', warning: 'bang', danger: 'cross' };\n\n/** Inside the 24 px ring (r 8): filled paths, then stroked ones. */\nconst FILL: Partial<Record<Mark, string>> = {\n half: 'M12 4a8 8 0 0 1 0 16z',\n quarter: 'M12 4a8 8 0 0 1 8 8h-8z',\n full: 'M12 4a8 8 0 1 1 0 16a8 8 0 1 1 0-16z',\n};\nconst STROKE: Partial<Record<Mark, string>> = {\n bang: 'M12 7.5v5.5M12 16.4v.2',\n cross: 'M9 9l6 6M15 9l-6 6',\n dash: 'M8.5 12h7',\n slash: 'M6.5 17.5l11-11',\n};\n\ninterface BadgeBase {\n /** Colour of the mark (and of the text for warning and danger). Default: the preset's, or 'neutral'. */\n tone?: BadgeTone;\n /** @deprecated Every Badge is now a mark and text without a chip; remove the prop. */\n variant?: 'chip' | 'dot';\n /** Extra class on the root element. */\n className?: string;\n}\n\nexport type BadgeProps = BadgeBase &\n (\n | {\n /** A preset: its name, tone and mark. */\n status: BadgePreset;\n /** Default: the preset's name (草稿, 進行中, 審核中, 完成, 失敗, 已關閉, 在線, 離線). */\n children?: React.ReactNode;\n }\n | {\n status?: undefined;\n /** The text; required without a preset. */\n children: React.ReactNode;\n }\n );\n\n/** The status of an item: a mark and text, no chip. The mark's shape carries the meaning too, never colour alone. */\nexport function Badge({ status, tone, variant, children, className }: BadgeProps) {\n devWarn(variant !== undefined, 'Badge', '`variant` is deprecated: every Badge is now a mark and text without a chip. Remove the prop.');\n const preset = status ? (STATUS[status] ?? STATUS.draft) : undefined;\n devWarn(\n !!status && !STATUS[status],\n 'Badge',\n `unknown status \"${String(status)}\"; it shows as 草稿. Use one of ${Object.keys(STATUS).join(', ')}, or give \\`tone\\` and text.`,\n );\n const t: BadgeTone = tone ?? preset?.tone ?? 'neutral';\n const mark: Mark = preset?.mark ?? TONE_MARK[t] ?? 'ring';\n devWarn(!preset && !children, 'Badge', 'a Badge without `status` has no text. Give it text as children, e.g. <Badge tone=\"success\">已付款</Badge>.');\n const key = status && STATUS[status] ? status : preset ? 'draft' : undefined;\n return (\n <span className={cx('ui-badge', 'is-' + t, key && 'ui-badge-' + key, className)}>\n <svg className=\"ui-badge-mark\" width={15} height={15} viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <circle cx={12} cy={12} r={8} fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} />\n {FILL[mark] ? <path d={FILL[mark]} fill=\"currentColor\" /> : null}\n {STROKE[mark] ? <path d={STROKE[mark]} fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" /> : null}\n </svg>\n <span className=\"ui-badge-text\">{children || (preset ? tr(preset.label) : null)}</span>\n </span>\n );\n}\n"],"mappings":";;;;;;AAgBA,MAAM,SAA8E;CAClF,OAAO;EAAE,OAAO;EAAM,MAAM;EAAW,MAAM;CAAO;CACpD,OAAO;EAAE,OAAO;EAAO,MAAM;EAAQ,MAAM;CAAO;CAClD,QAAQ;EAAE,OAAO;EAAO,MAAM;EAAW,MAAM;CAAU;CACzD,MAAM;EAAE,OAAO;EAAM,MAAM;EAAW,MAAM;CAAO;CACnD,MAAM;EAAE,OAAO;EAAM,MAAM;EAAU,MAAM;CAAQ;CACnD,QAAQ;EAAE,OAAO;EAAO,MAAM;EAAW,MAAM;CAAO;CACtD,QAAQ;EAAE,OAAO;EAAM,MAAM;EAAW,MAAM;CAAO;CACrD,SAAS;EAAE,OAAO;EAAM,MAAM;EAAW,MAAM;CAAQ;AACzD;;AAGA,MAAM,YAAqC;CAAE,SAAS;CAAQ,MAAM;CAAQ,SAAS;CAAQ,SAAS;CAAQ,QAAQ;AAAQ;;AAG9H,MAAM,OAAsC;CAC1C,MAAM;CACN,SAAS;CACT,MAAM;AACR;AACA,MAAM,SAAwC;CAC5C,MAAM;CACN,OAAO;CACP,MAAM;CACN,OAAO;AACT;;AA2BA,SAAgB,MAAM,EAAE,QAAQ,MAAM,SAAS,UAAU,aAAyB;CAChF,QAAQ,YAAY,KAAA,GAAW,SAAS,8FAA8F;CACtI,MAAM,SAAS,SAAU,OAAO,WAAW,OAAO,QAAS,KAAA;CAC3D,QACE,CAAC,CAAC,UAAU,CAAC,OAAO,SACpB,SACA,mBAAmB,OAAO,MAAM,EAAE,gCAAgC,OAAO,KAAK,MAAM,CAAC,CAAC,KAAK,IAAI,EAAE,6BACnG;CACA,MAAM,IAAe,QAAQ,QAAQ,QAAQ;CAC7C,MAAM,OAAa,QAAQ,QAAQ,UAAU,MAAM;CACnD,QAAQ,CAAC,UAAU,CAAC,UAAU,SAAS,2GAAyG;CAChJ,MAAM,MAAM,UAAU,OAAO,UAAU,SAAS,SAAS,UAAU,KAAA;CACnE,OACE,qBAAC,QAAD;EAAM,WAAW,GAAG,YAAY,QAAQ,GAAG,OAAO,cAAc,KAAK,SAAS;EAA9E,UAAA,CACE,qBAAC,OAAD;GAAK,WAAU;GAAgB,OAAO;GAAI,QAAQ;GAAI,SAAQ;GAAY,eAAY;GAAtF,UAAA;IACE,oBAAC,UAAD;KAAQ,IAAI;KAAI,IAAI;KAAI,GAAG;KAAG,MAAK;KAAO,QAAO;KAAe,aAAa;IAAM,CAAA;IAClF,KAAK,QAAQ,oBAAC,QAAD;KAAM,GAAG,KAAK;KAAO,MAAK;IAAgB,CAAA,IAAI;IAC3D,OAAO,QAAQ,oBAAC,QAAD;KAAM,GAAG,OAAO;KAAO,MAAK;KAAO,QAAO;KAAe,aAAa;KAAK,eAAc;IAAS,CAAA,IAAI;GACnH;EACL,CAAA,GAAA,oBAAC,QAAD;GAAM,WAAU;GAAiB,UAAA,aAAa,SAAS,GAAG,OAAO,KAAK,IAAI;EAAY,CAAA,CAClF;;AAEV"}
1
+ {"version":3,"file":"Badge.js","names":[],"sources":["../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\n\n/** The meaning of a status: its colour, and its mark's shape when no preset gives one. */\nexport type BadgeTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';\n\n/** The five work states: draft, doing, review, done and fail. */\nexport type BadgeStatus = 'draft' | 'doing' | 'review' | 'done' | 'fail';\n/** Every preset: the work states, closed for a state that ended without a result (已取消, 已停用), paused for one on\n * hold that can resume (已暫停, 已停權), and online and offline for monitoring. */\nexport type BadgePreset = BadgeStatus | 'closed' | 'paused' | 'online' | 'offline';\n\ntype Mark = 'ring' | 'half' | 'quarter' | 'full' | 'bang' | 'cross' | 'dash' | 'slash' | 'pause';\n\nconst STATUS: Record<BadgePreset, { label: string; tone: BadgeTone; mark: Mark }> = {\n draft: { label: '草稿', tone: 'neutral', mark: 'ring' },\n doing: { label: '進行中', tone: 'info', mark: 'half' },\n review: { label: '審核中', tone: 'warning', mark: 'quarter' },\n done: { label: '完成', tone: 'success', mark: 'full' },\n fail: { label: '失敗', tone: 'danger', mark: 'cross' },\n closed: { label: '已關閉', tone: 'neutral', mark: 'dash' },\n paused: { label: '已暫停', tone: 'warning', mark: 'pause' },\n online: { label: '在線', tone: 'success', mark: 'full' },\n offline: { label: '離線', tone: 'neutral', mark: 'slash' },\n};\n\n/** The mark of a tone without a preset: the shape tells the meaning too, never colour alone. */\nconst TONE_MARK: Record<BadgeTone, Mark> = { neutral: 'ring', info: 'half', success: 'full', warning: 'bang', danger: 'cross' };\n\n/** Inside the 24 px ring (r 8): filled paths, then stroked ones. */\nconst FILL: Partial<Record<Mark, string>> = {\n half: 'M12 4a8 8 0 0 1 0 16z',\n quarter: 'M12 4a8 8 0 0 1 8 8h-8z',\n full: 'M12 4a8 8 0 1 1 0 16a8 8 0 1 1 0-16z',\n};\nconst STROKE: Partial<Record<Mark, string>> = {\n bang: 'M12 7.5v5.5M12 16.4v.2',\n cross: 'M9 9l6 6M15 9l-6 6',\n dash: 'M8.5 12h7',\n slash: 'M6.5 17.5l11-11',\n pause: 'M10 8.5v7M14 8.5v7',\n};\n\ninterface BadgeBase {\n /** Colour of the mark (and of the text for warning and danger). Default: the preset's, or 'neutral'. */\n tone?: BadgeTone;\n /** @deprecated Every Badge is now a mark and text without a chip; remove the prop. */\n variant?: 'chip' | 'dot';\n /** Extra class on the root element. */\n className?: string;\n}\n\nexport type BadgeProps = BadgeBase &\n (\n | {\n /** A preset: its name, tone and mark. */\n status: BadgePreset;\n /** Default: the preset's name (草稿, 進行中, 審核中, 完成, 失敗, 已關閉, 已暫停, 在線, 離線). */\n children?: React.ReactNode;\n }\n | {\n status?: undefined;\n /** The text; required without a preset. */\n children: React.ReactNode;\n }\n );\n\n/** The status of an item: a mark and text, no chip. The mark's shape carries the meaning too, never colour alone. */\nexport function Badge({ status, tone, variant, children, className }: BadgeProps) {\n devWarn(variant !== undefined, 'Badge', '`variant` is deprecated: every Badge is now a mark and text without a chip. Remove the prop.');\n const preset = status ? (STATUS[status] ?? STATUS.draft) : undefined;\n devWarn(\n !!status && !STATUS[status],\n 'Badge',\n `unknown status \"${String(status)}\"; it shows as 草稿. Use one of ${Object.keys(STATUS).join(', ')}, or give \\`tone\\` and text.`,\n );\n const t: BadgeTone = tone ?? preset?.tone ?? 'neutral';\n const mark: Mark = preset?.mark ?? TONE_MARK[t] ?? 'ring';\n devWarn(!preset && !children, 'Badge', 'a Badge without `status` has no text. Give it text as children, e.g. <Badge tone=\"success\">已付款</Badge>.');\n const key = status && STATUS[status] ? status : preset ? 'draft' : undefined;\n return (\n <span className={cx('ui-badge', 'is-' + t, key && 'ui-badge-' + key, className)}>\n <svg className=\"ui-badge-mark\" width={15} height={15} viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <circle cx={12} cy={12} r={8} fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} />\n {FILL[mark] ? <path d={FILL[mark]} fill=\"currentColor\" /> : null}\n {STROKE[mark] ? <path d={STROKE[mark]} fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" /> : null}\n </svg>\n <span className=\"ui-badge-text\">{children || (preset ? tr(preset.label) : null)}</span>\n </span>\n );\n}\n"],"mappings":";;;;;;AAgBA,MAAM,SAA8E;CAClF,OAAO;EAAE,OAAO;EAAM,MAAM;EAAW,MAAM;CAAO;CACpD,OAAO;EAAE,OAAO;EAAO,MAAM;EAAQ,MAAM;CAAO;CAClD,QA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AAD;GAAK,WAAU;GAAgB,OAAO;GAAI,QAAQ;GAAI,SAAQ;GAAY,eAAY;GAAtF,UAAA;IACE,oBAAC,UAAD;KAAQ,IAAI;KAAI,IAAI;KAAI,GAAG;KAAG,MAAK;KAAO,QAAO;KAAe,aAAa;IAAM,CAAA;IAClF,KAAK,QAAQ,oBAAC,QAAD;KAAM,GAAG,KAAK;KAAO,MAAK;IAAgB,CAAA,IAAI;IAC3D,OAAO,QAAQ,oBAAC,QAAD;KAAM,GAAG,OAAO;KAAO,MAAK;KAAO,QAAO;KAAe,aAAa;KAAK,eAAc;IAAS,CAAA,IAAI;GACnH;EACL,CAAA,GAAA,oBAAC,QAAD;GAAM,WAAU;GAAiB,UAAA,aAAa,SAAS,GAAG,OAAO,KAAK,IAAI;EAAY,CAAA,CAClF;;AAEV"}
@@ -14,6 +14,7 @@ function Breadcrumb({ items, className }) {
14
14
  "aria-current": "page",
15
15
  children: it.label
16
16
  }) : it.href ? /* @__PURE__ */ jsx("a", {
17
+ className: "ui-crumb-link",
17
18
  href: it.href,
18
19
  children: it.label
19
20
  }) : /* @__PURE__ */ jsx("span", { children: it.label }), last ? null : /* @__PURE__ */ jsx("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"Breadcrumb.js","names":[],"sources":["../../../src/components/Breadcrumb/Breadcrumb.tsx"],"sourcesContent":["import { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\n\nexport interface BreadcrumbItem {\n label: string;\n href?: string;\n}\n\nexport interface BreadcrumbProps {\n /** From the top level down; the last one is the current page. */\n items: BreadcrumbItem[];\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Where the page sits: links to each level, the current page last and not a link. */\nexport function Breadcrumb({ items, className }: BreadcrumbProps) {\n return (\n <nav className={cx('ui-crumb', className)} aria-label={tr('路徑')}>\n <ol>\n {items.map((it, i) => {\n const last = i === items.length - 1;\n return (\n <li key={i}>\n {last ? <span aria-current=\"page\">{it.label}</span> : it.href ? <a href={it.href}>{it.label}</a> : <span>{it.label}</span>}\n {last ? null : (\n <span className=\"ui-crumb-sep\" aria-hidden=\"true\">\n ›\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n}\n"],"mappings":";;;;;;AAgBA,SAAgB,WAAW,EAAE,OAAO,aAA8B;CAChE,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,SAAS;EAAG,cAAY,GAAG,IAAI;EAC5D,UAAA,oBAAC,MAAD,EAAA,UACG,MAAM,KAAK,IAAI,MAAM;GACpB,MAAM,OAAO,MAAM,MAAM,SAAS;GAClC,OACE,qBAAC,MAAD,EAAA,UAAA,CACG,OAAO,oBAAC,QAAD;IAAM,gBAAa;IAAQ,UAAA,GAAG;GAAY,CAAA,IAAI,GAAG,OAAO,oBAAC,KAAD;IAAG,MAAM,GAAG;IAAO,UAAA,GAAG;GAAS,CAAA,IAAI,oBAAC,QAAD,EAAA,UAAO,GAAG,MAAY,CAAA,GACxH,OAAO,OACN,oBAAC,QAAD;IAAM,WAAU;IAAe,eAAY;IAAO,UAAA;GAE5C,CAAA,CAEN,EAAA,GAPK,CAOL;EAER,CAAC,EACC,CAAA;CACD,CAAA;AAET"}
1
+ {"version":3,"file":"Breadcrumb.js","names":[],"sources":["../../../src/components/Breadcrumb/Breadcrumb.tsx"],"sourcesContent":["import { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\n\nexport interface BreadcrumbItem {\n label: string;\n href?: string;\n}\n\nexport interface BreadcrumbProps {\n /** From the top level down; the last one is the current page. */\n items: BreadcrumbItem[];\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Where the page sits: links to each level, the current page last and not a link. */\nexport function Breadcrumb({ items, className }: BreadcrumbProps) {\n return (\n <nav className={cx('ui-crumb', className)} aria-label={tr('路徑')}>\n <ol>\n {items.map((it, i) => {\n const last = i === items.length - 1;\n return (\n <li key={i}>\n {last ? (\n <span aria-current=\"page\">{it.label}</span>\n ) : it.href ? (\n <a className=\"ui-crumb-link\" href={it.href}>\n {it.label}\n </a>\n ) : (\n <span>{it.label}</span>\n )}\n {last ? null : (\n <span className=\"ui-crumb-sep\" aria-hidden=\"true\">\n ›\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n}\n"],"mappings":";;;;;;AAgBA,SAAgB,WAAW,EAAE,OAAO,aAA8B;CAChE,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,SAAS;EAAG,cAAY,GAAG,IAAI;EAC5D,UAAA,oBAAC,MAAD,EAAA,UACG,MAAM,KAAK,IAAI,MAAM;GACpB,MAAM,OAAO,MAAM,MAAM,SAAS;GAClC,OACE,qBAAC,MAAD,EAAA,UAAA,CACG,OACC,oBAAC,QAAD;IAAM,gBAAa;IAAQ,UAAA,GAAG;GAAY,CAAA,IACxC,GAAG,OACL,oBAAC,KAAD;IAAG,WAAU;IAAgB,MAAM,GAAG;IACnC,UAAA,GAAG;GACH,CAAA,IAEH,oBAAC,QAAD,EAAA,UAAO,GAAG,MAAY,CAAA,GAEvB,OAAO,OACN,oBAAC,QAAD;IAAM,WAAU;IAAe,eAAY;IAAO,UAAA;GAE5C,CAAA,CAEN,EAAA,GAfK,CAeL;EAER,CAAC,EACC,CAAA;CACD,CAAA;AAET"}
@@ -19,9 +19,14 @@ function Calendar({ month: monthProp, defaultMonth, onMonthChange, focus: focusP
19
19
  const [month, setOwnMonth] = React.useState(() => first(focus || /* @__PURE__ */ new Date()));
20
20
  const followKey = monthProp ? monthProp.getFullYear() * 12 + monthProp.getMonth() : null;
21
21
  const [followed, setFollowed] = React.useState(followKey);
22
+ const [active, setActive] = React.useState(() => focus || /* @__PURE__ */ new Date());
22
23
  if (followKey !== followed) {
23
24
  setFollowed(followKey);
24
- if (monthProp) setOwnMonth(first(monthProp));
25
+ const to = monthProp ?? (monthProp === null ? /* @__PURE__ */ new Date() : null);
26
+ if (to) {
27
+ setOwnMonth(first(to));
28
+ setActive(to);
29
+ }
25
30
  }
26
31
  const setMonth = (d) => {
27
32
  setOwnMonth(d);
@@ -30,7 +35,6 @@ function Calendar({ month: monthProp, defaultMonth, onMonthChange, focus: focusP
30
35
  const today = /* @__PURE__ */ new Date();
31
36
  const y = month.getFullYear();
32
37
  const m = month.getMonth();
33
- const [active, setActive] = React.useState(() => focus || today);
34
38
  const cur = active.getFullYear() === y && active.getMonth() === m ? active : new Date(y, m, Math.min(active.getDate(), new Date(y, m + 1, 0).getDate()));
35
39
  const grid = React.useRef(null);
36
40
  const moveTo = React.useRef(false);
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.js","names":["phCaretLeft","phCaretRight"],"sources":["../../../src/components/Calendar/Calendar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { dayAdd, format, sameDay } from '../../format';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { browserKey, cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { includeIcons } from '../../icons/store';\nimport phCaretLeft from '../../icons/ph/caret-left';\nimport phCaretRight from '../../icons/ph/caret-right';\n\nincludeIcons(phCaretLeft, phCaretRight);\n\nexport interface DayState {\n selected?: boolean;\n inRange?: boolean;\n start?: boolean;\n end?: boolean;\n disabled?: boolean;\n}\n\nexport interface CalendarProps {\n /** The month to show (any day in it). When it changes, the calendar moves there; the arrows still move freely and\n * report with onMonthChange. */\n month?: Date | null;\n /** The month shown first, when month is not given. Default: this month. */\n defaultMonth?: Date | null;\n /** Called with the 1st of the month shown after the arrows, PageUp or PageDown change it. */\n onMonthChange?: (month: Date) => void;\n /** @deprecated use month (follows changes) or defaultMonth. */\n focus?: Date | null;\n /** Called with the day pressed. */\n onPick?: (d: Date) => void;\n /** Called with the day under the pointer or the keyboard (DateRangePicker's preview). */\n onHover?: (d: Date | null) => void;\n /** How each day looks: selected, inside a range, disabled. */\n dayState?: (d: Date) => DayState | undefined;\n}\n\n/** A month grid: selected days are rounded squares, today has a dot under the number. */\nexport function Calendar({ month: monthProp, defaultMonth, onMonthChange, focus: focusProp, onPick, onHover, dayState }: CalendarProps) {\n devWarn(focusProp !== undefined, 'Calendar', 'focus is deprecated: pass month={…} (the calendar follows it) or defaultMonth={…}.');\n const focus = monthProp !== undefined ? monthProp : focusProp !== undefined ? focusProp : defaultMonth;\n const first = (d: Date) => new Date(d.getFullYear(), d.getMonth(), 1);\n const [month, setOwnMonth] = React.useState(() => first(focus || new Date()));\n // A new month prop (another value picked outside, a reset): move there, during render so there is no flash.\n const followKey = monthProp ? monthProp.getFullYear() * 12 + monthProp.getMonth() : null;\n const [followed, setFollowed] = React.useState(followKey);\n if (followKey !== followed) {\n setFollowed(followKey);\n if (monthProp) setOwnMonth(first(monthProp));\n }\n const setMonth = (d: Date) => {\n setOwnMonth(d);\n onMonthChange?.(d);\n };\n const today = new Date();\n const y = month.getFullYear();\n const m = month.getMonth();\n // The day the keyboard is on: the only day in the Tab order (the focused, else the selected, else today, else the\n // 1st), always in the month shown.\n const [active, setActive] = React.useState<Date>(() => focus || today);\n const cur = active.getFullYear() === y && active.getMonth() === m ? active : new Date(y, m, Math.min(active.getDate(), new Date(y, m + 1, 0).getDate()));\n const grid = React.useRef<HTMLDivElement>(null);\n const moveTo = React.useRef(false);\n React.useEffect(() => {\n if (!moveTo.current) return;\n moveTo.current = false;\n grid.current?.querySelector<HTMLButtonElement>('.ui-cal-day[tabindex=\"0\"]')?.focus();\n });\n const go = (d: Date) => {\n // Disabled days are passed over in the same direction, up to a month.\n const step = d < cur ? -1 : 1;\n for (let k = 0; k < 31 && dayState?.(d)?.disabled; k++) d = dayAdd(d, step);\n setActive(d);\n if (d.getMonth() !== m || d.getFullYear() !== y) setMonth(new Date(d.getFullYear(), d.getMonth(), 1));\n moveTo.current = true;\n onHover?.(d);\n };\n const onKey = (e: React.KeyboardEvent) => {\n if (browserKey(e)) return;\n const wd = (cur.getDay() - format.firstDay() + 7) % 7;\n const sameDayIn = (dm: number) => {\n const last = new Date(cur.getFullYear(), cur.getMonth() + dm + 1, 0).getDate();\n return new Date(cur.getFullYear(), cur.getMonth() + dm, Math.min(cur.getDate(), last));\n };\n const to: Record<string, () => Date> = {\n ArrowLeft: () => dayAdd(cur, -1),\n ArrowRight: () => dayAdd(cur, 1),\n ArrowUp: () => dayAdd(cur, -7),\n ArrowDown: () => dayAdd(cur, 7),\n Home: () => dayAdd(cur, -wd),\n End: () => dayAdd(cur, 6 - wd),\n PageUp: () => sameDayIn(-1),\n PageDown: () => sameDayIn(1),\n };\n if (!to[e.key]) return;\n e.preventDefault();\n go(to[e.key]());\n };\n const start = (new Date(y, m, 1).getDay() - format.firstDay() + 7) % 7;\n const days = new Date(y, m + 1, 0).getDate();\n const cells: (Date | null)[] = [...Array<null>(start).fill(null), ...Array.from({ length: days }, (_, i) => new Date(y, m, i + 1))];\n return (\n <div className=\"ui-cal\">\n <div className=\"ui-cal-head\">\n <button type=\"button\" className=\"ui-cal-nav\" aria-label={tr('上個月')} onClick={() => setMonth(new Date(y, m - 1, 1))}>\n <Icon name=\"caret-left\" size={16} />\n </button>\n <span className=\"ui-cal-title\" aria-live=\"polite\">\n {format.month(month)}\n </span>\n <button type=\"button\" className=\"ui-cal-nav\" aria-label={tr('下個月')} onClick={() => setMonth(new Date(y, m + 1, 1))}>\n <Icon name=\"caret-right\" size={16} />\n </button>\n </div>\n <div ref={grid} className=\"ui-cal-grid\" role=\"group\" aria-label={format.month(month)} onKeyDown={onKey}>\n {format.weekdays().map((w, i) => (\n <span key={'w' + i} className=\"ui-cal-wk\" aria-hidden=\"true\">\n {w}\n </span>\n ))}\n {cells.map((c, i) => {\n if (!c) return <span key={'e' + i} />;\n const st = dayState?.(c) ?? {};\n const isToday = sameDay(c, today);\n return (\n <button\n key={i}\n type=\"button\"\n disabled={st.disabled}\n className={cx('ui-cal-day', st.selected && 'is-sel', st.inRange && 'is-range', st.start && 'is-start', st.end && 'is-end', isToday && 'is-today')}\n aria-pressed={!!st.selected}\n aria-label={format.date(c, { weekday: false, long: true }) + (isToday ? tr('(今天)') : '')}\n tabIndex={sameDay(c, cur) ? 0 : -1}\n onFocus={() => !sameDay(c, cur) && setActive(c)}\n onClick={() => onPick?.(c)}\n onMouseEnter={onHover ? () => onHover(c) : undefined}\n >\n {c.getDate()}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAUA,aAAaA,oBAAaC,mBAAY;;AA6BtC,SAAgB,SAAS,EAAE,OAAO,WAAW,cAAc,eAAe,OAAO,WAAW,QAAQ,SAAS,YAA2B;CACtI,QAAQ,cAAc,KAAA,GAAW,YAAY,oFAAoF;CACjI,MAAM,QAAQ,cAAc,KAAA,IAAY,YAAY,cAAc,KAAA,IAAY,YAAY;CAC1F,MAAM,SAAS,MAAY,IAAI,KAAK,EAAE,YAAY,GAAG,EAAE,SAAS,GAAG,CAAC;CACpE,MAAM,CAAC,OAAO,eAAe,MAAM,eAAe,MAAM,yBAAS,IAAI,KAAK,CAAC,CAAC;CAE5E,MAAM,YAAY,YAAY,UAAU,YAAY,IAAI,KAAK,UAAU,SAAS,IAAI;CACpF,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,SAAS;CACxD,IAAI,cAAc,UAAU;EAC1B,YAAY,SAAS;EACrB,IAAI,WAAW,YAAY,MAAM,SAAS,CAAC;CAC7C;CACA,MAAM,YAAY,MAAY;EAC5B,YAAY,CAAC;EACb,gBAAgB,CAAC;CACnB;CACA,MAAM,wBAAQ,IAAI,KAAK;CACvB,MAAM,IAAI,MAAM,YAAY;CAC5B,MAAM,IAAI,MAAM,SAAS;CAGzB,MAAM,CAAC,QAAQ,aAAa,MAAM,eAAqB,SAAS,KAAK;CACrE,MAAM,MAAM,OAAO,YAAY,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,SAAS,IAAI,KAAK,GAAG,GAAG,KAAK,IAAI,OAAO,QAAQ,GAAG,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;CACvJ,MAAM,OAAO,MAAM,OAAuB,IAAI;CAC9C,MAAM,SAAS,MAAM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GAAG,OAAO,oBAAC,QAAD,CAAqB,GAAV,MAAM,CAAI;IACpC,MAAM,KAAK,WAAW,CAAC,KAAK,CAAC;IAC7B,MAAM,UAAU,QAAQ,GAAG,KAAK;IAChC,OACE,oBAAC,UAAD;KAEE,MAAK;KACL,UAAU,GAAG;KACb,WAAW,GAAG,cAAc,GAAG,YAAY,UAAU,GAAG,WAAW,YAAY,GAAG,SAAS,YAAY,GAAG,OAAO,UAAU,WAAW,UAAU;KAChJ,gBAAc,CAAC,CAAC,GAAG;KACnB,cAAY,OAAO,KAAK,GAAG;MAAE,SAAS;MAAO,MAAM;KAAK,CAAC,KAAK,UAAU,GAAG,MAAM,IAAI;KACrF,UAAU,QAAQ,GAAG,GAAG,IAAI,IAAI;KAChC,eAAe,CAAC,QAAQ,GAAG,GAAG,KAAK,UAAU,CAAC;KAC9C,eAAe,SAAS,CAAC;KACzB,cAAc,gBAAgB,QAAQ,CAAC,IAAI,KAAA;KAE1C,UAAA,EAAE,QAAQ;IACL,GAZD,CAYC;GAEZ,CAAC,CACE;EACF,CAAA,CAAA;;AAET"}
1
+ {"version":3,"file":"Calendar.js","names":["phCaretLeft","phCaretRight"],"sources":["../../../src/components/Calendar/Calendar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { dayAdd, format, sameDay } from '../../format';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { browserKey, cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { includeIcons } from '../../icons/store';\nimport phCaretLeft from '../../icons/ph/caret-left';\nimport phCaretRight from '../../icons/ph/caret-right';\n\nincludeIcons(phCaretLeft, phCaretRight);\n\nexport interface DayState {\n selected?: boolean;\n inRange?: boolean;\n start?: boolean;\n end?: boolean;\n disabled?: boolean;\n}\n\nexport interface CalendarProps {\n /** The month to show (any day in it). When it changes, the calendar moves there; the arrows still move freely and\n * report with onMonthChange. */\n month?: Date | null;\n /** The month shown first, when month is not given. Default: this month. */\n defaultMonth?: Date | null;\n /** Called with the 1st of the month shown after the arrows, PageUp or PageDown change it. */\n onMonthChange?: (month: Date) => void;\n /** @deprecated use month (follows changes) or defaultMonth. */\n focus?: Date | null;\n /** Called with the day pressed. */\n onPick?: (d: Date) => void;\n /** Called with the day under the pointer or the keyboard (DateRangePicker's preview). */\n onHover?: (d: Date | null) => void;\n /** How each day looks: selected, inside a range, disabled. */\n dayState?: (d: Date) => DayState | undefined;\n}\n\n/** A month grid: selected days are rounded squares, today has a dot under the number. */\nexport function Calendar({ month: monthProp, defaultMonth, onMonthChange, focus: focusProp, onPick, onHover, dayState }: CalendarProps) {\n devWarn(focusProp !== undefined, 'Calendar', 'focus is deprecated: pass month={…} (the calendar follows it) or defaultMonth={…}.');\n const focus = monthProp !== undefined ? monthProp : focusProp !== undefined ? focusProp : defaultMonth;\n const first = (d: Date) => new Date(d.getFullYear(), d.getMonth(), 1);\n const [month, setOwnMonth] = React.useState(() => first(focus || new Date()));\n // A new month prop (another value picked outside, a reset): move there, during render so there is no flash.\n const followKey = monthProp ? monthProp.getFullYear() * 12 + monthProp.getMonth() : null;\n const [followed, setFollowed] = React.useState(followKey);\n // The day the keyboard is on: the only day in the Tab order (the focused, else the selected, else today, else the\n // 1st), always in the month shown.\n const [active, setActive] = React.useState<Date>(() => focus || new Date());\n // The keyboard's day follows too: the new value, or today once the value is cleared (null).\n if (followKey !== followed) {\n setFollowed(followKey);\n const to = monthProp ?? (monthProp === null ? new Date() : null);\n if (to) {\n setOwnMonth(first(to));\n setActive(to);\n }\n }\n const setMonth = (d: Date) => {\n setOwnMonth(d);\n onMonthChange?.(d);\n };\n const today = new Date();\n const y = month.getFullYear();\n const m = month.getMonth();\n const cur = active.getFullYear() === y && active.getMonth() === m ? active : new Date(y, m, Math.min(active.getDate(), new Date(y, m + 1, 0).getDate()));\n const grid = React.useRef<HTMLDivElement>(null);\n const moveTo = React.useRef(false);\n React.useEffect(() => {\n if (!moveTo.current) return;\n moveTo.current = false;\n grid.current?.querySelector<HTMLButtonElement>('.ui-cal-day[tabindex=\"0\"]')?.focus();\n });\n const go = (d: Date) => {\n // Disabled days are passed over in the same direction, up to a month.\n const step = d < cur ? -1 : 1;\n for (let k = 0; k < 31 && dayState?.(d)?.disabled; k++) d = dayAdd(d, step);\n setActive(d);\n if (d.getMonth() !== m || d.getFullYear() !== y) setMonth(new Date(d.getFullYear(), d.getMonth(), 1));\n moveTo.current = true;\n onHover?.(d);\n };\n const onKey = (e: React.KeyboardEvent) => {\n if (browserKey(e)) return;\n const wd = (cur.getDay() - format.firstDay() + 7) % 7;\n const sameDayIn = (dm: number) => {\n const last = new Date(cur.getFullYear(), cur.getMonth() + dm + 1, 0).getDate();\n return new Date(cur.getFullYear(), cur.getMonth() + dm, Math.min(cur.getDate(), last));\n };\n const to: Record<string, () => Date> = {\n ArrowLeft: () => dayAdd(cur, -1),\n ArrowRight: () => dayAdd(cur, 1),\n ArrowUp: () => dayAdd(cur, -7),\n ArrowDown: () => dayAdd(cur, 7),\n Home: () => dayAdd(cur, -wd),\n End: () => dayAdd(cur, 6 - wd),\n PageUp: () => sameDayIn(-1),\n PageDown: () => sameDayIn(1),\n };\n if (!to[e.key]) return;\n e.preventDefault();\n go(to[e.key]());\n };\n const start = (new Date(y, m, 1).getDay() - format.firstDay() + 7) % 7;\n const days = new Date(y, m + 1, 0).getDate();\n const cells: (Date | null)[] = [...Array<null>(start).fill(null), ...Array.from({ length: days }, (_, i) => new Date(y, m, i + 1))];\n return (\n <div className=\"ui-cal\">\n <div className=\"ui-cal-head\">\n <button type=\"button\" className=\"ui-cal-nav\" aria-label={tr('上個月')} onClick={() => setMonth(new Date(y, m - 1, 1))}>\n <Icon name=\"caret-left\" size={16} />\n </button>\n <span className=\"ui-cal-title\" aria-live=\"polite\">\n {format.month(month)}\n </span>\n <button type=\"button\" className=\"ui-cal-nav\" aria-label={tr('下個月')} onClick={() => setMonth(new Date(y, m + 1, 1))}>\n <Icon name=\"caret-right\" size={16} />\n </button>\n </div>\n <div ref={grid} className=\"ui-cal-grid\" role=\"group\" aria-label={format.month(month)} onKeyDown={onKey}>\n {format.weekdays().map((w, i) => (\n <span key={'w' + i} className=\"ui-cal-wk\" aria-hidden=\"true\">\n {w}\n </span>\n ))}\n {cells.map((c, i) => {\n if (!c) return <span key={'e' + i} />;\n const st = dayState?.(c) ?? {};\n const isToday = sameDay(c, today);\n return (\n <button\n key={i}\n type=\"button\"\n disabled={st.disabled}\n className={cx('ui-cal-day', st.selected && 'is-sel', st.inRange && 'is-range', st.start && 'is-start', st.end && 'is-end', isToday && 'is-today')}\n aria-pressed={!!st.selected}\n aria-label={format.date(c, { weekday: false, long: true }) + (isToday ? tr('(今天)') : '')}\n tabIndex={sameDay(c, cur) ? 0 : -1}\n onFocus={() => !sameDay(c, cur) && setActive(c)}\n onClick={() => onPick?.(c)}\n onMouseEnter={onHover ? () => onHover(c) : undefined}\n >\n {c.getDate()}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAUA,aAAaA,oBAAaC,mBAAY;;AA6BtC,SAAgB,SAAS,EAAE,OAAO,WAAW,cAAc,eAAe,OAAO,WAAW,QAAQ,SAAS,YAA2B;CACtI,QAAQ,cAAc,KAAA,GAAW,YAAY,oFAAoF;CACjI,MAAM,QAAQ,cAAc,KAAA,IAAY,YAAY,cAAc,KAAA,IAAY,YAAY;CAC1F,MAAM,SAAS,MAAY,IAAI,KAAK,EAAE,YAAY,GAAG,EAAE,SAAS,GAAG,CAAC;CACpE,MAAM,CAAC,OAAO,eAAe,MAAM,eAAe,MAAM,yBAAS,IAAI,KAAK,CAAC,CAAC;CAE5E,MAAM,YAAY,YAAY,UAAU,YAAY,IAAI,KAAK,UAAU,SAAS,IAAI;CACpF,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,SAAS;CAGxD,MAAM,CAAC,QAAQ,aAAa,MAAM,eAAqB,yBAAS,IAAI,KAAK,CAAC;CAE1E,IAAI,cAAc,UAAU;EAC1B,YAAY,SAAS;EAC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+101,25 @@ function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen = true, ma
101
101
  style: frameStyle,
102
102
  children: [
103
103
  top,
104
- /* @__PURE__ */ jsx("main", {
105
- className: "ui-console-main",
106
- children: main
104
+ /* @__PURE__ */ jsxs("main", {
105
+ className: "ui-console-content",
106
+ children: [/* @__PURE__ */ jsx("div", {
107
+ className: "ui-console-main",
108
+ children: main
109
+ }), phone ? /* @__PURE__ */ jsxs(Fragment, { children: [
110
+ side,
111
+ bottom,
112
+ shown.map((x) => /* @__PURE__ */ jsx(React.Fragment, { children: x.node }, x.id))
113
+ ] }) : bottom != null ? /* @__PURE__ */ jsx("div", {
114
+ className: "ui-console-bottom",
115
+ children: bottom
116
+ }) : null]
107
117
  }),
108
- phone ? /* @__PURE__ */ jsxs(Fragment, { children: [
109
- side,
110
- bottom,
111
- shown.map((x) => /* @__PURE__ */ jsx(React.Fragment, { children: x.node }, x.id))
112
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("aside", {
118
+ phone ? null : /* @__PURE__ */ jsxs("aside", {
113
119
  className: "ui-console-side",
114
120
  "aria-label": tr("側欄"),
115
121
  children: [side, shown.map((x) => /* @__PURE__ */ jsx(React.Fragment, { children: x.node }, x.id))]
116
- }), bottom != null ? /* @__PURE__ */ jsx("div", {
117
- className: "ui-console-bottom",
118
- children: bottom
119
- }) : null] })
122
+ })
120
123
  ]
121
124
  })
122
125
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ConsoleLayout.js","names":["phCornersIn","phCornersOut"],"sources":["../../../src/components/ConsoleLayout/ConsoleLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { IconButton } from '../IconButton/IconButton';\nimport { cx } from '../../internal/util';\nimport { tr } from '../../i18n';\nimport { includeIcons } from '../../icons/store';\nimport phCornersIn from '../../icons/ph/corners-in';\nimport phCornersOut from '../../icons/ph/corners-out';\n\nincludeIcons(phCornersIn, phCornersOut);\n\n/** A card that shows only when the screen is tall enough. */\nexport interface ConsoleExtra {\n /** Stable key for the card. */\n id: string;\n /** The card shows when the layout's logical height (the screen height divided by the zoom) is at least this many\n * px, e.g. 1040. */\n minHeight: number;\n /** The card: usually a Card. */\n node: React.ReactNode;\n}\n\nexport interface ConsoleLayoutProps {\n /** The product or screen name, the page's only heading: 「設施監控」. */\n title: string;\n /** Right after the title: a Tag 「示範資料」 with the info icon. Same size and color as the text around it. */\n tags?: React.ReactNode;\n /** Right side, before the KPIs: one short state in plain words, 「AI 最佳化中」. Shown in body size and ink color;\n * pass plain text, not a Badge. */\n status?: React.ReactNode;\n /** Right side: `<KpiCard size=\"compact\" />` side by side. In the top bar they lose their card look and sit between\n * 1 px lines. */\n kpis?: React.ReactNode;\n /** Right side, after the KPIs: the time and whether it is live, 「16:24 即時」. */\n clock?: React.ReactNode;\n /** A 「全螢幕」 button at the right end (Fullscreen API). Default true; hidden where the browser has no full screen. */\n fullscreen?: boolean;\n /** The main view, left of the side panel; it fills its cell (pass one Card, e.g. with a ZoneMap). */\n main: React.ReactNode;\n /** The side panel, 400 px (360 px under 1280 px): cards from top to bottom (TimeControl, EventTimeline). When they\n * do not fit, the side panel scrolls on its own; the page never does. */\n side?: React.ReactNode;\n /** The bottom row under the main view, as tall as its content: e.g. a LineChart in a Card. The main view takes the\n * height that is left. */\n bottom?: React.ReactNode;\n /** Cards added at the end of the side panel on tall screens: `[{ id, minHeight: 1040, node }]`. */\n extras?: ConsoleExtra[];\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Design size: at this size and up the layout zooms in. */\nconst BASE_W = 1440;\nconst BASE_H = 900;\nconst MAX_ZOOM = 1.5;\nconst PHONE = 600;\n\nconst noSubscribe = () => () => {};\nconst fullscreenEnabled = () => typeof document !== 'undefined' && document.fullscreenEnabled === true;\nconst serverFalse = () => false;\n\n/** Zoom for a screen of w × h px: 1 up to 1440 × 900, then grows with the screen, at most 1.5. */\nexport function consoleZoom(w: number, h: number): number {\n return Math.max(1, Math.min(MAX_ZOOM, Math.min(w / BASE_W, h / BASE_H)));\n}\n\n/** A full-screen monitoring layout: a top bar (title, tags, then status, KPIs, clock and full screen on the right),\n * the main view with a side panel beside it and a bottom row under it, filling the screen without scrolling. From\n * 1440 × 900 up everything zooms with the screen (at most 1.5×). Phones (under 600 px) get one scrolling column. */\nexport function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen = true, main, side, bottom, extras, className }: ConsoleLayoutProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const [size, setSize] = React.useState<{ w: number; h: number } | null>(null);\n const [full, setFull] = React.useState(false);\n // false on the server and the first browser render, so the markup matches; then whether full screen is allowed.\n const canFull = React.useSyncExternalStore(noSubscribe, fullscreenEnabled, serverFalse);\n\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const measure = () => setSize({ w: el.clientWidth, h: el.clientHeight });\n measure();\n if (typeof ResizeObserver === 'undefined') return;\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n React.useEffect(() => {\n const f = () => setFull(document.fullscreenElement != null && document.fullscreenElement === ref.current);\n document.addEventListener('fullscreenchange', f);\n return () => document.removeEventListener('fullscreenchange', f);\n }, []);\n\n const toggleFull = () => {\n const el = ref.current;\n if (!el) return;\n if (document.fullscreenElement) void document.exitFullscreen().catch(() => undefined);\n else void el.requestFullscreen().catch(() => undefined);\n };\n\n const phone = size != null && size.w < PHONE;\n const zoom = size && !phone ? consoleZoom(size.w, size.h) : 1;\n const logicalH = size ? size.h / zoom : 0;\n const shown = (extras ?? []).filter((x) => phone || logicalH >= x.minHeight);\n const frameStyle: React.CSSProperties | undefined =\n size && !phone && zoom !== 1 ? ({ zoom, width: size.w / zoom, height: size.h / zoom } as React.CSSProperties) : undefined;\n\n const top = (\n <header className=\"ui-console-top\">\n <div className=\"ui-console-start\">\n <h1 className=\"ui-console-title\">{title}</h1>\n {tags}\n </div>\n <div className=\"ui-console-end\">\n {status != null ? <span className=\"ui-console-status\">{status}</span> : null}\n {kpis != null ? <div className=\"ui-console-kpis\">{kpis}</div> : null}\n {clock != null ? <span className=\"ui-console-clock\">{clock}</span> : null}\n {fullscreen && canFull && !phone ? (\n <IconButton label={full ? tr('離開全螢幕') : tr('全螢幕')} icon={full ? 'corners-in' : 'corners-out'} onClick={toggleFull} />\n ) : null}\n </div>\n </header>\n );\n\n return (\n <div ref={ref} className={cx('ui-console', phone && 'is-stacked', className)}>\n <div className=\"ui-console-frame\" style={frameStyle}>\n {top}\n <main className=\"ui-console-main\">{main}</main>\n {phone ? (\n <>\n {side}\n {bottom}\n {shown.map((x) => (\n <React.Fragment key={x.id}>{x.node}</React.Fragment>\n ))}\n </>\n ) : (\n <>\n <aside className=\"ui-console-side\" aria-label={tr('側欄')}>\n {side}\n {shown.map((x) => (\n <React.Fragment key={x.id}>{x.node}</React.Fragment>\n ))}\n </aside>\n {bottom != null ? <div className=\"ui-console-bottom\">{bottom}</div> : null}\n </>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAQA,aAAaA,oBAAaC,mBAAY;;AA2CtC,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,WAAW;AACjB,MAAM,QAAQ;AAEd,MAAM,0BAA0B,CAAC;AACjC,MAAM,0BAA0B,OAAO,aAAa,eAAe,SAAS,sBAAsB;AAClG,MAAM,oBAAoB;;AAG1B,SAAgB,YAAY,GAAW,GAAmB;CACxD,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,UAAU,KAAK,IAAI,IAAI,QAAQ,IAAI,MAAM,CAAC,CAAC;AACzE;;;;AAKA,SAAgB,cAAc,EAAE,OAAO,MAAM,QAAQ,MAAM,OAAO,aAAa,MAAM,MAAM,MAAM,QAAQ,QAAQ,aAAiC;CAChJ,MAAM,MAAM,MAAM,OAAuB,IAAI;CAC7C,MAAM,CAAC,MAAM,WAAW,MAAM,SAA0C,IAAI;CAC5E,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAE5C,MAAM,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ConsoleLayout/ConsoleLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { IconButton } from '../IconButton/IconButton';\nimport { cx } from '../../internal/util';\nimport { tr } from '../../i18n';\nimport { includeIcons } from '../../icons/store';\nimport phCornersIn from '../../icons/ph/corners-in';\nimport phCornersOut from '../../icons/ph/corners-out';\n\nincludeIcons(phCornersIn, phCornersOut);\n\n/** A card that shows only when the screen is tall enough. */\nexport interface ConsoleExtra {\n /** Stable key for the card. */\n id: string;\n /** The card shows when the layout's logical height (the screen height divided by the zoom) is at least this many\n * px, e.g. 1040. */\n minHeight: number;\n /** The card: usually a Card. */\n node: React.ReactNode;\n}\n\nexport interface ConsoleLayoutProps {\n /** The product or screen name, the page's only heading: 「設施監控」. */\n title: string;\n /** Right after the title: a Tag 「示範資料」 with the info icon. Same size and color as the text around it. */\n tags?: React.ReactNode;\n /** Right side, before the KPIs: one short state in plain words, 「AI 最佳化中」. Shown in body size and ink color;\n * pass plain text, not a Badge. */\n status?: React.ReactNode;\n /** Right side: `<KpiCard size=\"compact\" />` side by side. In the top bar they lose their card look and sit between\n * 1 px lines. */\n kpis?: React.ReactNode;\n /** Right side, after the KPIs: the time and whether it is live, 「16:24 即時」. */\n clock?: React.ReactNode;\n /** A 「全螢幕」 button at the right end (Fullscreen API). Default true; hidden where the browser has no full screen. */\n fullscreen?: boolean;\n /** The main view, left of the side panel; it fills its cell (pass one Card, e.g. with a ZoneMap). */\n main: React.ReactNode;\n /** The side panel, 400 px (360 px under 1280 px): cards from top to bottom (TimeControl, EventTimeline). When they\n * do not fit, the side panel scrolls on its own; the page never does. */\n side?: React.ReactNode;\n /** The bottom row under the main view, as tall as its content: e.g. a LineChart in a Card. The main view takes the\n * height that is left. */\n bottom?: React.ReactNode;\n /** Cards added at the end of the side panel on tall screens: `[{ id, minHeight: 1040, node }]`. */\n extras?: ConsoleExtra[];\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Design size: at this size and up the layout zooms in. */\nconst BASE_W = 1440;\nconst BASE_H = 900;\nconst MAX_ZOOM = 1.5;\nconst PHONE = 600;\n\nconst noSubscribe = () => () => {};\nconst fullscreenEnabled = () => typeof document !== 'undefined' && document.fullscreenEnabled === true;\nconst serverFalse = () => false;\n\n/** Zoom for a screen of w × h px: 1 up to 1440 × 900, then grows with the screen, at most 1.5. */\nexport function consoleZoom(w: number, h: number): number {\n return Math.max(1, Math.min(MAX_ZOOM, Math.min(w / BASE_W, h / BASE_H)));\n}\n\n/** A full-screen monitoring layout: a top bar (title, tags, then status, KPIs, clock and full screen on the right),\n * the main view with a side panel beside it and a bottom row under it, filling the screen without scrolling. From\n * 1440 × 900 up everything zooms with the screen (at most 1.5×). Phones (under 600 px) get one scrolling column. */\nexport function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen = true, main, side, bottom, extras, className }: ConsoleLayoutProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const [size, setSize] = React.useState<{ w: number; h: number } | null>(null);\n const [full, setFull] = React.useState(false);\n // false on the server and the first browser render, so the markup matches; then whether full screen is allowed.\n const canFull = React.useSyncExternalStore(noSubscribe, fullscreenEnabled, serverFalse);\n\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const measure = () => setSize({ w: el.clientWidth, h: el.clientHeight });\n measure();\n if (typeof ResizeObserver === 'undefined') return;\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n React.useEffect(() => {\n const f = () => setFull(document.fullscreenElement != null && document.fullscreenElement === ref.current);\n document.addEventListener('fullscreenchange', f);\n return () => document.removeEventListener('fullscreenchange', f);\n }, []);\n\n const toggleFull = () => {\n const el = ref.current;\n if (!el) return;\n if (document.fullscreenElement) void document.exitFullscreen().catch(() => undefined);\n else void el.requestFullscreen().catch(() => undefined);\n };\n\n const phone = size != null && size.w < PHONE;\n const zoom = size && !phone ? consoleZoom(size.w, size.h) : 1;\n const logicalH = size ? size.h / zoom : 0;\n const shown = (extras ?? []).filter((x) => phone || logicalH >= x.minHeight);\n const frameStyle: React.CSSProperties | undefined =\n size && !phone && zoom !== 1 ? ({ zoom, width: size.w / zoom, height: size.h / zoom } as React.CSSProperties) : undefined;\n\n const top = (\n <header className=\"ui-console-top\">\n <div className=\"ui-console-start\">\n <h1 className=\"ui-console-title\">{title}</h1>\n {tags}\n </div>\n <div className=\"ui-console-end\">\n {status != null ? <span className=\"ui-console-status\">{status}</span> : null}\n {kpis != null ? <div className=\"ui-console-kpis\">{kpis}</div> : null}\n {clock != null ? <span className=\"ui-console-clock\">{clock}</span> : null}\n {fullscreen && canFull && !phone ? (\n <IconButton label={full ? tr('離開全螢幕') : tr('全螢幕')} icon={full ? 'corners-in' : 'corners-out'} onClick={toggleFull} />\n ) : null}\n </div>\n </header>\n );\n\n return (\n <div ref={ref} className={cx('ui-console', phone && 'is-stacked', className)}>\n <div className=\"ui-console-frame\" style={frameStyle}>\n {top}\n {/* The main landmark draws no box (display: contents): the main view and the bottom row stay grid cells, and\n on phones the whole column after the top bar is in it. */}\n <main className=\"ui-console-content\">\n <div className=\"ui-console-main\">{main}</div>\n {phone ? (\n <>\n {side}\n {bottom}\n {shown.map((x) => (\n <React.Fragment key={x.id}>{x.node}</React.Fragment>\n ))}\n </>\n ) : bottom != null ? (\n <div className=\"ui-console-bottom\">{bottom}</div>\n ) : null}\n </main>\n {phone ? null : (\n <aside className=\"ui-console-side\" aria-label={tr('側欄')}>\n {side}\n {shown.map((x) => (\n <React.Fragment key={x.id}>{x.node}</React.Fragment>\n ))}\n </aside>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAQA,aAAaA,oBAAaC,mBAAY;;AA2CtC,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,WAAW;AACjB,MAAM,QAAQ;AAEd,MAAM,0BAA0B,CAAC;AACjC,MAAM,0BAA0B,OAAO,aAAa,eAAe,SAAS,sBAAsB;AAClG,MAAM,oBAAoB;;AAG1B,SAAgB,YAAY,GAAW,GAAmB;CACxD,OA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ACA,UAAU,OACZ,oBAAC,OAAD;MAAK,WAAU;MAAqB,UAAA;KAAY,CAAA,IAC9C,IACA;;IACL,QAAQ,OACP,qBAAC,SAAD;KAAO,WAAU;KAAkB,cAAY,GAAG,IAAI;KAAtD,UAAA,CACG,MACA,MAAM,KAAK,MACV,oBAAC,MAAM,UAAP,EAAA,UAA4B,EAAE,KAAqB,GAA9B,EAAE,EAA4B,CACpD,CACI;;GAEN;;CACF,CAAA;AAET"}
@@ -21,6 +21,14 @@ export interface DataTableProps<R extends Row = Record<string, unknown>> {
21
21
  };
22
22
  /** aria-label when there is no caption. */
23
23
  label?: string;
24
+ /** What one row is, after every count (the summary, 「24 筆」, the pages, 「已選 2 筆」): 「個」, 「件」. A function gets
25
+ * the count, for plurals in other languages. Default summary.unit, else 「筆」. */
26
+ unit?: CountUnit;
27
+ /** Data is still loading: the toolbar and header stay, and loadingRows skeleton rows of the columns' shape take the
28
+ * rows' place. Default false. */
29
+ loading?: boolean;
30
+ /** How many skeleton rows loading shows. Default pageSize, at most 10. */
31
+ loadingRows?: number;
24
32
  /** Rows per page. Default 10. */
25
33
  pageSize?: number;
26
34
  /** Change it when the rows become a different data set: search, filters, sort, page, selection and summary reset. */