@threadlabs/looma 0.50.2 → 0.51.1

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 (373) hide show
  1. package/components/shared/binding-inputs.js +5 -0
  2. package/components/shared/calendar-model.js +84 -0
  3. package/components/shared/date-input-segments.js +25 -0
  4. package/components/shared/date-navigation.js +35 -0
  5. package/components/shared/date-picker.js +38 -0
  6. package/components/shared/date-range.js +61 -0
  7. package/components/shared/date-time.js +273 -0
  8. package/components/shared/external-value.js +12 -0
  9. package/components/shared/form-reset.js +1 -1
  10. package/components/shared/icons.js +2 -0
  11. package/components/shared/initial-field-value.js +14 -0
  12. package/components/shared/input-segments.js +190 -0
  13. package/components/shared/prepared-module.js +19 -0
  14. package/components/ui-button/ui-button.html +31 -10
  15. package/components/ui-calendar/calendar-source.js +34 -0
  16. package/components/ui-calendar/ui-calendar.html +221 -0
  17. package/components/ui-calendar/ui-calendar.js +185 -0
  18. package/components/ui-cluster/ui-cluster.html +5 -2
  19. package/components/ui-date-field/ui-date-field.html +143 -0
  20. package/components/ui-date-field/ui-date-field.js +258 -0
  21. package/components/ui-date-picker/ui-date-picker.html +213 -0
  22. package/components/ui-date-picker/ui-date-picker.js +153 -0
  23. package/components/ui-date-range-picker/ui-date-range-picker.html +202 -0
  24. package/components/ui-date-range-picker/ui-date-range-picker.js +224 -0
  25. package/components/ui-file-input/files.js +15 -0
  26. package/components/ui-file-input/ui-file-input.html +79 -0
  27. package/components/ui-file-input/ui-file-input.js +108 -0
  28. package/components/ui-form-field/ui-form-field.js +2 -2
  29. package/components/ui-grid/ui-grid.html +74 -5
  30. package/components/ui-icon/ui-icon.html +8 -0
  31. package/components/ui-icon-button/ui-icon-button.html +22 -7
  32. package/components/ui-input/ui-input.html +10 -1
  33. package/components/ui-input/ui-input.js +11 -5
  34. package/components/ui-input-group/ui-input-group.html +2 -2
  35. package/components/ui-input-group/ui-input-group.js +6 -5
  36. package/components/ui-popover/ui-popover.html +2 -0
  37. package/components/ui-popover/ui-popover.js +5 -1
  38. package/components/ui-select/ui-select.html +8 -3
  39. package/components/ui-time-field/ui-time-field.html +62 -0
  40. package/components/ui-time-field/ui-time-field.js +21 -0
  41. package/components/ui-time-picker/time-options.js +25 -0
  42. package/components/ui-time-picker/ui-time-picker.html +160 -0
  43. package/components/ui-time-picker/ui-time-picker.js +132 -0
  44. package/dist/index.js +68 -61
  45. package/docs/README.md +2 -2
  46. package/docs/catalog.json +14346 -6343
  47. package/docs/documentation.css +1 -1
  48. package/docs/framework-examples.mjs +13 -2
  49. package/docs/site.mjs +1 -1
  50. package/editor/components.css +62 -29
  51. package/editor/icons.d.ts +2 -0
  52. package/editor/index.js +602 -141
  53. package/package.json +6 -4
  54. package/styles/ui-action-bar.css +1 -1
  55. package/styles/ui-affordance-scope.css +1 -1
  56. package/styles/ui-avatar-group.css +1 -1
  57. package/styles/ui-avatar.css +1 -1
  58. package/styles/ui-badge.css +1 -1
  59. package/styles/ui-breadcrumb-item.css +1 -1
  60. package/styles/ui-breadcrumbs.css +1 -1
  61. package/styles/ui-button.css +19 -7
  62. package/styles/ui-calendar.css +1 -0
  63. package/styles/ui-callout.css +1 -1
  64. package/styles/ui-card-group.css +1 -1
  65. package/styles/ui-card.css +1 -1
  66. package/styles/ui-checkbox.css +1 -1
  67. package/styles/ui-cluster.css +4 -1
  68. package/styles/ui-color-picker.css +1 -1
  69. package/styles/ui-combobox.css +1 -1
  70. package/styles/ui-compact-content.css +1 -1
  71. package/styles/ui-compact-editor.css +1 -1
  72. package/styles/ui-compact-mark.css +1 -1
  73. package/styles/ui-compact-node.css +1 -1
  74. package/styles/ui-container.css +1 -1
  75. package/styles/ui-context-menu.css +1 -1
  76. package/styles/ui-cover.css +1 -1
  77. package/styles/ui-curve-editor.css +1 -1
  78. package/styles/ui-cycle-button.css +1 -1
  79. package/styles/ui-date-field.css +1 -0
  80. package/styles/ui-date-picker.css +1 -0
  81. package/styles/ui-date-range-picker.css +1 -0
  82. package/styles/ui-description-item.css +1 -1
  83. package/styles/ui-description-list.css +1 -1
  84. package/styles/ui-dialog.css +1 -1
  85. package/styles/ui-disclosure.css +1 -1
  86. package/styles/ui-editable.css +1 -1
  87. package/styles/ui-editor-block-actions.css +1 -1
  88. package/styles/ui-editor-chip-editor.css +1 -1
  89. package/styles/ui-editor-code-language.css +1 -1
  90. package/styles/ui-editor-footnote-editor.css +1 -1
  91. package/styles/ui-editor-formatting-tools.css +1 -1
  92. package/styles/ui-editor-image-toolbar.css +1 -1
  93. package/styles/ui-editor-insert-table-grid.css +1 -1
  94. package/styles/ui-editor-link-card.css +1 -1
  95. package/styles/ui-editor-link-form.css +1 -1
  96. package/styles/ui-editor-mention-menu-item.css +1 -1
  97. package/styles/ui-editor-mention-menu.css +1 -1
  98. package/styles/ui-editor-slash-menu-group.css +1 -1
  99. package/styles/ui-editor-slash-menu-item.css +1 -1
  100. package/styles/ui-editor-slash-menu.css +1 -1
  101. package/styles/ui-editor-surface.css +1 -1
  102. package/styles/ui-editor-table-context-menu.css +1 -1
  103. package/styles/ui-editor-table-overlay.css +1 -1
  104. package/styles/ui-editor-table-toolbar.css +1 -1
  105. package/styles/ui-editor-toolbar.css +1 -1
  106. package/styles/ui-editor.css +1 -1
  107. package/styles/ui-file-input.css +1 -0
  108. package/styles/ui-floating-action-button.css +1 -1
  109. package/styles/ui-form-field.css +1 -1
  110. package/styles/ui-grid.css +44 -1
  111. package/styles/ui-icon-button.css +19 -5
  112. package/styles/ui-icon.css +5 -1
  113. package/styles/ui-image.css +1 -1
  114. package/styles/ui-input-group.css +3 -3
  115. package/styles/ui-input.css +1 -1
  116. package/styles/ui-light-editor.css +1 -1
  117. package/styles/ui-list-item.css +1 -1
  118. package/styles/ui-list.css +1 -1
  119. package/styles/ui-listbox.css +1 -1
  120. package/styles/ui-menu-group.css +1 -1
  121. package/styles/ui-menu-item.css +1 -1
  122. package/styles/ui-menu.css +1 -1
  123. package/styles/ui-meter.css +1 -1
  124. package/styles/ui-nav-item.css +1 -1
  125. package/styles/ui-number-input.css +1 -1
  126. package/styles/ui-page-header.css +1 -1
  127. package/styles/ui-pagination.css +1 -1
  128. package/styles/ui-popover.css +1 -1
  129. package/styles/ui-radio-group.css +1 -1
  130. package/styles/ui-radio.css +1 -1
  131. package/styles/ui-reel.css +1 -1
  132. package/styles/ui-scroll-area.css +1 -1
  133. package/styles/ui-search-result-row.css +1 -1
  134. package/styles/ui-search-shell.css +1 -1
  135. package/styles/ui-section.css +1 -1
  136. package/styles/ui-select.css +9 -4
  137. package/styles/ui-separator.css +1 -1
  138. package/styles/ui-sidebar.css +1 -1
  139. package/styles/ui-site-header.css +19 -19
  140. package/styles/ui-skeleton.css +1 -1
  141. package/styles/ui-slider.css +1 -1
  142. package/styles/ui-spinner.css +1 -1
  143. package/styles/ui-stack.css +1 -1
  144. package/styles/ui-status-message.css +1 -1
  145. package/styles/ui-swatch.css +1 -1
  146. package/styles/ui-switch.css +1 -1
  147. package/styles/ui-switcher.css +1 -1
  148. package/styles/ui-table.css +1 -1
  149. package/styles/ui-tabs.css +1 -1
  150. package/styles/ui-text.css +1 -1
  151. package/styles/ui-textarea.css +1 -1
  152. package/styles/ui-time-field.css +1 -0
  153. package/styles/ui-time-picker.css +1 -0
  154. package/styles/ui-toast-region.css +1 -1
  155. package/styles/ui-toast.css +1 -1
  156. package/styles/ui-tooltip.css +1 -1
  157. package/styles/ui-top-bar.css +1 -1
  158. package/styles/ui-tree-item.css +1 -1
  159. package/styles/ui-tree.css +1 -1
  160. package/tokens.css +4 -0
  161. package/vanilla/UiActionBar.d.ts +1 -1
  162. package/vanilla/UiActionBar.js +1 -1
  163. package/vanilla/UiAffordanceScope.d.ts +1 -1
  164. package/vanilla/UiAffordanceScope.js +1 -1
  165. package/vanilla/UiAvatar.d.ts +1 -1
  166. package/vanilla/UiAvatar.js +1 -1
  167. package/vanilla/UiAvatarGroup.d.ts +1 -1
  168. package/vanilla/UiAvatarGroup.js +1 -1
  169. package/vanilla/UiBadge.d.ts +1 -1
  170. package/vanilla/UiBadge.js +1 -1
  171. package/vanilla/UiBreadcrumbItem.d.ts +1 -1
  172. package/vanilla/UiBreadcrumbItem.js +1 -1
  173. package/vanilla/UiBreadcrumbs.d.ts +1 -1
  174. package/vanilla/UiBreadcrumbs.js +1 -1
  175. package/vanilla/UiButton.d.ts +2 -1
  176. package/vanilla/UiButton.js +128 -108
  177. package/vanilla/UiCalendar.d.ts +50 -0
  178. package/vanilla/UiCalendar.js +477 -0
  179. package/vanilla/UiCallout.d.ts +1 -1
  180. package/vanilla/UiCallout.js +1 -1
  181. package/vanilla/UiCard.d.ts +1 -1
  182. package/vanilla/UiCard.js +1 -1
  183. package/vanilla/UiCardGroup.d.ts +1 -1
  184. package/vanilla/UiCardGroup.js +1 -1
  185. package/vanilla/UiCheckbox.d.ts +1 -1
  186. package/vanilla/UiCheckbox.js +1 -1
  187. package/vanilla/UiCluster.d.ts +2 -2
  188. package/vanilla/UiCluster.js +2 -2
  189. package/vanilla/UiColorPicker.d.ts +1 -1
  190. package/vanilla/UiColorPicker.js +1 -1
  191. package/vanilla/UiCombobox.d.ts +1 -1
  192. package/vanilla/UiCombobox.js +1 -1
  193. package/vanilla/UiCompactContent.d.ts +1 -1
  194. package/vanilla/UiCompactContent.js +1 -1
  195. package/vanilla/UiCompactEditor.d.ts +1 -1
  196. package/vanilla/UiCompactEditor.js +1 -1
  197. package/vanilla/UiCompactMark.d.ts +1 -1
  198. package/vanilla/UiCompactMark.js +1 -1
  199. package/vanilla/UiCompactNode.d.ts +1 -1
  200. package/vanilla/UiCompactNode.js +1 -1
  201. package/vanilla/UiContainer.d.ts +1 -1
  202. package/vanilla/UiContainer.js +1 -1
  203. package/vanilla/UiContextMenu.d.ts +1 -1
  204. package/vanilla/UiContextMenu.js +1 -1
  205. package/vanilla/UiCover.d.ts +1 -1
  206. package/vanilla/UiCover.js +1 -1
  207. package/vanilla/UiCurveEditor.d.ts +1 -1
  208. package/vanilla/UiCurveEditor.js +1 -1
  209. package/vanilla/UiCycleButton.d.ts +1 -1
  210. package/vanilla/UiCycleButton.js +1 -1
  211. package/vanilla/UiDateField.d.ts +52 -0
  212. package/vanilla/UiDateField.js +208 -0
  213. package/vanilla/UiDatePicker.d.ts +63 -0
  214. package/vanilla/UiDatePicker.js +360 -0
  215. package/vanilla/UiDateRangePicker.d.ts +60 -0
  216. package/vanilla/UiDateRangePicker.js +418 -0
  217. package/vanilla/UiDescriptionItem.d.ts +1 -1
  218. package/vanilla/UiDescriptionItem.js +1 -1
  219. package/vanilla/UiDescriptionList.d.ts +1 -1
  220. package/vanilla/UiDescriptionList.js +1 -1
  221. package/vanilla/UiDialog.d.ts +1 -1
  222. package/vanilla/UiDialog.js +1 -1
  223. package/vanilla/UiDisclosure.d.ts +1 -1
  224. package/vanilla/UiDisclosure.js +1 -1
  225. package/vanilla/UiEditable.d.ts +1 -1
  226. package/vanilla/UiEditable.js +1 -1
  227. package/vanilla/UiEditor.d.ts +1 -1
  228. package/vanilla/UiEditor.js +1 -1
  229. package/vanilla/UiEditorBlockActions.d.ts +1 -1
  230. package/vanilla/UiEditorBlockActions.js +1 -1
  231. package/vanilla/UiEditorChipEditor.d.ts +1 -1
  232. package/vanilla/UiEditorChipEditor.js +1 -1
  233. package/vanilla/UiEditorCodeLanguage.d.ts +1 -1
  234. package/vanilla/UiEditorCodeLanguage.js +1 -1
  235. package/vanilla/UiEditorFootnoteEditor.d.ts +1 -1
  236. package/vanilla/UiEditorFootnoteEditor.js +1 -1
  237. package/vanilla/UiEditorFormattingTools.d.ts +1 -1
  238. package/vanilla/UiEditorFormattingTools.js +1 -1
  239. package/vanilla/UiEditorImageToolbar.d.ts +1 -1
  240. package/vanilla/UiEditorImageToolbar.js +1 -1
  241. package/vanilla/UiEditorInsertTableGrid.d.ts +1 -1
  242. package/vanilla/UiEditorInsertTableGrid.js +1 -1
  243. package/vanilla/UiEditorLinkCard.d.ts +1 -1
  244. package/vanilla/UiEditorLinkCard.js +1 -1
  245. package/vanilla/UiEditorLinkForm.d.ts +1 -1
  246. package/vanilla/UiEditorLinkForm.js +1 -1
  247. package/vanilla/UiEditorMentionMenu.d.ts +1 -1
  248. package/vanilla/UiEditorMentionMenu.js +1 -1
  249. package/vanilla/UiEditorMentionMenuItem.d.ts +1 -1
  250. package/vanilla/UiEditorMentionMenuItem.js +1 -1
  251. package/vanilla/UiEditorSlashMenu.d.ts +1 -1
  252. package/vanilla/UiEditorSlashMenu.js +1 -1
  253. package/vanilla/UiEditorSlashMenuGroup.d.ts +1 -1
  254. package/vanilla/UiEditorSlashMenuGroup.js +1 -1
  255. package/vanilla/UiEditorSlashMenuItem.d.ts +1 -1
  256. package/vanilla/UiEditorSlashMenuItem.js +1 -1
  257. package/vanilla/UiEditorSurface.d.ts +1 -1
  258. package/vanilla/UiEditorSurface.js +1 -1
  259. package/vanilla/UiEditorTableContextMenu.d.ts +1 -1
  260. package/vanilla/UiEditorTableContextMenu.js +1 -1
  261. package/vanilla/UiEditorTableOverlay.d.ts +1 -1
  262. package/vanilla/UiEditorTableOverlay.js +1 -1
  263. package/vanilla/UiEditorTableToolbar.d.ts +1 -1
  264. package/vanilla/UiEditorTableToolbar.js +1 -1
  265. package/vanilla/UiEditorToolbar.d.ts +1 -1
  266. package/vanilla/UiEditorToolbar.js +1 -1
  267. package/vanilla/UiFileInput.d.ts +36 -0
  268. package/vanilla/UiFileInput.js +209 -0
  269. package/vanilla/UiFloatingActionButton.d.ts +1 -1
  270. package/vanilla/UiFloatingActionButton.js +1 -1
  271. package/vanilla/UiFormField.d.ts +1 -1
  272. package/vanilla/UiFormField.js +1 -1
  273. package/vanilla/UiGrid.d.ts +7 -2
  274. package/vanilla/UiGrid.js +85 -19
  275. package/vanilla/UiIcon.d.ts +2 -1
  276. package/vanilla/UiIcon.js +10 -10
  277. package/vanilla/UiIconButton.d.ts +2 -2
  278. package/vanilla/UiIconButton.js +2 -2
  279. package/vanilla/UiImage.d.ts +1 -1
  280. package/vanilla/UiImage.js +1 -1
  281. package/vanilla/UiInput.d.ts +2 -1
  282. package/vanilla/UiInput.js +11 -11
  283. package/vanilla/UiInputGroup.d.ts +1 -1
  284. package/vanilla/UiInputGroup.js +1 -1
  285. package/vanilla/UiLightEditor.d.ts +1 -1
  286. package/vanilla/UiLightEditor.js +1 -1
  287. package/vanilla/UiList.d.ts +1 -1
  288. package/vanilla/UiList.js +1 -1
  289. package/vanilla/UiListItem.d.ts +1 -1
  290. package/vanilla/UiListItem.js +1 -1
  291. package/vanilla/UiListbox.d.ts +1 -1
  292. package/vanilla/UiListbox.js +1 -1
  293. package/vanilla/UiMenu.d.ts +1 -1
  294. package/vanilla/UiMenu.js +1 -1
  295. package/vanilla/UiMenuGroup.d.ts +1 -1
  296. package/vanilla/UiMenuGroup.js +1 -1
  297. package/vanilla/UiMenuItem.d.ts +1 -1
  298. package/vanilla/UiMenuItem.js +1 -1
  299. package/vanilla/UiMeter.d.ts +1 -1
  300. package/vanilla/UiMeter.js +1 -1
  301. package/vanilla/UiNavItem.d.ts +1 -1
  302. package/vanilla/UiNavItem.js +1 -1
  303. package/vanilla/UiNumberInput.d.ts +1 -1
  304. package/vanilla/UiNumberInput.js +1 -1
  305. package/vanilla/UiPageHeader.d.ts +1 -1
  306. package/vanilla/UiPageHeader.js +1 -1
  307. package/vanilla/UiPagination.d.ts +1 -1
  308. package/vanilla/UiPagination.js +1 -1
  309. package/vanilla/UiPopover.d.ts +2 -1
  310. package/vanilla/UiPopover.js +4 -4
  311. package/vanilla/UiRadio.d.ts +1 -1
  312. package/vanilla/UiRadio.js +1 -1
  313. package/vanilla/UiRadioGroup.d.ts +1 -1
  314. package/vanilla/UiRadioGroup.js +1 -1
  315. package/vanilla/UiReel.d.ts +1 -1
  316. package/vanilla/UiReel.js +1 -1
  317. package/vanilla/UiScrollArea.d.ts +1 -1
  318. package/vanilla/UiScrollArea.js +1 -1
  319. package/vanilla/UiSearchResultRow.d.ts +1 -1
  320. package/vanilla/UiSearchResultRow.js +1 -1
  321. package/vanilla/UiSearchShell.d.ts +1 -1
  322. package/vanilla/UiSearchShell.js +1 -1
  323. package/vanilla/UiSection.d.ts +1 -1
  324. package/vanilla/UiSection.js +1 -1
  325. package/vanilla/UiSelect.d.ts +1 -1
  326. package/vanilla/UiSelect.js +1 -1
  327. package/vanilla/UiSeparator.d.ts +1 -1
  328. package/vanilla/UiSeparator.js +1 -1
  329. package/vanilla/UiSidebar.d.ts +1 -1
  330. package/vanilla/UiSidebar.js +1 -1
  331. package/vanilla/UiSiteHeader.d.ts +1 -1
  332. package/vanilla/UiSiteHeader.js +1 -1
  333. package/vanilla/UiSkeleton.d.ts +1 -1
  334. package/vanilla/UiSkeleton.js +1 -1
  335. package/vanilla/UiSlider.d.ts +1 -1
  336. package/vanilla/UiSlider.js +1 -1
  337. package/vanilla/UiSpinner.d.ts +1 -1
  338. package/vanilla/UiSpinner.js +1 -1
  339. package/vanilla/UiStack.d.ts +1 -1
  340. package/vanilla/UiStack.js +1 -1
  341. package/vanilla/UiStatusMessage.d.ts +1 -1
  342. package/vanilla/UiStatusMessage.js +1 -1
  343. package/vanilla/UiSwatch.d.ts +1 -1
  344. package/vanilla/UiSwatch.js +1 -1
  345. package/vanilla/UiSwitch.d.ts +1 -1
  346. package/vanilla/UiSwitch.js +1 -1
  347. package/vanilla/UiSwitcher.d.ts +1 -1
  348. package/vanilla/UiSwitcher.js +1 -1
  349. package/vanilla/UiTable.d.ts +1 -1
  350. package/vanilla/UiTable.js +1 -1
  351. package/vanilla/UiTabs.d.ts +1 -1
  352. package/vanilla/UiTabs.js +1 -1
  353. package/vanilla/UiText.d.ts +1 -1
  354. package/vanilla/UiText.js +1 -1
  355. package/vanilla/UiTextarea.d.ts +1 -1
  356. package/vanilla/UiTextarea.js +1 -1
  357. package/vanilla/UiTimeField.d.ts +42 -0
  358. package/vanilla/UiTimeField.js +112 -0
  359. package/vanilla/UiTimePicker.d.ts +48 -0
  360. package/vanilla/UiTimePicker.js +372 -0
  361. package/vanilla/UiToast.d.ts +1 -1
  362. package/vanilla/UiToast.js +1 -1
  363. package/vanilla/UiToastRegion.d.ts +1 -1
  364. package/vanilla/UiToastRegion.js +1 -1
  365. package/vanilla/UiTooltip.d.ts +1 -1
  366. package/vanilla/UiTooltip.js +1 -1
  367. package/vanilla/UiTopBar.d.ts +1 -1
  368. package/vanilla/UiTopBar.js +1 -1
  369. package/vanilla/UiTree.d.ts +1 -1
  370. package/vanilla/UiTree.js +1 -1
  371. package/vanilla/UiTreeItem.d.ts +1 -1
  372. package/vanilla/UiTreeItem.js +1 -1
  373. package/vanilla/index.js +7 -0
