vira 32.0.0-beta.0 → 32.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/dist/elements/color/vira-all-color-space-sliders.element.d.ts +11 -0
  2. package/dist/elements/color/vira-all-color-space-sliders.element.js +55 -0
  3. package/dist/elements/color/vira-all-spaces-color-picker.element.d.ts +15 -0
  4. package/dist/elements/color/vira-all-spaces-color-picker.element.js +73 -0
  5. package/dist/elements/color/vira-color-details.element.d.ts +14 -0
  6. package/{src/elements/color/vira-color-details.element.ts → dist/elements/color/vira-color-details.element.js} +43 -59
  7. package/dist/elements/color/vira-color-format-sliders.element.d.ts +14 -0
  8. package/dist/elements/color/vira-color-format-sliders.element.js +60 -0
  9. package/dist/elements/color/vira-color-pair-contrast-summary.element.d.ts +9 -0
  10. package/{src/elements/color/vira-color-pair-contrast-summary.element.ts → dist/elements/color/vira-color-pair-contrast-summary.element.js} +68 -100
  11. package/dist/elements/color/vira-color-pair.element.d.ts +17 -0
  12. package/{src/elements/color/vira-color-pair.element.ts → dist/elements/color/vira-color-pair.element.js} +50 -71
  13. package/dist/elements/color/vira-color-picker.element.d.ts +20 -0
  14. package/{src/elements/color/vira-color-picker.element.ts → dist/elements/color/vira-color-picker.element.js} +92 -117
  15. package/dist/elements/color/vira-color-slider.element.d.ts +14 -0
  16. package/dist/elements/color/vira-color-slider.element.js +124 -0
  17. package/dist/elements/color/vira-color-swatch.element.d.ts +20 -0
  18. package/{src/elements/color/vira-color-swatch.element.ts → dist/elements/color/vira-color-swatch.element.js} +6 -16
  19. package/dist/elements/color/vira-contrast-indicator.element.d.ts +10 -0
  20. package/{src/elements/color/vira-contrast-indicator.element.ts → dist/elements/color/vira-contrast-indicator.element.js} +13 -28
  21. package/dist/elements/index.js +39 -0
  22. package/dist/elements/pop-up/vira-menu-item.element.d.ts +38 -0
  23. package/{src/elements/pop-up/vira-menu-item.element.ts → dist/elements/pop-up/vira-menu-item.element.js} +80 -117
  24. package/dist/elements/pop-up/vira-menu-trigger.element.d.ts +45 -0
  25. package/dist/elements/pop-up/vira-menu-trigger.element.js +100 -0
  26. package/dist/elements/pop-up/vira-menu.element.d.ts +36 -0
  27. package/{src/elements/pop-up/vira-menu.element.ts → dist/elements/pop-up/vira-menu.element.js} +28 -31
  28. package/dist/elements/pop-up/vira-pop-up-trigger.element.d.ts +109 -0
  29. package/dist/elements/pop-up/vira-pop-up-trigger.element.js +408 -0
  30. package/dist/elements/vira-absolute-time.element.d.ts +35 -0
  31. package/dist/elements/vira-absolute-time.element.js +43 -0
  32. package/dist/elements/vira-bold-text.element.d.ts +9 -0
  33. package/{src/elements/vira-bold-text.element.ts → dist/elements/vira-bold-text.element.js} +11 -10
  34. package/dist/elements/vira-button.element.d.ts +44 -0
  35. package/{src/elements/vira-button.element.ts → dist/elements/vira-button.element.js} +107 -255
  36. package/dist/elements/vira-card.element.d.ts +18 -0
  37. package/{src/elements/vira-card.element.ts → dist/elements/vira-card.element.js} +19 -18
  38. package/dist/elements/vira-checkbox.element.d.ts +44 -0
  39. package/{src/elements/vira-checkbox.element.ts → dist/elements/vira-checkbox.element.js} +48 -95
  40. package/dist/elements/vira-collapsible-card.element.d.ts +36 -0
  41. package/{src/elements/vira-collapsible-card.element.ts → dist/elements/vira-collapsible-card.element.js} +44 -71
  42. package/dist/elements/vira-collapsible-wrapper.element.d.ts +30 -0
  43. package/{src/elements/vira-collapsible-wrapper.element.ts → dist/elements/vira-collapsible-wrapper.element.js} +47 -59
  44. package/dist/elements/vira-date-input.element.d.ts +47 -0
  45. package/dist/elements/vira-date-input.element.js +142 -0
  46. package/dist/elements/vira-drawer.element.d.ts +24 -0
  47. package/{src/elements/vira-drawer.element.ts → dist/elements/vira-drawer.element.js} +98 -125
  48. package/dist/elements/vira-dropdown.element.d.ts +43 -0
  49. package/dist/elements/vira-dropdown.element.js +247 -0
  50. package/dist/elements/vira-error.element.d.ts +7 -0
  51. package/{src/elements/vira-error.element.ts → dist/elements/vira-error.element.js} +7 -8
  52. package/dist/elements/vira-form.element.d.ts +56 -0
  53. package/dist/elements/vira-form.element.js +376 -0
  54. package/dist/elements/vira-icon.element.d.ts +13 -0
  55. package/{src/elements/vira-icon.element.ts → dist/elements/vira-icon.element.js} +12 -16
  56. package/dist/elements/vira-image.element.d.ts +45 -0
  57. package/{src/elements/vira-image.element.ts → dist/elements/vira-image.element.js} +50 -70
  58. package/dist/elements/vira-input.element.d.ts +64 -0
  59. package/{src/elements/vira-input.element.ts → dist/elements/vira-input.element.js} +112 -167
  60. package/dist/elements/vira-json-form.element.d.ts +35 -0
  61. package/{src/elements/vira-json-form.element.ts → dist/elements/vira-json-form.element.js} +356 -522
  62. package/dist/elements/vira-link.element.d.ts +78 -0
  63. package/{src/elements/vira-link.element.ts → dist/elements/vira-link.element.js} +24 -83
  64. package/dist/elements/vira-modal.element.d.ts +40 -0
  65. package/{src/elements/vira-modal.element.ts → dist/elements/vira-modal.element.js} +68 -104
  66. package/dist/elements/vira-progress.element.d.ts +18 -0
  67. package/{src/elements/vira-progress.element.ts → dist/elements/vira-progress.element.js} +12 -25
  68. package/dist/elements/vira-relative-time.element.d.ts +42 -0
  69. package/dist/elements/vira-relative-time.element.js +96 -0
  70. package/dist/elements/vira-select.element.d.ts +44 -0
  71. package/{src/elements/vira-select.element.ts → dist/elements/vira-select.element.js} +89 -138
  72. package/dist/elements/vira-tabs.element.d.ts +124 -0
  73. package/{src/elements/vira-tabs.element.ts → dist/elements/vira-tabs.element.js} +242 -446
  74. package/dist/elements/vira-tag.element.d.ts +40 -0
  75. package/{src/elements/vira-tag.element.ts → dist/elements/vira-tag.element.js} +152 -266
  76. package/dist/elements/vira-text-area.element.d.ts +48 -0
  77. package/{src/elements/vira-text-area.element.ts → dist/elements/vira-text-area.element.js} +52 -70
  78. package/dist/elements/vira-theme-switcher.element.d.ts +17 -0
  79. package/{src/elements/vira-theme-switcher.element.ts → dist/elements/vira-theme-switcher.element.js} +34 -49
  80. package/dist/icons/colored-icon.d.ts +11 -0
  81. package/{src/icons/colored-icon.ts → dist/icons/colored-icon.js} +17 -24
  82. package/dist/icons/icon-css-vars.d.ts +14 -0
  83. package/{src/icons/icon-css-vars.ts → dist/icons/icon-css-vars.js} +1 -2
  84. package/{src/icons/icon-svg.ts → dist/icons/icon-svg.d.ts} +3 -15
  85. package/dist/icons/icon-svg.js +12 -0
  86. package/dist/icons/icon-svgs/16/check-16.icon.d.ts +8 -0
  87. package/{src/icons/icon-svgs/16/check-16.icon.ts → dist/icons/icon-svgs/16/check-16.icon.js} +4 -5
  88. package/dist/icons/icon-svgs/16/chevron-down-16.icon.d.ts +8 -0
  89. package/{src/icons/icon-svgs/16/chevron-down-16.icon.ts → dist/icons/icon-svgs/16/chevron-down-16.icon.js} +4 -5
  90. package/dist/icons/icon-svgs/16/chevron-up-16.icon.d.ts +8 -0
  91. package/{src/icons/icon-svgs/16/chevron-up-16.icon.ts → dist/icons/icon-svgs/16/chevron-up-16.icon.js} +4 -5
  92. package/dist/icons/icon-svgs/16/dash-16.icon.d.ts +8 -0
  93. package/{src/icons/icon-svgs/16/dash-16.icon.ts → dist/icons/icon-svgs/16/dash-16.icon.js} +4 -5
  94. package/dist/icons/icon-svgs/16/element-16.icon.d.ts +8 -0
  95. package/{src/icons/icon-svgs/16/element-16.icon.ts → dist/icons/icon-svgs/16/element-16.icon.js} +4 -5
  96. package/dist/icons/icon-svgs/16/plus-16.icon.d.ts +8 -0
  97. package/{src/icons/icon-svgs/16/plus-16.icon.ts → dist/icons/icon-svgs/16/plus-16.icon.js} +4 -5
  98. package/dist/icons/icon-svgs/16/upload-16.icon.d.ts +8 -0
  99. package/{src/icons/icon-svgs/16/upload-16.icon.ts → dist/icons/icon-svgs/16/upload-16.icon.js} +4 -5
  100. package/dist/icons/icon-svgs/16/x-16.icon.d.ts +8 -0
  101. package/{src/icons/icon-svgs/16/x-16.icon.ts → dist/icons/icon-svgs/16/x-16.icon.js} +4 -5
  102. package/dist/icons/icon-svgs/24/arrow-down-24.icon.d.ts +8 -0
  103. package/{src/icons/icon-svgs/24/arrow-down-24.icon.ts → dist/icons/icon-svgs/24/arrow-down-24.icon.js} +4 -5
  104. package/dist/icons/icon-svgs/24/arrow-left-24.icon.d.ts +8 -0
  105. package/{src/icons/icon-svgs/24/arrow-left-24.icon.ts → dist/icons/icon-svgs/24/arrow-left-24.icon.js} +4 -5
  106. package/dist/icons/icon-svgs/24/arrow-right-24.icon.d.ts +8 -0
  107. package/{src/icons/icon-svgs/24/arrow-right-24.icon.ts → dist/icons/icon-svgs/24/arrow-right-24.icon.js} +4 -5
  108. package/dist/icons/icon-svgs/24/arrow-up-24.icon.d.ts +8 -0
  109. package/{src/icons/icon-svgs/24/arrow-up-24.icon.ts → dist/icons/icon-svgs/24/arrow-up-24.icon.js} +4 -5
  110. package/dist/icons/icon-svgs/24/auto-theme-24.icon.d.ts +8 -0
  111. package/{src/icons/icon-svgs/24/auto-theme-24.icon.ts → dist/icons/icon-svgs/24/auto-theme-24.icon.js} +4 -5
  112. package/dist/icons/icon-svgs/24/bell-24.icon.d.ts +8 -0
  113. package/{src/icons/icon-svgs/24/bell-24.icon.ts → dist/icons/icon-svgs/24/bell-24.icon.js} +4 -5
  114. package/dist/icons/icon-svgs/24/chat-24.icon.d.ts +8 -0
  115. package/{src/icons/icon-svgs/24/chat-24.icon.ts → dist/icons/icon-svgs/24/chat-24.icon.js} +4 -5
  116. package/dist/icons/icon-svgs/24/check-24.icon.d.ts +8 -0
  117. package/{src/icons/icon-svgs/24/check-24.icon.ts → dist/icons/icon-svgs/24/check-24.icon.js} +4 -5
  118. package/dist/icons/icon-svgs/24/chevron-down-24.icon.d.ts +8 -0
  119. package/{src/icons/icon-svgs/24/chevron-down-24.icon.ts → dist/icons/icon-svgs/24/chevron-down-24.icon.js} +4 -5
  120. package/dist/icons/icon-svgs/24/chevron-up-24.icon.d.ts +8 -0
  121. package/{src/icons/icon-svgs/24/chevron-up-24.icon.ts → dist/icons/icon-svgs/24/chevron-up-24.icon.js} +4 -5
  122. package/dist/icons/icon-svgs/24/close-x-24.icon.d.ts +8 -0
  123. package/{src/icons/icon-svgs/24/close-x-24.icon.ts → dist/icons/icon-svgs/24/close-x-24.icon.js} +4 -5
  124. package/dist/icons/icon-svgs/24/commit-24.icon.d.ts +8 -0
  125. package/{src/icons/icon-svgs/24/commit-24.icon.ts → dist/icons/icon-svgs/24/commit-24.icon.js} +4 -5
  126. package/dist/icons/icon-svgs/24/copy-24.icon.d.ts +8 -0
  127. package/{src/icons/icon-svgs/24/copy-24.icon.ts → dist/icons/icon-svgs/24/copy-24.icon.js} +4 -5
  128. package/dist/icons/icon-svgs/24/document-24.icon.d.ts +8 -0
  129. package/{src/icons/icon-svgs/24/document-24.icon.ts → dist/icons/icon-svgs/24/document-24.icon.js} +4 -5
  130. package/dist/icons/icon-svgs/24/document-search-24.icon.d.ts +8 -0
  131. package/{src/icons/icon-svgs/24/document-search-24.icon.ts → dist/icons/icon-svgs/24/document-search-24.icon.js} +4 -5
  132. package/dist/icons/icon-svgs/24/double-chevron-24.icon.d.ts +8 -0
  133. package/{src/icons/icon-svgs/24/double-chevron-24.icon.ts → dist/icons/icon-svgs/24/double-chevron-24.icon.js} +4 -5
  134. package/dist/icons/icon-svgs/24/element-24.icon.d.ts +8 -0
  135. package/{src/icons/icon-svgs/24/element-24.icon.ts → dist/icons/icon-svgs/24/element-24.icon.js} +4 -5
  136. package/dist/icons/icon-svgs/24/external-link-24.icon.d.ts +8 -0
  137. package/{src/icons/icon-svgs/24/external-link-24.icon.ts → dist/icons/icon-svgs/24/external-link-24.icon.js} +4 -5
  138. package/dist/icons/icon-svgs/24/eye-closed-24.icon.d.ts +8 -0
  139. package/{src/icons/icon-svgs/24/eye-closed-24.icon.ts → dist/icons/icon-svgs/24/eye-closed-24.icon.js} +4 -5
  140. package/dist/icons/icon-svgs/24/eye-open-24.icon.d.ts +8 -0
  141. package/{src/icons/icon-svgs/24/eye-open-24.icon.ts → dist/icons/icon-svgs/24/eye-open-24.icon.js} +4 -5
  142. package/dist/icons/icon-svgs/24/filter-24.icon.d.ts +8 -0
  143. package/{src/icons/icon-svgs/24/filter-24.icon.ts → dist/icons/icon-svgs/24/filter-24.icon.js} +4 -5
  144. package/dist/icons/icon-svgs/24/globe-24.icon.d.ts +8 -0
  145. package/{src/icons/icon-svgs/24/globe-24.icon.ts → dist/icons/icon-svgs/24/globe-24.icon.js} +4 -5
  146. package/dist/icons/icon-svgs/24/link-24.icon.d.ts +8 -0
  147. package/{src/icons/icon-svgs/24/link-24.icon.ts → dist/icons/icon-svgs/24/link-24.icon.js} +4 -5
  148. package/dist/icons/icon-svgs/24/loader-24.icon.d.ts +8 -0
  149. package/{src/icons/icon-svgs/24/loader-24.icon.ts → dist/icons/icon-svgs/24/loader-24.icon.js} +4 -5
  150. package/dist/icons/icon-svgs/24/loader-animated-24.icon.d.ts +8 -0
  151. package/{src/icons/icon-svgs/24/loader-animated-24.icon.ts → dist/icons/icon-svgs/24/loader-animated-24.icon.js} +6 -8
  152. package/dist/icons/icon-svgs/24/lock-24.icon.d.ts +8 -0
  153. package/{src/icons/icon-svgs/24/lock-24.icon.ts → dist/icons/icon-svgs/24/lock-24.icon.js} +4 -5
  154. package/dist/icons/icon-svgs/24/magnifying-glass-24.icon.d.ts +8 -0
  155. package/{src/icons/icon-svgs/24/magnifying-glass-24.icon.ts → dist/icons/icon-svgs/24/magnifying-glass-24.icon.js} +4 -5
  156. package/dist/icons/icon-svgs/24/moon-24.icon.d.ts +8 -0
  157. package/{src/icons/icon-svgs/24/moon-24.icon.ts → dist/icons/icon-svgs/24/moon-24.icon.js} +4 -5
  158. package/dist/icons/icon-svgs/24/options-24.icon.d.ts +8 -0
  159. package/{src/icons/icon-svgs/24/options-24.icon.ts → dist/icons/icon-svgs/24/options-24.icon.js} +4 -5
  160. package/dist/icons/icon-svgs/24/pencil-24.icon.d.ts +8 -0
  161. package/{src/icons/icon-svgs/24/pencil-24.icon.ts → dist/icons/icon-svgs/24/pencil-24.icon.js} +4 -5
  162. package/dist/icons/icon-svgs/24/plus-24.icon.d.ts +8 -0
  163. package/{src/icons/icon-svgs/24/plus-24.icon.ts → dist/icons/icon-svgs/24/plus-24.icon.js} +4 -5
  164. package/dist/icons/icon-svgs/24/printer-24.icon.d.ts +8 -0
  165. package/{src/icons/icon-svgs/24/printer-24.icon.ts → dist/icons/icon-svgs/24/printer-24.icon.js} +4 -5
  166. package/dist/icons/icon-svgs/24/shield-24.icon.d.ts +8 -0
  167. package/{src/icons/icon-svgs/24/shield-24.icon.ts → dist/icons/icon-svgs/24/shield-24.icon.js} +4 -5
  168. package/dist/icons/icon-svgs/24/sort-ascending-24.icon.d.ts +8 -0
  169. package/{src/icons/icon-svgs/24/sort-ascending-24.icon.ts → dist/icons/icon-svgs/24/sort-ascending-24.icon.js} +4 -5
  170. package/dist/icons/icon-svgs/24/sort-descending-24.icon.d.ts +8 -0
  171. package/{src/icons/icon-svgs/24/sort-descending-24.icon.ts → dist/icons/icon-svgs/24/sort-descending-24.icon.js} +4 -5
  172. package/dist/icons/icon-svgs/24/sparkle-24.icon.d.ts +8 -0
  173. package/{src/icons/icon-svgs/24/sparkle-24.icon.ts → dist/icons/icon-svgs/24/sparkle-24.icon.js} +4 -5
  174. package/dist/icons/icon-svgs/24/speaker-loud-24.icon.d.ts +8 -0
  175. package/{src/icons/icon-svgs/24/speaker-loud-24.icon.ts → dist/icons/icon-svgs/24/speaker-loud-24.icon.js} +4 -5
  176. package/dist/icons/icon-svgs/24/speaker-medium-24.icon.d.ts +8 -0
  177. package/{src/icons/icon-svgs/24/speaker-medium-24.icon.ts → dist/icons/icon-svgs/24/speaker-medium-24.icon.js} +4 -5
  178. package/dist/icons/icon-svgs/24/speaker-muted-24.icon.d.ts +8 -0
  179. package/{src/icons/icon-svgs/24/speaker-muted-24.icon.ts → dist/icons/icon-svgs/24/speaker-muted-24.icon.js} +4 -5
  180. package/dist/icons/icon-svgs/24/speaker-quiet-24.icon.d.ts +8 -0
  181. package/{src/icons/icon-svgs/24/speaker-quiet-24.icon.ts → dist/icons/icon-svgs/24/speaker-quiet-24.icon.js} +4 -5
  182. package/dist/icons/icon-svgs/24/star-24.icon.d.ts +8 -0
  183. package/{src/icons/icon-svgs/24/star-24.icon.ts → dist/icons/icon-svgs/24/star-24.icon.js} +4 -5
  184. package/dist/icons/icon-svgs/24/status-failure-24.icon.d.ts +8 -0
  185. package/{src/icons/icon-svgs/24/status-failure-24.icon.ts → dist/icons/icon-svgs/24/status-failure-24.icon.js} +4 -5
  186. package/dist/icons/icon-svgs/24/status-in-progress-24.icon.d.ts +8 -0
  187. package/{src/icons/icon-svgs/24/status-in-progress-24.icon.ts → dist/icons/icon-svgs/24/status-in-progress-24.icon.js} +4 -5
  188. package/dist/icons/icon-svgs/24/status-success-24.icon.d.ts +8 -0
  189. package/{src/icons/icon-svgs/24/status-success-24.icon.ts → dist/icons/icon-svgs/24/status-success-24.icon.js} +4 -5
  190. package/dist/icons/icon-svgs/24/status-unknown-24.icon.d.ts +8 -0
  191. package/{src/icons/icon-svgs/24/status-unknown-24.icon.ts → dist/icons/icon-svgs/24/status-unknown-24.icon.js} +4 -5
  192. package/dist/icons/icon-svgs/24/status-warning-24.icon.d.ts +8 -0
  193. package/{src/icons/icon-svgs/24/status-warning-24.icon.ts → dist/icons/icon-svgs/24/status-warning-24.icon.js} +4 -5
  194. package/dist/icons/icon-svgs/24/sun-24.icon.d.ts +8 -0
  195. package/{src/icons/icon-svgs/24/sun-24.icon.ts → dist/icons/icon-svgs/24/sun-24.icon.js} +4 -5
  196. package/dist/icons/icon-svgs/24/upload-24.icon.d.ts +8 -0
  197. package/{src/icons/icon-svgs/24/upload-24.icon.ts → dist/icons/icon-svgs/24/upload-24.icon.js} +4 -5
  198. package/dist/icons/icon-svgs/24/x-24.icon.d.ts +8 -0
  199. package/{src/icons/icon-svgs/24/x-24.icon.ts → dist/icons/icon-svgs/24/x-24.icon.js} +4 -5
  200. package/dist/icons/index.d.ts +197 -0
  201. package/{src/icons/index.ts → dist/icons/index.js} +60 -65
  202. package/dist/icons/lucide-icons.d.ts +15 -0
  203. package/dist/icons/lucide-icons.js +79 -0
  204. package/dist/icons/sized-icon.d.ts +8 -0
  205. package/{src/icons/sized-icon.ts → dist/icons/sized-icon.js} +1 -3
  206. package/dist/index.js +4 -0
  207. package/dist/styles/disabled.d.ts +6 -0
  208. package/{src/styles/disabled.ts → dist/styles/disabled.js} +2 -3
  209. package/dist/styles/durations.d.ts +22 -0
  210. package/{src/styles/durations.ts → dist/styles/durations.js} +1 -2
  211. package/dist/styles/focus.d.ts +26 -0
  212. package/{src/styles/focus.ts → dist/styles/focus.js} +12 -40
  213. package/dist/styles/font.d.ts +12 -0
  214. package/{src/styles/font.ts → dist/styles/font.js} +1 -3
  215. package/dist/styles/form-styles.d.ts +46 -0
  216. package/dist/styles/form-styles.js +53 -0
  217. package/dist/styles/form-variants.d.ts +117 -0
  218. package/{src/styles/form-variants.ts → dist/styles/form-variants.js} +34 -42
  219. package/{src/styles/index.ts → dist/styles/index.d.ts} +0 -1
  220. package/dist/styles/index.js +14 -0
  221. package/dist/styles/native-styles.d.ts +13 -0
  222. package/{src/styles/native-styles.ts → dist/styles/native-styles.js} +3 -5
  223. package/dist/styles/scrollbar.d.ts +6 -0
  224. package/{src/styles/scrollbar.ts → dist/styles/scrollbar.js} +3 -4
  225. package/dist/styles/shadows.d.ts +19 -0
  226. package/{src/styles/shadows.ts → dist/styles/shadows.js} +5 -7
  227. package/dist/styles/user-select.d.ts +6 -0
  228. package/{src/styles/user-select.ts → dist/styles/user-select.js} +2 -3
  229. package/dist/styles/vira-color-palette.d.ts +178 -0
  230. package/{src/styles/vira-color-palette.ts → dist/styles/vira-color-palette.js} +1 -3
  231. package/dist/styles/vira-color-theme-object.d.ts +65 -0
  232. package/dist/styles/vira-color-theme-object.js +65 -0
  233. package/dist/styles/vira-color-theme.d.ts +2785 -0
  234. package/{src/styles/vira-color-theme.ts → dist/styles/vira-color-theme.js} +1222 -1227
  235. package/dist/util/color-local-storage.client.d.ts +4 -0
  236. package/dist/util/color-local-storage.client.js +6 -0
  237. package/dist/util/define-table.d.ts +115 -0
  238. package/dist/util/define-table.js +115 -0
  239. package/dist/util/define-vira-element.d.ts +18 -0
  240. package/dist/util/define-vira-element.js +19 -0
  241. package/dist/util/dynamic-element.d.ts +62 -0
  242. package/dist/util/dynamic-element.js +61 -0
  243. package/dist/util/index.js +11 -0
  244. package/dist/util/overflow-observer.d.ts +25 -0
  245. package/{src/util/overflow-observer.ts → dist/util/overflow-observer.js} +1 -30
  246. package/dist/util/pop-up-helpers.d.ts +59 -0
  247. package/dist/util/pop-up-helpers.js +66 -0
  248. package/dist/util/pop-up-manager.d.ts +200 -0
  249. package/dist/util/pop-up-manager.js +258 -0
  250. package/dist/util/shared-text-input-logic.d.ts +69 -0
  251. package/dist/util/shared-text-input-logic.js +114 -0
  252. package/dist/util/vira-form-fields.d.ts +145 -0
  253. package/dist/util/vira-form-fields.js +66 -0
  254. package/dist/util/vira-json-schema.d.ts +206 -0
  255. package/{src/util/vira-json-schema.ts → dist/util/vira-json-schema.js} +155 -298
  256. package/{src/util/vira-select-option.ts → dist/util/vira-select-option.d.ts} +2 -9
  257. package/dist/util/vira-select-option.js +8 -0
  258. package/dist/util/vira-theme-client.d.ts +83 -0
  259. package/dist/util/vira-theme-client.js +93 -0
  260. package/package.json +13 -13
  261. package/src/elements/color/vira-all-color-space-sliders.element.ts +0 -66
  262. package/src/elements/color/vira-all-spaces-color-picker.element.ts +0 -85
  263. package/src/elements/color/vira-color-format-sliders.element.ts +0 -78
  264. package/src/elements/color/vira-color-slider.element.ts +0 -169
  265. package/src/elements/pop-up/vira-menu-trigger.element.ts +0 -135
  266. package/src/elements/pop-up/vira-pop-up-trigger.element.ts +0 -539
  267. package/src/elements/vira-absolute-time.element.ts +0 -81
  268. package/src/elements/vira-date-input.element.ts +0 -185
  269. package/src/elements/vira-dropdown.element.ts +0 -310
  270. package/src/elements/vira-form.element.ts +0 -466
  271. package/src/elements/vira-relative-time.element.ts +0 -135
  272. package/src/icons/icon-color.test-helper.ts +0 -9
  273. package/src/icons/lucide-icons.ts +0 -120
  274. package/src/styles/form-styles.ts +0 -86
  275. package/src/styles/vira-color-palette.json +0 -170
  276. package/src/styles/vira-color-theme-object.ts +0 -170
  277. package/src/util/color-local-storage.client.ts +0 -7
  278. package/src/util/define-table.ts +0 -286
  279. package/src/util/define-vira-element.ts +0 -29
  280. package/src/util/dynamic-element.ts +0 -128
  281. package/src/util/pop-up-helpers.ts +0 -133
  282. package/src/util/pop-up-manager.ts +0 -434
  283. package/src/util/shared-text-input-logic.ts +0 -192
  284. package/src/util/vira-form-fields.ts +0 -195
  285. package/src/util/vira-theme-client.ts +0 -140
  286. /package/{src/elements/index.ts → dist/elements/index.d.ts} +0 -0
  287. /package/{src/index.ts → dist/index.d.ts} +0 -0
  288. /package/{src/util/index.ts → dist/util/index.d.ts} +0 -0
