@linyao.tw/ui 0.0.0-snapshot.07df57

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 (169) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +85 -0
  3. package/dist/components/date-time/calendar.d.ts +20 -0
  4. package/dist/components/date-time/calendar.js +102 -0
  5. package/dist/components/date-time/calendar.js.map +1 -0
  6. package/dist/components/date-time/date-field.d.ts +11 -0
  7. package/dist/components/date-time/date-field.js +44 -0
  8. package/dist/components/date-time/date-field.js.map +1 -0
  9. package/dist/components/date-time/date-picker.d.ts +28 -0
  10. package/dist/components/date-time/date-picker.js +74 -0
  11. package/dist/components/date-time/date-picker.js.map +1 -0
  12. package/dist/components/date-time/date-range-picker.d.ts +11 -0
  13. package/dist/components/date-time/date-range-picker.js +79 -0
  14. package/dist/components/date-time/date-range-picker.js.map +1 -0
  15. package/dist/components/date-time/date-types.d.ts +110 -0
  16. package/dist/components/date-time/index.d.ts +8 -0
  17. package/dist/components/date-time/index.js +8 -0
  18. package/dist/components/date-time/shared.d.ts +25 -0
  19. package/dist/components/date-time/shared.js +53 -0
  20. package/dist/components/date-time/shared.js.map +1 -0
  21. package/dist/components/date-time/time-field.d.ts +13 -0
  22. package/dist/components/date-time/time-field.js +52 -0
  23. package/dist/components/date-time/time-field.js.map +1 -0
  24. package/dist/components/feedback/alert.d.ts +21 -0
  25. package/dist/components/feedback/alert.js +44 -0
  26. package/dist/components/feedback/alert.js.map +1 -0
  27. package/dist/components/feedback/banner.d.ts +8 -0
  28. package/dist/components/feedback/banner.js +20 -0
  29. package/dist/components/feedback/banner.js.map +1 -0
  30. package/dist/components/feedback/empty-state.d.ts +12 -0
  31. package/dist/components/feedback/empty-state.js +48 -0
  32. package/dist/components/feedback/empty-state.js.map +1 -0
  33. package/dist/components/feedback/feedback.module.js +42 -0
  34. package/dist/components/feedback/feedback.module.js.map +1 -0
  35. package/dist/components/feedback/feedback.types.d.ts +8 -0
  36. package/dist/components/feedback/feedback.types.js +24 -0
  37. package/dist/components/feedback/feedback.types.js.map +1 -0
  38. package/dist/components/feedback/index.d.ts +9 -0
  39. package/dist/components/feedback/meter.d.ts +12 -0
  40. package/dist/components/feedback/meter.js +28 -0
  41. package/dist/components/feedback/meter.js.map +1 -0
  42. package/dist/components/feedback/progress.d.ts +12 -0
  43. package/dist/components/feedback/progress.js +28 -0
  44. package/dist/components/feedback/progress.js.map +1 -0
  45. package/dist/components/feedback/skeleton.d.ts +5 -0
  46. package/dist/components/feedback/skeleton.js +18 -0
  47. package/dist/components/feedback/skeleton.js.map +1 -0
  48. package/dist/components/feedback/spinner.d.ts +23 -0
  49. package/dist/components/feedback/spinner.js +35 -0
  50. package/dist/components/feedback/spinner.js.map +1 -0
  51. package/dist/components/feedback/toast.d.ts +33 -0
  52. package/dist/components/feedback/toast.js +76 -0
  53. package/dist/components/feedback/toast.js.map +1 -0
  54. package/dist/components/forms/CodeField.d.ts +23 -0
  55. package/dist/components/forms/CodeField.js +63 -0
  56. package/dist/components/forms/CodeField.js.map +1 -0
  57. package/dist/components/forms/FileUpload.d.ts +34 -0
  58. package/dist/components/forms/FileUpload.js +319 -0
  59. package/dist/components/forms/FileUpload.js.map +1 -0
  60. package/dist/components/forms/Input.d.ts +14 -0
  61. package/dist/components/forms/Input.js +33 -0
  62. package/dist/components/forms/Input.js.map +1 -0
  63. package/dist/components/forms/NumberField.d.ts +15 -0
  64. package/dist/components/forms/NumberField.js +71 -0
  65. package/dist/components/forms/NumberField.js.map +1 -0
  66. package/dist/components/forms/OTPField.d.ts +15 -0
  67. package/dist/components/forms/OTPField.js +54 -0
  68. package/dist/components/forms/OTPField.js.map +1 -0
  69. package/dist/components/forms/TextField.d.ts +61 -0
  70. package/dist/components/forms/TextField.js +199 -0
  71. package/dist/components/forms/TextField.js.map +1 -0
  72. package/dist/components/forms/index.d.ts +7 -0
  73. package/dist/components/forms/internal.d.ts +33 -0
  74. package/dist/components/forms/internal.js +61 -0
  75. package/dist/components/forms/internal.js.map +1 -0
  76. package/dist/components/foundations/Avatar.d.ts +33 -0
  77. package/dist/components/foundations/Avatar.js +45 -0
  78. package/dist/components/foundations/Avatar.js.map +1 -0
  79. package/dist/components/foundations/Badge.d.ts +15 -0
  80. package/dist/components/foundations/Badge.js +32 -0
  81. package/dist/components/foundations/Badge.js.map +1 -0
  82. package/dist/components/foundations/Button.d.ts +18 -0
  83. package/dist/components/foundations/Button.js +47 -0
  84. package/dist/components/foundations/Button.js.map +1 -0
  85. package/dist/components/foundations/Card.d.ts +47 -0
  86. package/dist/components/foundations/Card.js +57 -0
  87. package/dist/components/foundations/Card.js.map +1 -0
  88. package/dist/components/foundations/IconButton.d.ts +25 -0
  89. package/dist/components/foundations/IconButton.js +19 -0
  90. package/dist/components/foundations/IconButton.js.map +1 -0
  91. package/dist/components/foundations/Link.d.ts +19 -0
  92. package/dist/components/foundations/Link.js +40 -0
  93. package/dist/components/foundations/Link.js.map +1 -0
  94. package/dist/components/foundations/ListCell.d.ts +68 -0
  95. package/dist/components/foundations/ListCell.js +105 -0
  96. package/dist/components/foundations/ListCell.js.map +1 -0
  97. package/dist/components/foundations/SectionHeading.d.ts +17 -0
  98. package/dist/components/foundations/SectionHeading.js +50 -0
  99. package/dist/components/foundations/SectionHeading.js.map +1 -0
  100. package/dist/components/foundations/Separator.d.ts +11 -0
  101. package/dist/components/foundations/Separator.js +21 -0
  102. package/dist/components/foundations/Separator.js.map +1 -0
  103. package/dist/components/foundations/index.d.ts +9 -0
  104. package/dist/components/foundations/shared.d.ts +5 -0
  105. package/dist/components/foundations/shared.js +8 -0
  106. package/dist/components/foundations/shared.js.map +1 -0
  107. package/dist/components/navigation-data/breadcrumb-pagination.d.ts +34 -0
  108. package/dist/components/navigation-data/breadcrumb-pagination.js +161 -0
  109. package/dist/components/navigation-data/breadcrumb-pagination.js.map +1 -0
  110. package/dist/components/navigation-data/command-palette.d.ts +35 -0
  111. package/dist/components/navigation-data/command-palette.js +151 -0
  112. package/dist/components/navigation-data/command-palette.js.map +1 -0
  113. package/dist/components/navigation-data/header-tab-bar.d.ts +23 -0
  114. package/dist/components/navigation-data/header-tab-bar.js +102 -0
  115. package/dist/components/navigation-data/header-tab-bar.js.map +1 -0
  116. package/dist/components/navigation-data/index.d.ts +7 -0
  117. package/dist/components/navigation-data/menubar-toolbar.d.ts +26 -0
  118. package/dist/components/navigation-data/menubar-toolbar.js +161 -0
  119. package/dist/components/navigation-data/menubar-toolbar.js.map +1 -0
  120. package/dist/components/navigation-data/navigation-menu.d.ts +14 -0
  121. package/dist/components/navigation-data/navigation-menu.js +87 -0
  122. package/dist/components/navigation-data/navigation-menu.js.map +1 -0
  123. package/dist/components/navigation-data/scroll-area.d.ts +6 -0
  124. package/dist/components/navigation-data/scroll-area.js +52 -0
  125. package/dist/components/navigation-data/scroll-area.js.map +1 -0
  126. package/dist/components/navigation-data/table-collection.d.ts +61 -0
  127. package/dist/components/navigation-data/table-collection.js +181 -0
  128. package/dist/components/navigation-data/table-collection.js.map +1 -0
  129. package/dist/components/navigation-data/utils.d.ts +2 -0
  130. package/dist/components/navigation-data/utils.js +11 -0
  131. package/dist/components/navigation-data/utils.js.map +1 -0
  132. package/dist/components/overlays/class-names.d.ts +6 -0
  133. package/dist/components/overlays/class-names.js +11 -0
  134. package/dist/components/overlays/class-names.js.map +1 -0
  135. package/dist/components/overlays/dialog.d.ts +98 -0
  136. package/dist/components/overlays/dialog.js +158 -0
  137. package/dist/components/overlays/dialog.js.map +1 -0
  138. package/dist/components/overlays/disclosure.d.ts +40 -0
  139. package/dist/components/overlays/disclosure.js +138 -0
  140. package/dist/components/overlays/disclosure.js.map +1 -0
  141. package/dist/components/overlays/drawer.d.ts +88 -0
  142. package/dist/components/overlays/drawer.js +192 -0
  143. package/dist/components/overlays/drawer.js.map +1 -0
  144. package/dist/components/overlays/floating.d.ts +83 -0
  145. package/dist/components/overlays/floating.js +220 -0
  146. package/dist/components/overlays/floating.js.map +1 -0
  147. package/dist/components/overlays/index.d.ts +4 -0
  148. package/dist/components/selection/classnames.d.ts +4 -0
  149. package/dist/components/selection/classnames.js +14 -0
  150. package/dist/components/selection/classnames.js.map +1 -0
  151. package/dist/components/selection/combobox.d.ts +118 -0
  152. package/dist/components/selection/combobox.js +284 -0
  153. package/dist/components/selection/combobox.js.map +1 -0
  154. package/dist/components/selection/controls.d.ts +65 -0
  155. package/dist/components/selection/controls.js +171 -0
  156. package/dist/components/selection/controls.js.map +1 -0
  157. package/dist/components/selection/index.d.ts +7 -0
  158. package/dist/components/selection/menu.d.ts +87 -0
  159. package/dist/components/selection/menu.js +157 -0
  160. package/dist/components/selection/menu.js.map +1 -0
  161. package/dist/components/selection/select.d.ts +55 -0
  162. package/dist/components/selection/select.js +138 -0
  163. package/dist/components/selection/select.js.map +1 -0
  164. package/dist/components/selection/selection.module.js +51 -0
  165. package/dist/components/selection/selection.module.js.map +1 -0
  166. package/dist/index.d.ts +7 -0
  167. package/dist/index.js +52 -0
  168. package/dist/styles.css +2 -0
  169. package/package.json +74 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # @linyao.tw/ui
