galath 1.0.4 → 1.0.5

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 (55) hide show
  1. package/package.json +16 -3
  2. package/{packages/galath/src → src}/rendering.js +4 -5
  3. package/.nojekyll +0 -0
  4. package/AGENTS.md +0 -1
  5. package/TODO.md +0 -140
  6. package/index.html +0 -188
  7. package/logo.jpg +0 -0
  8. package/logo.svg +0 -96
  9. package/packages/galath/package.json +0 -28
  10. package/packages/galath-css/css/bootstrap-icons.min.css +0 -5
  11. package/packages/galath-css/css/bootstrap.min.css +0 -6
  12. package/packages/galath-css/css/fonts/bootstrap-icons.json +0 -2077
  13. package/packages/galath-css/css/fonts/bootstrap-icons.woff +0 -0
  14. package/packages/galath-css/css/fonts/bootstrap-icons.woff2 +0 -0
  15. package/packages/galath-css/js/bootstrap.bundle.min.js +0 -7
  16. package/packages/galath-css/package.json +0 -13
  17. package/playground/app.xml +0 -214
  18. package/playground/chapters/01-welcome.xml +0 -94
  19. package/playground/chapters/02-signals.xml +0 -166
  20. package/playground/chapters/03-instance.xml +0 -130
  21. package/playground/chapters/04-bindings.xml +0 -156
  22. package/playground/chapters/05-lists.xml +0 -138
  23. package/playground/chapters/06-commands.xml +0 -144
  24. package/playground/chapters/07-controller.xml +0 -115
  25. package/playground/chapters/08-events.xml +0 -126
  26. package/playground/chapters/09-behaviors.xml +0 -210
  27. package/playground/chapters/10-components.xml +0 -152
  28. package/playground/chapters/11-imports.xml +0 -108
  29. package/playground/chapters/12-expressions.xml +0 -161
  30. package/playground/chapters/13-paths.xml +0 -197
  31. package/playground/components/chapter-shell.xml +0 -29
  32. package/playground/components/highlighter.js +0 -111
  33. package/playground/components/run-snippet.js +0 -120
  34. package/public/basic/bootstrap-icons.min.css +0 -5
  35. package/public/basic/bootstrap.bundle.min.js +0 -7
  36. package/public/basic/bootstrap.min.css +0 -6
  37. package/public/basic/fonts/bootstrap-icons.json +0 -2077
  38. package/public/basic/fonts/bootstrap-icons.woff +0 -0
  39. package/public/basic/fonts/bootstrap-icons.woff2 +0 -0
  40. package/public/basic/theme.css +0 -209
  41. package/seed.html +0 -321
  42. /package/{packages/galath/src → src}/behavior.js +0 -0
  43. /package/{packages/galath/src → src}/binding.js +0 -0
  44. /package/{packages/galath/src → src}/boot.js +0 -0
  45. /package/{packages/galath/src → src}/command.js +0 -0
  46. /package/{packages/galath/src → src}/component.js +0 -0
  47. /package/{packages/galath/src → src}/controller.js +0 -0
  48. /package/{packages/galath/src → src}/core.js +0 -0
  49. /package/{packages/galath/src → src}/imports.js +0 -0
  50. /package/{packages/galath/src → src}/index.js +0 -0
  51. /package/{packages/galath/src → src}/instance-model.js +0 -0
  52. /package/{packages/galath/src → src}/morph.js +0 -0
  53. /package/{packages/galath/src → src}/signals.js +0 -0
  54. /package/{packages/galath/src → src}/templates.js +0 -0
  55. /package/{packages/galath/src → src}/xml-events.js +0 -0