@@ -0,0 +1,224 @@
1
+ import { preparedModule } from "../shared/prepared-module.js";
2
+ import { componentInputs } from "@nextwebwg/html-next/inputs";
3
+ import { calendarWeekStart, compileDateRules, isRangeAllowed, rangeFromSelection, updateRangeStart, updateRangeEnd } from "../shared/date-time.js";
4
+ import { rangeAvailability } from "../shared/date-range.js";
5
+ import { afterFormReset } from "../shared/form-reset.js";
6
+ import { externalValueTracker } from "../shared/external-value.js";
7
+ import { readOptionalInput } from "../shared/binding-inputs.js";
8
+ import { initialFieldValue } from "../shared/initial-field-value.js";
9
+
10
+ const ruleNames = ["min", "max", "allowedDates", "allowedRanges", "disabledDates", "disabledRanges", "disabledWeekdays"];
11
+ const endpoints = ["start", "end"];
12
+ const copy = value => ({ start: value?.start ?? "", end: value?.end ?? "" });
13
+ const signature = value => JSON.stringify([value.start, value.end]);
14
+
15
+ /** Coordinate independently typed endpoints and commit completed calendar selections. */
16
+ function interactions(host) {
17
+ const element = host.element;
18
+ const fields = Object.fromEntries(endpoints.map(name => [name, element.querySelector(`[data-range-field="${name}"]`)]));
19
+ const controls = Object.fromEntries(endpoints.map(name => [name, fields[name].querySelector("[data-date-editor]")]));
20
+ const values = Object.fromEntries(endpoints.map(name => [name, element.querySelector(`[data-range-value="${name}"]`)]));
21
+ const triggers = Object.fromEntries(endpoints.map(name => [name, element.querySelector(`[data-range-trigger="${name}"]`)]));
22
+ const popover = element.querySelector("[data-range-popover]");
23
+ const calendar = element.querySelector("[data-range-calendar]");
24
+ let current = copy(host.state.current ?? host.props.value.value);
25
+ const externalChanged = externalValueTracker(element, { initialValue: signature(copy(host.props.value.value)) });
26
+ let committed = signature(current);
27
+ let connected = true;
28
+ let setting = false;
29
+ let frame;
30
+ let lastTrigger = "keyboard";
31
+ const settings = () => Object.fromEntries(ruleNames.map(name => [name, host.props[name].value]));
32
+ const allowed = range => isRangeAllowed(range, compileDateRules(settings()), host.props.allowUnavailableWithinRange.value);
33
+ const blocked = () => host.props.disabled.value || host.props.readonly.value || Object.values(controls).some(control => control.matches(":disabled") || control.readOnly);
34
+ const report = (message, endpoint) => {
35
+ host.state.error = message;
36
+ host.dispatch("validation-change", { invalid: Boolean(message), message, ...(endpoint ? { endpoint } : {}) });
37
+ };
38
+ const accept = range => {
39
+ current = copy(range); host.state.current = current; host.state.draft = copy(range);
40
+ // FormData reads made by an input listener see the complete accepted pair.
41
+ for (const name of endpoints) values[name].value = current[name];
42
+ };
43
+ const change = trigger => {
44
+ const next = signature(current);
45
+ if (next === committed) return;
46
+ committed = next; host.dispatch("change", { value: copy(current), trigger });
47
+ };
48
+ const initial = Object.fromEntries(endpoints.map(name => [name, initialFieldValue(fields[name], { locale: host.props.locale.value })]));
49
+ const readable = endpoints.every(name => initial[name] !== undefined);
50
+ const startChanged = initial.start !== undefined && initial.start !== current.start;
51
+ const endChanged = initial.end !== undefined && initial.end !== current.end;
52
+ if (startChanged || endChanged) {
53
+ const range = readable && startChanged && !endChanged ? updateRangeStart(current, initial.start)
54
+ : readable && endChanged && !startChanged ? updateRangeEnd(current, initial.end)
55
+ : { start: initial.start ?? current.start, end: initial.end ?? current.end };
56
+ host.state.draft = copy(range);
57
+ if (readable && (!range.start && !range.end && !host.props.required.value || range.start && range.end && allowed(range))) {
58
+ accept(range); committed = signature(current);
59
+ }
60
+ }
61
+ const close = (restore = false, reason = "programmatic", trigger = "programmatic") => {
62
+ const wasOpen = host.state.opened;
63
+ host.state.opened = false; host.state.anchor = ""; host.state.error = "";
64
+ if (wasOpen) host.dispatch("close", { open: false, reason, trigger });
65
+ if (restore) {
66
+ cancelAnimationFrame(frame);
67
+ frame = requestAnimationFrame(() => { if (connected) element.ownerDocument.getElementById(host.state.activeAnchor)?.focus(); });
68
+ }
69
+ };
70
+ const replaceFields = range => {
71
+ setting = true;
72
+ try {
73
+ for (const name of endpoints) fields[name].dispatchEvent(new CustomEvent("set-value", { cancelable: true, detail: { value: range[name] } }));
74
+ } finally { setting = false; }
75
+ };
76
+ const edit = (name, value, trigger) => {
77
+ const range = (name === "start" ? updateRangeStart : updateRangeEnd)(host.state.draft, value);
78
+ host.state.draft = range;
79
+ const empty = !range.start && !range.end;
80
+ const complete = Boolean(range.start && range.end);
81
+ if (empty && !host.props.required.value || complete && allowed(range)) {
82
+ const changed = signature(range) !== signature(current);
83
+ accept(range); host.state.error = "";
84
+ if (changed) host.dispatch("input", { value: copy(current), trigger });
85
+ } else if (range.start && range.end) {
86
+ const message = "Choose a range with available endpoints and permitted interior dates.";
87
+ controls[name].setCustomValidity(message);
88
+ report(message, name);
89
+ }
90
+ };
91
+ const listeners = [];
92
+ const on = (target, name, run, options) => { target.addEventListener(name, run, options); listeners.push(() => target.removeEventListener(name, run, options)); };
93
+ for (const name of endpoints) {
94
+ on(controls[name], "input", event => { lastTrigger = event.isTrusted ? "keyboard" : "programmatic"; }, true);
95
+ on(controls[name], "focusout", () => change(lastTrigger));
96
+ for (const type of ["input", "change", "query-change", "validation-change"]) on(fields[name], type, event => {
97
+ if (!(event instanceof CustomEvent)) return;
98
+ event.stopPropagation();
99
+ if (setting) return;
100
+ if (type === "query-change") {
101
+ if (!event.detail.query && !blocked()) edit(name, "", lastTrigger);
102
+ host.dispatch(type, { endpoint: name, query: event.detail.query });
103
+ } else if (type === "validation-change") {
104
+ host.dispatch(type, { ...event.detail, endpoint: name });
105
+ } else if (!blocked()) {
106
+ lastTrigger = event.detail.trigger;
107
+ edit(name, event.detail.value, lastTrigger);
108
+ if (type === "change") change(lastTrigger);
109
+ }
110
+ });
111
+ on(triggers[name], "click", event => {
112
+ if (blocked()) return;
113
+ const trigger = event.detail === 0 ? "keyboard" : "pointer";
114
+ const anchorId = triggers[name].id;
115
+ if (host.state.opened && host.state.activeAnchor === anchorId) { close(false, "action", trigger); return; }
116
+ const range = copy(host.state.draft);
117
+ host.state.selection = range; host.state.preview = copy(range);
118
+ host.state.mode = range.start && range.end ? name : "range";
119
+ host.state.anchor = ""; host.state.popupValue = range[name] || range.start || range.end || "";
120
+ host.state.activeAnchor = anchorId; host.state.error = ""; host.state.opened = true;
121
+ host.dispatch("open", { open: true, reason: "action", trigger });
122
+ cancelAnimationFrame(frame);
123
+ frame = requestAnimationFrame(() => {
124
+ if (!connected || !host.state.opened) return;
125
+ const date = host.state.popupValue || host.props.today.value;
126
+ if (date) calendar.dispatchEvent(new CustomEvent("focus-date", { detail: { value: date } }));
127
+ else calendar.querySelector('[data-calendar-day][tabindex="0"], [data-calendar-days][tabindex="0"]')?.focus();
128
+ });
129
+ });
130
+ }
131
+ on(popover, "open", event => { if (event instanceof CustomEvent) event.stopPropagation(); });
132
+ on(popover, "close", event => {
133
+ if (!(event instanceof CustomEvent)) return;
134
+ event.stopPropagation(); close(event.detail.reason === "escape", event.detail.reason, event.detail.trigger);
135
+ });
136
+ // Calendar's scalar edits are local to this composition; range events report both endpoints.
137
+ for (const type of ["input", "change"]) on(calendar, type, event => event.stopPropagation());
138
+ const commitSelection = trigger => {
139
+ const range = copy(host.state.selection);
140
+ if (!allowed(range)) { report("Choose two available dates within the permitted range."); return; }
141
+ const changed = signature(range) !== signature(current);
142
+ accept(range); replaceFields(range);
143
+ if (changed) host.dispatch("input", { value: copy(current), trigger });
144
+ change(trigger); close(true, "action", trigger);
145
+ };
146
+ on(calendar, "select", event => {
147
+ event.stopPropagation();
148
+ if (!(event instanceof CustomEvent) || blocked()) return;
149
+ const value = event.detail.value;
150
+ let range;
151
+ if (host.state.mode === "range") {
152
+ if (!host.state.anchor) {
153
+ host.state.anchor = value; range = { start: value, end: "" };
154
+ } else {
155
+ range = rangeFromSelection(host.state.anchor, value);
156
+ if (!allowed(range)) { report("Choose a range with permitted interior dates."); return; }
157
+ host.state.anchor = "";
158
+ }
159
+ } else range = (host.state.mode === "start" ? updateRangeStart : updateRangeEnd)(host.state.selection, value);
160
+ host.state.selection = range; host.state.preview = copy(range); host.state.popupValue = value; host.state.error = "";
161
+ if (range.start && range.end) commitSelection(event.detail.trigger);
162
+ });
163
+ const preview = event => {
164
+ if (host.state.mode !== "range" || !host.state.anchor || !host.state.opened) return;
165
+ const day = event.target.closest?.("[data-calendar-day]");
166
+ if (!day || day.disabled) return;
167
+ const range = rangeFromSelection(host.state.anchor, day.dataset.calendarDay);
168
+ if (allowed(range) && signature(range) !== signature(host.state.preview)) host.state.preview = range;
169
+ };
170
+ // Pointer movement expresses a new pointer choice. DOM refreshes may fire
171
+ // pointerover under a stationary cursor and must not replace keyboard preview.
172
+ on(calendar, "pointermove", preview); on(calendar, "focusin", preview);
173
+ on(element, "validate", event => {
174
+ if (event.target !== element) return;
175
+ for (const field of Object.values(fields)) field.dispatchEvent(new Event("validate"));
176
+ });
177
+ const mutability = () => { host.state.blocked = Boolean(blocked()); if (blocked()) close(); };
178
+ const observer = new MutationObserver(mutability);
179
+ for (const control of Object.values(controls)) observer.observe(control, { attributes: true, attributeFilter: ["disabled", "readonly"] });
180
+ for (let ancestor = element.parentElement; ancestor; ancestor = ancestor.parentElement) {
181
+ if (ancestor.localName === "fieldset") observer.observe(ancestor, { attributes: true, attributeFilter: ["disabled"] });
182
+ }
183
+ if (!host.state.idPrefix) host.state.idPrefix = `ui-date-range-${Math.random().toString(36).slice(2, 11)}`;
184
+ const stop = host.effect(() => {
185
+ const value = copy(host.props.value.value);
186
+ if (externalChanged(signature(value)) && signature(value) !== signature(current)) {
187
+ committed = signature(value); accept(value); close();
188
+ }
189
+ host.state.enhanced = Boolean(host.props.model.value);
190
+ mutability();
191
+ });
192
+ const reset = afterFormReset(controls.start, () => {
193
+ accept(copy(host.props.value.value)); committed = signature(current); close(); replaceFields(current);
194
+ });
195
+ return () => {
196
+ connected = false; cancelAnimationFrame(frame); observer.disconnect(); stop(); reset();
197
+ for (const release of listeners) release();
198
+ host.state.opened = false; host.state.enhanced = false;
199
+ };
200
+ }
201
+
202
+ /** Prepare endpoint rules before rendering and retain their producer ownership through hydration. */
203
+ export const { connect, prepare, adopt } = preparedModule(host => {
204
+ const inputs = componentInputs(host);
205
+ return {
206
+ props: { model: {
207
+ input: (props, { state }) => ({
208
+ ...Object.fromEntries(ruleNames.filter(name => !name.startsWith("allowed")).map(name => [name, props[name]])),
209
+ ...Object.fromEntries(["allowedDates", "allowedRanges", "weekStartsOn"].map(name => [name, readOptionalInput(inputs, props, name)]).filter(([, value]) => value !== undefined)),
210
+ locale: props.locale, allowUnavailableWithinRange: props.allowUnavailableWithinRange,
211
+ range: state.draft, selection: state.selection, mode: state.mode, anchor: state.anchor,
212
+ }),
213
+ load(options) {
214
+ const rules = compileDateRules(options);
215
+ const configuration = { rules, allowUnavailableWithinRange: options.allowUnavailableWithinRange };
216
+ const fields = rangeAvailability(options.range, configuration);
217
+ const calendar = rangeAvailability(options.selection, { ...configuration, mode: options.mode, anchor: options.anchor });
218
+ return { ...fields, calendarRanges: calendar.calendarRanges,
219
+ weekStartsOn: calendarWeekStart(options.locale, options.weekStartsOn) };
220
+ },
221
+ } },
222
+ connect: interactions,
223
+ };
224
+ });
@@ -0,0 +1,15 @@
1
+ /** Native accept-style filters guide selection; they never replace server-side file validation. */
2
+ export function fileRejection(files, options = {}) {
3
+ if (!options.multiple && files.length > 1) return "Choose a single file.";
4
+ const accepted = (options.accept ?? "").split(",").map(value => value.trim().toLowerCase()).filter(Boolean);
5
+ for (const file of files) {
6
+ const name = file.name.toLowerCase();
7
+ const type = file.type.toLowerCase();
8
+ if (accepted.length && !accepted.some(rule => rule.startsWith(".") ? name.endsWith(rule)
9
+ : rule === "*/*" ? Boolean(type) : rule.endsWith("/*") ? type.startsWith(rule.slice(0, -1)) : type === rule)) {
10
+ return `${file.name}: choose a permitted file type.`;
11
+ }
12
+ if (options.maxFileSize !== undefined && options.maxFileSize !== null && file.size > options.maxFileSize) return `${file.name}: this file exceeds the permitted size.`;
13
+ }
14
+ return "";
15
+ }
@@ -0,0 +1,79 @@
1
+ <link rel="component" href="../ui-card/ui-card.html">
2
+ <link rel="component" href="../ui-input/ui-input.html">
3
+ <link rel="component" href="../ui-text/ui-text.html">
4
+ <link rel="component" href="../ui-list/ui-list.html">
5
+ <link rel="component" href="../ui-list-item/ui-list-item.html">
6
+ <link rel="component" href="../ui-icon-button/ui-icon-button.html">
7
+ <link rel="component" href="../ui-icon/ui-icon.html">
8
+ <template component="ui-file-input" module="./ui-file-input.js">
9
+ <defs>
10
+ <prop name="name" type="string" default=""
11
+ >Native form field name. Selected files submit as File entries; upload transport remains with the application.</prop>
12
+ <prop name="form" type="string" default="">Optional ID of a form outside the component's ancestor tree.</prop>
13
+ <prop name="inputId" type="string" default="">Optional native file input ID for an external label.</prop>
14
+ <prop name="label" type="string" default="Files">Visible heading and accessible name for the file input and group.</prop>
15
+ <prop name="accept" type="string" default=""
16
+ >Comma-separated extensions or MIME types, such as .pdf,image/*. Applies to browsing and dropping after upgrade; servers still validate files.</prop>
17
+ <prop name="multiple" type="boolean" default="false"
18
+ >Allows several files in one selection. A new browse or drop replaces the selection, matching the native input.</prop>
19
+ <prop name="maxFileSize" type="number" min="0">Optional per-file byte limit. Omit for no size restriction; an explicit zero permits only empty files.</prop>
20
+ <prop name="locale" type="string" default="en-US">Intl locale used to display file sizes.</prop>
21
+ <prop name="removeLabel" type="string" default="Remove">Accessible action prefix, followed by the file name.</prop>
22
+ <prop name="disabled" type="boolean" default="false">Prevents browsing, dropping and removal, and omits files from native submission.</prop>
23
+ <prop name="required" type="boolean" default="false">Requires at least one selected file for submission.</prop>
24
+ <prop name="invalid" type="boolean" default="false">External invalid appearance supplied by the application.</prop>
25
+ <state name="enhanced" type="boolean" value="false"></state>
26
+ <state name="dragging" type="boolean" value="false"></state>
27
+ <state name="invalidSelection" type="boolean" value="false"></state>
28
+ <state name="error" type="string" value=""></state>
29
+ <state name="files" type="list(object({ id: string, name: string, size: number }))" value="[]"></state>
30
+ <event name="change" type="object">
31
+ <prop name="files" type="list" required><prop type="unknown"></prop></prop>
32
+ <prop name="trigger" type="keyword" values="keyboard, pointer, programmatic" required></prop>
33
+ Accepted native File objects, in selection order. No requests or uploads are started.
34
+ </event>
35
+ <event name="reject" type="object">
36
+ <prop name="files" type="list" required><prop type="unknown"></prop></prop>
37
+ <prop name="message" type="string" required></prop>
38
+ A rejected proposal leaves the previous selection intact.
39
+ </event>
40
+ </defs>
41
+ <ui-card padding="sm" role="group" from:aria-label="$label" from:tone="{ true: 'accent', false: 'neutral' }[concat($dragging)]">
42
+ <ui-text weight="semibold">{$label}</ui-text>
43
+ <ui-text tone="secondary" from:hidden="not $enhanced"><slot>Drop files here, or choose files below.</slot></ui-text>
44
+ <ui-input
45
+ data-file-control
46
+ data-ui-field-control
47
+ type="file"
48
+ from:id="{ true: $inputId, false: null }[concat($inputId != '')]"
49
+ from:name="$name"
50
+ from:form="{ true: $form, false: null }[concat($form != '')]"
51
+ from:accept="$accept"
52
+ from:multiple="$multiple"
53
+ from:disabled="$disabled"
54
+ from:required="$required"
55
+ from:invalid="$invalid or $invalidSelection"
56
+ from:aria-label="$label"
57
+ ></ui-input>
58
+ <ui-list density="compact" from:hidden="not $files.0" from:aria-label="$label">
59
+ <template $each="file of $files" $key="$file.id">
60
+ <ui-list-item wrap align="title">
61
+ {$file.name}
62
+ <span slot="description">{format($file.size, 'unit', { unit: 'byte', unitDisplay: 'short', maximumFractionDigits: 0 }, $locale)}</span>
63
+ <ui-icon-button
64
+ slot="trailing"
65
+ data-file-remove
66
+ from:data-file-id="$file.id"
67
+ size="sm"
68
+ variant="ghost"
69
+ tone="neutral"
70
+ from:label="concat($removeLabel, ' ', $file.name)"
71
+ from:disabled="$disabled"
72
+ ><ui-icon name="x"></ui-icon></ui-icon-button>
73
+ </ui-list-item>
74
+ </template>
75
+ </ui-list>
76
+ <ui-text tone="danger" role="alert" from:hidden="$error = ''">{$error}</ui-text>
77
+ <slot name="footer"></slot>
78
+ </ui-card>
79
+ </template>
@@ -0,0 +1,108 @@
1
+ import { fileRejection } from "./files.js";
2
+ import { afterFormReset } from "../shared/form-reset.js";
3
+
4
+ /** Own native file selection and drag/drop; applications own every upload and its lifecycle. */
5
+ export function connect(host) {
6
+ const element = host.element;
7
+ const input = element.querySelector("[data-file-control]");
8
+ let selected = Array.from(input.files ?? []);
9
+ const ids = new WeakMap();
10
+ let nextId = 0;
11
+ let options;
12
+ let signature;
13
+ let depth = 0;
14
+ let validity = "";
15
+ let connected = true;
16
+ let trigger = "programmatic";
17
+ const blocked = () => input.matches(":disabled");
18
+ const id = file => { if (!ids.has(file)) ids.set(file, String(++nextId)); return ids.get(file); };
19
+ const paint = () => {
20
+ host.state.files = selected.map(file => ({ id: id(file), name: file.name, size: file.size }));
21
+ };
22
+ const setValidity = message => {
23
+ validity = message;
24
+ host.state.invalidSelection = Boolean(message);
25
+ input.setCustomValidity(message);
26
+ queueMicrotask(() => { if (connected) input.setCustomValidity(validity); });
27
+ };
28
+ const validate = (announce = false) => {
29
+ const previous = validity;
30
+ const message = fileRejection(selected, options) || (announce && input.required && !selected.length ? "Choose at least one file." : "");
31
+ setValidity(message);
32
+ if (announce || message || host.state.error === previous) host.state.error = message;
33
+ return !message;
34
+ };
35
+ const writeFiles = files => {
36
+ if (!files.length) { input.value = ""; return; }
37
+ const transfer = new input.ownerDocument.defaultView.DataTransfer();
38
+ for (const file of files) transfer.items.add(file);
39
+ input.files = transfer.files;
40
+ };
41
+ const propose = (files, source) => {
42
+ if (blocked()) return;
43
+ const message = fileRejection(files, options);
44
+ if (message) {
45
+ writeFiles(selected);
46
+ host.state.error = message;
47
+ input.setCustomValidity(validity);
48
+ queueMicrotask(() => { if (connected) input.setCustomValidity(validity); });
49
+ host.dispatch("reject", { files, message });
50
+ return;
51
+ }
52
+ writeFiles(files);
53
+ selected = files;
54
+ host.state.error = "";
55
+ paint(); validate(true);
56
+ host.dispatch("change", { files: [...selected], trigger: source });
57
+ };
58
+ const change = event => { event.stopPropagation(); propose(Array.from(input.files ?? []), trigger); };
59
+ const stopInput = event => event.stopPropagation();
60
+ const key = () => { trigger = "keyboard"; };
61
+ const pointer = () => { trigger = "pointer"; };
62
+ const invalid = () => { validate(true); };
63
+ const hasFiles = event => Array.from(event.dataTransfer?.types ?? []).includes("Files");
64
+ const enter = event => { if (hasFiles(event) && !blocked()) { depth++; host.state.dragging = true; } };
65
+ const leave = event => { if (hasFiles(event)) { depth = Math.max(0, depth - 1); host.state.dragging = depth > 0; } };
66
+ const over = event => {
67
+ if (!hasFiles(event)) return;
68
+ event.preventDefault();
69
+ event.dataTransfer.dropEffect = blocked() ? "none" : "copy";
70
+ };
71
+ const drop = event => {
72
+ if (!hasFiles(event)) return;
73
+ event.preventDefault(); depth = 0; host.state.dragging = false;
74
+ propose(Array.from(event.dataTransfer.files), "pointer");
75
+ };
76
+ const remove = event => {
77
+ const button = event.target.closest?.("[data-file-remove]");
78
+ if (!button || !element.contains(button) || blocked()) return;
79
+ const at = selected.findIndex(file => id(file) === button.getAttribute("data-file-id"));
80
+ if (at < 0) return;
81
+ propose(selected.filter((_, index) => index !== at), event.detail === 0 ? "keyboard" : "pointer");
82
+ queueMicrotask(() => {
83
+ if (!connected) return;
84
+ const buttons = element.querySelectorAll("[data-file-remove]");
85
+ (buttons[Math.min(at, buttons.length - 1)] ?? input).focus();
86
+ });
87
+ };
88
+ input.addEventListener("change", change); input.addEventListener("input", stopInput);
89
+ input.addEventListener("keydown", key); input.addEventListener("pointerdown", pointer); input.addEventListener("invalid", invalid);
90
+ element.addEventListener("dragenter", enter); element.addEventListener("dragleave", leave);
91
+ element.addEventListener("dragover", over); element.addEventListener("drop", drop); element.addEventListener("click", remove);
92
+ const stop = host.effect(() => {
93
+ const next = { multiple: host.props.multiple.value, accept: host.props.accept.value, maxFileSize: host.props.maxFileSize.value, locale: host.props.locale.value, required: host.props.required.value };
94
+ const nextSignature = JSON.stringify(next);
95
+ if (nextSignature === signature) return;
96
+ signature = nextSignature; options = next; paint(); validate();
97
+ });
98
+ host.state.enhanced = true;
99
+ const reset = afterFormReset(input, () => { selected = Array.from(input.files ?? []); host.state.error = ""; paint(); validate(); });
100
+ return () => {
101
+ connected = false; stop(); reset(); host.state.enhanced = false;
102
+ input.setCustomValidity("");
103
+ input.removeEventListener("change", change); input.removeEventListener("input", stopInput);
104
+ input.removeEventListener("keydown", key); input.removeEventListener("pointerdown", pointer); input.removeEventListener("invalid", invalid);
105
+ element.removeEventListener("dragenter", enter); element.removeEventListener("dragleave", leave);
106
+ element.removeEventListener("dragover", over); element.removeEventListener("drop", drop); element.removeEventListener("click", remove);
107
+ };
108
+ }
@@ -25,7 +25,7 @@ export function connect(host) {
25
25
  };
