trebol 0.1.1 → 0.2.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.
- package/README.md +12 -1
- package/dist/cli.js +17097 -12238
- package/dist/fonts/OFL.txt +93 -0
- package/dist/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/dist/fonts/inter-cyrillic.woff2 +0 -0
- package/dist/fonts/inter-greek-ext.woff2 +0 -0
- package/dist/fonts/inter-greek.woff2 +0 -0
- package/dist/fonts/inter-latin-ext.woff2 +0 -0
- package/dist/fonts/inter-latin.woff2 +0 -0
- package/dist/fonts/inter-vietnamese.woff2 +0 -0
- package/dist/lib/core/boot.js +12 -8
- package/dist/lib/core/eval.js +2 -2
- package/dist/lib/core/func.d.ts +4 -0
- package/dist/lib/core/machine/checks.d.ts +1 -0
- package/dist/lib/core/machine/checks.js +250 -0
- package/dist/lib/core/machine/events.d.ts +1 -0
- package/dist/lib/core/machine/events.js +365 -0
- package/dist/lib/core/machine/running.d.ts +1 -0
- package/dist/lib/core/machine/running.js +180 -0
- package/dist/lib/core/machine/shared.d.ts +1 -0
- package/dist/lib/core/machine/shared.js +123 -0
- package/dist/lib/core/machine/snapshot.d.ts +1 -0
- package/dist/lib/core/machine/snapshot.js +244 -0
- package/dist/lib/core/machine/spec.d.ts +1 -0
- package/dist/lib/core/machine/spec.js +274 -0
- package/dist/lib/core/machine/words.d.ts +1 -0
- package/dist/lib/core/machine/words.js +98 -0
- package/dist/lib/core/machine.d.ts +1 -0
- package/dist/lib/core/machine.js +17 -0
- package/dist/lib/core/mezz.js +31 -0
- package/dist/lib/core/natives/control.js +2 -2
- package/dist/lib/core/natives/data.js +6 -1
- package/dist/lib/core/natives/series.js +59 -9
- package/dist/lib/core/natives/text.js +3 -1
- package/dist/lib/host/browser/calendar.d.ts +34 -0
- package/dist/lib/host/browser/calendar.js +268 -0
- package/dist/lib/host/browser/count.d.ts +15 -0
- package/dist/lib/host/browser/count.js +48 -0
- package/dist/lib/host/browser/dialogs.d.ts +39 -0
- package/dist/lib/host/browser/dialogs.js +443 -0
- package/dist/lib/host/browser/drag.d.ts +70 -0
- package/dist/lib/host/browser/drag.js +268 -0
- package/dist/lib/host/browser/drawings.d.ts +30 -0
- package/dist/lib/host/browser/drawings.js +176 -0
- package/dist/lib/host/browser/events.d.ts +16 -0
- package/dist/lib/host/browser/events.js +125 -0
- package/dist/lib/host/browser/faces.d.ts +35 -0
- package/dist/lib/host/browser/faces.js +131 -0
- package/dist/lib/host/browser/fields.d.ts +16 -0
- package/dist/lib/host/browser/fields.js +322 -0
- package/dist/lib/host/browser/keys.d.ts +29 -0
- package/dist/lib/host/browser/keys.js +151 -0
- package/dist/lib/host/browser/lookup.d.ts +25 -0
- package/dist/lib/host/browser/lookup.js +275 -0
- package/dist/lib/host/browser/menus.d.ts +20 -0
- package/dist/lib/host/browser/menus.js +149 -0
- package/dist/lib/host/browser/mount.d.ts +92 -0
- package/dist/lib/host/browser/mount.js +448 -0
- package/dist/lib/host/browser/orbits.d.ts +90 -0
- package/dist/lib/host/browser/orbits.js +379 -0
- package/dist/lib/host/browser/page.d.ts +13 -0
- package/dist/lib/host/browser/page.js +35 -0
- package/dist/lib/host/browser/richtext.d.ts +19 -0
- package/dist/lib/host/browser/richtext.js +379 -0
- package/dist/lib/host/browser/row-faces.d.ts +5 -0
- package/dist/lib/host/browser/row-faces.js +74 -0
- package/dist/lib/host/browser/screens.d.ts +37 -0
- package/dist/lib/host/browser/screens.js +140 -0
- package/dist/lib/host/browser/swipe.d.ts +31 -0
- package/dist/lib/host/browser/swipe.js +178 -0
- package/dist/lib/host/browser/sync.d.ts +24 -0
- package/dist/lib/host/browser/sync.js +450 -0
- package/dist/lib/host/browser/tables.d.ts +65 -0
- package/dist/lib/host/browser/tables.js +505 -0
- package/dist/lib/host/browser/times.d.ts +14 -0
- package/dist/lib/host/browser/times.js +114 -0
- package/dist/lib/host/browser/toolbars.d.ts +17 -0
- package/dist/lib/host/browser/toolbars.js +129 -0
- package/dist/lib/host/browser/trees.d.ts +20 -0
- package/dist/lib/host/browser/trees.js +235 -0
- package/dist/lib/host/browser/uploads.d.ts +29 -0
- package/dist/lib/host/browser/uploads.js +370 -0
- package/dist/lib/host/browser/widget.d.ts +13 -0
- package/dist/lib/host/browser/widget.js +105 -0
- package/dist/lib/host/browser.d.ts +25 -0
- package/dist/lib/host/browser.js +129 -3964
- package/dist/lib/host/devlog.d.ts +11 -0
- package/dist/lib/host/devlog.js +13 -0
- package/dist/lib/host/devtools/console.d.ts +9 -0
- package/dist/lib/host/devtools/console.js +104 -0
- package/dist/lib/host/devtools/faces.d.ts +25 -0
- package/dist/lib/host/devtools/faces.js +169 -0
- package/dist/lib/host/devtools/log.d.ts +3 -0
- package/dist/lib/host/devtools/log.js +32 -0
- package/dist/lib/host/devtools/machines.d.ts +34 -0
- package/dist/lib/host/devtools/machines.js +212 -0
- package/dist/lib/host/devtools/read.d.ts +13 -0
- package/dist/lib/host/devtools/read.js +52 -0
- package/dist/lib/host/devtools/state.d.ts +90 -0
- package/dist/lib/host/devtools/state.js +123 -0
- package/dist/lib/host/devtools.d.ts +19 -0
- package/dist/lib/host/devtools.js +238 -0
- package/dist/lib/host/fonts/OFL.txt +93 -0
- package/dist/lib/host/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/dist/lib/host/fonts/inter-cyrillic.woff2 +0 -0
- package/dist/lib/host/fonts/inter-greek-ext.woff2 +0 -0
- package/dist/lib/host/fonts/inter-greek.woff2 +0 -0
- package/dist/lib/host/fonts/inter-latin-ext.woff2 +0 -0
- package/dist/lib/host/fonts/inter-latin.woff2 +0 -0
- package/dist/lib/host/fonts/inter-vietnamese.woff2 +0 -0
- package/dist/lib/host/fonts.d.ts +11 -0
- package/dist/lib/host/fonts.js +30 -0
- package/dist/lib/host/icons.js +4 -0
- package/dist/lib/host/index.d.ts +5 -1
- package/dist/lib/host/index.js +110 -5
- package/dist/lib/host/js.d.ts +5 -0
- package/dist/lib/host/js.js +130 -0
- package/dist/lib/host/locale.d.ts +18 -0
- package/dist/lib/host/locale.js +75 -5
- package/dist/lib/host/markdown.d.ts +6 -0
- package/dist/lib/host/markdown.js +18 -0
- package/dist/lib/host/modules.d.ts +4 -0
- package/dist/lib/host/modules.js +157 -20
- package/dist/lib/host/motion.d.ts +32 -0
- package/dist/lib/host/motion.js +190 -0
- package/dist/lib/host/net.js +14 -3
- package/dist/lib/host/orbit.d.ts +121 -0
- package/dist/lib/host/orbit.js +374 -0
- package/dist/lib/host/palette.d.ts +17 -0
- package/dist/lib/host/palette.js +131 -0
- package/dist/lib/host/rows.d.ts +14 -0
- package/dist/lib/host/rows.js +29 -0
- package/dist/lib/host/scheduler.d.ts +8 -0
- package/dist/lib/host/scheduler.js +64 -36
- package/dist/lib/host/share.d.ts +31 -0
- package/dist/lib/host/share.js +134 -0
- package/dist/lib/host/theme/classic.d.ts +1 -0
- package/dist/lib/host/theme/classic.js +120 -0
- package/dist/lib/host/theme/cupertino.d.ts +1 -0
- package/dist/lib/host/theme/cupertino.js +65 -0
- package/dist/lib/host/theme/data.d.ts +1 -0
- package/dist/lib/host/theme/data.js +109 -0
- package/dist/lib/host/theme/devtools.d.ts +1 -0
- package/dist/lib/host/theme/devtools.js +166 -0
- package/dist/lib/host/theme/dialogs.d.ts +1 -0
- package/dist/lib/host/theme/dialogs.js +63 -0
- package/dist/lib/host/theme/fluent.d.ts +1 -0
- package/dist/lib/host/theme/fluent.js +64 -0
- package/dist/lib/host/theme/forms.d.ts +1 -0
- package/dist/lib/host/theme/forms.js +239 -0
- package/dist/lib/host/theme/fusion.d.ts +1 -0
- package/dist/lib/host/theme/fusion.js +66 -0
- package/dist/lib/host/theme/layout.d.ts +1 -0
- package/dist/lib/host/theme/layout.js +166 -0
- package/dist/lib/host/theme/media.d.ts +1 -0
- package/dist/lib/host/theme/media.js +106 -0
- package/dist/lib/host/theme/navigation.d.ts +1 -0
- package/dist/lib/host/theme/navigation.js +36 -0
- package/dist/lib/host/theme/panes.d.ts +1 -0
- package/dist/lib/host/theme/panes.js +99 -0
- package/dist/lib/host/theme/popups.d.ts +1 -0
- package/dist/lib/host/theme/popups.js +149 -0
- package/dist/lib/host/theme/responsive.d.ts +1 -0
- package/dist/lib/host/theme/responsive.js +103 -0
- package/dist/lib/host/theme/toasts.d.ts +1 -0
- package/dist/lib/host/theme/toasts.js +62 -0
- package/dist/lib/host/theme.js +19 -1179
- package/dist/lib/ui/dialect/events.trb +276 -0
- package/dist/lib/ui/dialect/faces.trb +135 -0
- package/dist/lib/ui/dialect/layout.trb +283 -0
- package/dist/lib/ui/dialect/palette.trb +87 -0
- package/dist/lib/ui/dialect/problems.trb +174 -0
- package/dist/lib/ui/dialect/reactions.trb +198 -0
- package/dist/lib/ui/dialect/rows.trb +208 -0
- package/dist/lib/ui/dialect/screens.trb +293 -0
- package/dist/lib/ui/dialect/steps.trb +203 -0
- package/dist/lib/ui/dialect/validation.trb +137 -0
- package/dist/lib/ui/dialect/view.trb +110 -0
- package/dist/lib/ui/dialect/walking.trb +98 -0
- package/dist/lib/ui/dialect/words.trb +70 -0
- package/dist/lib/ui/i18n.trb +23 -0
- package/dist/lib/ui/test.trb +12 -0
- package/dist/lib/ui/testing/actions.trb +421 -0
- package/dist/lib/ui/testing/faces.trb +148 -0
- package/dist/lib/ui/testing/server.trb +73 -0
- package/dist/lib/ui/ui.trb +25 -1234
- package/dist/trebol.js +4882 -1088
- package/editors/vscode/README.md +15 -0
- package/editors/vscode/language-configuration.json +28 -0
- package/editors/vscode/package.json +42 -0
- package/editors/vscode/syntaxes/trebol.tmLanguage.json +237 -0
- package/package.json +7 -3
- package/src/core/boot.ts +10 -7
- package/src/core/eval.ts +2 -2
- package/src/core/func.ts +4 -0
- package/src/core/machine/checks.ts +251 -0
- package/src/core/machine/events.ts +366 -0
- package/src/core/machine/running.ts +181 -0
- package/src/core/machine/shared.ts +124 -0
- package/src/core/machine/snapshot.ts +245 -0
- package/src/core/machine/spec.ts +275 -0
- package/src/core/machine/words.ts +99 -0
- package/src/core/machine.ts +20 -0
- package/src/core/mezz.ts +31 -0
- package/src/core/natives/control.ts +2 -2
- package/src/core/natives/data.ts +6 -1
- package/src/core/natives/parse.ts +1 -1
- package/src/core/natives/series.ts +55 -11
- package/src/core/natives/text.ts +2 -1
- package/src/host/browser/calendar.ts +264 -0
- package/src/host/browser/count.ts +48 -0
- package/src/host/browser/dialogs.ts +439 -0
- package/src/host/browser/drag.ts +278 -0
- package/src/host/browser/drawings.ts +178 -0
- package/src/host/browser/events.ts +117 -0
- package/src/host/browser/faces.ts +143 -0
- package/src/host/browser/fields.ts +315 -0
- package/src/host/browser/keys.ts +145 -0
- package/src/host/browser/lookup.ts +262 -0
- package/src/host/browser/menus.ts +146 -0
- package/src/host/browser/mount.ts +420 -0
- package/src/host/browser/orbits.ts +418 -0
- package/src/host/browser/page.ts +43 -0
- package/src/host/browser/richtext.ts +346 -0
- package/src/host/browser/row-faces.ts +75 -0
- package/src/host/browser/screens.ts +142 -0
- package/src/host/browser/swipe.ts +168 -0
- package/src/host/browser/sync.ts +354 -0
- package/src/host/browser/tables.ts +461 -0
- package/src/host/browser/times.ts +115 -0
- package/src/host/browser/toolbars.ts +126 -0
- package/src/host/browser/trees.ts +205 -0
- package/src/host/browser/uploads.ts +367 -0
- package/src/host/browser/widget.ts +103 -0
- package/src/host/browser.ts +128 -3747
- package/src/host/devlog.ts +16 -0
- package/src/host/devtools/console.ts +102 -0
- package/src/host/devtools/faces.ts +160 -0
- package/src/host/devtools/log.ts +34 -0
- package/src/host/devtools/machines.ts +208 -0
- package/src/host/devtools/read.ts +58 -0
- package/src/host/devtools/state.ts +148 -0
- package/src/host/devtools.ts +238 -0
- package/src/host/fonts/OFL.txt +93 -0
- package/src/host/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/src/host/fonts/inter-cyrillic.woff2 +0 -0
- package/src/host/fonts/inter-greek-ext.woff2 +0 -0
- package/src/host/fonts/inter-greek.woff2 +0 -0
- package/src/host/fonts/inter-latin-ext.woff2 +0 -0
- package/src/host/fonts/inter-latin.woff2 +0 -0
- package/src/host/fonts/inter-vietnamese.woff2 +0 -0
- package/src/host/fonts.ts +40 -0
- package/src/host/icons.ts +4 -0
- package/src/host/index.ts +110 -5
- package/src/host/js.ts +127 -0
- package/src/host/locale.ts +71 -5
- package/src/host/markdown.ts +18 -0
- package/src/host/modules.ts +150 -22
- package/src/host/motion.ts +204 -0
- package/src/host/net.ts +13 -3
- package/src/host/orbit.ts +432 -0
- package/src/host/palette.ts +139 -0
- package/src/host/rows.ts +30 -0
- package/src/host/scheduler.ts +67 -36
- package/src/host/share.ts +168 -0
- package/src/host/theme/classic.ts +121 -0
- package/src/host/theme/cupertino.ts +66 -0
- package/src/host/theme/data.ts +110 -0
- package/src/host/theme/devtools.ts +167 -0
- package/src/host/theme/dialogs.ts +64 -0
- package/src/host/theme/fluent.ts +65 -0
- package/src/host/theme/forms.ts +240 -0
- package/src/host/theme/fusion.ts +67 -0
- package/src/host/theme/layout.ts +167 -0
- package/src/host/theme/media.ts +107 -0
- package/src/host/theme/navigation.ts +37 -0
- package/src/host/theme/panes.ts +100 -0
- package/src/host/theme/popups.ts +150 -0
- package/src/host/theme/responsive.ts +104 -0
- package/src/host/theme/toasts.ts +63 -0
- package/src/host/theme.ts +19 -1179
- package/src/ui/dialect/events.trb +276 -0
- package/src/ui/dialect/faces.trb +135 -0
- package/src/ui/dialect/layout.trb +283 -0
- package/src/ui/dialect/palette.trb +87 -0
- package/src/ui/dialect/problems.trb +174 -0
- package/src/ui/dialect/reactions.trb +198 -0
- package/src/ui/dialect/rows.trb +208 -0
- package/src/ui/dialect/screens.trb +293 -0
- package/src/ui/dialect/steps.trb +203 -0
- package/src/ui/dialect/validation.trb +137 -0
- package/src/ui/dialect/view.trb +110 -0
- package/src/ui/dialect/walking.trb +98 -0
- package/src/ui/dialect/words.trb +70 -0
- package/src/ui/i18n.trb +23 -0
- package/src/ui/test.trb +12 -0
- package/src/ui/testing/actions.trb +421 -0
- package/src/ui/testing/faces.trb +148 -0
- package/src/ui/testing/server.trb +73 -0
- package/src/ui/ui.trb +25 -1234
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
; A part of the UI dialect: see ui.trb, whose words it shares.
|
|
2
|
+
|
|
3
|
+
; --- events --------------------------------------------------------------------
|
|
4
|
+
;
|
|
5
|
+
; The host calls these from DOM events, each in its own task.
|
|
6
|
+
|
|
7
|
+
; A handler block runs with face, value, values and, as in Red, event bound;
|
|
8
|
+
; event is an object (event/key, event/away? ...) or none. Named fields are
|
|
9
|
+
; not bound: their values are in values, their faces reached through labels.
|
|
10
|
+
run-handler: function [f body [block!] /with ev [object!] /on node "row is this node, not the selected one" /given v "value is this, not the face's"] [
|
|
11
|
+
scope: any [f/form f/root]
|
|
12
|
+
; /only: a value that is a block stays one block
|
|
13
|
+
words: compose/only [
|
|
14
|
+
face: (f)
|
|
15
|
+
value: (quoted either given [:v] [f/value])
|
|
16
|
+
values: (form-values any [scope f])
|
|
17
|
+
]
|
|
18
|
+
if find data-styles f/style [append words compose [row: (either on [node] [f/selected])]]
|
|
19
|
+
append words compose [event: (either with [ev] [none])]
|
|
20
|
+
ctx: make object! words
|
|
21
|
+
do bind copy/deep body ctx
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
; A value as it must appear in a block given to make object!
|
|
25
|
+
quoted: func [v] [
|
|
26
|
+
case [
|
|
27
|
+
word? :v [to lit-word! :v]
|
|
28
|
+
path? :v [to lit-path! :v]
|
|
29
|
+
true [:v]
|
|
30
|
+
]
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
handler-for: function [f name] [
|
|
34
|
+
all [f/events select f/events name]
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
ui-input: function [
|
|
38
|
+
"Called by the host when the user changes a field."
|
|
39
|
+
f new
|
|
40
|
+
] [
|
|
41
|
+
f/value: switch/default f/style [
|
|
42
|
+
number [any [attempt [to decimal! new] none]]
|
|
43
|
+
slider [slider-at f attempt [to decimal! new]]
|
|
44
|
+
; the host gives the amount as 1234.5, whatever the language
|
|
45
|
+
money [all [new attempt [to money! rejoin [any [f/currency ""] "$" new]]]]
|
|
46
|
+
; and a date as 2026-11-03
|
|
47
|
+
date [all [new attempt [to date! new]]]
|
|
48
|
+
; and a range of dates as 2026-11-03 2026-11-10, the start first
|
|
49
|
+
; and a time as 09:30
|
|
50
|
+
time [all [new attempt [to time! new]]]
|
|
51
|
+
date-range [all [new attempt [range: load new all [block? range 2 = length? range date? range/1 date? range/2 range/1 <= range/2 range]]]]
|
|
52
|
+
check [to logic! new]
|
|
53
|
+
toggle [to logic! new]
|
|
54
|
+
] [new]
|
|
55
|
+
if find [number slider] f/style [
|
|
56
|
+
if all [decimal? f/value f/value = to integer! f/value] [f/value: to integer! f/value]
|
|
57
|
+
]
|
|
58
|
+
; text that is not a number, amount or date stays on screen, with its message
|
|
59
|
+
f/typed: all [find [number money date date-range time] f/style new none? f/value new]
|
|
60
|
+
changed f
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
changed: function [f] [
|
|
64
|
+
f/async-error: none
|
|
65
|
+
store-around f
|
|
66
|
+
refresh-form any [f/form f/root]
|
|
67
|
+
if f/action [run-handler f f/action]
|
|
68
|
+
if h: handler-for f 'on-change [run-handler f h]
|
|
69
|
+
if all [f/form f/form/style = 'entry] [changed f/form/owner]
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
; An upload's value is none or a block of objects [name size type file];
|
|
73
|
+
; file is a handle the host keeps, read with read-file or sent with multipart.
|
|
74
|
+
; A photo's is none, the object of the image chosen, or the address of one kept elsewhere.
|
|
75
|
+
ui-files: function [
|
|
76
|
+
"Called by the host when the user chooses or drops files: name size type file for each, and the names it refused."
|
|
77
|
+
f files [block!] refused [block!]
|
|
78
|
+
] [
|
|
79
|
+
chosen: collect [
|
|
80
|
+
foreach [n s t h] files [keep make object! [name: n size: s type: t file: h]]
|
|
81
|
+
]
|
|
82
|
+
unless empty? chosen [
|
|
83
|
+
f/value: case [
|
|
84
|
+
f/style = 'photo [first chosen]
|
|
85
|
+
f/multiple [append copy any [f/value []] chosen]
|
|
86
|
+
true [copy/part chosen 1]
|
|
87
|
+
]
|
|
88
|
+
]
|
|
89
|
+
f/typed: either empty? refused [none] [refused]
|
|
90
|
+
f/touched: true
|
|
91
|
+
changed f
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
ui-remove-file: function [
|
|
95
|
+
"Called by the host when the user removes the file at a position of an upload, or a photo's."
|
|
96
|
+
f index [integer!]
|
|
97
|
+
] [
|
|
98
|
+
f/value: either f/style = 'photo [none] [
|
|
99
|
+
files: remove at copy f/value index
|
|
100
|
+
either empty? head files [none] [head files]
|
|
101
|
+
]
|
|
102
|
+
f/typed: none
|
|
103
|
+
f/touched: true
|
|
104
|
+
changed f
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
; A lookup's value is none, one value, or with `multiple` a block of them. Its on-search
|
|
108
|
+
; answers the options for event/query: maps with value and text, as a choice takes them.
|
|
109
|
+
ui-lookup-search: function [
|
|
110
|
+
"Called by the host when the user opens a lookup or types in it."
|
|
111
|
+
f text [string!]
|
|
112
|
+
] [
|
|
113
|
+
f/query: text
|
|
114
|
+
found: fire-event f 'on-search compose [query: (text)]
|
|
115
|
+
; the user may have typed on while this was answering
|
|
116
|
+
if f/query = text [f/options: either block? :found [found] [copy []]]
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
ui-lookup-pick: function [
|
|
120
|
+
"Called by the host when the user chooses an option of a lookup."
|
|
121
|
+
f option [map!]
|
|
122
|
+
] [
|
|
123
|
+
unless f/known [f/known: make map! []]
|
|
124
|
+
poke f/known option/value option/text
|
|
125
|
+
f/value: either f/multiple [
|
|
126
|
+
any [
|
|
127
|
+
all [f/value find f/value option/value f/value]
|
|
128
|
+
append copy any [f/value []] option/value
|
|
129
|
+
]
|
|
130
|
+
] [option/value]
|
|
131
|
+
changed f
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
ui-lookup-remove: function [
|
|
135
|
+
"Called by the host when the user removes the value at a position of a multiple lookup."
|
|
136
|
+
f index [integer!]
|
|
137
|
+
] [
|
|
138
|
+
chosen: head remove at copy f/value index
|
|
139
|
+
f/value: either empty? chosen [none] [chosen]
|
|
140
|
+
changed f
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
ui-blur: function [
|
|
144
|
+
"Called by the host when the user leaves a field."
|
|
145
|
+
f
|
|
146
|
+
] [
|
|
147
|
+
f/touched: true
|
|
148
|
+
check-async f
|
|
149
|
+
refresh-form any [f/form f/root]
|
|
150
|
+
]
|
|
151
|
+
|
|
152
|
+
ui-click: function [
|
|
153
|
+
"Called by the host when the user activates a button."
|
|
154
|
+
f
|
|
155
|
+
] [
|
|
156
|
+
if f/submit [
|
|
157
|
+
scope: any [f/form f/root]
|
|
158
|
+
faces: own-faces scope
|
|
159
|
+
foreach g faces [if g/rules [g/touched: true]]
|
|
160
|
+
foreach g faces [check-async g]
|
|
161
|
+
refresh-form scope
|
|
162
|
+
if f/disabled [exit]
|
|
163
|
+
]
|
|
164
|
+
if f/action [run-handler f f/action]
|
|
165
|
+
]
|
|
166
|
+
|
|
167
|
+
ui-select: function [
|
|
168
|
+
"Called by the host when the user chooses a row of a table or list."
|
|
169
|
+
f row
|
|
170
|
+
] [
|
|
171
|
+
f/selected: row
|
|
172
|
+
if h: handler-for f 'on-select [run-handler f h]
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
ui-sort: function [
|
|
176
|
+
"Called by the host when the user chooses the header of a column of a table."
|
|
177
|
+
f column [word!]
|
|
178
|
+
] [
|
|
179
|
+
order: either all [block? f/sorted f/sorted/1 = column f/sorted/2 = 'asc] ['desc] ['asc]
|
|
180
|
+
f/sorted: reduce [column order]
|
|
181
|
+
fire-event f 'on-sort reduce [quote column: to lit-word! column quote order: to lit-word! order]
|
|
182
|
+
]
|
|
183
|
+
|
|
184
|
+
ui-close: function [
|
|
185
|
+
"Called by the host when the user dismisses a dialog."
|
|
186
|
+
f
|
|
187
|
+
] [
|
|
188
|
+
f/hidden: true
|
|
189
|
+
if h: handler-for f 'on-close [run-handler f h]
|
|
190
|
+
]
|
|
191
|
+
|
|
192
|
+
; Runs the on-xxx handler of an event with event bound to an object made of
|
|
193
|
+
; type (the event name without on-) and the given [word: value ...] fields.
|
|
194
|
+
fire-event: function [f name [word!] fields [block!]] [
|
|
195
|
+
if h: handler-for f name [
|
|
196
|
+
type: to word! skip form name 3
|
|
197
|
+
run-handler/with f h make object! append reduce [quote type: to lit-word! type] fields
|
|
198
|
+
]
|
|
199
|
+
]
|
|
200
|
+
|
|
201
|
+
ui-event: function [
|
|
202
|
+
"Called by the host for on-focus, on-unfocus, on-over, on-dbl-click and on-key."
|
|
203
|
+
f name [word!] fields [block!]
|
|
204
|
+
] [
|
|
205
|
+
fire-event f name fields
|
|
206
|
+
]
|
|
207
|
+
|
|
208
|
+
ui-crumb: function [
|
|
209
|
+
"Called by the host when the user chooses an item of a breadcrumb."
|
|
210
|
+
f item [word! path!]
|
|
211
|
+
] [
|
|
212
|
+
f/value: item
|
|
213
|
+
if f/action [run-handler f f/action]
|
|
214
|
+
]
|
|
215
|
+
|
|
216
|
+
ui-menu: function [
|
|
217
|
+
"Called by the host when the user chooses a menu item; row is the row it was opened on."
|
|
218
|
+
f item row
|
|
219
|
+
] [
|
|
220
|
+
if row [f/selected: row]
|
|
221
|
+
fire-event f 'on-menu reduce [quote picked: quoted item/id]
|
|
222
|
+
]
|
|
223
|
+
|
|
224
|
+
ui-drop: function [
|
|
225
|
+
"Called by the host when something is dropped on a face; index is where it goes (1-based), parent the tree node."
|
|
226
|
+
f dropped source index [integer!] parent
|
|
227
|
+
] [
|
|
228
|
+
; a lane of a board
|
|
229
|
+
if all [f/owner f/owner/style = 'board] [return board-drop f/owner f :dropped]
|
|
230
|
+
fields: reduce [quote dropped: quoted :dropped quote source: source quote index: index]
|
|
231
|
+
if f/style = 'tree [append fields reduce [quote parent: parent]]
|
|
232
|
+
fire-event f 'on-drop fields
|
|
233
|
+
]
|
|
234
|
+
|
|
235
|
+
ui-reorder: function [
|
|
236
|
+
"Called by the host when the user moves a child or row of a face; in a tree, among the children of parent."
|
|
237
|
+
f from [integer!] to [integer!] parent
|
|
238
|
+
] [
|
|
239
|
+
fields: reduce [quote from: from quote to: to]
|
|
240
|
+
case [
|
|
241
|
+
f/style = 'tree [
|
|
242
|
+
either parent [parent/children: move-item parent/children from to] [f/data: move-item f/data from to]
|
|
243
|
+
f/data: f/data ; repaint the tree
|
|
244
|
+
append fields reduce [quote parent: parent]
|
|
245
|
+
]
|
|
246
|
+
find data-styles f/style [f/data: move-item f/data from to]
|
|
247
|
+
true [f/pane: move-item f/pane from to]
|
|
248
|
+
]
|
|
249
|
+
fire-event f 'on-reorder fields
|
|
250
|
+
]
|
|
251
|
+
|
|
252
|
+
ui-orbit: function [
|
|
253
|
+
"Called by the host when the user picks a node of an orbit: a neighbour, or one of the trail when back is true."
|
|
254
|
+
f id back [logic!]
|
|
255
|
+
] [
|
|
256
|
+
f/value: id
|
|
257
|
+
; with no on-back, stepping back is one more pick
|
|
258
|
+
either all [back handler-for f 'on-back] [fire-event f 'on-back []] [if f/action [run-handler f f/action]]
|
|
259
|
+
]
|
|
260
|
+
|
|
261
|
+
ui-expand: function [
|
|
262
|
+
"Called by the host when the user opens a node of a tree."
|
|
263
|
+
f node
|
|
264
|
+
] [
|
|
265
|
+
if h: handler-for f 'on-expand [
|
|
266
|
+
run-handler/with/on f h make object! [type: 'expand] node
|
|
267
|
+
]
|
|
268
|
+
]
|
|
269
|
+
|
|
270
|
+
move-item: function [items [block!] from [integer!] to [integer!]] [
|
|
271
|
+
items: copy items
|
|
272
|
+
x: pick items from
|
|
273
|
+
remove at items from
|
|
274
|
+
insert/only at items to :x
|
|
275
|
+
items
|
|
276
|
+
]
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
; A part of the UI dialect: see ui.trb, whose words it shares.
|
|
2
|
+
|
|
3
|
+
; --- faces ---------------------------------------------------------------------
|
|
4
|
+
;
|
|
5
|
+
; A face is an object. The host keeps one DOM node per face and copies these
|
|
6
|
+
; fields to it after every scheduler slice, so code changes a face by
|
|
7
|
+
; setting a field: `total/text: "42"`.
|
|
8
|
+
|
|
9
|
+
face: make object! [
|
|
10
|
+
style: 'face ; what the host renders
|
|
11
|
+
name: none ; field name: the key in `values`, and a word in handlers
|
|
12
|
+
text: none ; label, caption or content
|
|
13
|
+
value: none ; a field's value; also a progress (0-1 or percent) or an image (file or url)
|
|
14
|
+
hint: none ; placeholder
|
|
15
|
+
role: none ; primary accent danger success warning muted
|
|
16
|
+
size: none ; small medium large
|
|
17
|
+
align: none ; left center right spread
|
|
18
|
+
valign: none ; a row's children, top middle bottom; none lines them up on the controls
|
|
19
|
+
cols: none ; columns of a grid: a number, or the weight of each [1 4 1]
|
|
20
|
+
icon: none
|
|
21
|
+
fill: false
|
|
22
|
+
fit: false ; takes the height the window has left, and its children scroll inside
|
|
23
|
+
pad: none ; inner and between-children spacing, a step of the spacing scale (0-7)
|
|
24
|
+
gap: none
|
|
25
|
+
narrow-only: false ; shown only on narrow screens
|
|
26
|
+
wide-only: false ; hidden on narrow screens
|
|
27
|
+
hidden: false
|
|
28
|
+
disabled: false
|
|
29
|
+
readonly: false ; shown and sent, but the user cannot change it, and no rule applies
|
|
30
|
+
inert: false ; shown as it is, but neither it nor its children can be used
|
|
31
|
+
linked: false ; a tile that stands for something kept elsewhere: marked with an arrow
|
|
32
|
+
mark: none ; a tile: a second, small icon on its own (#list), and what it says (mark-text)
|
|
33
|
+
mark-text: none
|
|
34
|
+
round: false ; an image: cut to a circle, as for a person's photo
|
|
35
|
+
count: false ; a text whose number changes runs from the old one to the new
|
|
36
|
+
tag: none ; a widget: the name of the element it is, as the page's JavaScript defines it
|
|
37
|
+
props: none ; a widget: the element's properties, an object
|
|
38
|
+
poster: none ; a video: the image shown before it plays
|
|
39
|
+
captions: none ; a video: its captions, a .vtt file, or a block of one per language [en %a.vtt es %b.vtt]
|
|
40
|
+
looping: false ; a video or a sound starts again when it ends (loop in the dialect)
|
|
41
|
+
silent: false ; a video or a sound plays without its sound (muted in the dialect)
|
|
42
|
+
autoplay: false ; a video or a sound plays on its own, always silent, as browsers allow
|
|
43
|
+
drag: false ; can be dragged: carries its value, or the row in a table, list or tree
|
|
44
|
+
drop: false ; accepts drops (on-drop)
|
|
45
|
+
reorder: false ; its children or rows can be moved around (on-reorder)
|
|
46
|
+
rules: none ; validation: a block of [rule args...] blocks
|
|
47
|
+
error: none ; current message, shown once the face is touched
|
|
48
|
+
touched: false
|
|
49
|
+
pending: false ; an asynchronous check is running
|
|
50
|
+
sent: none ; an upload or photo: how far its files went up, 0-1; none hides the bar
|
|
51
|
+
async-error: none ; result of the last asynchronous check
|
|
52
|
+
action: none ; the block after the face: click, change
|
|
53
|
+
events: none ; [on-change [...] on-select [...]]
|
|
54
|
+
shortcut: none ; a key that activates a button or link: "Ctrl+S"
|
|
55
|
+
menu: none ; context menu (or the menu a button opens): a block of menu items; on-menu runs
|
|
56
|
+
options: none ; choices of a choice or radio; what a lookup's search found
|
|
57
|
+
known: none ; a lookup: what each value shows as, a map; a value not in it shows as itself
|
|
58
|
+
links: none ; a lookup: the screen each value links to when readonly, a map
|
|
59
|
+
query: none ; a lookup: the text last searched for
|
|
60
|
+
currency: none ; a money field's currency code: EUR
|
|
61
|
+
step: none ; a slider: how far one move takes it, none is 1; a time: minutes between those listed, none is 30
|
|
62
|
+
reactions: none ; react, is and calc: a block of reaction objects
|
|
63
|
+
template: none ; rows: the block of the fields of one row
|
|
64
|
+
built: none ; rows: what its rows were last made from
|
|
65
|
+
owner: none ; a row of rows: the rows face it belongs to
|
|
66
|
+
typed: none ; what the user typed in a number, money or date field when it is not one;
|
|
67
|
+
; in an upload or photo, the names of the files it refused
|
|
68
|
+
multiple: false ; an upload or a lookup takes more than one
|
|
69
|
+
accept: none ; the files an upload takes: ["pdf" "image/*"]; a photo, images unless told
|
|
70
|
+
pane: none
|
|
71
|
+
columns: none ; table, list and tree: [field "Label" ...]; a column of images, [field ["Label" image round]]
|
|
72
|
+
data: none ; table, list and tree: a block of map! or object! rows (a tree's
|
|
73
|
+
; have their own in `children`); breadcrumb: its items; orbit: its focus, nodes, edges and trail
|
|
74
|
+
key: 'id ; the row field that identifies a row
|
|
75
|
+
morph: none ; a name shared with a face of the next screen, which this one becomes as the screen
|
|
76
|
+
; changes: a word, or a block of values; a table or list gives each row its name and key
|
|
77
|
+
selected: none ; the row last chosen
|
|
78
|
+
sortable: false ; a table the host sorts, from the rows it has, when a header is chosen
|
|
79
|
+
sorted: none ; a table: the order shown, [column asc] or [column desc]
|
|
80
|
+
totals: none ; a table: a row shown at the foot, never chosen nor sorted
|
|
81
|
+
kind: none ; a chart: bar line area pie
|
|
82
|
+
stacked: false ; a chart: its series one on top of another
|
|
83
|
+
draw: none ; a canvas: the block of the draw dialect it shows
|
|
84
|
+
extent: none ; a canvas: the size of its drawing space, a pair
|
|
85
|
+
form: none ; the enclosing form, if any
|
|
86
|
+
root: none ; the view this face belongs to
|
|
87
|
+
place: none ; where the face was written, file:line:col; none if made at run time
|
|
88
|
+
submit: false
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
; style name -> prototype face
|
|
92
|
+
styles: make map! []
|
|
93
|
+
|
|
94
|
+
container-styles: [view column row form panel grid dialog scroll split toolbar desktop]
|
|
95
|
+
input-styles: [field password number money date date-range time area rich check toggle choice radio upload photo lookup rows widget slider]
|
|
96
|
+
data-styles: [table list tree chart board]
|
|
97
|
+
|
|
98
|
+
foreach [name base] [
|
|
99
|
+
view column column column row row form form panel panel grid grid scroll scroll desktop desktop
|
|
100
|
+
title title heading heading text text divider divider
|
|
101
|
+
field field password password number number money money date date date-range date-range time time area area rich rich check check choice choice
|
|
102
|
+
toggle toggle radio radio upload upload photo photo lookup lookup progress progress image image backdrop backdrop icon icon
|
|
103
|
+
video video audio audio widget widget slider slider
|
|
104
|
+
button button link link tile tile table table list list tabs tabs tab tab steps steps step step
|
|
105
|
+
toolbar toolbar breadcrumb breadcrumb tree tree screens screens screen screen rows rows entry entry
|
|
106
|
+
canvas canvas chart chart orbit orbit board board
|
|
107
|
+
] [
|
|
108
|
+
poke styles name make face [style: base]
|
|
109
|
+
]
|
|
110
|
+
poke styles 'view make face [style: 'view]
|
|
111
|
+
poke styles 'submit make face [style: 'button role: 'primary submit: true]
|
|
112
|
+
poke styles 'dialog make face [style: 'dialog hidden: true]
|
|
113
|
+
poke styles 'tabs make face [style: 'tabs value: 1]
|
|
114
|
+
; value: the step on show, counting every step; flow: the word of a machine that leads them; trail: the
|
|
115
|
+
; snapshots of that machine before each Next, which Back puts back
|
|
116
|
+
poke styles 'steps make face [style: 'steps value: 1 flow: none trail: none]
|
|
117
|
+
poke styles 'screens make face [style: 'screens entering: false] ; entering: the screen on show is still the old one
|
|
118
|
+
poke styles 'split make face [style: 'split value: 1] ; value: the pane shown on narrow screens
|
|
119
|
+
poke styles 'canvas make face [style: 'canvas extent: 300x150]
|
|
120
|
+
poke styles 'chart make face [style: 'chart kind: 'bar]
|
|
121
|
+
; field: the field of a row that names its lane; lanes: [word label ...]; card: the columns a card shows
|
|
122
|
+
poke styles 'board make face [style: 'board field: none lanes: none card: none]
|
|
123
|
+
|
|
124
|
+
stylize: function [
|
|
125
|
+
"Defines styles from existing ones: name: base [field: value ...]"
|
|
126
|
+
spec [block!]
|
|
127
|
+
] [
|
|
128
|
+
parse spec [some [
|
|
129
|
+
set name set-word! set base word! set defaults block! (
|
|
130
|
+
proto: select styles base
|
|
131
|
+
unless proto [do make error! rejoin ["stylize: unknown style " base ui-suggest base words-of styles]]
|
|
132
|
+
poke styles to word! name make proto defaults
|
|
133
|
+
)
|
|
134
|
+
]]
|
|
135
|
+
]
|