@@ -1,152 +0,0 @@
1
- <!--
2
- chapters/10-components.xml
3
-
4
- Components: <component name="..." tag="..."> compiles into a real
5
- Custom Element. Props become signals via attributes; <style> is auto-
6
- scoped; <on:mount>/<on:unmount> let components run setup/teardown.
7
-
8
- This chapter defines a tiny <x-counter-pair> component inline and uses
9
- it twice on the page.
10
- -->
11
- <galath xmlns:bind="urn:galath:bind" xmlns:on="urn:galath:on" xmlns:use="urn:galath:use" xmlns:drag="urn:galath:drag" xmlns:drop="urn:galath:drop" xmlns:class="urn:galath:class">
12
- <!--
13
- A reusable counter component scoped to this chapter. Has props:
14
- label - the heading.
15
- step - how much each tick adds.
16
- And a private `count` signal.
17
-
18
- The <style> block is automatically prefixed so its rules only apply
19
- inside instances of this component.
20
- -->
21
- <component name="counter-pair" tag="x-counter-pair" label="Counter" step="1">
22
- <style>
23
- .panel { border: 1px dashed rgba(255,255,255,.2); border-radius: .5rem; padding: 1rem; }
24
- .panel:hover { border-color: rgba(13, 202, 240, .5); }
25
- .number { font-size: 2rem; font-weight: 600; }
26
- </style>
27
-
28
- <model>
29
- <signal name="count" value="0" />
30
- </model>
31
-
32
- <controller>
33
- <action name="up"><set signal="count" value="count + Number(step)" /></action>
34
- <action name="down"><set signal="count" value="count - Number(step)" /></action>
35
- <action name="reset"><set signal="count" value="0" /></action>
36
- </controller>
37
-
38
- <view>
39
- <div class="panel">
40
- <div class="d-flex align-items-center justify-content-between mb-2">
41
- <strong>{label}</strong>
42
- <small class="text-secondary">step: {step}</small>
43
- </div>
44
- <div class="number text-info">{count}</div>
45
- <div class="d-flex gap-2 mt-2">
46
- <button class="btn btn-sm btn-info" on:click="#up">+ {step}</button>
47
- <button class="btn btn-sm btn-outline-light" on:click="#down">- {step}</button>
48
- <button class="btn btn-sm btn-outline-secondary" on:click="#reset">reset</button>
49
- </div>
50
- </div>
51
- </view>
52
- </component>
53
-
54
- <component name="chapter-components" tag="x-chapter-components">
55
- <model>
56
- <signal name="snippet"><![CDATA[<component name="counter-pair" tag="x-counter-pair" label="Counter" step="1">
57
- <style>
58
- .panel { border: 1px dashed rgba(255,255,255,.2); padding: 1rem; }
59
- </style>
60
-
61
- <model>
62
- <signal name="count" value="0" />
63
- </model>
64
-
65
- <controller>
66
- <action name="up">
67
- <set signal="count" value="count + Number(step)" />
68
- </action>
69
- </controller>
70
-
71
- <view>
72
- <div class="panel">
73
- <strong>{label}</strong>
74
- <div>{count}</div>
75
- <button on:click="#up">+ {step}</button>
76
- </div>
77
- </view>
78
- </component>
79
-
80
- <!-- Use it: -->
81
- <x-counter-pair label="Visitors" step="1" />
82
- <x-counter-pair label="Score" step="10" />]]></signal>
83
- </model>
84
-
85
- <view>
86
- <div class="px-4 py-5">
87
- <x-chapter-heading icon="bi-boxes" title="Components"
88
- subtitle="Compile your own custom elements with props, scoped style, and lifecycle hooks." />
89
-
90
- <div class="row g-4 mb-4">
91
- <div class="col-lg-6">
92
- <div class="card xes-card h-100">
93
- <div class="card-body">
94
- <h2 class="h5"><i class="bi bi-journal-text me-2 text-info"></i>How it works</h2>
95
- <p class="text-secondary">
96
- Every <code>&lt;component&gt;</code> registers a Custom Element with the browser.
97
- Once registered, it's just HTML - you can use it anywhere, even inside other
98
- Galath views.
99
- </p>
100
- <ul class="text-secondary">
101
- <li><strong>Props</strong> are attributes on the component definition. Their
102
- default value is the attribute value. The runtime maps them to signals of
103
- the same name in the component's scope.</li>
104
- <li><strong>Scoped style</strong>: a <code>&lt;style&gt;</code> block at the top
105
- of the component is rewritten so its rules only match inside that
106
- component's root.</li>
107
- <li><strong>Lifecycle</strong>: <code>&lt;on:mount&gt;</code> runs after
108
- connect; <code>&lt;on:unmount&gt;</code> runs before disconnect. Both
109
- accept the same operation vocabulary as commands and actions.</li>
110
- </ul>
111
- <p class="text-secondary mb-0">
112
- The two counter panels below are the same component with different props - one
113
- source of truth, two independent instances.
114
- </p>
115
- </div>
116
- </div>
117
- </div>
118
- <div class="col-lg-6">
119
- <div class="card xes-card h-100">
120
- <div class="card-header bg-transparent d-flex justify-content-between align-items-center">
121
- <strong><i class="bi bi-code-slash me-2"></i>Source</strong>
122
- <div class="btn-group btn-group-sm" role="group"><button class="btn btn-outline-info" on:click="window.galathRunSnippet(snippet)" title="Open this snippet in a new tab"><i class="bi bi-play-fill me-1"></i>Run</button><button class="btn btn-outline-info" use:copy="snippet" title="Copy to clipboard"><i class="bi bi-clipboard me-1"></i>Copy</button></div>
123
- </div>
124
- <div class="card-body p-0">
125
- <pre class="xes-code rounded p-3 mb-0"><code><text value="snippet" /></code></pre>
126
- </div>
127
- </div>
128
- </div>
129
- </div>
130
-
131
- <div class="card xes-card">
132
- <div class="card-header bg-transparent">
133
- <strong><i class="bi bi-play-circle me-2"></i>Live demo</strong>
134
- </div>
135
- <div class="card-body">
136
- <div class="row g-3">
137
- <div class="col-md-4">
138
- <x-counter-pair label="Visitors" step="1" />
139
- </div>
140
- <div class="col-md-4">
141
- <x-counter-pair label="Score" step="10" />
142
- </div>
143
- <div class="col-md-4">
144
- <x-counter-pair label="Temperature" step="5" />
145
- </div>
146
- </div>
147
- </div>
148
- </div>
149
- </div>
150
- </view>
151
- </component>
152
- </galath>
@@ -1,108 +0,0 @@
1
- <!--
2
- chapters/11-imports.xml
3
-
4
- <import src="..."> - the modularity primitive. Galath's answer to ES
5
- modules. Every chapter you've seen in this playground is a separate
6
- XML file, imported into index.html.
7
- -->
8
- <galath xmlns:bind="urn:galath:bind" xmlns:on="urn:galath:on" xmlns:use="urn:galath:use" xmlns:drag="urn:galath:drag" xmlns:drop="urn:galath:drop" xmlns:class="urn:galath:class">
9
- <component name="chapter-imports" tag="x-chapter-imports">
10
- <model>
11
- <signal name="snippetEntry"><![CDATA[<!-- index.html, inside the embedded <galath> source -->
12
- <galath xmlns:bind="urn:galath:bind" xmlns:on="urn:galath:on" xmlns:use="urn:galath:use" xmlns:drag="urn:galath:drag" xmlns:drop="urn:galath:drop" xmlns:class="urn:galath:class">
13
- <import src="./playground/components/chapter-shell.xml" />
14
- <import src="./playground/chapters/01-welcome.xml" />
15
- <import src="./playground/chapters/02-signals.xml" />
16
- <!-- ...one line per chapter... -->
17
- <import src="./playground/app.xml" />
18
-
19
- <application name="playground">
20
- <x-playground />
21
- </application>
22
- </galath>]]></signal>
23
-
24
- <signal name="snippetChild"><![CDATA[<!-- playground/chapters/01-welcome.xml -->
25
- <galath xmlns:bind="urn:galath:bind" xmlns:on="urn:galath:on" xmlns:use="urn:galath:use" xmlns:drag="urn:galath:drag" xmlns:drop="urn:galath:drop" xmlns:class="urn:galath:class">
26
- <component name="chapter-welcome" tag="x-chapter-welcome">
27
- <view>
28
- <h1>Welcome</h1>
29
- </view>
30
- </component>
31
- </galath>]]></signal>
32
- </model>
33
-
34
- <view>
35
- <div class="px-4 py-5">
36
- <x-chapter-heading icon="bi-arrow-down-up" title="Imports"
37
- subtitle="Split a Galath app across files. The same way ES modules split a JS app." />
38
-
39
- <div class="row g-4 mb-4">
40
- <div class="col-lg-6">
41
- <div class="card xes-card h-100">
42
- <div class="card-body">
43
- <h2 class="h5"><i class="bi bi-journal-text me-2 text-info"></i>How it works</h2>
44
- <p class="text-secondary">
45
- An <code>&lt;import src="./path/to/file.xml"/&gt;</code> element is replaced at
46
- boot time by the children of the imported file's root. The import is fetched
47
- asynchronously, the result is cached by URL, and nested imports inside the
48
- imported file are resolved relative to that file's URL.
49
- </p>
50
- <p class="text-secondary">
51
- The fetched file's root can be:
52
- </p>
53
- <ul class="text-secondary">
54
- <li><code>&lt;galath&gt;</code> or <code>&lt;fragment&gt;</code> - splices in
55
- its <em>children</em>. Use this when one file ships several components.</li>
56
- <li>Anything else - splices in the root element itself. Use this when one file
57
- is one component.</li>
58
- </ul>
59
- <p class="text-secondary mb-0">
60
- Cycles are detected by URL and broken silently. If a fetch fails, a
61
- <code>&lt;parseerror&gt;</code> element appears in place so you can spot the
62
- problem.
63
- </p>
64
- </div>
65
- </div>
66
- </div>
67
- <div class="col-lg-6">
68
- <div class="card xes-card h-100">
69
- <div class="card-header bg-transparent">
70
- <strong><i class="bi bi-house me-2"></i>Entry document</strong>
71
- </div>
72
- <div class="card-body p-0">
73
- <pre class="xes-code rounded p-3 mb-0"><code><text value="snippetEntry" /></code></pre>
74
- </div>
75
- </div>
76
- </div>
77
- </div>
78
-
79
- <div class="card xes-card mb-4">
80
- <div class="card-header bg-transparent">
81
- <strong><i class="bi bi-file-earmark-code me-2"></i>One imported chapter</strong>
82
- </div>
83
- <div class="card-body p-0">
84
- <pre class="xes-code rounded p-3 mb-0"><code><text value="snippetChild" /></code></pre>
85
- </div>
86
- </div>
87
-
88
- <div class="card xes-card">
89
- <div class="card-header bg-transparent">
90
- <strong><i class="bi bi-lightbulb me-2"></i>You're already inside one</strong>
91
- </div>
92
- <div class="card-body">
93
- <p class="text-secondary mb-2">
94
- Every chapter you've clicked through is a separate <code>.xml</code> file under
95
- <code>./playground/chapters/</code>. The shared chapter heading is in
96
- <code>./playground/components/</code>. Open <code>index.html</code> to see how it
97
- all wires together - it's a small file because the work is delegated to imports.
98
- </p>
99
- <p class="text-secondary mb-0">
100
- Rule of thumb: when an XML file gets long enough that you start scrolling to find
101
- things, break it into imports. Same heuristic as JS modules.
102
- </p>
103
- </div>
104
- </div>
105
- </div>
106
- </view>
107
- </component>
108
- </galath>
@@ -1,161 +0,0 @@
1
- <!--
2
- chapters/12-expressions.xml
3
-
4
- Documents the expression language: where expressions run, what names are
5
- in scope, path shortcuts, and how JavaScript's type rules apply.
6
- -->
7
- <galath xmlns:bind="urn:galath:bind" xmlns:on="urn:galath:on" xmlns:use="urn:galath:use" xmlns:drag="urn:galath:drag" xmlns:drop="urn:galath:drop" xmlns:class="urn:galath:class">
8
- <component name="chapter-expressions" tag="x-chapter-expressions">
9
- <model>
10
- <signal name="count" value="10" />
11
- <signal name="step" value="10" />
12
- <signal name="name" value="Galath" />
13
-
14
- <signal name="snippet"><![CDATA[<model>
15
- <signal name="count" value="10" />
16
- <signal name="step" value="10" />
17
- </model>
18
-
19
- <view>
20
- <input type="number" bind:value="step" />
21
-
22
- <!-- Inline event code gets signals and helpers in scope. -->
23
- <button on:click="set('count', count + step)">+</button>
24
-
25
- <!-- test/value attributes are JavaScript expressions. -->
26
- <if test="count >= 20">large enough</if>
27
- <text value="count + step" />
28
- </view>]]></signal>
29
- </model>
30
-
31
- <view>
32
- <div class="px-4 py-5">
33
- <x-chapter-heading icon="bi-braces" title="Expressions"
34
- subtitle="JavaScript expressions with signals, XML paths, locals, and helpers in scope." />
35
-
36
- <div class="row g-4 mb-4">
37
- <div class="col-lg-6">
38
- <div class="card xes-card h-100">
39
- <div class="card-body">
40
- <h2 class="h5"><i class="bi bi-journal-text me-2 text-info"></i>How it works</h2>
41
- <p class="text-secondary">
42
- Galath evaluates expressions as JavaScript against a scoped context. Every
43
- signal is available by name, repeat locals are available as both
44
- <code>item</code> and <code>$item</code>, and event handlers receive
45
- <code>$event</code>.
46
- </p>
47
- <p class="text-secondary">
48
- Simple names and XML paths are resolved directly. A bare <code>count</code>
49
- reads a signal, while <code>$ch/@title</code> or <code>/chapters/chapter</code>
50
- reads the instance tree. Once you use operators like <code>+</code>,
51
- <code>&gt;=</code>, or <code>?</code>, normal JavaScript rules apply.
52
- </p>
53
- <p class="text-secondary mb-0">
54
- Values from <code>&lt;signal value="10"/&gt;</code> and XML instance
55
- attributes are coerced into primitives. Bound number and range inputs also
56
- write numbers back to signals, so arithmetic stays arithmetic.
57
- </p>
58
- </div>
59
- </div>
60
- </div>
61
- <div class="col-lg-6">
62
- <div class="card xes-card h-100">
63
- <div class="card-header bg-transparent d-flex justify-content-between align-items-center">
64
- <strong><i class="bi bi-code-slash me-2"></i>Source</strong>
65
- <div class="btn-group btn-group-sm" role="group"><button class="btn btn-outline-info" on:click="window.galathRunSnippet(snippet)" title="Open this snippet in a new tab"><i class="bi bi-play-fill me-1"></i>Run</button><button class="btn btn-outline-info" use:copy="snippet" title="Copy to clipboard"><i class="bi bi-clipboard me-1"></i>Copy</button></div>
66
- </div>
67
- <div class="card-body p-0">
68
- <pre class="xes-code rounded p-3 mb-0"><code><text value="snippet" /></code></pre>
69
- </div>
70
- </div>
71
- </div>
72
- </div>
73
-
74
- <div class="card xes-card mb-4">
75
- <div class="card-header bg-transparent">
76
- <strong><i class="bi bi-calculator me-2"></i>Live demo</strong>
77
- </div>
78
- <div class="card-body">
79
- <div class="row g-3 align-items-end mb-4">
80
- <div class="col-md-4">
81
- <label class="form-label">Count</label>
82
- <input class="form-control" type="number" bind:value="count" />
83
- </div>
84
- <div class="col-md-4">
85
- <label class="form-label">Step</label>
86
- <input class="form-control" type="number" bind:value="step" />
87
- </div>
88
- <div class="col-md-4 d-flex gap-2">
89
- <button class="btn btn-info flex-grow-1" on:click="set('count', count + step)">
90
- <i class="bi bi-plus-circle me-1"></i>Add
91
- </button>
92
- <button class="btn btn-outline-light flex-grow-1" on:click="set('count', 10)">
93
- Reset
94
- </button>
95
- </div>
96
- </div>
97
-
98
- <div class="row g-3">
99
- <div class="col-lg-6">
100
- <div class="xes-pill rounded p-3 h-100">
101
- <div class="xes-tiny text-secondary mb-1">Expression</div>
102
- <code>count + step</code>
103
- <div class="display-6 mt-2">{count + step}</div>
104
- <small class="text-secondary">
105
- count is <code>{typeof count}</code>, step is <code>{typeof step}</code>.
106
- </small>
107
- </div>
108
- </div>
109
- <div class="col-lg-6">
110
- <div class="xes-pill rounded p-3 h-100">
111
- <div class="xes-tiny text-secondary mb-1">String expression</div>
112
- <div class="input-group mb-2">
113
- <span class="input-group-text">name</span>
114
- <input class="form-control" bind:value="name" />
115
- </div>
116
- <code>name + ' docs'</code>
117
- <div class="h4 mb-0 mt-2">{name + ' docs'}</div>
118
- </div>
119
- </div>
120
- </div>
121
- </div>
122
- </div>
123
-
124
- <div class="row g-4">
125
- <div class="col-lg-6">
126
- <div class="card xes-card h-100">
127
- <div class="card-header bg-transparent">
128
- <strong><i class="bi bi-diagram-2 me-2"></i>Where expressions run</strong>
129
- </div>
130
- <div class="card-body">
131
- <ul class="text-secondary mb-0">
132
- <li><code>{name}</code> in text or attributes interpolates a value.</li>
133
- <li><code>&lt;text value="count + step"/&gt;</code> renders escaped text.</li>
134
- <li><code>&lt;if test="count &gt;= 20"&gt;</code> switches view branches.</li>
135
- <li><code>on:click="set('count', count + step)"</code> runs event code.</li>
136
- <li><code>&lt;set signal="count" value="count + step"/&gt;</code> updates state from controllers.</li>
137
- </ul>
138
- </div>
139
- </div>
140
- </div>
141
- <div class="col-lg-6">
142
- <div class="card xes-card h-100">
143
- <div class="card-header bg-transparent">
144
- <strong><i class="bi bi-box-arrow-in-right me-2"></i>What is in scope</strong>
145
- </div>
146
- <div class="card-body">
147
- <ul class="text-secondary mb-0">
148
- <li>Signals: <code>count</code>, <code>step</code>, <code>name</code>.</li>
149
- <li>Repeat locals: <code>item</code>, <code>$item</code>, and <code>index</code>.</li>
150
- <li>Events: <code>$event</code> inside <code>on:*</code> handlers.</li>
151
- <li>Helpers: <code>set</code>, <code>valueOf</code>, <code>select</code>, <code>uid</code>, <code>attr</code>, <code>deleteNode</code>, <code>setNode</code>.</li>
152
- <li>XML paths: <code>/root/item</code>, <code>$item/@name</code>, and <code>$item/text()</code>.</li>
153
- </ul>
154
- </div>
155
- </div>
156
- </div>
157
- </div>
158
- </div>
159
- </view>
160
- </component>
161
- </galath>
@@ -1,197 +0,0 @@
1
- <!--
2
- chapters/13-paths.xml
3
-
4
- Documents Galath's deliberately small instance-tree path grammar.
5
- -->
6
- <galath xmlns:bind="urn:galath:bind" xmlns:on="urn:galath:on" xmlns:use="urn:galath:use" xmlns:drag="urn:galath:drag" xmlns:drop="urn:galath:drop" xmlns:class="urn:galath:class">
7
- <component name="chapter-paths" tag="x-chapter-paths">
8
- <model>
9
- <instance>
10
- <todos>
11
- <todo id="a" text="Draft the path chapter" done="true">first todo text</todo>
12
- <todo id="b" text="Test wildcard selectors" done="false">second todo text</todo>
13
- <note id="n1" text="Wildcard also matches this note">note text</note>
14
- </todos>
15
- <projects>
16
- <project id="docs">
17
- <task id="a" text="Nested task" />
18
- </project>
19
- </projects>
20
- </instance>
21
-
22
- <signal name="snippet"><![CDATA[<repeat ref="/todos/todo" as="todo">
23
- <text value="$todo/@text" />
24
- </repeat>
25
-
26
- <text value="/todos/todo[@id=a]/@text" />
27
- <text value="/todos/todo[2]/text()" />
28
- <repeat ref="/todos/*" as="item">
29
- <text value="$item/@id" />
30
- </repeat>]]></signal>
31
- </model>
32
-
33
- <view>
34
- <div class="px-4 py-5">
35
- <x-chapter-heading icon="bi-signpost-split" title="Paths"
36
- subtitle="A small, predictable path grammar for reading and writing XML instance data." />
37
-
38
- <div class="row g-4 mb-4">
39
- <div class="col-lg-6">
40
- <div class="card xes-card h-100">
41
- <div class="card-body">
42
- <h2 class="h5"><i class="bi bi-journal-text me-2 text-info"></i>How it works</h2>
43
- <p class="text-secondary">
44
- Galath paths address the component's XML instance tree. They look like a
45
- small subset of XPath, but they are intentionally simpler: walk direct
46
- children with <code>/</code>, filter one step with an attribute predicate,
47
- read attributes with <code>@</code>, read direct text with
48
- <code>text()</code>, and use <code>*</code> for a single wildcard step.
49
- </p>
50
- <p class="text-secondary mb-0">
51
- Paths show up in <code>repeat ref</code>, <code>items source</code>,
52
- <code>bind:value</code>, <code>setvalue ref</code>, <code>delete ref</code>,
53
- <code>listener observer</code>, <code>valueOf(path)</code>, and
54
- <code>&lt;text value="path"/&gt;</code>.
55
- </p>
56
- </div>
57
- </div>
58
- </div>
59
- <div class="col-lg-6">
60
- <div class="card xes-card h-100">
61
- <div class="card-header bg-transparent d-flex justify-content-between align-items-center">
62
- <strong><i class="bi bi-code-slash me-2"></i>Source</strong>
63
- <button class="btn btn-sm btn-outline-info" use:copy="snippet"><i class="bi bi-clipboard me-1"></i>Copy</button>
64
- </div>
65
- <div class="card-body p-0">
66
- <pre class="xes-code rounded p-3 mb-0"><code><text value="snippet" /></code></pre>
67
- </div>
68
- </div>
69
- </div>
70
- </div>
71
-
72
- <div class="card xes-card mb-4">
73
- <div class="card-header bg-transparent">
74
- <strong><i class="bi bi-list-check me-2"></i>Cheat sheet</strong>
75
- </div>
76
- <div class="card-body">
77
- <div class="table-responsive">
78
- <table class="table table-dark table-sm align-middle mb-0">
79
- <thead>
80
- <tr>
81
- <th>Path</th>
82
- <th>Meaning</th>
83
- <th>Result in this chapter</th>
84
- </tr>
85
- </thead>
86
- <tbody>
87
- <tr>
88
- <td><code>/foo/bar</code></td>
89
- <td>Direct child steps from the instance root.</td>
90
- <td><code>/todos/todo</code>: {select('/todos/todo').length} todo nodes</td>
91
- </tr>
92
- <tr>
93
- <td><code>/foo/bar[@id=x]</code></td>
94
- <td>Attribute equality predicate on one step.</td>
95
- <td><code>/todos/todo[@id=a]</code>: {valueOf('/todos/todo[@id=a]/@text')}</td>
96
- </tr>
97
- <tr>
98
- <td><code>/foo/bar[n]</code></td>
99
- <td>1-based index after matching the step.</td>
100
- <td><code>/todos/todo[2]</code>: {valueOf('/todos/todo[2]/@text')}</td>
101
- </tr>
102
- <tr>
103
- <td><code>$todo/@text</code></td>
104
- <td>Attribute from a repeat-local node.</td>
105
- <td>
106
- <repeat ref="/todos/todo" as="todo">
107
- <span class="badge text-bg-secondary me-1"><text value="$todo/@text" /></span>
108
- </repeat>
109
- </td>
110
- </tr>
111
- <tr>
112
- <td><code>/foo/text()</code> via the <code>/text()</code> suffix</td>
113
- <td>Direct text value of the first matching node.</td>
114
- <td><code>/todos/todo/text()</code>: {valueOf('/todos/todo/text()')}</td>
115
- </tr>
116
- <tr>
117
- <td><code>*</code></td>
118
- <td>Wildcard for one child step.</td>
119
- <td><code>/todos/*</code>: {select('/todos/*').length} children under <code>todos</code></td>
120
- </tr>
121
- </tbody>
122
- </table>
123
- </div>
124
- </div>
125
- </div>
126
-
127
- <div class="row g-4 mb-4">
128
- <div class="col-lg-6">
129
- <div class="card xes-card h-100">
130
- <div class="card-header bg-transparent">
131
- <strong><i class="bi bi-braces me-2"></i>Grammar</strong>
132
- </div>
133
- <div class="card-body">
134
- <pre class="xes-code rounded p-3 mb-0"><code>path = absolute | local
135
- absolute = "/" step ("/" step)*
136
- local = "$" name ("/" step)*
137
- step = name | "*"
138
- step = step "[@attr=value]"
139
- step = step "[n]"
140
- value-path = path "/@attr"
141
- value-path = path "/text()"</code></pre>
142
- </div>
143
- </div>
144
- </div>
145
- <div class="col-lg-6">
146
- <div class="card xes-card h-100">
147
- <div class="card-header bg-transparent">
148
- <strong><i class="bi bi-tree me-2"></i>Sample instance</strong>
149
- </div>
150
- <div class="card-body">
151
- <pre class="xes-code rounded p-3 mb-0"><code>&lt;todos&gt;
152
- &lt;todo id="a" text="Draft the path chapter"&gt;first todo text&lt;/todo&gt;
153
- &lt;todo id="b" text="Test wildcard selectors"&gt;second todo text&lt;/todo&gt;
154
- &lt;note id="n1" text="Wildcard also matches this note"&gt;note text&lt;/note&gt;
155
- &lt;/todos&gt;</code></pre>
156
- </div>
157
- </div>
158
- </div>
159
- </div>
160
-
161
- <div class="card xes-card">
162
- <div class="card-header bg-transparent">
163
- <strong><i class="bi bi-slash-circle me-2"></i>Unsupported on purpose</strong>
164
- </div>
165
- <div class="card-body">
166
- <div class="row g-3">
167
- <div class="col-md-6 col-xl-3">
168
- <div class="xes-pill rounded p-3 h-100">
169
- <code>//todo</code>
170
- <p class="text-secondary mb-0 mt-2">No descendant search. Write the explicit child path.</p>
171
- </div>
172
- </div>
173
- <div class="col-md-6 col-xl-3">
174
- <div class="xes-pill rounded p-3 h-100">
175
- <code>/todos/todo[last()]</code>
176
- <p class="text-secondary mb-0 mt-2">No function calls beyond trailing <code>text()</code>.</p>
177
- </div>
178
- </div>
179
- <div class="col-md-6 col-xl-3">
180
- <div class="xes-pill rounded p-3 h-100">
181
- <code>/projects/project[task/@id=a]</code>
182
- <p class="text-secondary mb-0 mt-2">No multi-step predicates inside brackets.</p>
183
- </div>
184
- </div>
185
- <div class="col-md-6 col-xl-3">
186
- <div class="xes-pill rounded p-3 h-100">
187
- <code>/todos/todo[@id=a and @done=true]</code>
188
- <p class="text-secondary mb-0 mt-2">No boolean predicate expressions. Use a computed signal or controller code.</p>
189
- </div>
190
- </div>
191
- </div>
192
- </div>
193
- </div>
194
- </div>
195
- </view>
196
- </component>
197
- </galath>
@@ -1,29 +0,0 @@
1
- <!--
2
- components/chapter-shell.xml
3
-
4
- A small heading component used by every chapter. We deliberately keep
5
- this minimal - chapters render their own docs / demo / code cards
6
- inline because their content differs in length and structure.
7
-
8
- Usage:
9
-
10
- <x-chapter-heading
11
- icon="bi-broadcast"
12
- title="Signals"
13
- subtitle="Reactive cells that drive the rest of the system." />
14
- -->
15
- <galath xmlns:bind="urn:galath:bind" xmlns:on="urn:galath:on" xmlns:use="urn:galath:use" xmlns:drag="urn:galath:drag" xmlns:drop="urn:galath:drop" xmlns:class="urn:galath:class">
16
- <component name="chapter-heading" tag="x-chapter-heading"
17
- icon="bi-bookmark"
18
- title="Chapter"
19
- subtitle="">
20
- <view>
21
- <div class="d-flex align-items-center gap-2 mb-1">
22
- <i class="bi {icon} text-info fs-4"></i>
23
- <span class="badge text-bg-info-subtle text-info-emphasis">Chapter</span>
24
- </div>
25
- <h1 class="display-6 fw-semibold mb-2">{title}</h1>
26
- <p class="lead text-secondary mb-4">{subtitle}</p>
27
- </view>
28
- </component>
29
- </galath>