@@ -1,44 +1,26 @@
1
- import {assertWrap, check} from '@augment-vir/assert';
2
- import {omitObjectKeys, removeDuplicates, removePrefix, type JsonValue} from '@augment-vir/common';
3
- import {type JSONSchema} from 'json-schema-to-ts';
4
-
5
- /**
6
- * The JSON Schema type used by `ViraJsonForm`. Re-exported from `json-schema-to-ts` so that callers
7
- * can pass standard JSON Schema objects.
8
- *
9
- * @category Internal
10
- */
11
- export type ViraJsonSchema = JSONSchema;
12
-
13
- /**
14
- * A non-boolean JSON Schema object. Boolean schemas (`true` / `false`) are valid JSON Schemas but
15
- * don't constrain the editor in useful ways, so we normalize them away during traversal.
16
- *
17
- * @category Internal
18
- */
19
- export type ViraJsonSchemaObject = Exclude<ViraJsonSchema, boolean>;
20
-
1
+ import { assertWrap, check } from '@augment-vir/assert';
2
+ import { omitObjectKeys, removeDuplicates, removePrefix } from '@augment-vir/common';
21
3
  /**
22
4
  * The JSON types supported by `ViraJsonForm`.
23
5
  *
24
6
  * @category Internal
25
7
  */
