@perspective-dev/viewer 5.3.0 → 5.4.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 (265) hide show
  1. package/dist/cdn/perspective-viewer.js +8 -8
  2. package/dist/cdn/perspective-viewer.js.map +3 -3
  3. package/dist/css/blueprint.css +1 -0
  4. package/dist/css/botanical.css +1 -1
  5. package/dist/css/dracula.css +1 -1
  6. package/dist/css/eggplant.css +1 -0
  7. package/dist/css/gruvbox-dark.css +1 -1
  8. package/dist/css/gruvbox.css +1 -1
  9. package/dist/css/icons.css +1 -1
  10. package/dist/css/intl/ar.css +1 -0
  11. package/dist/css/intl/de.css +1 -1
  12. package/dist/css/intl/es.css +1 -1
  13. package/dist/css/intl/fr.css +1 -1
  14. package/dist/css/intl/ja.css +1 -1
  15. package/dist/css/intl/pt.css +1 -1
  16. package/dist/css/intl/zh.css +1 -1
  17. package/dist/css/intl.css +1 -1
  18. package/dist/css/ledger.css +1 -0
  19. package/dist/css/monokai.css +1 -1
  20. package/dist/css/nord.css +1 -0
  21. package/dist/css/phosphor.css +1 -1
  22. package/dist/css/pro-dark.css +1 -1
  23. package/dist/css/pro.css +1 -1
  24. package/dist/css/solarized-dark.css +1 -1
  25. package/dist/css/solarized.css +1 -1
  26. package/dist/css/themes.css +1 -1
  27. package/dist/css/vaporwave.css +1 -1
  28. package/dist/css/velvet.css +1 -0
  29. package/dist/docs/perspective-docs.json +1 -1
  30. package/dist/esm/column-format.d.ts +16 -3
  31. package/dist/esm/extensions.d.ts +0 -5
  32. package/dist/esm/perspective-viewer.inline.js +7 -7
  33. package/dist/esm/perspective-viewer.inline.js.map +3 -3
  34. package/dist/esm/perspective-viewer.js +8 -8
  35. package/dist/esm/perspective-viewer.js.map +3 -3
  36. package/dist/esm/ts-rs/ViewOnUpdateResp.d.ts +1 -1
  37. package/dist/wasm/perspective-viewer.d.ts +62 -73
  38. package/dist/wasm/perspective-viewer.js +230 -238
  39. package/dist/wasm/perspective-viewer.wasm +0 -0
  40. package/dist/wasm/perspective-viewer.wasm.d.ts +18 -28
  41. package/package.json +7 -7
  42. package/src/css/_context_menu.css +1 -1
  43. package/src/css/_dropdown_menu.css +1 -1
  44. package/src/css/_viewer_bundle.css +7 -8
  45. package/src/css/column-dropdown.css +0 -3
  46. package/src/css/column-selector.css +8 -5
  47. package/src/css/column-settings-panel.css +0 -206
  48. package/src/css/column-style.css +95 -0
  49. package/src/css/config-selector.css +18 -10
  50. package/src/css/filter-dropdown.css +5 -5
  51. package/src/css/form/debug.css +28 -4
  52. package/src/css/function-dropdown.css +5 -5
  53. package/src/css/panel-tab.css +23 -0
  54. package/src/css/plugin-selector.css +6 -5
  55. package/src/css/render-warning.css +1 -1
  56. package/src/css/status-bar.css +52 -21
  57. package/src/css/type-icon.css +1 -3
  58. package/src/css/{containers → ui/containers}/context-menu.css +22 -16
  59. package/src/css/ui/containers/dropdown-menu-items.css +66 -0
  60. package/src/css/{containers → ui/containers}/dropdown-menu.css +8 -53
  61. package/src/css/{containers → ui/containers}/tabs.css +13 -3
  62. package/src/css/{dom → ui/dom}/select.css +19 -8
  63. package/src/css/viewer.css +32 -31
  64. package/src/rust/agent/tools.rs +5 -2
  65. package/src/rust/components/chat_panel.rs +1 -1
  66. package/src/rust/components/{form/code_editor.rs → code_editor.rs} +4 -2
  67. package/src/rust/components/column_dropdown.rs +2 -2
  68. package/src/rust/components/column_selector/active_column.rs +15 -9
  69. package/src/rust/components/column_selector/aggregate_selector.rs +1 -1
  70. package/src/rust/components/column_selector/config_selector.rs +2 -2
  71. package/src/rust/components/column_selector/filter_column.rs +8 -5
  72. package/src/rust/components/column_selector/inactive_column.rs +4 -2
  73. package/src/rust/components/column_selector/pivot_column.rs +4 -3
  74. package/src/rust/components/column_selector/sort_column.rs +7 -4
  75. package/src/rust/components/column_selector.rs +3 -3
  76. package/src/rust/components/column_settings_sidebar/style_tab/agg_depth_selector.rs +1 -1
  77. package/src/rust/components/column_settings_sidebar/style_tab/primitive_field.rs +15 -17
  78. package/src/rust/components/column_settings_sidebar/style_tab/symbol/symbol_selector.rs +1 -1
  79. package/src/rust/components/column_settings_sidebar/style_tab.rs +296 -238
  80. package/src/rust/components/column_settings_sidebar.rs +3 -4
  81. package/src/rust/components/copy_dropdown.rs +1 -1
  82. package/src/rust/components/datetime_column_style/custom.rs +1 -3
  83. package/src/rust/components/datetime_column_style/simple.rs +16 -6
  84. package/src/rust/components/datetime_column_style.rs +51 -12
  85. package/src/rust/components/{form/debug.rs → debug_panel.rs} +5 -5
  86. package/src/rust/components/{containers/dragdrop_list.rs → dragdrop_list.rs} +2 -10
  87. package/src/rust/components/export_dropdown.rs +1 -1
  88. package/src/rust/components/expression_editor.rs +1 -1
  89. package/src/rust/components/filter_dropdown.rs +2 -2
  90. package/src/rust/components/function_dropdown.rs +2 -2
  91. package/src/rust/components/main_panel/frame_theme.rs +3 -59
  92. package/src/rust/components/main_panel/reconcile.rs +9 -4
  93. package/src/rust/components/main_panel/render.rs +62 -11
  94. package/src/rust/components/main_panel/update.rs +39 -10
  95. package/src/rust/components/main_panel.rs +26 -2
  96. package/src/rust/components/mod.rs +5 -7
  97. package/src/rust/components/new_panel_menu.rs +97 -0
  98. package/src/rust/components/number_series_style.rs +2 -3
  99. package/src/rust/components/panel_menu.rs +61 -87
  100. package/src/rust/components/panel_tab.rs +100 -43
  101. package/src/rust/components/plugin_tab.rs +125 -87
  102. package/src/rust/components/render_warning.rs +2 -2
  103. package/src/rust/components/{status_bar_counter.rs → rows_counter.rs} +10 -10
  104. package/src/rust/components/settings_panel.rs +3 -2
  105. package/src/rust/components/status_bar.rs +113 -20
  106. package/src/rust/components/status_indicator.rs +5 -14
  107. package/src/rust/components/string_column_style.rs +1 -2
  108. package/src/rust/components/{style/mod.rs → style.rs} +32 -15
  109. package/src/rust/components/style_controls/number_string_format/digits_section.rs +25 -15
  110. package/src/rust/components/style_controls/number_string_format/misc_section.rs +7 -3
  111. package/src/rust/components/style_controls/number_string_format/style_section.rs +2 -1
  112. package/src/rust/components/style_controls/number_string_format/types.rs +24 -0
  113. package/src/rust/components/style_controls/number_string_format.rs +37 -14
  114. package/src/rust/components/viewer/msg.rs +43 -30
  115. package/src/rust/components/viewer/panels.rs +50 -19
  116. package/src/rust/components/viewer/render.rs +15 -13
  117. package/src/rust/components/viewer/settings.rs +137 -68
  118. package/src/rust/components/viewer/snapshots.rs +5 -10
  119. package/src/rust/components/viewer/wiring.rs +1 -21
  120. package/src/rust/components/viewer.rs +15 -10
  121. package/src/rust/components/window_editor.rs +8 -9
  122. package/src/rust/config/column_config_schema.rs +358 -52
  123. package/src/rust/config/datetime_column_style.rs +4 -21
  124. package/src/rust/config/mod.rs +0 -2
  125. package/src/rust/config/number_string_format.rs +211 -18
  126. package/src/rust/config/workspace_config.rs +2 -1
  127. package/src/rust/custom_elements/debug_plugin.rs +1 -10
  128. package/src/rust/custom_elements/mod.rs +0 -3
  129. package/src/rust/custom_elements/viewer.rs +0 -18
  130. package/src/rust/js/plugin.rs +0 -86
  131. package/src/rust/lib.rs +12 -15
  132. package/src/rust/presentation/column_locator.rs +3 -7
  133. package/src/rust/presentation.rs +85 -38
  134. package/src/rust/queries/hosted_tables.rs +38 -0
  135. package/src/rust/queries/mod.rs +2 -0
  136. package/src/rust/queries/palette_set.rs +1 -1
  137. package/src/rust/queries/plugin_column_styles.rs +2 -2
  138. package/src/rust/renderer/activate.rs +1 -3
  139. package/src/rust/renderer/dispatch.rs +117 -30
  140. package/src/rust/renderer/limits.rs +24 -5
  141. package/src/rust/renderer/plugin_config.rs +56 -8
  142. package/src/rust/renderer/props.rs +2 -1
  143. package/src/rust/renderer.rs +14 -27
  144. package/src/rust/session/props.rs +4 -3
  145. package/src/rust/session/view_subscription.rs +19 -6
  146. package/src/rust/session.rs +38 -70
  147. package/src/rust/tasks/create_panel.rs +1 -1
  148. package/src/rust/tasks/dismiss_render_warning.rs +1 -1
  149. package/src/rust/tasks/eject.rs +1 -0
  150. package/src/rust/tasks/pipeline.rs +0 -60
  151. package/src/rust/tasks/presize_panels.rs +24 -1
  152. package/src/rust/tasks/restore_and_render.rs +0 -17
  153. package/src/rust/tasks/send_column_config.rs +1 -1
  154. package/src/rust/tasks/send_plugin_config.rs +1 -1
  155. package/src/rust/tasks/set_edit_mode.rs +1 -1
  156. package/src/rust/ui/containers/control_group.rs +113 -0
  157. package/src/rust/{components → ui}/containers/dropdown_menu.rs +5 -2
  158. package/src/rust/{components → ui}/containers/mod.rs +1 -4
  159. package/src/rust/{components → ui}/containers/scroll_panel.rs +0 -22
  160. package/src/rust/{components → ui}/containers/scroll_panel_item.rs +0 -13
  161. package/src/rust/{components → ui}/containers/select.rs +8 -8
  162. package/src/rust/{components → ui}/containers/sidebar.rs +5 -32
  163. package/src/rust/{components → ui}/containers/split_panel.rs +8 -80
  164. package/src/rust/{components → ui}/containers/tab_list.rs +15 -9
  165. package/src/rust/{components → ui}/context_menu.rs +8 -13
  166. package/src/rust/{presentation/drag_helpers.rs → ui/dragdrop.rs} +26 -31
  167. package/src/rust/{components → ui}/font_loader.rs +0 -26
  168. package/src/rust/{components → ui}/form/color_selector.rs +4 -2
  169. package/src/rust/ui/form/intl_label.rs +81 -0
  170. package/src/rust/{components → ui}/form/mirrored_textarea.rs +0 -53
  171. package/src/rust/{components → ui}/form/mod.rs +1 -10
  172. package/src/rust/{components → ui}/form/multi_stop_gradient_selector.rs +4 -5
  173. package/src/rust/{components → ui}/form/named_value_picker.rs +1 -6
  174. package/src/rust/{components → ui}/form/number_field.rs +1 -1
  175. package/src/rust/{components → ui}/form/number_range_field.rs +1 -1
  176. package/src/rust/{components → ui}/form/optional_field.rs +3 -1
  177. package/src/rust/{components → ui}/form/palette_selector.rs +4 -5
  178. package/src/rust/{components → ui}/form/select_enum_field.rs +2 -2
  179. package/src/rust/{components → ui}/form/select_value_field.rs +2 -2
  180. package/src/rust/ui/mod.rs +56 -0
  181. package/src/rust/ui/modal.rs +61 -0
  182. package/src/rust/{components → ui}/portal.rs +174 -79
  183. package/src/rust/{components/style/style_provider.rs → ui/style.rs} +4 -34
  184. package/src/rust/utils/completion.rs +0 -6
  185. package/src/rust/{config/css_scale.rs → utils/css.rs} +38 -35
  186. package/src/rust/utils/mod.rs +2 -0
  187. package/src/rust/workspace.rs +35 -0
  188. package/src/svg/boolean-type.svg +3 -2
  189. package/src/svg/checkbox-checked-icon.svg +4 -7
  190. package/src/svg/checkbox-hover.svg +3 -3
  191. package/src/svg/checkbox-off.svg +2 -3
  192. package/src/svg/checkbox-on.svg +3 -3
  193. package/src/svg/checkbox-unchecked-icon.svg +3 -3
  194. package/src/svg/datagrid-select-column.svg +8 -15
  195. package/src/svg/datagrid-select-region.svg +8 -15
  196. package/src/svg/datagrid-select-row-tree.svg +7 -12
  197. package/src/svg/datagrid-select-row.svg +8 -13
  198. package/src/svg/date-type.svg +4 -23
  199. package/src/svg/drawer-tab-hover.svg +4 -6
  200. package/src/svg/drawer-tab-invert-hover.svg +5 -5
  201. package/src/svg/drawer-tab-invert.svg +3 -5
  202. package/src/svg/drawer-tab.svg +5 -5
  203. package/src/svg/mega-menu-icons-candlestick.svg +5 -37
  204. package/src/svg/mega-menu-icons-ohlc.svg +4 -39
  205. package/src/svg/mega-menu-icons-sunburst.svg +4 -38
  206. package/src/svg/mega-menu-icons-treemap.svg +3 -43
  207. package/src/svg/mega-menu-icons-y-scatter.svg +12 -72
  208. package/src/svg/new-panel-icon.svg +4 -0
  209. package/src/svg/number-type.svg +3 -3
  210. package/src/svg/radio-hover.svg +3 -3
  211. package/src/svg/radio-off.svg +3 -3
  212. package/src/svg/radio-on.svg +3 -3
  213. package/src/svg/status_ok.svg +3 -26
  214. package/src/svg/string-type.svg +4 -8
  215. package/src/svg/theme-icon.svg +5 -5
  216. package/src/themes/blueprint.css +133 -0
  217. package/src/themes/botanical.css +3 -52
  218. package/src/themes/defaults.css +3 -144
  219. package/src/themes/dracula.css +1 -71
  220. package/src/themes/eggplant.css +131 -0
  221. package/src/themes/gruvbox-dark.css +2 -79
  222. package/src/themes/gruvbox.css +2 -40
  223. package/src/themes/icons.css +2 -10
  224. package/src/themes/intl/ar.css +185 -0
  225. package/src/themes/intl/de.css +65 -33
  226. package/src/themes/intl/es.css +60 -28
  227. package/src/themes/intl/fr.css +60 -28
  228. package/src/themes/intl/ja.css +62 -30
  229. package/src/themes/intl/pt.css +58 -26
  230. package/src/themes/intl/zh.css +68 -36
  231. package/src/themes/intl.css +42 -7
  232. package/src/themes/ledger.css +137 -0
  233. package/src/themes/monokai.css +1 -64
  234. package/src/themes/nord.css +131 -0
  235. package/src/themes/phosphor.css +1 -61
  236. package/src/themes/pro-dark.css +1 -52
  237. package/src/themes/pro.css +98 -0
  238. package/src/themes/solarized-dark.css +1 -46
  239. package/src/themes/solarized.css +1 -24
  240. package/src/themes/themes.css +10 -5
  241. package/src/themes/vaporwave.css +1 -57
  242. package/src/themes/velvet.css +132 -0
  243. package/src/ts/column-format.ts +52 -2
  244. package/src/ts/extensions.ts +0 -13
  245. package/src/ts/ts-rs/ViewOnUpdateResp.ts +1 -1
  246. package/src/css/plugin-settings-panel.css +0 -99
  247. package/src/rust/components/modal.rs +0 -177
  248. package/src/rust/custom_elements/copy_dropdown.rs +0 -219
  249. package/src/rust/custom_elements/export_dropdown.rs +0 -216
  250. package/src/rust/custom_elements/modal.rs +0 -299
  251. package/src/svg/dropdown-selector-light.svg +0 -3
  252. /package/dist/wasm/snippets/{perspective-viewer-39c3c3b28e3cbd48 → perspective-viewer-adc6f3f79141112b}/inline0.js +0 -0
  253. /package/dist/wasm/snippets/{perspective-viewer-39c3c3b28e3cbd48 → perspective-viewer-adc6f3f79141112b}/inline1.js +0 -0
  254. /package/dist/wasm/snippets/{perspective-viewer-39c3c3b28e3cbd48 → perspective-viewer-adc6f3f79141112b}/inline2.js +0 -0
  255. /package/dist/wasm/snippets/{perspective-viewer-39c3c3b28e3cbd48 → perspective-viewer-adc6f3f79141112b}/inline3.js +0 -0
  256. /package/dist/wasm/snippets/{perspective-viewer-39c3c3b28e3cbd48 → perspective-viewer-adc6f3f79141112b}/inline4.js +0 -0
  257. /package/dist/wasm/snippets/{perspective-viewer-39c3c3b28e3cbd48 → perspective-viewer-adc6f3f79141112b}/inline5.js +0 -0
  258. /package/src/css/{containers → ui/containers}/scroll-panel.css +0 -0
  259. /package/src/css/{containers → ui/containers}/split-panel.css +0 -0
  260. /package/src/css/{dom → ui/dom}/checkbox.css +0 -0
  261. /package/src/css/{dom → ui/dom}/scrollbar.css +0 -0
  262. /package/src/css/{form → ui/form}/mirrored-textarea.css +0 -0
  263. /package/src/rust/components/{form → code_editor}/highlight.rs +0 -0
  264. /package/src/rust/{components → ui}/containers/sidebar_close_button.rs +0 -0
  265. /package/src/rust/{components → ui}/form/number_input.rs +0 -0