2
+
3
+ ![Linyao Design System 元件示意圖](https://raw.githubusercontent.com/linyao-tw/ui/main/assets/og-image.png)
4
+
5
+ Linyao Design System 是麟曜數位工作室的設計系統。`@linyao.tw/ui` 提供 React 元件、TypeScript 型別、語意設計變數、亮色與深色主題,以及元件樣式。
6
+
7
+ ## 安裝
8
+
9
+ 使用 pnpm 安裝:
10
+
11
+ ```sh
12
+ pnpm add @linyao.tw/ui @phosphor-icons/react
13
+ ```
14
+
15
+ 在應用程式入口匯入一次樣式:
16
+
17
+ ```tsx
18
+ import "@linyao.tw/ui/styles.css";
19
+ ```
20
+
21
+ ## 使用
22
+
23
+ ```tsx
24
+ import { FloppyDiskIcon } from "@phosphor-icons/react/dist/csr/FloppyDisk";
25
+ import { Button, TextField } from "@linyao.tw/ui";
26
+
27
+ export function ProfileForm() {
28
+ return (
29
+ <form>
30
+ <TextField label="顯示名稱" name="displayName" required />
31
+ <Button type="submit" startIcon={<FloppyDiskIcon weight="bold" />}>
32
+ 儲存
33
+ </Button>
34
+ </form>
35
+ );
36
+ }
37
+ ```
38
+
39
+ ## 主題
40
+
41
+ 以 `data-lyds-theme` 切換亮色或深色主題:
42
+
43
+ ```html
44
+ <html data-lyds-theme="dark"></html>
45
+ ```
46
+
47
+ 自訂主題時應覆寫語意角色,不要直接修改元件顏色:
48
+
49
+ ```css
50
+ .product-theme {
51
+ --control-primary: var(--palette-signal-600);
52
+ --control-primary-hover: var(--palette-signal-700);
53
+ --control-on-primary: var(--palette-warm-25);
54
+ --focus-ring: oklch(48% 0.17 32);
55
+ }
56
+ ```
57
+
58
+ ## 設計邊界
59
+
60
+ - 元件不包含 API 呼叫、路由、分析、儲存或業務驗證。
61
+ - `DataTable` 不內建排序、篩選或資料擷取。
62
+ - `FileUpload` 與 `DropZone` 不內建上傳傳輸或安全驗證。
63
+ - 日期與時間元件使用結構化值,不預設地區、時區或顯示格式。
64
+ - 一般互動以 Base UI 實作;日期與時間元件使用 React Aria Components 與 `@internationalized/date`。
65
+
66
+ ## 公開介面
67
+
68
+ 請從套件公開匯出項目匯入:
69
+
70
+ ```tsx
71
+ import { Button, DatePicker } from "@linyao.tw/ui";
72
+ import "@linyao.tw/ui/styles.css";
73
+ ```
74
+
75
+ 不要匯入 `@linyao.tw/ui/src/**`、`@linyao.tw/ui/dist/**` 或內部工具。公開介面以套件提供的 `dist/index.d.ts` 為準。
76
+
77
+ ## 無障礙
78
+
79
+ Linyao Design System 以 WCAG 2.2 AA 為目標,提供鍵盤操作、焦點樣式、錯誤與狀態語意、最小操作尺寸及降低動態效果支援。使用端仍須提供正確標籤、內容、焦點順序、符合對比要求的自訂主題與實際流程測試。
80
+
81
+ ## 文件
82
+
83
+ 完整的安裝、Storybook、開發、元件、設計變數、主題與發佈規範請參閱 [專案 README](https://github.com/linyao-tw/ui#readme) 與 [文件目錄](https://github.com/linyao-tw/ui/tree/main/docs)。
84
+
85
+ 授權:Apache-2.0。套件與專案包含相同的完整授權檔。
@@ -0,0 +1,20 @@
1
+ import { CalendarDate } from '@internationalized/date';
2
+ import { ReactElement, RefAttributes } from 'react';
3
+ import { CalendarBehaviorProps, DateValue as LydsDateValue } from './date-types.js';
4
+ export type { FirstDayOfWeek } from './date-types.js';
5
+ export type WeekdayStyle = "narrow" | "short" | "long";
6
+ export interface CalendarProps<T extends LydsDateValue = CalendarDate> extends CalendarBehaviorProps<T> {
7
+ locale?: string | undefined;
8
+ className?: string;
9
+ weekdayStyle?: WeekdayStyle | undefined;
10
+ }
11
+ export interface CalendarPanelProps {
12
+ weekdayStyle?: WeekdayStyle | undefined;
13
+ showMonthYearPickers?: boolean | undefined;
14
+ disabled?: boolean | undefined;
15
+ className?: string | undefined;
16
+ }
17
+ export declare function CalendarNavigation({ showMonthYearPickers, disabled }: Pick<CalendarPanelProps, "showMonthYearPickers" | "disabled">): import("react").JSX.Element;
18
+ export declare function CalendarGridView({ weekdayStyle }: Pick<CalendarPanelProps, "weekdayStyle">): import("react").JSX.Element;
19
+ export declare function CalendarPanel({ weekdayStyle, showMonthYearPickers, disabled, className }: CalendarPanelProps): import("react").JSX.Element;
20
+ export declare const Calendar: <T extends LydsDateValue = CalendarDate>(props: CalendarProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;
@@ -0,0 +1,102 @@
1
+ import { LocaleBoundary as e, cx as t } from "./shared.js";
2
+ import { CaretLeftIcon as n } from "@phosphor-icons/react/dist/csr/CaretLeft";
3
+ import { CaretRightIcon as r } from "@phosphor-icons/react/dist/csr/CaretRight";
4
+ import { forwardRef as i } from "react";
5
+ import { Button as a } from "react-aria-components/Button";
6
+ import { Calendar as o, CalendarCell as s, CalendarGrid as c, CalendarGridBody as l, CalendarGridHeader as u, CalendarHeaderCell as d, CalendarHeading as f, CalendarMonthPicker as p, CalendarYearPicker as m } from "react-aria-components/Calendar";
7
+ import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
8
+ //#region src/components/date-time/calendar.tsx
9
+ function v({ showMonthYearPickers: e = !0, disabled: t }) {
10
+ return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("div", {
11
+ className: "lyds-calendar-navigation",
12
+ children: [
13
+ /* @__PURE__ */ g(a, {
14
+ slot: "previous",
15
+ className: "lyds-calendar-navigation-button",
16
+ children: /* @__PURE__ */ g(n, {
17
+ "aria-hidden": "true",
18
+ className: "lyds-date-glyph",
19
+ weight: "bold"
20
+ })
21
+ }),
22
+ /* @__PURE__ */ g(f, { className: "lyds-calendar-heading" }),
23
+ /* @__PURE__ */ g(a, {
24
+ slot: "next",
25
+ className: "lyds-calendar-navigation-button",
26
+ children: /* @__PURE__ */ g(r, {
27
+ "aria-hidden": "true",
28
+ className: "lyds-date-glyph",
29
+ weight: "bold"
30
+ })
31
+ })
32
+ ]
33
+ }), e ? /* @__PURE__ */ _("div", {
34
+ className: "lyds-calendar-period-pickers",
35
+ children: [/* @__PURE__ */ g(p, { children: ({ items: e, value: n, onChange: r, ...i }) => /* @__PURE__ */ g("select", {
36
+ ...i,
37
+ className: "lyds-calendar-period-select",
38
+ value: String(n),
39
+ disabled: t,
40
+ onChange: (e) => r(Number(e.currentTarget.value)),
41
+ children: e.map((e) => /* @__PURE__ */ g("option", {
42
+ value: e.id,
43
+ children: e.formatted
44
+ }, e.id))
45
+ }) }), /* @__PURE__ */ g(m, { children: ({ items: e, value: n, onChange: r, ...i }) => /* @__PURE__ */ g("select", {
46
+ ...i,
47
+ className: "lyds-calendar-period-select",
48
+ value: String(n),
49
+ disabled: t,
50
+ onChange: (e) => r(Number(e.currentTarget.value)),
51
+ children: e.map((e) => /* @__PURE__ */ g("option", {
52
+ value: e.id,
53
+ children: e.formatted
54
+ }, e.id))
55
+ }) })]
56
+ }) : null] });
57
+ }
58
+ function y({ weekdayStyle: e = "short" }) {
59
+ return /* @__PURE__ */ _(c, {
60
+ weekdayStyle: e,
61
+ className: "lyds-calendar-grid",
62
+ children: [/* @__PURE__ */ g(u, { children: (e) => /* @__PURE__ */ g(d, {
63
+ className: "lyds-calendar-weekday",
64
+ children: e
65
+ }) }), /* @__PURE__ */ g(l, { children: (e) => /* @__PURE__ */ g(s, {
66
+ date: e,
67
+ className: "lyds-calendar-cell"
68
+ }) })]
69
+ });
70
+ }
71
+ function b({ weekdayStyle: e, showMonthYearPickers: n, disabled: r, className: i }) {
72
+ return /* @__PURE__ */ _("div", {
73
+ className: t("lyds-calendar-panel", i),
74
+ children: [/* @__PURE__ */ g(v, {
75
+ showMonthYearPickers: n,
76
+ disabled: r
77
+ }), /* @__PURE__ */ g(y, { weekdayStyle: e })]
78
+ });
79
+ }
80
+ function x({ locale: n, className: r, disabled: i, readOnly: a, invalid: s, onValueChange: c, weekdayStyle: l, ...u }, d) {
81
+ return /* @__PURE__ */ g(e, {
82
+ locale: n,
83
+ children: /* @__PURE__ */ g(o, {
84
+ ...u,
85
+ ref: d,
86
+ className: t("lyds-calendar", r),
87
+ ...i === void 0 ? {} : { isDisabled: i },
88
+ ...a === void 0 ? {} : { isReadOnly: a },
89
+ ...s === void 0 ? {} : { isInvalid: s },
90
+ ...c === void 0 ? {} : { onChange: c },
91
+ children: /* @__PURE__ */ g(b, {
92
+ weekdayStyle: l,
93
+ disabled: i
94
+ })
95
+ })
96
+ });
97
+ }
98
+ var S = i(x);
99
+ //#endregion
100
+ export { S as Calendar, y as CalendarGridView, v as CalendarNavigation, b as CalendarPanel };
101
+
102
+ //# sourceMappingURL=calendar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.js","names":[],"sources":["../../../src/components/date-time/calendar.tsx"],"sourcesContent":["import type { CalendarDate } from \"@internationalized/date\";\nimport { CaretLeftIcon } from \"@phosphor-icons/react/dist/csr/CaretLeft\";\nimport { CaretRightIcon } from \"@phosphor-icons/react/dist/csr/CaretRight\";\nimport { forwardRef, type ReactElement, type RefAttributes } from \"react\";\nimport { Button } from \"react-aria-components/Button\";\nimport {\n\tCalendar as AriaCalendar,\n\tCalendarCell,\n\tCalendarGrid,\n\tCalendarGridBody,\n\tCalendarGridHeader,\n\tCalendarHeaderCell,\n\tCalendarHeading,\n\tCalendarMonthPicker,\n\tCalendarYearPicker,\n\ttype CalendarProps as AriaCalendarProps\n} from \"react-aria-components/Calendar\";\nimport type { CalendarBehaviorProps, DateValue as LydsDateValue } from \"./date-types\";\nimport { LocaleBoundary, cx } from \"./shared\";\n\nexport type { FirstDayOfWeek } from \"./date-types\";\nexport type WeekdayStyle = \"narrow\" | \"short\" | \"long\";\n\nexport interface CalendarProps<T extends LydsDateValue = CalendarDate> extends CalendarBehaviorProps<T> {\n\tlocale?: string | undefined;\n\tclassName?: string;\n\tweekdayStyle?: WeekdayStyle | undefined;\n}\n\ntype CalendarForwardedKeys = Exclude<keyof CalendarBehaviorProps<LydsDateValue>, \"disabled\" | \"invalid\" | \"onValueChange\" | \"readOnly\">;\ntype CalendarUnexpectedForwardedKeys = Exclude<CalendarForwardedKeys, keyof AriaCalendarProps<LydsDateValue>>;\ntype CalendarPropContract = CalendarUnexpectedForwardedKeys extends never ? true : never;\nconst calendarPropContract: CalendarPropContract = true;\nvoid calendarPropContract;\n\nexport interface CalendarPanelProps {\n\tweekdayStyle?: WeekdayStyle | undefined;\n\tshowMonthYearPickers?: boolean | undefined;\n\tdisabled?: boolean | undefined;\n\tclassName?: string | undefined;\n}\n\nexport function CalendarNavigation({ showMonthYearPickers = true, disabled }: Pick<CalendarPanelProps, \"showMonthYearPickers\" | \"disabled\">) {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"lyds-calendar-navigation\">\n\t\t\t\t<Button slot=\"previous\" className=\"lyds-calendar-navigation-button\">\n\t\t\t\t\t<CaretLeftIcon aria-hidden=\"true\" className=\"lyds-date-glyph\" weight=\"bold\" />\n\t\t\t\t</Button>\n\t\t\t\t<CalendarHeading className=\"lyds-calendar-heading\" />\n\t\t\t\t<Button slot=\"next\" className=\"lyds-calendar-navigation-button\">\n\t\t\t\t\t<CaretRightIcon aria-hidden=\"true\" className=\"lyds-date-glyph\" weight=\"bold\" />\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t\t{showMonthYearPickers ? (\n\t\t\t\t<div className=\"lyds-calendar-period-pickers\">\n\t\t\t\t\t<CalendarMonthPicker>\n\t\t\t\t\t\t{({ items, value, onChange, ...ariaProps }) => (\n\t\t\t\t\t\t\t<select {...ariaProps} className=\"lyds-calendar-period-select\" value={String(value)} disabled={disabled} onChange={event => onChange(Number(event.currentTarget.value))}>\n\t\t\t\t\t\t\t\t{items.map(item => (\n\t\t\t\t\t\t\t\t\t<option key={item.id} value={item.id}>\n\t\t\t\t\t\t\t\t\t\t{item.formatted}\n\t\t\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</CalendarMonthPicker>\n\t\t\t\t\t<CalendarYearPicker>\n\t\t\t\t\t\t{({ items, value, onChange, ...ariaProps }) => (\n\t\t\t\t\t\t\t<select {...ariaProps} className=\"lyds-calendar-period-select\" value={String(value)} disabled={disabled} onChange={event => onChange(Number(event.currentTarget.value))}>\n\t\t\t\t\t\t\t\t{items.map(item => (\n\t\t\t\t\t\t\t\t\t<option key={item.id} value={item.id}>\n\t\t\t\t\t\t\t\t\t\t{item.formatted}\n\t\t\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</CalendarYearPicker>\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</>\n\t);\n}\n\nexport function CalendarGridView({ weekdayStyle = \"short\" }: Pick<CalendarPanelProps, \"weekdayStyle\">) {\n\treturn (\n\t\t<CalendarGrid weekdayStyle={weekdayStyle} className=\"lyds-calendar-grid\">\n\t\t\t<CalendarGridHeader>{day => <CalendarHeaderCell className=\"lyds-calendar-weekday\">{day}</CalendarHeaderCell>}</CalendarGridHeader>\n\t\t\t<CalendarGridBody>{date => <CalendarCell date={date} className=\"lyds-calendar-cell\" />}</CalendarGridBody>\n\t\t</CalendarGrid>\n\t);\n}\n\nexport function CalendarPanel({ weekdayStyle, showMonthYearPickers, disabled, className }: CalendarPanelProps) {\n\treturn (\n\t\t<div className={cx(\"lyds-calendar-panel\", className)}>\n\t\t\t<CalendarNavigation showMonthYearPickers={showMonthYearPickers} disabled={disabled} />\n\t\t\t<CalendarGridView weekdayStyle={weekdayStyle} />\n\t\t</div>\n\t);\n}\n\nfunction CalendarImpl<T extends LydsDateValue>(\n\t{ locale, className, disabled, readOnly, invalid, onValueChange, weekdayStyle, ...calendarProps }: CalendarProps<T>,\n\tref: React.ForwardedRef<HTMLDivElement>\n) {\n\tconst ariaCalendarProps = calendarProps as unknown as Omit<AriaCalendarProps<T>, \"children\" | \"className\" | \"isDisabled\" | \"isInvalid\" | \"isReadOnly\" | \"onChange\">;\n\n\treturn (\n\t\t<LocaleBoundary locale={locale}>\n\t\t\t<AriaCalendar\n\t\t\t\t{...ariaCalendarProps}\n\t\t\t\tref={ref}\n\t\t\t\tclassName={cx(\"lyds-calendar\", className)}\n\t\t\t\t{...(disabled === undefined ? {} : { isDisabled: disabled })}\n\t\t\t\t{...(readOnly === undefined ? {} : { isReadOnly: readOnly })}\n\t\t\t\t{...(invalid === undefined ? {} : { isInvalid: invalid })}\n\t\t\t\t{...(onValueChange === undefined ? {} : { onChange: onValueChange as unknown as NonNullable<AriaCalendarProps<T>[\"onChange\"]> })}\n\t\t\t>\n\t\t\t\t<CalendarPanel weekdayStyle={weekdayStyle} disabled={disabled} />\n\t\t\t</AriaCalendar>\n\t\t</LocaleBoundary>\n\t);\n}\n\nexport const Calendar = forwardRef(CalendarImpl) as <T extends LydsDateValue = CalendarDate>(props: CalendarProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;\n"],"mappings":";;;;;;;;AA0CA,SAAgB,EAAmB,EAAE,0BAAuB,IAAM,eAA2E;CAC5I,OACC,kBAAA,GAAA,EAAA,UAAA,CACC,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACC,kBAAC,GAAD;IAAQ,MAAK;IAAW,WAAU;IACjC,UAAA,kBAAC,GAAD;KAAe,eAAY;KAAO,WAAU;KAAkB,QAAO;IAAQ,CAAA;GACtE,CAAA;GACR,kBAAC,GAAD,EAAiB,WAAU,wBAAyB,CAAA;GACpD,kBAAC,GAAD;IAAQ,MAAK;IAAO,WAAU;IAC7B,UAAA,kBAAC,GAAD;KAAgB,eAAY;KAAO,WAAU;KAAkB,QAAO;IAAQ,CAAA;GACvE,CAAA;EACJ;CACJ,CAAA,GAAA,IACA,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACC,kBAAC,GAAD,EAAA,WACG,EAAE,UAAO,UAAO,aAAU,GAAG,QAC9B,kBAAC,UAAD;GAAQ,GAAI;GAAW,WAAU;GAA8B,OAAO,OAAO,CAAK;GAAa;GAAU,WAAU,MAAS,EAAS,OAAO,EAAM,cAAc,KAAK,CAAC;GACpK,UAAA,EAAM,KAAI,MACV,kBAAC,UAAD;IAAsB,OAAO,EAAK;IAChC,UAAA,EAAK;GACC,GAFK,EAAK,EAEV,CACR;EACM,CAAA,EAEW,CAAA,GACrB,kBAAC,GAAD,EAAA,WACG,EAAE,UAAO,UAAO,aAAU,GAAG,QAC9B,kBAAC,UAAD;GAAQ,GAAI;GAAW,WAAU;GAA8B,OAAO,OAAO,CAAK;GAAa;GAAU,WAAU,MAAS,EAAS,OAAO,EAAM,cAAc,KAAK,CAAC;GACpK,UAAA,EAAM,KAAI,MACV,kBAAC,UAAD;IAAsB,OAAO,EAAK;IAChC,UAAA,EAAK;GACC,GAFK,EAAK,EAEV,CACR;EACM,CAAA,EAEU,CAAA,CAChB;CACF,CAAA,IAAA,IACH,EAAA,CAAA;AAEJ;AAEA,SAAgB,EAAiB,EAAE,kBAAe,WAAqD;CACtG,OACC,kBAAC,GAAD;EAA4B;EAAc,WAAU;EAApD,UAAA,CACC,kBAAC,GAAD,EAAA,WAAqB,MAAO,kBAAC,GAAD;GAAoB,WAAU;GAAyB,UAAA;EAAwB,CAAA,EAAsB,CAAA,GACjI,kBAAC,GAAD,EAAA,WAAmB,MAAQ,kBAAC,GAAD;GAAoB;GAAM,WAAU;EAAsB,CAAA,EAAoB,CAAA,CAC5F;;AAEhB;AAEA,SAAgB,EAAc,EAAE,iBAAc,yBAAsB,aAAU,gBAAiC;CAC9G,OACC,kBAAC,OAAD;EAAK,WAAW,EAAG,uBAAuB,CAAS;EAAnD,UAAA,CACC,kBAAC,GAAD;GAA0C;GAAgC;EAAW,CAAA,GACrF,kBAAC,GAAD,EAAgC,gBAAe,CAAA,CAC3C;;AAEP;AAEA,SAAS,EACR,EAAE,WAAQ,cAAW,aAAU,aAAU,YAAS,kBAAe,iBAAc,GAAG,KAClF,GACC;CAGD,OACC,kBAAC,GAAD;EAAwB;EACvB,UAAA,kBAAC,GAAD;GACC,GAAI;GACC;GACL,WAAW,EAAG,iBAAiB,CAAS;GACxC,GAAK,MAAa,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,EAAS;GAC1D,GAAK,MAAa,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,EAAS;GAC1D,GAAK,MAAY,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,EAAQ;GACvD,GAAK,MAAkB,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,EAA0E;GAE9H,UAAA,kBAAC,GAAD;IAA6B;IAAwB;GAAW,CAAA;EACnD,CAAA;CACC,CAAA;AAElB;AAEA,IAAa,IAAW,EAAW,CAAY"}
@@ -0,0 +1,11 @@
1
+ import { CalendarDate } from '@internationalized/date';
2
+ import { ReactElement, RefAttributes } from 'react';
3
+ import { DateFieldBehaviorProps, DateValue as LydsDateValue } from './date-types.js';
4
+ import { DateTimeFieldChromeProps } from './shared.js';
5
+ export interface DateFieldProps<T extends LydsDateValue = CalendarDate> extends DateFieldBehaviorProps<T>, DateTimeFieldChromeProps {
6
+ }
7
+ export declare function DateInputSegments({ className, slot }: {
8
+ className?: string;
9
+ slot?: string;
10
+ }): import("react").JSX.Element;
11
+ export declare const DateField: <T extends LydsDateValue = CalendarDate>(props: DateFieldProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;
@@ -0,0 +1,44 @@
1
+ import { FieldLabel as e, FieldMessages as t, LocaleBoundary as n, cx as r } from "./shared.js";
2
+ import { forwardRef as i } from "react";
3
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
4
+ import { DateField as s, DateInput as c, DateSegment as l } from "react-aria-components/DateField";
5
+ //#region src/components/date-time/date-field.tsx
6
+ function u({ className: e, slot: t }) {
7
+ return /* @__PURE__ */ a(c, {
8
+ className: r("lyds-date-input", e),
9
+ ...t ? { slot: t } : {},
10
+ children: (e) => /* @__PURE__ */ a(l, {
11
+ segment: e,
12
+ className: "lyds-date-segment"
13
+ })
14
+ });
15
+ }
16
+ function d({ label: i, description: c, error: l, locale: d, size: f = "md", className: p, disabled: m, readOnly: h, required: g, invalid: _, onValueChange: v, ...y }, b) {
17
+ return /* @__PURE__ */ a(n, {
18
+ locale: d,
19
+ children: /* @__PURE__ */ o(s, {
20
+ ...y,
21
+ ref: b,
22
+ className: r("lyds-date-field", p),
23
+ "data-size": f,
24
+ ...m === void 0 ? {} : { isDisabled: m },
25
+ ...h === void 0 ? {} : { isReadOnly: h },
26
+ ...g === void 0 ? {} : { isRequired: g },
27
+ ..._ === void 0 ? {} : { isInvalid: _ },
28
+ ...v === void 0 ? {} : { onChange: v },
29
+ children: [
30
+ /* @__PURE__ */ a(e, { children: i }),
31
+ /* @__PURE__ */ a(u, {}),
32
+ /* @__PURE__ */ a(t, {
33
+ description: c,
34
+ error: l
35
+ })
36
+ ]
37
+ })
38
+ });
39
+ }
40
+ var f = i(d);
41
+ //#endregion
42
+ export { f as DateField, u as DateInputSegments };
43
+
44
+ //# sourceMappingURL=date-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-field.js","names":[],"sources":["../../../src/components/date-time/date-field.tsx"],"sourcesContent":["import type { CalendarDate } from \"@internationalized/date\";\nimport { forwardRef, type ReactElement, type RefAttributes } from \"react\";\nimport { DateField as AriaDateField, DateInput, DateSegment, type DateFieldProps as AriaDateFieldProps } from \"react-aria-components/DateField\";\nimport type { DateFieldBehaviorProps, DateValue as LydsDateValue } from \"./date-types\";\nimport { FieldLabel, FieldMessages, LocaleBoundary, cx, type DateTimeFieldChromeProps } from \"./shared\";\n\nexport interface DateFieldProps<T extends LydsDateValue = CalendarDate> extends DateFieldBehaviorProps<T>, DateTimeFieldChromeProps {}\n\ntype DateFieldForwardedKeys = Exclude<keyof DateFieldBehaviorProps<LydsDateValue>, \"disabled\" | \"invalid\" | \"onValueChange\" | \"readOnly\" | \"required\">;\ntype DateFieldUnexpectedForwardedKeys = Exclude<DateFieldForwardedKeys, keyof AriaDateFieldProps<LydsDateValue>>;\ntype DateFieldPropContract = DateFieldUnexpectedForwardedKeys extends never ? true : never;\nconst dateFieldPropContract: DateFieldPropContract = true;\nvoid dateFieldPropContract;\n\nexport function DateInputSegments({ className, slot }: { className?: string; slot?: string }) {\n\treturn (\n\t\t<DateInput className={cx(\"lyds-date-input\", className)} {...(slot ? { slot } : {})}>\n\t\t\t{segment => <DateSegment segment={segment} className=\"lyds-date-segment\" />}\n\t\t</DateInput>\n\t);\n}\n\nfunction DateFieldImpl<T extends LydsDateValue>(\n\t{ label, description, error, locale, size = \"md\", className, disabled, readOnly, required, invalid, onValueChange, ...fieldProps }: DateFieldProps<T>,\n\tref: React.ForwardedRef<HTMLDivElement>\n) {\n\tconst ariaFieldProps = fieldProps as unknown as Omit<AriaDateFieldProps<T>, \"children\" | \"className\" | \"isDisabled\" | \"isInvalid\" | \"isReadOnly\" | \"isRequired\" | \"onChange\">;\n\n\treturn (\n\t\t<LocaleBoundary locale={locale}>\n\t\t\t<AriaDateField\n\t\t\t\t{...ariaFieldProps}\n\t\t\t\tref={ref}\n\t\t\t\tclassName={cx(\"lyds-date-field\", className)}\n\t\t\t\tdata-size={size}\n\t\t\t\t{...(disabled === undefined ? {} : { isDisabled: disabled })}\n\t\t\t\t{...(readOnly === undefined ? {} : { isReadOnly: readOnly })}\n\t\t\t\t{...(required === undefined ? {} : { isRequired: required })}\n\t\t\t\t{...(invalid === undefined ? {} : { isInvalid: invalid })}\n\t\t\t\t{...(onValueChange === undefined ? {} : { onChange: onValueChange as unknown as NonNullable<AriaDateFieldProps<T>[\"onChange\"]> })}\n\t\t\t>\n\t\t\t\t<FieldLabel>{label}</FieldLabel>\n\t\t\t\t<DateInputSegments />\n\t\t\t\t<FieldMessages description={description} error={error} />\n\t\t\t</AriaDateField>\n\t\t</LocaleBoundary>\n\t);\n}\n\nexport const DateField = forwardRef(DateFieldImpl) as <T extends LydsDateValue = CalendarDate>(props: DateFieldProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;\n"],"mappings":";;;;;AAcA,SAAgB,EAAkB,EAAE,cAAW,WAA+C;CAC7F,OACC,kBAAC,GAAD;EAAW,WAAW,EAAG,mBAAmB,CAAS;EAAG,GAAK,IAAO,EAAE,QAAK,IAAI,CAAC;EAC9E,WAAA,MAAW,kBAAC,GAAD;GAAsB;GAAS,WAAU;EAAqB,CAAA;CAChE,CAAA;AAEb;AAEA,SAAS,EACR,EAAE,UAAO,gBAAa,UAAO,WAAQ,UAAO,MAAM,cAAW,aAAU,aAAU,aAAU,YAAS,kBAAe,GAAG,KACtH,GACC;CAGD,OACC,kBAAC,GAAD;EAAwB;EACvB,UAAA,kBAAC,GAAD;GACC,GAAI;GACC;GACL,WAAW,EAAG,mBAAmB,CAAS;GAC1C,aAAW;GACX,GAAK,MAAa,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,EAAS;GAC1D,GAAK,MAAa,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,EAAS;GAC1D,GAAK,MAAa,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,EAAS;GAC1D,GAAK,MAAY,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,EAAQ;GACvD,GAAK,MAAkB,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,EAA2E;GAThI,UAAA;IAWC,kBAAC,GAAD,EAAA,UAAa,EAAkB,CAAA;IAC/B,kBAAC,GAAD,CAAoB,CAAA;IACpB,kBAAC,GAAD;KAA4B;KAAoB;IAAQ,CAAA;GAC1C;;CACA,CAAA;AAElB;AAEA,IAAa,IAAY,EAAW,CAAa"}
@@ -0,0 +1,28 @@
1
+ import { CalendarDate, CalendarDateTime, ZonedDateTime } from '@internationalized/date';
2
+ import { ReactElement, RefAttributes } from 'react';
3
+ import { WeekdayStyle } from './calendar.js';
4
+ import { DatePickerBehaviorProps, DatePopoverPlacement, DateValue as LydsDateValue } from './date-types.js';
5
+ import { DateTimeFieldChromeProps } from './shared.js';
6
+ interface DatePickerChromeProps extends DateTimeFieldChromeProps {
7
+ open?: boolean;
8
+ disabled?: boolean;
9
+ readOnly?: boolean;
10
+ required?: boolean;
11
+ invalid?: boolean;
12
+ weekdayStyle?: WeekdayStyle | undefined;
13
+ showMonthYearPickers?: boolean | undefined;
14
+ popoverPlacement?: DatePopoverPlacement | undefined;
15
+ }
16
+ export interface DatePickerProps<T extends LydsDateValue = CalendarDate> extends DatePickerBehaviorProps<T>, DatePickerChromeProps {
17
+ }
18
+ /**
19
+ * 日期時間值保留自身語意。不含時區的日期時間請使用 `CalendarDateTime`;
20
+ * 具明確時區的時間點請使用 `ZonedDateTime`。Linyao Design System 不會在兩者之間自動轉換。
21
+ */
22
+ export type DateTimeValue = CalendarDateTime | ZonedDateTime;
23
+ export interface DateTimePickerProps<T extends DateTimeValue = CalendarDateTime> extends Omit<DatePickerProps<T>, "granularity"> {
24
+ granularity?: "hour" | "minute" | "second";
25
+ }
26
+ export declare const DatePicker: <T extends LydsDateValue = CalendarDate>(props: DatePickerProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;
27
+ export declare const DateTimePicker: <T extends DateTimeValue = CalendarDateTime>(props: DateTimePickerProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;
28
+ export {};
@@ -0,0 +1,74 @@
1
+ import { CalendarGlyph as e, FieldLabel as t, FieldMessages as n, LocaleBoundary as r, cx as i } from "./shared.js";
2
+ import { CalendarPanel as a } from "./calendar.js";
3
+ import { DateInputSegments as o } from "./date-field.js";
4
+ import { forwardRef as s } from "react";
5
+ import { Button as c } from "react-aria-components/Button";
6
+ import { Calendar as l } from "react-aria-components/Calendar";
7
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
8
+ import { DatePicker as f } from "react-aria-components/DatePicker";
9
+ import { Dialog as p } from "react-aria-components/Dialog";
10
+ import { Group as m } from "react-aria-components/Group";
11
+ import { Popover as h } from "react-aria-components/Popover";
12
+ //#region src/components/date-time/date-picker.tsx
13
+ function g({ label: s, description: g, error: _, locale: v, size: y = "md", className: b, open: x, disabled: S, readOnly: C, required: w, invalid: T, onValueChange: E, firstDayOfWeek: D, weekdayStyle: O, showMonthYearPickers: k, popoverPlacement: A = "bottom start", ...j }, M, N) {
14
+ return /* @__PURE__ */ u(r, {
15
+ locale: v,
16
+ children: /* @__PURE__ */ d(f, {
17
+ ...j,
18
+ ref: M,
19
+ className: i("lyds-date-field", "lyds-date-picker", N && "lyds-date-time-picker", b),
20
+ "data-size": y,
21
+ ...x === void 0 ? {} : { isOpen: x },
22
+ ...S === void 0 ? {} : { isDisabled: S },
23
+ ...C === void 0 ? {} : { isReadOnly: C },
24
+ ...w === void 0 ? {} : { isRequired: w },
25
+ ...T === void 0 ? {} : { isInvalid: T },
26
+ ...E === void 0 ? {} : { onChange: E },
27
+ ...D === void 0 ? {} : { firstDayOfWeek: D },
28
+ children: [
29
+ /* @__PURE__ */ u(t, { children: s }),
30
+ /* @__PURE__ */ d(m, {
31
+ className: "lyds-date-picker-group",
32
+ children: [/* @__PURE__ */ u(o, { className: "lyds-date-picker-input" }), /* @__PURE__ */ u(c, {
33
+ className: "lyds-date-picker-button",
34
+ children: /* @__PURE__ */ u(e, {})
35
+ })]
36
+ }),
37
+ /* @__PURE__ */ u(n, {
38
+ description: g,
39
+ error: _
40
+ }),
41
+ /* @__PURE__ */ u(h, {
42
+ className: "lyds-date-popover",
43
+ placement: A,
44
+ children: /* @__PURE__ */ u(p, {
45
+ className: "lyds-date-popover-dialog",
46
+ children: /* @__PURE__ */ u(l, {
47
+ className: "lyds-calendar",
48
+ ...D === void 0 ? {} : { firstDayOfWeek: D },
49
+ children: /* @__PURE__ */ u(a, {
50
+ weekdayStyle: O,
51
+ showMonthYearPickers: k,
52
+ disabled: S
53
+ })
54
+ })
55
+ })
56
+ })
57
+ ]
58
+ })
59
+ });
60
+ }
61
+ function _(e, t) {
62
+ return g(e, t, !1);
63
+ }
64
+ function v(e, t) {
65
+ return g({
66
+ ...e,
67
+ granularity: e.granularity ?? "minute"
68
+ }, t, !0);
69
+ }
70
+ var y = s(_), b = s(v);
71
+ //#endregion
72
+ export { y as DatePicker, b as DateTimePicker };
73
+
74
+ //# sourceMappingURL=date-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-picker.js","names":[],"sources":["../../../src/components/date-time/date-picker.tsx"],"sourcesContent":["import type { CalendarDate, CalendarDateTime, ZonedDateTime } from \"@internationalized/date\";\nimport { forwardRef, type ReactElement, type RefAttributes } from \"react\";\nimport { Button } from \"react-aria-components/Button\";\nimport { Calendar as AriaCalendar } from \"react-aria-components/Calendar\";\nimport { DatePicker as AriaDatePicker, type DatePickerProps as AriaDatePickerProps } from \"react-aria-components/DatePicker\";\nimport { Dialog } from \"react-aria-components/Dialog\";\nimport { Group } from \"react-aria-components/Group\";\nimport { Popover } from \"react-aria-components/Popover\";\nimport { CalendarPanel, type WeekdayStyle } from \"./calendar\";\nimport { DateInputSegments } from \"./date-field\";\nimport type { DatePickerBehaviorProps, DatePopoverPlacement, DateValue as LydsDateValue } from \"./date-types\";\nimport { CalendarGlyph, FieldLabel, FieldMessages, LocaleBoundary, cx, type DateTimeFieldChromeProps } from \"./shared\";\n\ninterface DatePickerChromeProps extends DateTimeFieldChromeProps {\n\topen?: boolean;\n\tdisabled?: boolean;\n\treadOnly?: boolean;\n\trequired?: boolean;\n\tinvalid?: boolean;\n\tweekdayStyle?: WeekdayStyle | undefined;\n\tshowMonthYearPickers?: boolean | undefined;\n\tpopoverPlacement?: DatePopoverPlacement | undefined;\n}\n\nexport interface DatePickerProps<T extends LydsDateValue = CalendarDate> extends DatePickerBehaviorProps<T>, DatePickerChromeProps {}\n\ntype DatePickerForwardedKeys = Exclude<keyof DatePickerBehaviorProps<LydsDateValue>, \"disabled\" | \"invalid\" | \"onValueChange\" | \"open\" | \"readOnly\" | \"required\">;\ntype DatePickerUnexpectedForwardedKeys = Exclude<DatePickerForwardedKeys, keyof AriaDatePickerProps<LydsDateValue>>;\ntype DatePickerPropContract = DatePickerUnexpectedForwardedKeys extends never ? true : never;\nconst datePickerPropContract: DatePickerPropContract = true;\nvoid datePickerPropContract;\n\n/**\n * 日期時間值保留自身語意。不含時區的日期時間請使用 `CalendarDateTime`;\n * 具明確時區的時間點請使用 `ZonedDateTime`。Linyao Design System 不會在兩者之間自動轉換。\n */\nexport type DateTimeValue = CalendarDateTime | ZonedDateTime;\n\nexport interface DateTimePickerProps<T extends DateTimeValue = CalendarDateTime> extends Omit<DatePickerProps<T>, \"granularity\"> {\n\tgranularity?: \"hour\" | \"minute\" | \"second\";\n}\n\nfunction SingleDatePicker<T extends LydsDateValue>(\n\t{\n\t\tlabel,\n\t\tdescription,\n\t\terror,\n\t\tlocale,\n\t\tsize = \"md\",\n\t\tclassName,\n\t\topen,\n\t\tdisabled,\n\t\treadOnly,\n\t\trequired,\n\t\tinvalid,\n\t\tonValueChange,\n\t\tfirstDayOfWeek,\n\t\tweekdayStyle,\n\t\tshowMonthYearPickers,\n\t\tpopoverPlacement = \"bottom start\",\n\t\t...pickerProps\n\t}: DatePickerProps<T>,\n\tref: React.ForwardedRef<HTMLDivElement>,\n\tdateTime: boolean\n) {\n\tconst ariaPickerProps = pickerProps as unknown as Omit<AriaDatePickerProps<T>, \"children\" | \"className\" | \"isDisabled\" | \"isInvalid\" | \"isOpen\" | \"isReadOnly\" | \"isRequired\" | \"onChange\">;\n\n\treturn (\n\t\t<LocaleBoundary locale={locale}>\n\t\t\t<AriaDatePicker\n\t\t\t\t{...ariaPickerProps}\n\t\t\t\tref={ref}\n\t\t\t\tclassName={cx(\"lyds-date-field\", \"lyds-date-picker\", dateTime && \"lyds-date-time-picker\", className)}\n\t\t\t\tdata-size={size}\n\t\t\t\t{...(open === undefined ? {} : { isOpen: open })}\n\t\t\t\t{...(disabled === undefined ? {} : { isDisabled: disabled })}\n\t\t\t\t{...(readOnly === undefined ? {} : { isReadOnly: readOnly })}\n\t\t\t\t{...(required === undefined ? {} : { isRequired: required })}\n\t\t\t\t{...(invalid === undefined ? {} : { isInvalid: invalid })}\n\t\t\t\t{...(onValueChange === undefined ? {} : { onChange: onValueChange as unknown as NonNullable<AriaDatePickerProps<T>[\"onChange\"]> })}\n\t\t\t\t{...(firstDayOfWeek === undefined ? {} : { firstDayOfWeek })}\n\t\t\t>\n\t\t\t\t<FieldLabel>{label}</FieldLabel>\n\t\t\t\t<Group className=\"lyds-date-picker-group\">\n\t\t\t\t\t<DateInputSegments className=\"lyds-date-picker-input\" />\n\t\t\t\t\t<Button className=\"lyds-date-picker-button\">\n\t\t\t\t\t\t<CalendarGlyph />\n\t\t\t\t\t</Button>\n\t\t\t\t</Group>\n\t\t\t\t<FieldMessages description={description} error={error} />\n\t\t\t\t<Popover className=\"lyds-date-popover\" placement={popoverPlacement}>\n\t\t\t\t\t<Dialog className=\"lyds-date-popover-dialog\">\n\t\t\t\t\t\t<AriaCalendar className=\"lyds-calendar\" {...(firstDayOfWeek === undefined ? {} : { firstDayOfWeek })}>\n\t\t\t\t\t\t\t<CalendarPanel weekdayStyle={weekdayStyle} showMonthYearPickers={showMonthYearPickers} disabled={disabled} />\n\t\t\t\t\t\t</AriaCalendar>\n\t\t\t\t\t</Dialog>\n\t\t\t\t</Popover>\n\t\t\t</AriaDatePicker>\n\t\t</LocaleBoundary>\n\t);\n}\n\nfunction DatePickerImpl<T extends LydsDateValue>(props: DatePickerProps<T>, ref: React.ForwardedRef<HTMLDivElement>) {\n\treturn SingleDatePicker(props, ref, false);\n}\n\nfunction DateTimePickerImpl<T extends DateTimeValue>(props: DateTimePickerProps<T>, ref: React.ForwardedRef<HTMLDivElement>) {\n\treturn SingleDatePicker({ ...props, granularity: props.granularity ?? \"minute\" }, ref, true);\n}\n\nexport const DatePicker = forwardRef(DatePickerImpl) as <T extends LydsDateValue = CalendarDate>(props: DatePickerProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;\n\nexport const DateTimePicker = forwardRef(DateTimePickerImpl) as <T extends DateTimeValue = CalendarDateTime>(props: DateTimePickerProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;\n"],"mappings":";;;;;;;;;;;;AA0CA,SAAS,EACR,EACC,UACA,gBACA,UACA,WACA,UAAO,MACP,cACA,SACA,aACA,aACA,aACA,YACA,kBACA,mBACA,iBACA,yBACA,sBAAmB,gBACnB,GAAG,KAEJ,GACA,GACC;CAGD,OACC,kBAAC,GAAD;EAAwB;EACvB,UAAA,kBAAC,GAAD;GACC,GAAI;GACC;GACL,WAAW,EAAG,mBAAmB,oBAAoB,KAAY,yBAAyB,CAAS;GACnG,aAAW;GACX,GAAK,MAAS,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,EAAK;GAC9C,GAAK,MAAa,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,EAAS;GAC1D,GAAK,MAAa,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,EAAS;GAC1D,GAAK,MAAa,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,EAAS;GAC1D,GAAK,MAAY,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,EAAQ;GACvD,GAAK,MAAkB,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,EAA4E;GAChI,GAAK,MAAmB,KAAA,IAAY,CAAC,IAAI,EAAE,kBAAe;GAX3D,UAAA;IAaC,kBAAC,GAAD,EAAA,UAAa,EAAkB,CAAA;IAC/B,kBAAC,GAAD;KAAO,WAAU;KAAjB,UAAA,CACC,kBAAC,GAAD,EAAmB,WAAU,yBAA0B,CAAA,GACvD,kBAAC,GAAD;MAAQ,WAAU;MACjB,UAAA,kBAAC,GAAD,CAAgB,CAAA;KACT,CAAA,CACF;;IACP,kBAAC,GAAD;KAA4B;KAAoB;IAAQ,CAAA;IACxD,kBAAC,GAAD;KAAS,WAAU;KAAoB,WAAW;KACjD,UAAA,kBAAC,GAAD;MAAQ,WAAU;MACjB,UAAA,kBAAC,GAAD;OAAc,WAAU;OAAgB,GAAK,MAAmB,KAAA,IAAY,CAAC,IAAI,EAAE,kBAAe;OACjG,UAAA,kBAAC,GAAD;QAA6B;QAAoC;QAAgC;OAAW,CAAA;MAC/F,CAAA;KACP,CAAA;IACA,CAAA;GACM;;CACD,CAAA;AAElB;AAEA,SAAS,EAAwC,GAA2B,GAAyC;CACpH,OAAO,EAAiB,GAAO,GAAK,EAAK;AAC1C;AAEA,SAAS,EAA4C,GAA+B,GAAyC;CAC5H,OAAO,EAAiB;EAAE,GAAG;EAAO,aAAa,EAAM,eAAe;CAAS,GAAG,GAAK,EAAI;AAC5F;AAEA,IAAa,IAAa,EAAW,CAAc,GAEtC,IAAiB,EAAW,CAAkB"}
@@ -0,0 +1,11 @@
1
+ import { CalendarDate } from '@internationalized/date';
2
+ import { ReactElement, RefAttributes } from 'react';
3
+ import { WeekdayStyle } from './calendar.js';
4
+ import { DatePopoverPlacement, DateRangePickerBehaviorProps, DateValue as LydsDateValue } from './date-types.js';
5
+ import { DateTimeFieldChromeProps } from './shared.js';
6
+ export interface DateRangePickerProps<T extends LydsDateValue = CalendarDate> extends DateRangePickerBehaviorProps<T>, DateTimeFieldChromeProps {
7
+ weekdayStyle?: WeekdayStyle | undefined;
8
+ showMonthYearPickers?: boolean | undefined;
9
+ popoverPlacement?: DatePopoverPlacement | undefined;
10
+ }
11
+ export declare const DateRangePicker: <T extends LydsDateValue = CalendarDate>(props: DateRangePickerProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;