26
- export enum ViraJsonType {
27
- String = 'string',
28
- Number = 'number',
29
- Integer = 'integer',
30
- Boolean = 'boolean',
31
- Null = 'null',
32
- Object = 'object',
33
- Array = 'array',
34
- }
35
-
8
+ export var ViraJsonType;
9
+ (function (ViraJsonType) {
10
+ ViraJsonType["String"] = "string";
11
+ ViraJsonType["Number"] = "number";
12
+ ViraJsonType["Integer"] = "integer";
13
+ ViraJsonType["Boolean"] = "boolean";
14
+ ViraJsonType["Null"] = "null";
15
+ ViraJsonType["Object"] = "object";
16
+ ViraJsonType["Array"] = "array";
17
+ })(ViraJsonType || (ViraJsonType = {}));
36
18
  /**
37
19
  * Human-friendly labels for each {@link ViraJsonType}.
38
20
  *
39
21
  * @category Internal
40
22
  */
41
- export const viraJsonTypeLabels: Readonly<Record<ViraJsonType, string>> = {
23
+ export const viraJsonTypeLabels = {
42
24
  [ViraJsonType.String]: 'string',
43
25
  [ViraJsonType.Number]: 'number',
44
26
  [ViraJsonType.Integer]: 'integer',
@@ -47,8 +29,7 @@ export const viraJsonTypeLabels: Readonly<Record<ViraJsonType, string>> = {
47
29
  [ViraJsonType.Object]: 'object',
48
30
  [ViraJsonType.Array]: 'array',
49
31
  };
50
-
51
- const allJsonTypes: ReadonlyArray<ViraJsonType> = [
32
+ const allJsonTypes = [
52
33
  ViraJsonType.String,
53
34
  ViraJsonType.Number,
54
35
  ViraJsonType.Integer,
@@ -57,7 +38,6 @@ const allJsonTypes: ReadonlyArray<ViraJsonType> = [
57
38
  ViraJsonType.Object,
58
39
  ViraJsonType.Array,
59
40
  ];
60
-
61
41
  /**
62
42
  * Classifies a JSON value's runtime type. Note that {@link ViraJsonType.Integer} is never returned;
63
43
  * it only appears in schemas. All numbers (whole or fractional) classify as
@@ -65,101 +45,83 @@ const allJsonTypes: ReadonlyArray<ViraJsonType> = [
65
45
  *
66
46
  * @category Internal
67
47
  */
68
- export function getJsonType(value: JsonValue | undefined): ViraJsonType {
48
+ export function getJsonType(value) {
69
49
  if (value === null) {
70
50
  return ViraJsonType.Null;
71
- } else if (check.isArray(value)) {
51
+ }
52
+ else if (check.isArray(value)) {
72
53
  return ViraJsonType.Array;
73
- } else if (check.isObject(value)) {
54
+ }
55
+ else if (check.isObject(value)) {
74
56
  return ViraJsonType.Object;
75
- } else if (check.isBoolean(value)) {
57
+ }
58
+ else if (check.isBoolean(value)) {
76
59
  return ViraJsonType.Boolean;
77
- } else if (check.isNumber(value)) {
60
+ }
61
+ else if (check.isNumber(value)) {
78
62
  return ViraJsonType.Number;
79
- } else {
63
+ }
64
+ else {
80
65
  return ViraJsonType.String;
81
66
  }
82
67
  }
83
-
84
68
  /**
85
69
  * Normalizes a schema to a non-boolean object form. `true` becomes an unconstrained schema (`{}`),
86
70
  * `false` becomes `undefined` (nothing is allowed; treated as "no schema available").
87
71
  *
88
72
  * @category Internal
89
73
  */
90
- export function normalizeSchema(
91
- schema: ViraJsonSchema | undefined,
92
- ): ViraJsonSchemaObject | undefined {
93
- if (schema === undefined || schema === false) {
74
+ export function normalizeSchema(schema) {
75
+ if (schema == undefined || schema === false) {
94
76
  return undefined;
95
- } else if (schema === true) {
77
+ }
78
+ else if (schema === true) {
96
79
  return {};
97
- } else {
80
+ }
81
+ else {
98
82
  return schema;
99
83
  }
100
84
  }
101
-
102
- function jsonTypeFromSchemaType(type: string): ViraJsonType | undefined {
103
- if (allJsonTypes.includes(type as ViraJsonType)) {
104
- return type as ViraJsonType;
85
+ function jsonTypeFromSchemaType(type) {
86
+ if (allJsonTypes.includes(type)) {
87
+ return type;
105
88
  }
106
89
  return undefined;
107
90
  }
108
-
109
- /**
110
- * Context used while resolving `$ref` entries against a root schema's `$defs` (or `definitions`)
111
- * map. A stack of seen refs prevents infinite recursion from cyclical schemas.
112
- *
113
- * @category Internal
114
- */
115
- export type SchemaResolveContext = {
116
- root: ViraJsonSchemaObject | undefined;
117
- seenRefs: ReadonlySet<string>;
118
- };
119
-
120
91
  /** @category Internal */
121
- export function createResolveContext(schema: ViraJsonSchema | undefined): SchemaResolveContext {
92
+ export function createResolveContext(schema) {
122
93
  return {
123
94
  root: normalizeSchema(schema),
124
95
  seenRefs: new Set(),
125
96
  };
126
97
  }
127
-
128
- function resolveRef(
129
- ref: string,
130
- context: SchemaResolveContext,
131
- ): {resolved: ViraJsonSchemaObject | undefined; context: SchemaResolveContext} {
98
+ function resolveRef(ref, context) {
132
99
  if (context.seenRefs.has(ref) || !context.root) {
133
100
  return {
134
101
  resolved: undefined,
135
102
  context,
136
103
  };
137
104
  }
138
-
139
105
  const defsKey = ref.startsWith('#/$defs/')
140
106
  ? removePrefix({
141
- value: ref,
142
- prefix: '#/$defs/',
143
- })
107
+ value: ref,
108
+ prefix: '#/$defs/',
109
+ })
144
110
  : ref.startsWith('#/definitions/')
145
- ? removePrefix({
111
+ ? removePrefix({
146
112
  value: ref,
147
113
  prefix: '#/definitions/',
148
114
  })
149
- : undefined;
150
-
115
+ : undefined;
151
116
  if (!defsKey) {
152
117
  return {
153
118
  resolved: undefined,
154
119
  context,
155
120
  };
156
121
  }
157
-
158
- const defsRecord =
159
- (context.root as {$defs?: Record<string, ViraJsonSchema>}).$defs ??
160
- (context.root as {definitions?: Record<string, ViraJsonSchema>}).definitions;
122
+ const defsRecord = context.root.$defs ??
123
+ context.root.definitions;
161
124
  const resolved = normalizeSchema(defsRecord?.[defsKey]);
162
-
163
125
  return {
164
126
  resolved,
165
127
  context: {
@@ -171,17 +133,13 @@ function resolveRef(
171
133
  },
172
134
  };
173
135
  }
174
-
175
136
  /**
176
137
  * Resolves a schema through `$ref` (via its root's `$defs`/`definitions`), returning the resolved
177
138
  * schema and an updated resolve context. Non-ref schemas are returned as-is.
178
139
  *
179
140
  * @category Internal
180
141
  */
181
- export function resolveSchema(
182
- schema: ViraJsonSchema | undefined,
183
- context: SchemaResolveContext,
184
- ): {resolved: ViraJsonSchemaObject | undefined; context: SchemaResolveContext} {
142
+ export function resolveSchema(schema, context) {
185
143
  const normalized = normalizeSchema(schema);
186
144
  if (!normalized) {
187
145
  return {
@@ -189,7 +147,7 @@ export function resolveSchema(
189
147
  context,
190
148
  };
191
149
  }
192
- const ref = (normalized as {$ref?: string}).$ref;
150
+ const ref = normalized.$ref;
193
151
  if (check.isString(ref)) {
194
152
  return resolveRef(ref, context);
195
153
  }
@@ -198,24 +156,20 @@ export function resolveSchema(
198
156
  context,
199
157
  };
200
158
  }
201
-
202
159
  /**
203
160
  * Flattens `anyOf` / `oneOf` branches into a single list of non-union schemas so that the editor
204
161
  * can treat them uniformly.
205
162
  *
206
163
  * @category Internal
207
164
  */
208
- export function expandSchemaBranches(
209
- schema: ViraJsonSchema | undefined,
210
- context: SchemaResolveContext,
211
- ): ReadonlyArray<ViraJsonSchemaObject> {
212
- const {resolved} = resolveSchema(schema, context);
165
+ export function expandSchemaBranches(schema, context) {
166
+ const { resolved } = resolveSchema(schema, context);
213
167
  if (!resolved) {
214
168
  return [];
215
169
  }
216
170
  const branches = [
217
- ...((resolved as {anyOf?: ReadonlyArray<ViraJsonSchema>}).anyOf ?? []),
218
- ...((resolved as {oneOf?: ReadonlyArray<ViraJsonSchema>}).oneOf ?? []),
171
+ ...(resolved.anyOf ?? []),
172
+ ...(resolved.oneOf ?? []),
219
173
  ];
220
174
  if (branches.length === 0) {
221
175
  return [resolved];
@@ -227,41 +181,39 @@ export function expandSchemaBranches(
227
181
  });
228
182
  });
229
183
  }
230
-
231
184
  /**
232
185
  * Computes the set of JSON types that a given schema allows.
233
186
  *
234
187
  * @category Internal
235
188
  */
236
- export function getAllowedJsonTypes(
237
- schema: ViraJsonSchema | undefined,
238
- context: SchemaResolveContext,
239
- ): ReadonlyArray<ViraJsonType> {
189
+ export function getAllowedJsonTypes(schema, context) {
240
190
  const branches = expandSchemaBranches(schema, context);
241
191
  if (branches.length === 0) {
242
192
  return allJsonTypes;
243
193
  }
244
- const collected: ViraJsonType[] = [];
194
+ const collected = [];
245
195
  for (const branch of branches) {
246
196
  const schemaType = branch.type;
247
197
  if (schemaType == undefined) {
248
198
  if ('const' in branch || 'enum' in branch) {
249
- const source =
250
- 'enum' in branch && check.isArray(branch.enum) ? branch.enum : [branch.const];
199
+ const source = 'enum' in branch && check.isArray(branch.enum) ? branch.enum : [branch.const];
251
200
  for (const entry of source) {
252
- collected.push(getJsonType(entry as JsonValue | undefined));
201
+ collected.push(getJsonType(entry));
253
202
  }
254
- } else {
203
+ }
204
+ else {
255
205
  return allJsonTypes;
256
206
  }
257
- } else if (check.isArray(schemaType)) {
207
+ }
208
+ else if (check.isArray(schemaType)) {
258
209
  for (const entry of schemaType) {
259
210
  const mapped = jsonTypeFromSchemaType(entry);
260
211
  if (mapped) {
261
212
  collected.push(mapped);
262
213
  }
263
214
  }
264
- } else {
215
+ }
216
+ else {
265
217
  const mapped = jsonTypeFromSchemaType(schemaType);
266
218
  if (mapped) {
267
219
  collected.push(mapped);
@@ -270,10 +222,9 @@ export function getAllowedJsonTypes(
270
222
  }
271
223
  return removeDuplicates(collected);
272
224
  }
273
-
274
225
  /** @category Internal */
275
- export function createDefaultForJsonType(type: ViraJsonType): JsonValue {
276
- const defaults: Readonly<Record<ViraJsonType, JsonValue>> = {
226
+ export function createDefaultForJsonType(type) {
227
+ const defaults = {
277
228
  [ViraJsonType.String]: '',
278
229
  [ViraJsonType.Number]: 0,
279
230
  [ViraJsonType.Integer]: 0,
@@ -284,18 +235,13 @@ export function createDefaultForJsonType(type: ViraJsonType): JsonValue {
284
235
  };
285
236
  return defaults[type];
286
237
  }
287
-
288
238
  /**
289
239
  * Picks the first schema branch whose `type` contains (or is) the given JSON type. Used to narrow
290
240
  * the schema when traversing into a concrete value.
291
241
  *
292
242
  * @category Internal
293
243
  */
294
- export function pickBranchForType(
295
- schema: ViraJsonSchema | undefined,
296
- valueType: ViraJsonType,
297
- context: SchemaResolveContext,
298
- ): ViraJsonSchemaObject | undefined {
244
+ export function pickBranchForType(schema, valueType, context) {
299
245
  const branches = expandSchemaBranches(schema, context);
300
246
  for (const branch of branches) {
301
247
  const branchTypes = getAllowedJsonTypes(branch, context);
@@ -303,12 +249,11 @@ export function pickBranchForType(
303
249
  return branch;
304
250
  }
305
251
  }
306
- const numericFallback =
307
- valueType === ViraJsonType.Number
308
- ? ViraJsonType.Integer
309
- : valueType === ViraJsonType.Integer
310
- ? ViraJsonType.Number
311
- : undefined;
252
+ const numericFallback = valueType === ViraJsonType.Number
253
+ ? ViraJsonType.Integer
254
+ : valueType === ViraJsonType.Integer
255
+ ? ViraJsonType.Number
256
+ : undefined;
312
257
  if (numericFallback) {
313
258
  for (const branch of branches) {
314
259
  const branchTypes = getAllowedJsonTypes(branch, context);
@@ -319,55 +264,43 @@ export function pickBranchForType(
319
264
  }
320
265
  return branches[0];
321
266
  }
322
-
323
267
  /**
324
268
  * Finds the sub-schema for a given object property key, considering `properties`,
325
269
  * `patternProperties`, and `additionalProperties`.
326
270
  *
327
271
  * @category Internal
328
272
  */
329
- export function getPropertySchema(
330
- parentSchema: ViraJsonSchema | undefined,
331
- key: string,
332
- context: SchemaResolveContext,
333
- ): ViraJsonSchema | undefined {
273
+ export function getPropertySchema(parentSchema, key, context) {
334
274
  const branch = pickBranchForType(parentSchema, ViraJsonType.Object, context);
335
275
  if (!branch) {
336
276
  return undefined;
337
277
  }
338
278
  const propertySchema = branch.properties?.[key];
339
- if (propertySchema !== undefined) {
279
+ if (propertySchema != undefined) {
340
280
  return propertySchema;
341
281
  }
342
282
  const patternProperties = branch.patternProperties;
343
283
  if (patternProperties) {
344
- for (const [
345
- pattern,
346
- subSchema,
347
- ] of Object.entries(patternProperties)) {
284
+ for (const [pattern, subSchema,] of Object.entries(patternProperties)) {
348
285
  try {
349
286
  if (new RegExp(pattern).test(key)) {
350
287
  return subSchema;
351
288
  }
352
- } catch {
289
+ }
290
+ catch {
353
291
  continue;
354
292
  }
355
293
  }
356
294
  }
357
295
  return branch.additionalProperties;
358
296
  }
359
-
360
297
  /**
361
298
  * Finds the sub-schema for an array item at a given index, considering tuple `items` arrays and
362
299
  * `additionalItems` fallbacks.
363
300
  *
364
301
  * @category Internal
365
302
  */
366
- export function getItemSchema(
367
- parentSchema: ViraJsonSchema | undefined,
368
- index: number,
369
- context: SchemaResolveContext,
370
- ): ViraJsonSchema | undefined {
303
+ export function getItemSchema(parentSchema, index, context) {
371
304
  const branch = pickBranchForType(parentSchema, ViraJsonType.Array, context);
372
305
  if (!branch) {
373
306
  return undefined;
@@ -378,21 +311,15 @@ export function getItemSchema(
378
311
  }
379
312
  return items;
380
313
  }
381
-
382
314
  /**
383
315
  * Returns the schema used when appending a new item to an array. Falls back to `additionalItems`
384
316
  * when `items` is a tuple array and the new index is beyond the tuple's length.
385
317
  *
386
318
  * @category Internal
387
319
  */
388
- export function getNewItemSchema(
389
- parentSchema: ViraJsonSchema | undefined,
390
- currentLength: number,
391
- context: SchemaResolveContext,
392
- ): ViraJsonSchema | undefined {
320
+ export function getNewItemSchema(parentSchema, currentLength, context) {
393
321
  return getItemSchema(parentSchema, currentLength, context);
394
322
  }
395
-
396
323
  /**
397
324
  * Returns the schema used when adding an arbitrary new field to an object. When no schema is
398
325
  * provided at all the editor is unconstrained, so additions are allowed; once a schema is provided,
@@ -402,11 +329,8 @@ export function getNewItemSchema(
402
329
  *
403
330
  * @category Internal
404
331
  */
405
- export function getAdditionalPropertiesSchema(
406
- parentSchema: ViraJsonSchema | undefined,
407
- context: SchemaResolveContext,
408
- ): {allowed: boolean; schema: ViraJsonSchema | undefined} {
409
- if (parentSchema === undefined) {
332
+ export function getAdditionalPropertiesSchema(parentSchema, context) {
333
+ if (parentSchema == undefined) {
410
334
  return {
411
335
  allowed: true,
412
336
  schema: undefined,
@@ -420,7 +344,7 @@ export function getAdditionalPropertiesSchema(
420
344
  };
421
345
  }
422
346
  const additional = branch.additionalProperties;
423
- if (additional === undefined || additional === false) {
347
+ if (additional == undefined || additional === false) {
424
348
  return {
425
349
  allowed: false,
426
350
  schema: undefined,
@@ -431,36 +355,33 @@ export function getAdditionalPropertiesSchema(
431
355
  schema: additional === true ? undefined : additional,
432
356
  };
433
357
  }
434
-
435
358
  /**
436
359
  * Returns the `enum` values defined by any resolved branch of a schema. Aggregates across
437
360
  * `anyOf`/`oneOf` branches and includes `const` values so the editor can offer them as a select.
438
361
  *
439
362
  * @category Internal
440
363
  */
441
- export function getSchemaEnumValues(
442
- schema: ViraJsonSchema | undefined,
443
- context: SchemaResolveContext,
444
- ): ReadonlyArray<JsonValue> | undefined {
364
+ export function getSchemaEnumValues(schema, context) {
445
365
  const branches = expandSchemaBranches(schema, context);
446
366
  if (branches.length === 0) {
447
367
  return undefined;
448
368
  }
449
- const collected: JsonValue[] = [];
369
+ const collected = [];
450
370
  for (const branch of branches) {
451
371
  if ('enum' in branch && check.isArray(branch.enum)) {
452
372
  for (const entry of branch.enum) {
453
- collected.push(entry as JsonValue);
373
+ collected.push(entry);
454
374
  }
455
- } else if ('const' in branch) {
456
- collected.push(branch.const as JsonValue);
457
- } else {
375
+ }
376
+ else if ('const' in branch) {
377
+ collected.push(branch.const);
378
+ }
379
+ else {
458
380
  return undefined;
459
381
  }
460
382
  }
461
383
  return collected.length > 0 ? collected : undefined;
462
384
  }
463
-
464
385
  /**
465
386
  * Collects the string `enum`/`const` values declared by any branch of a schema, ignoring branches
466
387
  * that declare no enum/const. Unlike {@link getSchemaEnumValues}, a schema that mixes an enum branch
@@ -469,23 +390,21 @@ export function getSchemaEnumValues(
469
390
  *
470
391
  * @category Internal
471
392
  */
472
- export function getStringEnumValues(
473
- schema: ViraJsonSchema | undefined,
474
- context: SchemaResolveContext,
475
- ): ReadonlyArray<string> {
393
+ export function getStringEnumValues(schema, context) {
476
394
  const branches = expandSchemaBranches(schema, context);
477
- const values = branches.flatMap((branch): ReadonlyArray<string> => {
395
+ const values = branches.flatMap((branch) => {
478
396
  if ('enum' in branch && check.isArray(branch.enum)) {
479
397
  return branch.enum.filter(check.isString);
480
- } else if ('const' in branch && check.isString(branch.const)) {
398
+ }
399
+ else if ('const' in branch && check.isString(branch.const)) {
481
400
  return [branch.const];
482
- } else {
401
+ }
402
+ else {
483
403
  return [];
484
404
  }
485
405
  });
486
406
  return removeDuplicates(values);
487
407
  }
488
-
489
408
  /**
490
409
  * Returns whether the schema permits an arbitrary (non-enum, non-const) string in any of its
491
410
  * branches. Used alongside {@link getStringEnumValues} to detect fields that accept both a fixed set
@@ -493,10 +412,7 @@ export function getStringEnumValues(
493
412
  *
494
413
  * @category Internal
495
414
  */
496
- export function allowsFreeformString(
497
- schema: ViraJsonSchema | undefined,
498
- context: SchemaResolveContext,
499
- ): boolean {
415
+ export function allowsFreeformString(schema, context) {
500
416
  return expandSchemaBranches(schema, context).some((branch) => {
501
417
  if ('enum' in branch || 'const' in branch) {
502
418
  return false;
@@ -504,43 +420,31 @@ export function allowsFreeformString(
504
420
  return getAllowedJsonTypes(branch, context).includes(ViraJsonType.String);
505
421
  });
506
422
  }
507
-
508
423
  /**
509
424
  * Returns the list of required property names declared by the object branch of a schema.
510
425
  *
511
426
  * @category Internal
512
427
  */
513
- export function getRequiredProperties(
514
- schema: ViraJsonSchema | undefined,
515
- context: SchemaResolveContext,
516
- ): ReadonlyArray<string> {
428
+ export function getRequiredProperties(schema, context) {
517
429
  const branch = pickBranchForType(schema, ViraJsonType.Object, context);
518
430
  return branch?.required ?? [];
519
431
  }
520
-
521
432
  /**
522
433
  * Returns the `properties` map declared by the object branch of a schema, or an empty record when
523
434
  * none is defined.
524
435
  *
525
436
  * @category Internal
526
437
  */
527
- export function getDefinedProperties(
528
- schema: ViraJsonSchema | undefined,
529
- context: SchemaResolveContext,
530
- ): Readonly<Record<string, ViraJsonSchema>> {
438
+ export function getDefinedProperties(schema, context) {
531
439
  const branch = pickBranchForType(schema, ViraJsonType.Object, context);
532
440
  return branch?.properties ?? {};
533
441
  }
534
-
535
442
  /**
536
443
  * Reads the title of a schema's first resolved branch (for display purposes).
537
444
  *
538
445
  * @category Internal
539
446
  */
540
- export function getSchemaTitle(
541
- schema: ViraJsonSchema | undefined,
542
- context: SchemaResolveContext,
543
- ): string | undefined {
447
+ export function getSchemaTitle(schema, context) {
544
448
  const branches = expandSchemaBranches(schema, context);
545
449
  for (const branch of branches) {
546
450
  if (check.isString(branch.title)) {
@@ -549,8 +453,7 @@ export function getSchemaTitle(
549
453
  }
550
454
  return undefined;
551
455
  }
552
-
553
- function formatPathLabel(path: ViraJsonPath): string {
456
+ function formatPathLabel(path) {
554
457
  if (path.length === 0) {
555
458
  return 'root';
556
459
  }
@@ -559,14 +462,12 @@ function formatPathLabel(path: ViraJsonPath): string {
559
462
  .join('')
560
463
  .replace(/^\./, '');
561
464
  }
562
-
563
- function isJsonValueMatchingType(value: JsonValue, type: ViraJsonType): boolean {
465
+ function isJsonValueMatchingType(value, type) {
564
466
  if (type === ViraJsonType.Integer) {
565
467
  return check.isNumber(value) && Number.isInteger(value);
566
468
  }
567
469
  return getJsonType(value) === type;
568
470
  }
569
-
570
471
  /**
571
472
  * Validates a JSON value against the (loose) JSON Schema subset supported by `ViraJsonForm`.
572
473
  * Returns a list of human-readable error messages; an empty array means the value is valid. Only
@@ -575,15 +476,12 @@ function isJsonValueMatchingType(value: JsonValue, type: ViraJsonType): boolean
575
476
  *
576
477
  * @category Internal
577
478
  */
578
- export function validateAgainstSchema(
579
- value: JsonValue,
580
- schema: ViraJsonSchema | undefined,
581
- ): ReadonlyArray<string> {
582
- if (schema === undefined) {
479
+ export function validateAgainstSchema(value, schema) {
480
+ if (schema == undefined) {
583
481
  return [];
584
482
  }
585
483
  const context = createResolveContext(schema);
586
- const errors: string[] = [];
484
+ const errors = [];
587
485
  validateRecursive({
588
486
  value,
589
487
  schema,
@@ -593,27 +491,14 @@ export function validateAgainstSchema(
593
491
  });
594
492
  return errors;
595
493
  }
596
-
597
- function validateRecursive({
598
- value,
599
- schema,
600
- path,
601
- context,
602
- errors,
603
- }: Readonly<{
604
- value: JsonValue;
605
- schema: ViraJsonSchema | undefined;
606
- path: ViraJsonPath;
607
- context: SchemaResolveContext;
608
- errors: string[];
609
- }>): void {
494
+ function validateRecursive({ value, schema, path, context, errors, }) {
610
495
  const branches = expandSchemaBranches(schema, context);
611
496
  if (branches.length === 0) {
612
497
  return;
613
498
  }
614
- const branchErrorSets: string[][] = [];
499
+ const branchErrorSets = [];
615
500
  for (const branch of branches) {
616
- const branchErrors: string[] = [];
501
+ const branchErrors = [];
617
502
  validateBranch({
618
503
  value,
619
504
  branch,
@@ -628,49 +513,29 @@ function validateRecursive({
628
513
  }
629
514
  if (branches.length === 1) {
630
515
  errors.push(...assertWrap.isDefined(branchErrorSets[0]));
631
- } else {
632
- errors.push(
633
- `${formatPathLabel(path)} did not match any allowed schema branch (anyOf/oneOf).`,
634
- );
516
+ }
517
+ else {
518
+ errors.push(`${formatPathLabel(path)} did not match any allowed schema branch (anyOf/oneOf).`);
635
519
  }
636
520
  }
637
-
638
- function validateBranch({
639
- value,
640
- branch,
641
- path,
642
- context,
643
- errors,
644
- }: Readonly<{
645
- value: JsonValue;
646
- branch: ViraJsonSchemaObject;
647
- path: ViraJsonPath;
648
- context: SchemaResolveContext;
649
- errors: string[];
650
- }>): void {
521
+ function validateBranch({ value, branch, path, context, errors, }) {
651
522
  const allowedTypes = getAllowedJsonTypes(branch, context);
652
523
  const concreteType = getJsonType(value);
653
524
  if (allowedTypes.length > 0) {
654
525
  const matchesAny = allowedTypes.some((type) => isJsonValueMatchingType(value, type));
655
526
  if (!matchesAny) {
656
527
  const allowedLabel = allowedTypes.map((type) => viraJsonTypeLabels[type]).join(' | ');
657
- errors.push(
658
- `${formatPathLabel(path)} expected ${allowedLabel} but got ${
659
- concreteType === ViraJsonType.Number && Number.isInteger(value)
660
- ? 'integer'
661
- : viraJsonTypeLabels[concreteType]
662
- }.`,
663
- );
528
+ errors.push(`${formatPathLabel(path)} expected ${allowedLabel} but got ${concreteType === ViraJsonType.Number && Number.isInteger(value)
529
+ ? 'integer'
530
+ : viraJsonTypeLabels[concreteType]}.`);
664
531
  return;
665
532
  }
666
533
  }
667
- if (
668
- 'const' in branch &&
534
+ if ('const' in branch &&
669
535
  !deepEqualsJson({
670
536
  a: value,
671
- b: branch.const as JsonValue,
672
- })
673
- ) {
537
+ b: branch.const,
538
+ })) {
674
539
  errors.push(`${formatPathLabel(path)} must equal const value.`);
675
540
  return;
676
541
  }
@@ -678,7 +543,7 @@ function validateBranch({
678
543
  const matched = branch.enum.some((entry) => {
679
544
  return deepEqualsJson({
680
545
  a: value,
681
- b: entry as JsonValue,
546
+ b: entry,
682
547
  });
683
548
  });
684
549
  if (!matched) {
@@ -695,16 +560,13 @@ function validateBranch({
695
560
  }
696
561
  const additional = branch.additionalProperties;
697
562
  const definedKeys = new Set(Object.keys(branch.properties ?? {}));
698
- for (const [
699
- propKey,
700
- propValue,
701
- ] of Object.entries(value)) {
702
- const propPath: ViraJsonPath = [
563
+ for (const [propKey, propValue,] of Object.entries(value)) {
564
+ const propPath = [
703
565
  ...path,
704
566
  propKey,
705
567
  ];
706
568
  const propSchema = branch.properties?.[propKey];
707
- if (propSchema !== undefined) {
569
+ if (propSchema != undefined) {
708
570
  validateRecursive({
709
571
  value: propValue,
710
572
  schema: propSchema,
@@ -712,11 +574,11 @@ function validateBranch({
712
574
  context,
713
575
  errors,
714
576
  });
715
- } else if (additional === false) {
716
- errors.push(
717
- `${formatPathLabel(propPath)} is not allowed (additionalProperties is false).`,
718
- );
719
- } else if (check.isObject(additional)) {
577
+ }
578
+ else if (additional === false) {
579
+ errors.push(`${formatPathLabel(propPath)} is not allowed (additionalProperties is false).`);
580
+ }
581
+ else if (check.isObject(additional)) {
720
582
  validateRecursive({
721
583
  value: propValue,
722
584
  schema: additional,
@@ -724,20 +586,22 @@ function validateBranch({
724
586
  context,
725
587
  errors,
726
588
  });
727
- } else if (additional === undefined && definedKeys.size > 0) {
589
+ }
590
+ else if (additional == undefined && definedKeys.size > 0) {
728
591
  continue;
729
592
  }
730
593
  }
731
- } else if (check.isArray(value)) {
594
+ }
595
+ else if (check.isArray(value)) {
732
596
  const items = branch.items;
733
597
  value.forEach((item, index) => {
734
- const itemPath: ViraJsonPath = [
598
+ const itemPath = [
735
599
  ...path,
736
600
  index,
737
601
  ];
738
602
  if (check.isArray(items)) {
739
603
  const tupleSchema = items[index] ?? branch.additionalItems;
740
- if (tupleSchema !== undefined) {
604
+ if (tupleSchema != undefined) {
741
605
  validateRecursive({
742
606
  value: item,
743
607
  schema: tupleSchema,
@@ -746,7 +610,8 @@ function validateBranch({
746
610
  errors,
747
611
  });
748
612
  }
749
- } else if (items !== undefined) {
613
+ }
614
+ else if (items != undefined) {
750
615
  validateRecursive({
751
616
  value: item,
752
617
  schema: items,
@@ -758,21 +623,20 @@ function validateBranch({
758
623
  });
759
624
  }
760
625
  }
761
-
762
- function deepEqualsJson({a, b}: Readonly<{a: JsonValue; b: JsonValue}>): boolean {
626
+ function deepEqualsJson({ a, b }) {
763
627
  if (a === b) {
764
628
  return true;
765
- } else if (check.isArray(a) && check.isArray(b)) {
766
- return (
767
- a.length === b.length &&
629
+ }
630
+ else if (check.isArray(a) && check.isArray(b)) {
631
+ return (a.length === b.length &&
768
632
  a.every((entry, i) => {
769
633
  return deepEqualsJson({
770
634
  a: entry,
771
635
  b: b[i] ?? null,
772
636
  });
773
- })
774
- );
775
- } else if (check.isObject(a) && check.isObject(b)) {
637
+ }));
638
+ }
639
+ else if (check.isObject(a) && check.isObject(b)) {
776
640
  const aKeys = Object.keys(a);
777
641
  const bKeys = Object.keys(b);
778
642
  if (aKeys.length !== bKeys.length) {
@@ -784,33 +648,21 @@ function deepEqualsJson({a, b}: Readonly<{a: JsonValue; b: JsonValue}>): boolean
784
648
  b: b[key] ?? null,
785
649
  });
786
650
  });
787
- } else {
651
+ }
652
+ else {
788
653
  return false;
789
654
  }
790
655
  }
791
-
792
- /**
793
- * Type of a JSON path element. `string` selects an object key; `number` selects an array index.
794
- *
795
- * @category Internal
796
- */
797
- export type ViraJsonPath = ReadonlyArray<string | number>;
798
-
799
656
  /** @category Internal */
800
- export function pathToKey(path: ViraJsonPath): string {
657
+ export function pathToKey(path) {
801
658
  return JSON.stringify(path);
802
659
  }
803
-
804
660
  /**
805
661
  * Returns a new JSON value where the value at `path` has been replaced with `newValue`.
806
662
  *
807
663
  * @category Internal
808
664
  */
809
- export function setValueAtPath({
810
- root,
811
- path,
812
- newValue,
813
- }: Readonly<{root: JsonValue; path: ViraJsonPath; newValue: JsonValue}>): JsonValue {
665
+ export function setValueAtPath({ root, path, newValue, }) {
814
666
  if (path.length === 0) {
815
667
  return newValue;
816
668
  }
@@ -825,7 +677,7 @@ export function setValueAtPath({
825
677
  newValue,
826
678
  });
827
679
  if (head >= array.length) {
828
- const extended: JsonValue[] = [...array];
680
+ const extended = [...array];
829
681
  while (extended.length < head) {
830
682
  extended.push(null);
831
683
  }
@@ -833,7 +685,8 @@ export function setValueAtPath({
833
685
  return extended;
834
686
  }
835
687
  return array.map((item, index) => (index === head ? replaced : item));
836
- } else {
688
+ }
689
+ else {
837
690
  const object = check.isObject(root) ? root : {};
838
691
  const existing = object[head] ?? null;
839
692
  return {
@@ -846,14 +699,13 @@ export function setValueAtPath({
846
699
  };
847
700
  }
848
701
  }
849
-
850
702
  /**
851
703
  * Returns a new JSON value where the value at `path` has been removed. If `path` targets an object
852
704
  * key, the key is deleted; if it targets an array index, the item is spliced out.
853
705
  *
854
706
  * @category Internal
855
707
  */
856
- export function deleteValueAtPath(root: JsonValue, path: ViraJsonPath): JsonValue {
708
+ export function deleteValueAtPath(root, path) {
857
709
  if (path.length === 0) {
858
710
  return root;
859
711
  }
@@ -862,19 +714,24 @@ export function deleteValueAtPath(root: JsonValue, path: ViraJsonPath): JsonValu
862
714
  if (rest.length === 0) {
863
715
  if (typeof head === 'number' && check.isArray(root)) {
864
716
  return root.filter((unusedItem, index) => index !== head);
865
- } else if (typeof head === 'string' && check.isObject(root)) {
717
+ }
718
+ else if (typeof head === 'string' && check.isObject(root)) {
866
719
  return omitObjectKeys(root, [head]);
867
- } else {
720
+ }
721
+ else {
868
722
  return root;
869
723
  }
870
- } else if (typeof head === 'number' && check.isArray(root)) {
724
+ }
725
+ else if (typeof head === 'number' && check.isArray(root)) {
871
726
  return root.map((item, index) => (index === head ? deleteValueAtPath(item, rest) : item));
872
- } else if (typeof head === 'string' && check.isObject(root)) {
727
+ }
728
+ else if (typeof head === 'string' && check.isObject(root)) {
873
729
  return {
874
730
  ...root,
875
731
  [head]: deleteValueAtPath(root[head] ?? null, rest),
876
732
  };
877
- } else {
733
+ }
734
+ else {
878
735
  return root;
879
736
  }
880
737
  }