@aldi/ralma 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +67 -0
- package/bin/ralma.js +683 -0
- package/bin/ralma.min.js +175 -0
- package/package.json +81 -0
- package/src/index.js +783 -0
- package/types/index.d.ts +47 -0
package/bin/ralma.js
ADDED
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
/* Ralma v1.0.0 */
|
|
2
|
+
(() => {
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
|
|
23
|
+
// src/index.js
|
|
24
|
+
var REGISTRY_MARKER = /* @__PURE__ */ Symbol.for("ralma.__registered__");
|
|
25
|
+
var UNSAFE_HREF_SCHEME_PATTERN = /^\s*(?:javascript|data|vbscript):/i;
|
|
26
|
+
var hrefAwareComponentNames = /* @__PURE__ */ new Set([
|
|
27
|
+
"button",
|
|
28
|
+
"card-footer-item",
|
|
29
|
+
"dropdown-item",
|
|
30
|
+
"navbar-item",
|
|
31
|
+
"navbar-link",
|
|
32
|
+
"pagination-previous",
|
|
33
|
+
"pagination-next",
|
|
34
|
+
"pagination-link",
|
|
35
|
+
"panel-block",
|
|
36
|
+
"tab-link"
|
|
37
|
+
]);
|
|
38
|
+
var columnFractionModifiers = [
|
|
39
|
+
"three-quarters",
|
|
40
|
+
"two-thirds",
|
|
41
|
+
"half",
|
|
42
|
+
"one-third",
|
|
43
|
+
"one-quarter",
|
|
44
|
+
"four-fifths",
|
|
45
|
+
"three-fifths",
|
|
46
|
+
"two-fifths",
|
|
47
|
+
"one-fifth"
|
|
48
|
+
];
|
|
49
|
+
var columnNumberModifiers = Array.from({ length: 12 }, (_, index) => String(index + 1));
|
|
50
|
+
var columnBreakpoints = ["mobile", "tablet", "touch", "desktop", "widescreen", "fullhd"];
|
|
51
|
+
var columnModifierClassNames = (
|
|
52
|
+
/** @type {Array<[string, string]>} */
|
|
53
|
+
[
|
|
54
|
+
...columnFractionModifiers.flatMap((modifier) => [
|
|
55
|
+
[modifier, `is-${modifier}`],
|
|
56
|
+
[`offset-${modifier}`, `is-offset-${modifier}`]
|
|
57
|
+
]),
|
|
58
|
+
...columnNumberModifiers.flatMap((modifier) => [
|
|
59
|
+
[modifier, `is-${modifier}`],
|
|
60
|
+
[`offset-${modifier}`, `is-offset-${modifier}`]
|
|
61
|
+
]),
|
|
62
|
+
["narrow", "is-narrow"],
|
|
63
|
+
...columnBreakpoints.map((breakpoint) => [`narrow-${breakpoint}`, `is-narrow-${breakpoint}`]),
|
|
64
|
+
...columnBreakpoints.flatMap(
|
|
65
|
+
(breakpoint) => columnFractionModifiers.flatMap((modifier) => [
|
|
66
|
+
[`${modifier}-${breakpoint}`, `is-${modifier}-${breakpoint}`],
|
|
67
|
+
[`offset-${modifier}-${breakpoint}`, `is-offset-${modifier}-${breakpoint}`]
|
|
68
|
+
])
|
|
69
|
+
),
|
|
70
|
+
...columnBreakpoints.flatMap(
|
|
71
|
+
(breakpoint) => columnNumberModifiers.flatMap((modifier) => [
|
|
72
|
+
[`${modifier}-${breakpoint}`, `is-${modifier}-${breakpoint}`],
|
|
73
|
+
[`offset-${modifier}-${breakpoint}`, `is-offset-${modifier}-${breakpoint}`]
|
|
74
|
+
])
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
);
|
|
78
|
+
var columnsModifierClassNames = (
|
|
79
|
+
/** @type {Array<[string, string]>} */
|
|
80
|
+
[
|
|
81
|
+
["centered", "is-centered"],
|
|
82
|
+
["gapless", "is-gapless"],
|
|
83
|
+
["multiline", "is-multiline"],
|
|
84
|
+
["vcentered", "is-vcentered"],
|
|
85
|
+
["mobile", "is-mobile"],
|
|
86
|
+
["desktop", "is-desktop"]
|
|
87
|
+
]
|
|
88
|
+
);
|
|
89
|
+
function modifierSections(...modifiers) {
|
|
90
|
+
return modifiers.map((modifier) => `{{#${modifier}}}is-${modifier}{{/}}`).join(" ");
|
|
91
|
+
}
|
|
92
|
+
var colorModifiers = [
|
|
93
|
+
"white",
|
|
94
|
+
"light",
|
|
95
|
+
"dark",
|
|
96
|
+
"black",
|
|
97
|
+
"text",
|
|
98
|
+
"primary",
|
|
99
|
+
"link",
|
|
100
|
+
"info",
|
|
101
|
+
"success",
|
|
102
|
+
"warning",
|
|
103
|
+
"danger"
|
|
104
|
+
];
|
|
105
|
+
var panelColorModifiers = ["primary", "link", "info", "success", "warning", "danger", "dark"];
|
|
106
|
+
var sizeModifiers = ["small", "medium", "large"];
|
|
107
|
+
var buttonStateModifiers = [
|
|
108
|
+
"outlined",
|
|
109
|
+
"inverted",
|
|
110
|
+
"rounded",
|
|
111
|
+
"hovered",
|
|
112
|
+
"focused",
|
|
113
|
+
"loading",
|
|
114
|
+
"static",
|
|
115
|
+
"active"
|
|
116
|
+
];
|
|
117
|
+
var buttonModifiers = modifierSections(
|
|
118
|
+
...colorModifiers,
|
|
119
|
+
...sizeModifiers,
|
|
120
|
+
...buttonStateModifiers
|
|
121
|
+
);
|
|
122
|
+
var navbarModifiers = modifierSections(
|
|
123
|
+
"transparent",
|
|
124
|
+
"spaced",
|
|
125
|
+
"fixed-top",
|
|
126
|
+
"fixed-bottom",
|
|
127
|
+
...colorModifiers
|
|
128
|
+
);
|
|
129
|
+
var messageModifiers = modifierSections(...panelColorModifiers, ...sizeModifiers);
|
|
130
|
+
var panelModifiers = modifierSections(...panelColorModifiers);
|
|
131
|
+
var buttonTemplate = `
|
|
132
|
+
{{#if safeHref}}
|
|
133
|
+
<a
|
|
134
|
+
class="button ${buttonModifiers} {{class}}"
|
|
135
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
136
|
+
{{#if title}}title="{{title}}"{{/if}}
|
|
137
|
+
{{#if disabled}}aria-disabled="true" tabindex="-1"{{/if}}
|
|
138
|
+
{{#if dropdown}}aria-haspopup="true"{{/if}}
|
|
139
|
+
{{#if ariaControls}}aria-controls="{{ariaControls}}"{{/if}}
|
|
140
|
+
{{#if safeHref}}{{#if disabled}}{{else}}href="{{safeHref}}"{{/if}}{{/if}}
|
|
141
|
+
>{{yield}}</a>
|
|
142
|
+
{{else}}
|
|
143
|
+
<button
|
|
144
|
+
type="{{buttonType}}"
|
|
145
|
+
class="button ${buttonModifiers} {{class}}"
|
|
146
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
147
|
+
{{#if title}}title="{{title}}"{{/if}}
|
|
148
|
+
{{#if disabled}}disabled{{/if}}
|
|
149
|
+
{{#if dropdown}}aria-haspopup="true"{{/if}}
|
|
150
|
+
{{#if ariaControls}}aria-controls="{{ariaControls}}"{{/if}}
|
|
151
|
+
>{{yield}}</button>
|
|
152
|
+
{{/if}}
|
|
153
|
+
`.trim();
|
|
154
|
+
var componentDefinitions = {
|
|
155
|
+
button: {
|
|
156
|
+
isolated: true,
|
|
157
|
+
data() {
|
|
158
|
+
return {
|
|
159
|
+
buttonType: "button"
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
template: buttonTemplate
|
|
163
|
+
},
|
|
164
|
+
// Breadcrumb
|
|
165
|
+
breadcrumb: {
|
|
166
|
+
isolated: true,
|
|
167
|
+
template: `
|
|
168
|
+
<nav
|
|
169
|
+
class="breadcrumb {{#centered}}is-centered{{/}} {{#right}}is-right{{/}} {{#small}}is-small{{/}} {{#medium}}is-medium{{/}} {{#large}}is-large{{/}} {{#arrow}}has-arrow-separator{{/}} {{#bullet}}has-bullet-separator{{/}} {{#dot}}has-dot-separator{{/}} {{#succeeds}}has-succeeds-separator{{/}} {{class}}"
|
|
170
|
+
aria-label="{{#if ariaLabel}}{{ariaLabel}}{{else}}breadcrumbs{{/if}}"
|
|
171
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
172
|
+
>
|
|
173
|
+
<ul>{{yield}}</ul>
|
|
174
|
+
</nav>
|
|
175
|
+
`.trim()
|
|
176
|
+
},
|
|
177
|
+
"breadcrumb-item": {
|
|
178
|
+
isolated: true,
|
|
179
|
+
template: `
|
|
180
|
+
<li class="{{#active}}is-active{{/}} {{class}}" {{#if id}}id="{{id}}"{{/if}}>
|
|
181
|
+
{{yield}}
|
|
182
|
+
</li>
|
|
183
|
+
`.trim()
|
|
184
|
+
},
|
|
185
|
+
// Card
|
|
186
|
+
card: {
|
|
187
|
+
isolated: true,
|
|
188
|
+
template: `<div class="card {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
189
|
+
},
|
|
190
|
+
"card-header": {
|
|
191
|
+
isolated: true,
|
|
192
|
+
template: `<header class="card-header {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</header>`
|
|
193
|
+
},
|
|
194
|
+
"card-header-title": {
|
|
195
|
+
isolated: true,
|
|
196
|
+
template: `<p class="card-header-title {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</p>`
|
|
197
|
+
},
|
|
198
|
+
"card-header-icon": {
|
|
199
|
+
isolated: true,
|
|
200
|
+
template: `
|
|
201
|
+
<button
|
|
202
|
+
type="button"
|
|
203
|
+
class="card-header-icon {{class}}"
|
|
204
|
+
aria-label="{{#if ariaLabel}}{{ariaLabel}}{{else}}more options{{/if}}"
|
|
205
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
206
|
+
{{#if onclick}}on-click="{{onclick}}"{{/if}}
|
|
207
|
+
>{{yield}}</button>
|
|
208
|
+
`.trim()
|
|
209
|
+
},
|
|
210
|
+
"card-image": {
|
|
211
|
+
isolated: true,
|
|
212
|
+
template: `<div class="card-image {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
213
|
+
},
|
|
214
|
+
"card-content": {
|
|
215
|
+
isolated: true,
|
|
216
|
+
template: `<div class="card-content {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
217
|
+
},
|
|
218
|
+
"card-footer": {
|
|
219
|
+
isolated: true,
|
|
220
|
+
template: `<footer class="card-footer {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</footer>`
|
|
221
|
+
},
|
|
222
|
+
"card-footer-item": {
|
|
223
|
+
isolated: true,
|
|
224
|
+
template: `
|
|
225
|
+
{{#if safeHref}}
|
|
226
|
+
<a class="card-footer-item {{class}}" href="{{safeHref}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</a>
|
|
227
|
+
{{else}}
|
|
228
|
+
<div class="card-footer-item {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>
|
|
229
|
+
{{/if}}
|
|
230
|
+
`.trim()
|
|
231
|
+
},
|
|
232
|
+
// Dropdowns (beta)
|
|
233
|
+
dropdown: {
|
|
234
|
+
isolated: true,
|
|
235
|
+
template: "<div class='dropdown {{#active}}is-active{{/}} {{class}}' {{#if id}} id='{{id}}' {{/if}}>{{yield}}</div>"
|
|
236
|
+
},
|
|
237
|
+
"dropdown-trigger": {
|
|
238
|
+
isolated: true,
|
|
239
|
+
template: "<div class='dropdown-trigger {{class}}' {{#if id}} id='{{id}}' {{/if}}>{{yield}}</div>"
|
|
240
|
+
},
|
|
241
|
+
"dropdown-button": {
|
|
242
|
+
isolated: true,
|
|
243
|
+
template: "<button type='button' class='button {{class}}' {{#if id}} id='{{id}}' {{/if}} aria-haspopup='true' {{#if ariaControls}}aria-controls='{{ariaControls}}'{{/if}}><span>{{yield}}</span><span class='icon is-small'><i class='fas fa-angle-down' aria-hidden='true'></i></span></button>"
|
|
244
|
+
},
|
|
245
|
+
"dropdown-item": {
|
|
246
|
+
isolated: true,
|
|
247
|
+
// Without an href this must be a <button>: an <a> with no href is not keyboard-focusable, and
|
|
248
|
+
// this element carries an on-click. Bulma styles both a.dropdown-item and button.dropdown-item.
|
|
249
|
+
template: `
|
|
250
|
+
{{#if safeHref}}
|
|
251
|
+
<a
|
|
252
|
+
class="dropdown-item {{class}} {{#active}}is-active{{/}}"
|
|
253
|
+
href="{{safeHref}}"
|
|
254
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
255
|
+
{{#if onclick}}on-click="{{onclick}}"{{/if}}
|
|
256
|
+
>{{yield}}</a>
|
|
257
|
+
{{else}}
|
|
258
|
+
<button
|
|
259
|
+
type="button"
|
|
260
|
+
class="dropdown-item {{class}} {{#active}}is-active{{/}}"
|
|
261
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
262
|
+
{{#if onclick}}on-click="{{onclick}}"{{/if}}
|
|
263
|
+
>{{yield}}</button>
|
|
264
|
+
{{/if}}
|
|
265
|
+
`.trim()
|
|
266
|
+
},
|
|
267
|
+
"dropdown-menu": {
|
|
268
|
+
isolated: true,
|
|
269
|
+
// No default role. A real ARIA menu needs role="menuitem" on every child and arrow-key focus
|
|
270
|
+
// management, and Ralma ships no behavior — an announced "menu" that doesn't respond to arrow
|
|
271
|
+
// keys is worse for assistive tech than a plain container. Pass `role` to opt in.
|
|
272
|
+
template: "<div class='dropdown-menu {{class}}' {{#if id}} id='{{id}}' {{/if}} {{#if role}}role='{{role}}'{{/if}}>{{yield}}</div>"
|
|
273
|
+
},
|
|
274
|
+
"dropdown-content": {
|
|
275
|
+
isolated: true,
|
|
276
|
+
template: "<div class='dropdown-content {{class}}' {{#if id}} id='{{id}}' {{/if}}>{{yield}}</div>"
|
|
277
|
+
},
|
|
278
|
+
"dropdown-divider": {
|
|
279
|
+
isolated: true,
|
|
280
|
+
template: "<hr class='dropdown-divider {{class}}' {{#if id}} id='{{id}}' {{/if}}>"
|
|
281
|
+
},
|
|
282
|
+
// Menu
|
|
283
|
+
menu: {
|
|
284
|
+
isolated: true,
|
|
285
|
+
template: `<aside class="menu {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</aside>`
|
|
286
|
+
},
|
|
287
|
+
"menu-label": {
|
|
288
|
+
isolated: true,
|
|
289
|
+
template: `<p class="menu-label {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</p>`
|
|
290
|
+
},
|
|
291
|
+
"menu-list": {
|
|
292
|
+
isolated: true,
|
|
293
|
+
template: `<ul class="menu-list {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</ul>`
|
|
294
|
+
},
|
|
295
|
+
// Message
|
|
296
|
+
message: {
|
|
297
|
+
isolated: true,
|
|
298
|
+
template: `
|
|
299
|
+
<article class="message ${messageModifiers} {{class}}" {{#if id}}id="{{id}}"{{/if}}>
|
|
300
|
+
{{yield}}
|
|
301
|
+
</article>
|
|
302
|
+
`.trim()
|
|
303
|
+
},
|
|
304
|
+
"message-header": {
|
|
305
|
+
isolated: true,
|
|
306
|
+
template: `<div class="message-header {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
307
|
+
},
|
|
308
|
+
"message-body": {
|
|
309
|
+
isolated: true,
|
|
310
|
+
template: `<div class="message-body {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
311
|
+
},
|
|
312
|
+
// Modal
|
|
313
|
+
modal: {
|
|
314
|
+
isolated: true,
|
|
315
|
+
template: `<div class="modal {{#active}}is-active{{/}} {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
316
|
+
},
|
|
317
|
+
"modal-background": {
|
|
318
|
+
isolated: true,
|
|
319
|
+
template: `<div class="modal-background {{class}}" {{#if id}}id="{{id}}"{{/if}}></div>`
|
|
320
|
+
},
|
|
321
|
+
"modal-content": {
|
|
322
|
+
isolated: true,
|
|
323
|
+
template: `<div class="modal-content {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
324
|
+
},
|
|
325
|
+
"modal-close": {
|
|
326
|
+
isolated: true,
|
|
327
|
+
template: `
|
|
328
|
+
<button
|
|
329
|
+
type="button"
|
|
330
|
+
class="modal-close {{#small}}is-small{{/}} {{#medium}}is-medium{{/}} {{#large}}is-large{{/}} {{class}}"
|
|
331
|
+
aria-label="{{#if ariaLabel}}{{ariaLabel}}{{else}}close{{/if}}"
|
|
332
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
333
|
+
{{#if onclick}}on-click="{{onclick}}"{{/if}}
|
|
334
|
+
></button>
|
|
335
|
+
`.trim()
|
|
336
|
+
},
|
|
337
|
+
"modal-card": {
|
|
338
|
+
isolated: true,
|
|
339
|
+
template: `<div class="modal-card {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
340
|
+
},
|
|
341
|
+
"modal-card-head": {
|
|
342
|
+
isolated: true,
|
|
343
|
+
template: `<header class="modal-card-head {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</header>`
|
|
344
|
+
},
|
|
345
|
+
"modal-card-title": {
|
|
346
|
+
isolated: true,
|
|
347
|
+
template: `<p class="modal-card-title {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</p>`
|
|
348
|
+
},
|
|
349
|
+
"modal-card-body": {
|
|
350
|
+
isolated: true,
|
|
351
|
+
template: `<section class="modal-card-body {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</section>`
|
|
352
|
+
},
|
|
353
|
+
"modal-card-foot": {
|
|
354
|
+
isolated: true,
|
|
355
|
+
template: `<footer class="modal-card-foot {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</footer>`
|
|
356
|
+
},
|
|
357
|
+
// Navbar
|
|
358
|
+
navbar: {
|
|
359
|
+
isolated: true,
|
|
360
|
+
template: `
|
|
361
|
+
<nav
|
|
362
|
+
class="navbar ${navbarModifiers} {{class}}"
|
|
363
|
+
role="{{#if role}}{{role}}{{else}}navigation{{/if}}"
|
|
364
|
+
aria-label="{{#if ariaLabel}}{{ariaLabel}}{{else}}main navigation{{/if}}"
|
|
365
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
366
|
+
>
|
|
367
|
+
{{yield}}
|
|
368
|
+
</nav>
|
|
369
|
+
`.trim()
|
|
370
|
+
},
|
|
371
|
+
"navbar-brand": {
|
|
372
|
+
isolated: true,
|
|
373
|
+
template: `<div class="navbar-brand {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
374
|
+
},
|
|
375
|
+
"navbar-burger": {
|
|
376
|
+
isolated: true,
|
|
377
|
+
template: `
|
|
378
|
+
<button
|
|
379
|
+
type="button"
|
|
380
|
+
class="navbar-burger {{#active}}is-active{{/}} {{class}}"
|
|
381
|
+
aria-label="{{#if ariaLabel}}{{ariaLabel}}{{else}}menu{{/if}}"
|
|
382
|
+
aria-expanded="{{#if expanded}}true{{else}}false{{/if}}"
|
|
383
|
+
{{#if dataTarget}}data-target="{{dataTarget}}"{{/if}}
|
|
384
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
385
|
+
{{#if onclick}}on-click="{{onclick}}"{{/if}}
|
|
386
|
+
>{{yield}}</button>
|
|
387
|
+
`.trim()
|
|
388
|
+
},
|
|
389
|
+
"navbar-menu": {
|
|
390
|
+
isolated: true,
|
|
391
|
+
template: `<div class="navbar-menu {{#active}}is-active{{/}} {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
392
|
+
},
|
|
393
|
+
"navbar-start": {
|
|
394
|
+
isolated: true,
|
|
395
|
+
template: `<div class="navbar-start {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
396
|
+
},
|
|
397
|
+
"navbar-end": {
|
|
398
|
+
isolated: true,
|
|
399
|
+
template: `<div class="navbar-end {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>`
|
|
400
|
+
},
|
|
401
|
+
"navbar-item": {
|
|
402
|
+
isolated: true,
|
|
403
|
+
template: `
|
|
404
|
+
{{#if safeHref}}
|
|
405
|
+
<a
|
|
406
|
+
class="navbar-item {{#active}}is-active{{/}} {{class}}"
|
|
407
|
+
href="{{safeHref}}"
|
|
408
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
409
|
+
{{#if onclick}}on-click="{{onclick}}"{{/if}}
|
|
410
|
+
>{{yield}}</a>
|
|
411
|
+
{{else}}
|
|
412
|
+
<div class="navbar-item {{#active}}is-active{{/}} {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>
|
|
413
|
+
{{/if}}
|
|
414
|
+
`.trim()
|
|
415
|
+
},
|
|
416
|
+
"navbar-item-dropdown": {
|
|
417
|
+
isolated: true,
|
|
418
|
+
template: `
|
|
419
|
+
<div class="navbar-item has-dropdown {{#active}}is-active{{/}} {{#hoverable}}is-hoverable{{/}} {{class}}" {{#if id}}id="{{id}}"{{/if}}>
|
|
420
|
+
{{yield}}
|
|
421
|
+
</div>
|
|
422
|
+
`.trim()
|
|
423
|
+
},
|
|
424
|
+
"navbar-link": {
|
|
425
|
+
isolated: true,
|
|
426
|
+
template: `
|
|
427
|
+
{{#if safeHref}}
|
|
428
|
+
<a class="navbar-link {{#active}}is-active{{/}} {{class}}" href="{{safeHref}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</a>
|
|
429
|
+
{{else}}
|
|
430
|
+
<button type="button" class="navbar-link {{#active}}is-active{{/}} {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</button>
|
|
431
|
+
{{/if}}
|
|
432
|
+
`.trim()
|
|
433
|
+
},
|
|
434
|
+
"navbar-dropdown": {
|
|
435
|
+
isolated: true,
|
|
436
|
+
template: `
|
|
437
|
+
<div class="navbar-dropdown {{#right}}is-right{{/}} {{#boxed}}is-boxed{{/}} {{class}}" {{#if id}}id="{{id}}"{{/if}}>
|
|
438
|
+
{{yield}}
|
|
439
|
+
</div>
|
|
440
|
+
`.trim()
|
|
441
|
+
},
|
|
442
|
+
"navbar-divider": {
|
|
443
|
+
isolated: true,
|
|
444
|
+
template: `<hr class="navbar-divider {{class}}" {{#if id}}id="{{id}}"{{/if}} />`
|
|
445
|
+
},
|
|
446
|
+
// Pagination
|
|
447
|
+
pagination: {
|
|
448
|
+
isolated: true,
|
|
449
|
+
template: `
|
|
450
|
+
<nav
|
|
451
|
+
class="pagination {{#centered}}is-centered{{/}} {{#right}}is-right{{/}} {{#rounded}}is-rounded{{/}} {{#small}}is-small{{/}} {{#medium}}is-medium{{/}} {{#large}}is-large{{/}} {{class}}"
|
|
452
|
+
role="{{#if role}}{{role}}{{else}}navigation{{/if}}"
|
|
453
|
+
aria-label="{{#if ariaLabel}}{{ariaLabel}}{{else}}pagination{{/if}}"
|
|
454
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
455
|
+
>
|
|
456
|
+
{{yield}}
|
|
457
|
+
</nav>
|
|
458
|
+
`.trim()
|
|
459
|
+
},
|
|
460
|
+
"pagination-previous": {
|
|
461
|
+
isolated: true,
|
|
462
|
+
template: `
|
|
463
|
+
<a
|
|
464
|
+
class="pagination-previous {{class}}"
|
|
465
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
466
|
+
{{#if title}}title="{{title}}"{{/if}}
|
|
467
|
+
{{#if disabled}}aria-disabled="true" tabindex="-1"{{/if}}
|
|
468
|
+
{{#if safeHref}}{{#if disabled}}{{else}}href="{{safeHref}}"{{/if}}{{/if}}
|
|
469
|
+
>{{yield}}</a>
|
|
470
|
+
`.trim()
|
|
471
|
+
},
|
|
472
|
+
"pagination-next": {
|
|
473
|
+
isolated: true,
|
|
474
|
+
template: `
|
|
475
|
+
<a
|
|
476
|
+
class="pagination-next {{class}}"
|
|
477
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
478
|
+
{{#if title}}title="{{title}}"{{/if}}
|
|
479
|
+
{{#if disabled}}aria-disabled="true" tabindex="-1"{{/if}}
|
|
480
|
+
{{#if safeHref}}{{#if disabled}}{{else}}href="{{safeHref}}"{{/if}}{{/if}}
|
|
481
|
+
>{{yield}}</a>
|
|
482
|
+
`.trim()
|
|
483
|
+
},
|
|
484
|
+
"pagination-list": {
|
|
485
|
+
isolated: true,
|
|
486
|
+
template: `<ul class="pagination-list {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</ul>`
|
|
487
|
+
},
|
|
488
|
+
"pagination-link": {
|
|
489
|
+
isolated: true,
|
|
490
|
+
template: `
|
|
491
|
+
<a
|
|
492
|
+
class="pagination-link {{#current}}is-current{{/}} {{class}}"
|
|
493
|
+
{{#if ariaLabel}}aria-label="{{ariaLabel}}"{{else}}{{#if page}}aria-label="Goto page {{page}}"{{/if}}{{/if}}
|
|
494
|
+
{{#if current}}aria-current="page"{{/if}}
|
|
495
|
+
{{#if id}}id="{{id}}"{{/if}}
|
|
496
|
+
{{#if safeHref}}href="{{safeHref}}"{{/if}}
|
|
497
|
+
>{{yield}}</a>
|
|
498
|
+
`.trim()
|
|
499
|
+
},
|
|
500
|
+
"pagination-ellipsis": {
|
|
501
|
+
isolated: true,
|
|
502
|
+
template: `<span class="pagination-ellipsis {{class}}" {{#if id}}id="{{id}}"{{/if}}>…</span>`
|
|
503
|
+
},
|
|
504
|
+
// Panel
|
|
505
|
+
panel: {
|
|
506
|
+
isolated: true,
|
|
507
|
+
template: `
|
|
508
|
+
<nav class="panel ${panelModifiers} {{class}}" {{#if id}}id="{{id}}"{{/if}}>
|
|
509
|
+
{{yield}}
|
|
510
|
+
</nav>
|
|
511
|
+
`.trim()
|
|
512
|
+
},
|
|
513
|
+
"panel-heading": {
|
|
514
|
+
isolated: true,
|
|
515
|
+
template: `<p class="panel-heading {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</p>`
|
|
516
|
+
},
|
|
517
|
+
"panel-tabs": {
|
|
518
|
+
isolated: true,
|
|
519
|
+
template: `<p class="panel-tabs {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</p>`
|
|
520
|
+
},
|
|
521
|
+
"panel-block": {
|
|
522
|
+
isolated: true,
|
|
523
|
+
template: `
|
|
524
|
+
{{#if safeHref}}
|
|
525
|
+
<a class="panel-block {{#active}}is-active{{/}} {{class}}" href="{{safeHref}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</a>
|
|
526
|
+
{{else}}
|
|
527
|
+
<div class="panel-block {{#active}}is-active{{/}} {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</div>
|
|
528
|
+
{{/if}}
|
|
529
|
+
`.trim()
|
|
530
|
+
},
|
|
531
|
+
"panel-icon": {
|
|
532
|
+
isolated: true,
|
|
533
|
+
template: `<span class="panel-icon {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</span>`
|
|
534
|
+
},
|
|
535
|
+
// Tabs
|
|
536
|
+
tabs: {
|
|
537
|
+
isolated: true,
|
|
538
|
+
template: `
|
|
539
|
+
<div class="tabs {{#centered}}is-centered{{/}} {{#right}}is-right{{/}} {{#boxed}}is-boxed{{/}} {{#toggle}}is-toggle{{/}} {{#toggle-rounded}}is-toggle-rounded{{/}} {{#fullwidth}}is-fullwidth{{/}} {{#small}}is-small{{/}} {{#medium}}is-medium{{/}} {{#large}}is-large{{/}} {{class}}" {{#if id}}id="{{id}}"{{/if}}>
|
|
540
|
+
<ul>{{yield}}</ul>
|
|
541
|
+
</div>
|
|
542
|
+
`.trim()
|
|
543
|
+
},
|
|
544
|
+
tab: {
|
|
545
|
+
isolated: true,
|
|
546
|
+
template: `<li class="{{#active}}is-active{{/}} {{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</li>`
|
|
547
|
+
},
|
|
548
|
+
"tab-link": {
|
|
549
|
+
isolated: true,
|
|
550
|
+
template: `
|
|
551
|
+
{{#if safeHref}}
|
|
552
|
+
<a href="{{safeHref}}" class="{{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</a>
|
|
553
|
+
{{else}}
|
|
554
|
+
<button type="button" class="{{class}}" {{#if id}}id="{{id}}"{{/if}}>{{yield}}</button>
|
|
555
|
+
{{/if}}
|
|
556
|
+
`.trim()
|
|
557
|
+
},
|
|
558
|
+
content: {
|
|
559
|
+
isolated: true,
|
|
560
|
+
template: "<div class='content {{#small}}is-small{{/}} {{#medium}}is-medium{{/}} {{#large}}is-large{{/}} {{class}}' {{#if id}} id='{{id}}' {{/if}}>{{yield}}</div>"
|
|
561
|
+
},
|
|
562
|
+
column: {
|
|
563
|
+
isolated: true,
|
|
564
|
+
computed: {
|
|
565
|
+
/** @this {RactiveInstance} */
|
|
566
|
+
columnModifiers() {
|
|
567
|
+
return buildModifierClassNames(this, columnModifierClassNames);
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
template: "<div class='column {{class}} {{columnModifiers}}' {{#if id}} id='{{id}}' {{/if}}>{{yield}}</div>"
|
|
571
|
+
},
|
|
572
|
+
columns: {
|
|
573
|
+
isolated: true,
|
|
574
|
+
computed: {
|
|
575
|
+
/** @this {RactiveInstance} */
|
|
576
|
+
columnsModifiers() {
|
|
577
|
+
return buildModifierClassNames(this, columnsModifierClassNames);
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
template: "<div class='columns {{class}} {{columnsModifiers}}' {{#if id}} id='{{id}}' {{/if}}>{{yield}}</div>"
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
for (const definition of Object.values(componentDefinitions)) Object.freeze(definition);
|
|
584
|
+
Object.freeze(componentDefinitions);
|
|
585
|
+
var componentEntries = (
|
|
586
|
+
/** @type {Array<[string, RalmaComponentDefinition]>} */
|
|
587
|
+
Object.entries(componentDefinitions)
|
|
588
|
+
);
|
|
589
|
+
var runtimeComponentEntries = componentEntries.map(([name, definition]) => [
|
|
590
|
+
name,
|
|
591
|
+
hrefAwareComponentNames.has(name) ? withSafeHref(definition) : definition
|
|
592
|
+
]);
|
|
593
|
+
var componentNames = Object.freeze(componentEntries.map(([name]) => name));
|
|
594
|
+
function stripControlCharacters(value) {
|
|
595
|
+
return Array.from(value).filter((character) => {
|
|
596
|
+
const code = character.charCodeAt(0);
|
|
597
|
+
return code > 32 && code !== 127;
|
|
598
|
+
}).join("");
|
|
599
|
+
}
|
|
600
|
+
function sanitizeHref(href) {
|
|
601
|
+
if (typeof href !== "string") return null;
|
|
602
|
+
const trimmedHref = href.trim();
|
|
603
|
+
if (trimmedHref === "") return null;
|
|
604
|
+
if (UNSAFE_HREF_SCHEME_PATTERN.test(stripControlCharacters(trimmedHref))) return null;
|
|
605
|
+
return trimmedHref;
|
|
606
|
+
}
|
|
607
|
+
function buildModifierClassNames(component, modifierClassNames) {
|
|
608
|
+
return modifierClassNames.filter(([key]) => component.get(key)).map(([, className]) => className).join(" ");
|
|
609
|
+
}
|
|
610
|
+
function withSafeHref(definition) {
|
|
611
|
+
const existingData = typeof definition.data === "function" ? definition.data : null;
|
|
612
|
+
const existingOninit = typeof definition.oninit === "function" ? definition.oninit : null;
|
|
613
|
+
return __spreadProps(__spreadValues({}, definition), {
|
|
614
|
+
/** @this {RactiveInstance} */
|
|
615
|
+
data() {
|
|
616
|
+
const baseData = existingData ? existingData.call(this) : {};
|
|
617
|
+
return __spreadProps(__spreadValues({}, baseData), {
|
|
618
|
+
safeHref: sanitizeHref(baseData.href)
|
|
619
|
+
});
|
|
620
|
+
},
|
|
621
|
+
/** @this {RactiveInstance} */
|
|
622
|
+
oninit() {
|
|
623
|
+
if (existingOninit) existingOninit.call(this);
|
|
624
|
+
const syncSafeHref = (href) => {
|
|
625
|
+
const nextSafeHref = sanitizeHref(href);
|
|
626
|
+
if (this.get("safeHref") !== nextSafeHref) this.set("safeHref", nextSafeHref);
|
|
627
|
+
};
|
|
628
|
+
syncSafeHref(this.get("href"));
|
|
629
|
+
this.observe(
|
|
630
|
+
"href",
|
|
631
|
+
(nextHref) => {
|
|
632
|
+
syncSafeHref(nextHref);
|
|
633
|
+
},
|
|
634
|
+
{ init: false }
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
function registerRalma(ractive, options = {}) {
|
|
640
|
+
if (ractive == null || typeof ractive !== "object" && typeof ractive !== "function") {
|
|
641
|
+
throw new TypeError("registerRalma(Ractive): Ractive must be an object or function");
|
|
642
|
+
}
|
|
643
|
+
const target = (
|
|
644
|
+
/** @type {RactiveLike} */
|
|
645
|
+
ractive
|
|
646
|
+
);
|
|
647
|
+
const hasExtend = typeof target.extend === "function";
|
|
648
|
+
const hasComponents = target.components != null && typeof target.components === "object";
|
|
649
|
+
if (!hasExtend || !hasComponents) {
|
|
650
|
+
throw new TypeError("registerRalma(Ractive): Ractive must have .extend() and .components");
|
|
651
|
+
}
|
|
652
|
+
if (options == null || typeof options !== "object" && typeof options !== "function") {
|
|
653
|
+
throw new TypeError("registerRalma(Ractive, options): options must be an object when provided");
|
|
654
|
+
}
|
|
655
|
+
const overwrite = options.overwrite === true;
|
|
656
|
+
const warnOnCollision = options.warnOnCollision === true;
|
|
657
|
+
const registrationState = target.components[REGISTRY_MARKER];
|
|
658
|
+
if (registrationState && typeof registrationState === "object" && /** @type {{ definitions?: unknown }} */
|
|
659
|
+
registrationState.definitions === componentDefinitions && /** @type {{ overwrite?: unknown }} */
|
|
660
|
+
registrationState.overwrite === overwrite) {
|
|
661
|
+
return ractive;
|
|
662
|
+
}
|
|
663
|
+
for (const [name, def] of runtimeComponentEntries) {
|
|
664
|
+
if (!overwrite && Object.prototype.hasOwnProperty.call(target.components, name)) {
|
|
665
|
+
if (warnOnCollision) {
|
|
666
|
+
console.warn(`registerRalma: skipping existing component "${name}"`);
|
|
667
|
+
}
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
670
|
+
target.components[name] = target.extend(def);
|
|
671
|
+
}
|
|
672
|
+
target.components[REGISTRY_MARKER] = Object.freeze({
|
|
673
|
+
definitions: componentDefinitions,
|
|
674
|
+
overwrite
|
|
675
|
+
});
|
|
676
|
+
return ractive;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// src/ralma-browser-entry.js
|
|
680
|
+
var globalObject = typeof window !== "undefined" ? window : globalThis;
|
|
681
|
+
if (!globalObject.Ractive) throw new Error("Ralma: window.Ractive is required before loading ralma.js");
|
|
682
|
+
registerRalma(globalObject.Ractive);
|
|
683
|
+
})();
|