26
26
  const wire = () => {
27
27
  const label = element.querySelector('[slot="label"], label');
28
- const selector = "[data-ui-field-control], input:not([type=hidden]), textarea, select";
28
+ const selector = "[data-ui-field-control]:not([hidden]), input:not([type=hidden]):not([hidden]), textarea:not([hidden]), select:not([hidden])";
29
29
  const target = label?.getAttribute("for") ? element.ownerDocument.getElementById(label.getAttribute("for")) : null;
30
30
  const requested = target && element.contains(target) ? (target.matches(selector) ? target : target.querySelector(selector)) : null;
31
31
  const input = requested ?? element.querySelector(selector);
@@ -73,7 +73,7 @@ export function connect(host) {
73
73
  });
74
74
  };
75
75
  const observer = new MutationObserver(schedule);
76
- observer.observe(element, { childList: true, subtree: true, attributes: true, attributeFilter: ["aria-describedby", "slot", "id", "role"] });
76
+ observer.observe(element, { childList: true, subtree: true, attributes: true, attributeFilter: ["aria-describedby", "slot", "id", "role", "hidden"] });
77
77
  // Track props before deferred rewiring, even when no control is mounted yet.
78
78
  const stop = host.effect(() => {
79
79
  void host.props.disabled.value;
@@ -1,19 +1,46 @@
1
1
  <template component="ui-grid">
2
2
  <defs>
3
- <prop name="gap" type="keyword" values="xs, s, m, l, xl"
4
- >Space between cells, on the spacing scale: xs is 0.5rem, s 0.75rem, m 1rem (also the default), l 1.5rem, and xl 2rem. The --ui-grid-gap custom property,
5
- set on :root, an ancestor, or the component itself, overrides it.</prop>
3
+ <prop name="gap" type="keyword" values="none, xs, s, m, l, xl"
4
+ >Space between cells, on the spacing scale: none removes the gap, xs is 0.5rem, s 0.75rem, m 1rem (also the default), l 1.5rem, and xl 2rem. The
5
+ --ui-grid-gap custom property, set on :root, an ancestor, or the component itself, overrides it.</prop>
6
6
  <prop name="min" type="keyword" values="sm, md, lg"
7
7
  >The narrowest a column may get before the grid drops to fewer columns: sm is 12rem (also the default), md is 16rem, and lg is 20rem. The grid fits as many
8
8
  equal columns as its width allows, and a single column never overflows a narrower container.</prop>
9
9
  <prop name="columns" type="integer"
10
- >Maximum columns when there is room. Omit for no cap. The grid still drops columns as its container narrows; it never forces a fixed column count.</prop>
10
+ >Maximum columns when there is room. Omit for no cap. Columns normally decrease as the container narrows; fixed opts into an exact count.</prop>
11
+ <prop name="fixed" type="boolean" default="false"
12
+ >Keeps the declared columns at every width, for aligned matrices such as weekday grids. Cells share the available width; omitted columns gives one
13
+ column.</prop>
14
+ <prop name="shadedColumns" type="list(integer)" default="[]"
15
+ >One-based columns to shade in a fixed grid with explicit columns, such as nonworking days in a date matrix. A soft wash of the theme's ink distinguishes
16
+ them from the canvas; --ui-grid-shade-surface can replace it. Shading follows writing direction and does not change cell sizing.</prop>
17
+ <prop name="shadeTone" type="keyword" values="neutral, accent" default="neutral"
18
+ >The shaded columns' paint: neutral uses the theme's ink; accent uses its readable accent pigment. Both are subtle washes over the current surface.</prop>
19
+ <prop name="selectionStart" type="integer"
20
+ >First selected one-based column in a fixed grid row. Pair with selection-end to paint a continuous rounded interval behind the cells.</prop>
21
+ <prop name="selectionEnd" type="integer"
22
+ >Last selected one-based column, inclusive. The interval combines the theme's selection surface and border colors; --ui-grid-selection-inset and
23
+ --ui-grid-selection-surface customize its inset and paint.</prop>
11
24
  </defs>
12
- <div style:--_grid-column-cap="$columns"><slot></slot></div>
25
+ <!-- Keep decorations adjacent so an empty grid has no generated text cells. -->
26
+ <!-- markup-fmt-ignore -->
27
+ <div style:--_grid-column-cap="$columns" from:data-shaded="$fixed and ($shadedColumns.length > 0 or $selectionStart > 0)"><template $each="column of $shadedColumns"><span
28
+ $if="$fixed and $columns != null and $column > 0 and $column &lt;= $columns"
29
+ class="column-shade"
30
+ aria-hidden="true"
31
+ style:--_grid-shaded-column="$column"
32
+ ></span></template><span
33
+ $if="$fixed and $selectionStart > 0 and $selectionEnd >= $selectionStart and $selectionEnd &lt;= $columns"
34
+ class="selection-band"
35
+ aria-hidden="true"
36
+ style:--_grid-selection-start="$selectionStart"
37
+ style:--_grid-selection-end="$selectionEnd + 1"
38
+ ></span><slot></slot></div>
13
39
  <style>
14
40
  :host {
15
41
  --_grid-gap: var(--ui-space-4);
16
42
  --_grid-min: 12rem;
43
+ --_grid-shade-surface: color-mix(in oklab, var(--ui-text) 8%, transparent);
17
44
  display: grid !important;
18
45
  gap: var(--ui-grid-gap, var(--_grid-gap)) !important;
19
46
  grid-template-columns:
@@ -38,6 +65,48 @@
38
65
  :host([gap="xs"]) {
39
66
  --_grid-gap: var(--ui-space-2);
40
67
  }
68
+
69
+ :host([fixed]) {
70
+ grid-template-columns: repeat(max(1, var(--_grid-column-cap, 1)), minmax(0, 1fr)) !important;
71
+ }
72
+
73
+ :host[data-shaded] {
74
+ position: relative !important;
75
+ isolation: isolate;
76
+ }
77
+
78
+ :host([shadeTone="accent"]) {
79
+ --_grid-shade-surface: color-mix(in oklab, var(--ui-accent-subtle-text) 12%, transparent);
80
+ }
81
+
82
+ .column-shade {
83
+ position: absolute !important;
84
+ inset: 0 !important;
85
+ grid-column: var(--_grid-shaded-column) / span 1 !important;
86
+ z-index: -1;
87
+ pointer-events: none;
88
+ background-color: var(--ui-grid-shade-surface, var(--_grid-shade-surface));
89
+ }
90
+
91
+ .selection-band {
92
+ position: absolute !important;
93
+ grid-column: var(--_grid-selection-start) / var(--_grid-selection-end) !important;
94
+ inset: var(--ui-grid-selection-inset, var(--ui-space-1)) !important;
95
+ border-radius: var(--ui-radius-round);
96
+ background: var(
97
+ --ui-grid-selection-surface,
98
+ light-dark(
99
+ color-mix(in oklab, var(--ui-selection-border) 80%, var(--ui-selection-surface)),
100
+ color-mix(in oklab, var(--ui-selection-border) 28%, var(--ui-selection-surface))
101
+ )
102
+ );
103
+ pointer-events: none;
104
+ z-index: -1;
105
+ }
106
+
107
+ :host([gap="none"]) {
108
+ --_grid-gap: 0px;
109
+ }
41
110
  :host([gap="s"]) {
42
111
  --_grid-gap: var(--ui-space-3);
43
112
  }
@@ -5,6 +5,8 @@
5
5
  <prop name="name" type="string" default=""
6
6
  >Which icon to draw, by its name in Looma's icon set (LOOMA_ICONS), such as "align-left". An unknown or empty name draws nothing. The icon is hidden from
7
7
  assistive technology, so name the control it sits in.</prop>
8
+ <prop name="directional" type="boolean" default="false"
9
+ >Mirrors the glyph in RTL for logical previous/next actions. Leave off for icons whose left/right direction is literal.</prop>
8
10
  <!-- Derived from name as it renders, so every render path, a server render included, draws the icon without JavaScript. Generated from LOOMA_ICONS by tools/scripts/generate-icon-catalog.mjs. -->
9
11
  <computed
10
12
  name="shapes"
@@ -18,6 +20,7 @@
18
20
  'book-user': [{ tag: 'path', d: 'M15 13a3 3 0 1 0-6 0' }, { tag: 'path', d: 'M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20' }, { tag: 'circle', cx: '12', cy: '8', r: '2' }],
19
21
  'braces': [{ tag: 'path', d: 'M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1' }, { tag: 'path', d: 'M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1' }],
20
22
  'calculator': [{ tag: 'rect', width: '16', height: '20', x: '4', y: '2', rx: '2' }, { tag: 'line', x1: '8', x2: '16', y1: '6', y2: '6' }, { tag: 'line', x1: '16', x2: '16', y1: '14', y2: '18' }, { tag: 'path', d: 'M16 10h.01' }, { tag: 'path', d: 'M12 10h.01' }, { tag: 'path', d: 'M8 10h.01' }, { tag: 'path', d: 'M12 14h.01' }, { tag: 'path', d: 'M8 14h.01' }, { tag: 'path', d: 'M12 18h.01' }, { tag: 'path', d: 'M8 18h.01' }],
23
+ 'calendar': [{ tag: 'path', d: 'M8 2v4' }, { tag: 'path', d: 'M16 2v4' }, { tag: 'rect', width: '18', height: '18', x: '3', y: '4', rx: '2' }, { tag: 'path', d: 'M3 10h18' }, { tag: 'path', d: 'M8 14h.01' }, { tag: 'path', d: 'M12 14h.01' }, { tag: 'path', d: 'M16 14h.01' }, { tag: 'path', d: 'M8 18h.01' }, { tag: 'path', d: 'M12 18h.01' }, { tag: 'path', d: 'M16 18h.01' }],
21
24
  'check': [{ tag: 'path', d: 'M20 6 9 17l-5-5' }],
22
25
  'chevron-down': [{ tag: 'path', d: 'm6 9 6 6 6-6' }],
23
26
  'chevron-left': [{ tag: 'path', d: 'm15 18-6-6 6-6' }],
@@ -25,6 +28,7 @@
25
28
  'circle-check': [{ tag: 'circle', cx: '12', cy: '12', r: '10' }, { tag: 'path', d: 'm9 12 2 2 4-4' }],
26
29
  'circle-dot': [{ tag: 'circle', cx: '12', cy: '12', r: '10' }, { tag: 'circle', cx: '12', cy: '12', r: '1' }],
27
30
  'circle-x': [{ tag: 'circle', cx: '12', cy: '12', r: '10' }, { tag: 'path', d: 'm15 9-6 6' }, { tag: 'path', d: 'm9 9 6 6' }],
31
+ 'clock': [{ tag: 'path', d: 'M12 6v6l4 2' }, { tag: 'circle', cx: '12', cy: '12', r: '10' }],
28
32
  'code-xml': [{ tag: 'path', d: 'm18 16 4-4-4-4' }, { tag: 'path', d: 'm6 8-4 4 4 4' }, { tag: 'path', d: 'm14.5 4-5 16' }],
29
33
  'columns': [{ tag: 'rect', width: '18', height: '18', x: '3', y: '3', rx: '2' }, { tag: 'path', d: 'M9 3v18' }, { tag: 'path', d: 'M15 3v18' }],
30
34
  'compass': [{ tag: 'path', d: 'm16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z' }, { tag: 'circle', cx: '12', cy: '12', r: '10' }],
@@ -131,6 +135,10 @@
131
135
  color: var(--ui-text-muted);
132
136
  }
133
137
 
138
+ :host([directional]):dir(rtl) svg {
139
+ transform: scaleX(-1);
140
+ }
141
+
134
142
  svg {
135
143
  inline-size: 100%;
136
144
  block-size: 100%;