@@ -10,31 +10,6 @@
10
10
  // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
11
  // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
12
 
13
- //! A `<textarea>` whose box is sized by its own text.
14
- //!
15
- //! A textarea cannot grow with its content — it scrolls at whatever height
16
- //! it was given. The technique here, shared by [`CodeEditor`] and the chat
17
- //! prompt, is to make the textarea a purely functional layer: it takes the
18
- //! keystrokes, the selection and the caret, but paints no glyphs
19
- //! (`color: transparent`). Underneath sits a `<pre>` mirror of the same
20
- //! characters which IS painted and IS in flow, so the ordinary layout
21
- //! engine sizes the box.
22
- //!
23
- //! This is deliberately not a JS measure-and-resize loop
24
- //! (`scrollHeight` → inline `height`): that re-measures on a reflow it
25
- //! just forced, drifts whenever font-size or the loaded font changes
26
- //! without an `input` event to re-trigger it, and jitters at fractional
27
- //! line heights. Here the two layers share their text metrics, so growth
28
- //! is exact by construction and free at runtime.
29
- //!
30
- //! Consumers decide the AXES: the mirror's `white-space` governs growth,
31
- //! so `pre-wrap` grows only downward (the chat prompt) while `pre` also
32
- //! grows sideways (the expression editor). They also own the box —
33
- //! padding, borders, min/max size — with `mirrored-textarea.css` fixing
34
- //! only what MUST agree between the two layers.
35
- //!
36
- //! [`CodeEditor`]: super::code_editor::CodeEditor
37
-
38
13
  use yew::html::IntoPropValue;
39
14
  use yew::prelude::*;
40
15
 
@@ -55,20 +30,13 @@ impl IntoPropValue<Mirror> for Html {
55
30
 
56
31
  #[derive(Properties, PartialEq)]
57
32
  pub struct MirroredTextareaProps {
58
- /// `id` of the `<textarea>` itself — consumer CSS and tests key on it.
59
33
  pub id: AttrValue,
60
34
 
61
- /// The mirror's content: the same characters the textarea holds,
62
- /// as plain text, or marked up (`CodeEditor` passes highlighted
63
- /// spans). A stale mirror means a caret that drifts from the glyphs,
64
- /// so this is re-rendered unconditionally — see [`Mirror`].
65
35
  pub mirror: Mirror,
66
36
 
67
- /// `id` of the mirror `<pre>`, for consumers that style it directly.
68
37
  #[prop_or_default]
69
38
  pub mirror_id: Option<AttrValue>,
70
39
 
71
- /// Extra classes for the positioned container.
72
40
  #[prop_or_default]
73
41
  pub class: Classes,
74
42
 
@@ -78,19 +46,9 @@ pub struct MirroredTextareaProps {
78
46
  #[prop_or_default]
79
47
  pub mirror_ref: NodeRef,
80
48
 
81
- /// The `placeholder` ATTRIBUTE, which exists for assistive tech: it
82
- /// is painted transparent, because a CSS-`content` label cannot be
83
- /// written into an attribute and so cannot be localized. The text a
84
- /// sighted user reads comes from the mirror instead — see
85
- /// [`Self::is_empty`].
86
49
  #[prop_or_default]
87
50
  pub placeholder: AttrValue,
88
51
 
89
- /// Whether [`Self::mirror`] is empty, which the component cannot see
90
- /// for itself (the mirror is opaque `Html`). Tags the mirror with
91
- /// `is-empty` so a consumer's stylesheet can supply placeholder text
92
- /// through `content`, and therefore through the intl label
93
- /// mechanism, rather than through the untranslatable attribute.
94
52
  #[prop_or_default]
95
53
  pub is_empty: bool,
96
54
 
@@ -106,8 +64,6 @@ pub struct MirroredTextareaProps {
106
64
  #[prop_or_default]
107
65
  pub onscroll: Callback<Event>,
108
66
 
109
- /// Extra nodes inside the positioned container, e.g. `CodeEditor`'s
110
- /// minimum-height sizer.
111
67
  #[prop_or_default]
112
68
  pub children: Children,
113
69
  }
@@ -116,11 +72,6 @@ pub struct MirroredTextareaProps {
116
72
  pub fn MirroredTextarea(props: &MirroredTextareaProps) -> Html {
117
73
  html! {
118
74
  <div class={classes!("mirrored-textarea", props.class.clone())}>
119
- // `scrollable` is the viewer's webkit scrollbar styling: the
120
- // input layer scrolls wherever a consumer lets it (the
121
- // expression editor syncs its `scrollTop` to the mirror and
122
- // line numbers), and is inert where it does not (the chat
123
- // prompt, whose wrapper scrolls instead).
124
75
  <textarea
125
76
  id={props.id.clone()}
126
77
  ref={props.textarea_ref.clone()}
@@ -142,10 +93,6 @@ pub fn MirroredTextarea(props: &MirroredTextareaProps) -> Html {
142
93
  )}
143
94
  >
144
95
  { props.mirror.0.clone() }
145
- // A trailing newline opens a line box in the textarea but
146
- // not in the `<pre>` (which has no caret to place there),
147
- // so the mirror would come up one line short exactly when
148
- // the text is about to overflow. The space forces it.
149
96
  { " " }
150
97
  </pre>
151
98
  </div>
@@ -10,15 +10,8 @@
10
10
  // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
11
  // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
12
 
13
- //! A module for form controls (though form controls like `<Select>` which are
14
- //! also container elements should go in the `containers` module).
15
- //!
16
- //! Components in this module should not be imported from the `components`
17
- //! parent module directly.
18
-
19
- pub mod code_editor;
20
13
  pub mod color_selector;
21
- pub mod debug;
14
+ pub mod intl_label;
22
15
  pub mod mirrored_textarea;
23
16
  pub mod multi_stop_gradient_selector;
24
17
  pub mod named_value_picker;
@@ -29,5 +22,3 @@ pub mod optional_field;
29
22
  pub mod palette_selector;
30
23
  pub mod select_enum_field;
31
24
  pub mod select_value_field;
32
-
33
- mod highlight;
@@ -15,10 +15,9 @@ use wasm_bindgen::JsCast;
15
15
  use web_sys::*;
16
16
  use yew::prelude::*;
17
17
 
18
- use crate::config::{GradientStopSpec, canonicalize_gradient_stops};
18
+ use crate::ui::form::intl_label::IntlLabel;
19
+ use crate::utils::{GradientStopSpec, canonicalize_gradient_stops};
19
20
 
20
- /// The widget for [`crate::config::ControlSpec::GradientStops`]: a
21
- /// horizontal gradient preview bar with one handle per stop.
22
21
  #[derive(Properties, PartialEq)]
23
22
  pub struct MultiStopGradientProps {
24
23
  pub stops: Vec<GradientStopSpec>,
@@ -30,7 +29,7 @@ pub struct MultiStopGradientProps {
30
29
  pub discrete: bool,
31
30
 
32
31
  #[prop_or_default]
33
- pub title: Option<String>,
32
+ pub label: Option<String>,
34
33
  }
35
34
 
36
35
  fn event_index(target: &Element) -> Option<usize> {
@@ -335,7 +334,7 @@ pub fn multi_stop_gradient_selector(props: &MultiStopGradientProps) -> Html {
335
334
  let pinned = props.discrete && !can_remove;
336
335
  html! {
337
336
  <>
338
- <label id={props.title.as_deref().unwrap_or("gradient-label").to_owned()} />
337
+ <IntlLabel name={props.label.clone().unwrap_or_else(|| "gradient".to_owned())} />
339
338
  <div class="color-gradient-container gradient-stops-selector">
340
339
  <div
341
340
  class={if props.discrete {"gradient-stops-bar discrete"} else {"gradient-stops-bar"}}
@@ -16,18 +16,13 @@ use wasm_bindgen::JsCast;
16
16
  use web_sys::{Event, HtmlSelectElement, MouseEvent};
17
17
  use yew::prelude::*;
18
18
 
19
- use crate::config::{CssKind, NamedValue};
19
+ use crate::utils::{CssKind, NamedValue};
20
20
 
21
- /// The named-value controls above a CSS-valued style field: a stateless
22
- /// quick-action `<select>` over every named value of the field's kind,
23
- /// and a Pin button that force-adds the field's value to the workspace
24
- /// palette.
25
21
  #[derive(Properties, PartialEq)]
26
22
  pub struct NamedValuePickerProps {
27
23
  pub kind: CssKind,
28
24
  pub entries: Rc<Vec<NamedValue>>,
29
25
 
30
- /// Loads the named entry's value into the field.
31
26
  pub on_select: Callback<String>,
32
27
 
33
28
  #[prop_or_default]
@@ -13,7 +13,7 @@
13
13
  use web_sys::{HtmlInputElement, InputEvent};
14
14
  use yew::{Callback, Properties, TargetCast, function_component, html};
15
15
 
16
- use crate::components::form::optional_field::OptionalField;
16
+ use crate::ui::form::optional_field::OptionalField;
17
17
 
18
18
  #[derive(Properties, Debug, PartialEq, Clone)]
19
19
  pub struct NumberFieldProps {
@@ -13,7 +13,7 @@
13
13
  use web_sys::HtmlInputElement;
14
14
  use yew::{Callback, Properties, function_component, html, use_callback, use_node_ref};
15
15
 
16
- use crate::components::form::optional_field::OptionalField;
16
+ use crate::ui::form::optional_field::OptionalField;
17
17
 
18
18
  #[derive(Properties, Debug, PartialEq, Clone)]
19
19
  pub struct NumberRangeFieldProps {
@@ -12,6 +12,8 @@
12
12
 
13
13
  use yew::{Callback, Children, Html, MouseEvent, Properties, classes, function_component, html};
14
14
 
15
+ use crate::ui::form::intl_label::IntlLabel;
16
+
15
17
  #[derive(Properties, PartialEq)]
16
18
  pub struct OptionalFieldProps {
17
19
  pub checked: bool,
@@ -30,7 +32,7 @@ pub struct OptionalFieldProps {
30
32
  pub fn optional_field(props: &OptionalFieldProps) -> Html {
31
33
  html! {
32
34
  <>
33
- <label id={format!("{}-label", props.label)} />
35
+ <IntlLabel name={props.label.clone()} />
34
36
  <div
35
37
  class={classes!(props.class.clone(), props.checked.then_some("is-default-value"))}
36
38
  >
@@ -14,9 +14,8 @@ use wasm_bindgen::JsCast;
14
14
  use web_sys::*;
15
15
  use yew::prelude::*;
16
16
 
17
- /// The widget for [`crate::config::ControlSpec::Palette`]: an ordered row
18
- /// of discrete color swatches with per-swatch edit/remove, pointer-drag
19
- /// reordering, and a trailing add tile.
17
+ use crate::ui::form::intl_label::IntlLabel;
18
+
20
19
  #[derive(Properties, PartialEq)]
21
20
  pub struct PaletteProps {
22
21
  pub values: Vec<String>,
@@ -28,7 +27,7 @@ pub struct PaletteProps {
28
27
  pub max: Option<usize>,
29
28
 
30
29
  #[prop_or_default]
31
- pub title: Option<String>,
30
+ pub label: Option<String>,
32
31
  }
33
32
 
34
33
  const DRAG_THRESHOLD_PX: f64 = 4.0;
@@ -340,7 +339,7 @@ pub fn palette_selector(props: &PaletteProps) -> Html {
340
339
 
341
340
  html! {
342
341
  <>
343
- <label id={props.title.as_deref().unwrap_or("palette-label").to_owned()} />
342
+ <IntlLabel name={props.label.clone().unwrap_or_else(|| "palette".to_owned())} />
344
343
  <div class="color-gradient-container palette-selector">
345
344
  <div
346
345
  class={classes!("palette-swatches", drag.is_some().then_some("reordering"))}
@@ -16,8 +16,8 @@ use itertools::Itertools;
16
16
  use strum::IntoEnumIterator;
17
17
  use yew::{Callback, Properties, function_component, html};
18
18
 
19
- use crate::components::containers::select::{Select, SelectItem};
20
- use crate::components::form::optional_field::OptionalField;
19
+ use crate::ui::containers::select::{Select, SelectItem};
20
+ use crate::ui::form::optional_field::OptionalField;
21
21
 
22
22
  #[derive(Properties, Debug, PartialEq, Clone)]
23
23
  pub struct SelectEnumFieldProps<T>
@@ -16,8 +16,8 @@ use std::rc::Rc;
16
16
  use itertools::Itertools;
17
17
  use yew::{Callback, Properties, function_component, html};
18
18
 
19
- use crate::components::containers::select::{Select, SelectItem};
20
- use crate::components::form::optional_field::OptionalField;
19
+ use crate::ui::containers::select::{Select, SelectItem};
20
+ use crate::ui::form::optional_field::OptionalField;
21
21
 
22
22
  #[derive(Properties, Debug, PartialEq, Clone)]
23
23
  pub struct SelectValueFieldProps<T>
@@ -0,0 +1,56 @@
1
+ // ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2
+ // ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3
+ // ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4
+ // ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5
+ // ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6
+ // ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7
+ // ┃ Copyright (c) 2017, the Perspective Authors. ┃
8
+ // ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9
+ // ┃ This file is part of the Perspective library, distributed under the terms ┃
10
+ // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
+ // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
+
13
+ //! Generic widgets and DOM infrastructure with no dependency on viewer
14
+ //! state: nothing here may import `config`, `session`, `renderer`,
15
+ //! `presentation`, `tasks`, `queries`, `workspace`, `agent`,
16
+ //! `custom_elements`, `components`, or `js::plugin`.
17
+
18
+ pub mod containers;
19
+ pub mod context_menu;
20
+ pub mod dragdrop;
21
+ pub mod font_loader;
22
+ pub mod form;
23
+ pub mod modal;
24
+ pub use modal::{ModalLink, SetModalLink};
25
+ pub mod portal;
26
+ pub mod style;
27
+
28
+ pub use containers::control_group::ControlGroup;
29
+ pub use containers::dropdown_menu::{DropDownMenu, DropDownMenuItem};
30
+ pub use containers::scroll_panel::ScrollPanel;
31
+ pub use containers::scroll_panel_item::ScrollPanelItem;
32
+ pub use containers::select::{Select, SelectItem};
33
+ pub use containers::sidebar::Sidebar;
34
+ pub use containers::sidebar_close_button::SidebarCloseButton;
35
+ pub use containers::split_panel::{Orientation, SplitPanel};
36
+ pub use containers::tab_list::{TabItem, TabList};
37
+ pub use context_menu::{ContextMenu, ContextMenuEntry, ContextMenuItem};
38
+ pub use dragdrop::{
39
+ DragDropContainer, DragEndCallback, DragTargetState, PointerDownCallback,
40
+ clear_document_selection, closest_draggable,
41
+ };
42
+ pub use font_loader::{FontLoader, FontLoaderProps, FontLoaderStatus};
43
+ pub use form::color_selector::ColorSelector;
44
+ pub use form::intl_label::{IntlLabel, intl_content_style, intl_slug};
45
+ pub use form::mirrored_textarea::MirroredTextarea;
46
+ pub use form::multi_stop_gradient_selector::MultiStopGradientSelector;
47
+ pub use form::named_value_picker::NamedValuePicker;
48
+ pub use form::number_field::NumberField;
49
+ pub use form::number_input::NumberInput;
50
+ pub use form::number_range_field::NumberRangeField;
51
+ pub use form::optional_field::OptionalField;
52
+ pub use form::palette_selector::PaletteSelector;
53
+ pub use form::select_enum_field::SelectEnumField;
54
+ pub use form::select_value_field::SelectValueField;
55
+ pub use portal::{MODAL_SLOT, PortalModal};
56
+ pub use style::StyleProvider;
@@ -0,0 +1,61 @@
1
+ // ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2
+ // ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3
+ // ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4
+ // ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5
+ // ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6
+ // ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7
+ // ┃ Copyright (c) 2017, the Perspective Authors. ┃
8
+ // ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9
+ // ┃ This file is part of the Perspective library, distributed under the terms ┃
10
+ // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
+ // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
+
13
+ use std::cell::Cell;
14
+ use std::rc::Rc;
15
+
16
+ use yew::html::ImplicitClone;
17
+ use yew::prelude::*;
18
+
19
+ use crate::utils::WeakScope;
20
+
21
+ /// Whether a modal has been flipped to open upward from its anchor, provided
22
+ /// as a Yew context by `PortalModal`.
23
+ #[derive(Clone, Default, Eq, PartialEq)]
24
+ pub struct ModalOrientation(Rc<Cell<bool>>);
25
+
26
+ impl ImplicitClone for ModalOrientation {}
27
+
28
+ impl ModalOrientation {
29
+ pub fn set(&self, value: bool) {
30
+ self.0.set(value);
31
+ }
32
+ }
33
+
34
+ impl From<ModalOrientation> for bool {
35
+ fn from(x: ModalOrientation) -> Self {
36
+ x.0.get()
37
+ }
38
+ }
39
+
40
+ /// Props that expose a weak link to their component, so an owner can send it
41
+ /// messages after the fact (the column-style editors hosted in a modal).
42
+ pub trait ModalLink<T>
43
+ where
44
+ T: Component,
45
+ {
46
+ fn weak_link(&self) -> &'_ WeakScope<T>;
47
+ }
48
+
49
+ pub trait SetModalLink {
50
+ fn set_modal_link(&self);
51
+ }
52
+
53
+ impl<T> SetModalLink for &Context<T>
54
+ where
55
+ T: Component,
56
+ T::Properties: ModalLink<T>,
57
+ {
58
+ fn set_modal_link(&self) {
59
+ *self.props().weak_link().borrow_mut() = Some(self.link().clone());
60
+ }
61
+ }