@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/types/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Ractive component definition as accepted by `Ractive.extend()`.
|
|
3
|
+
*
|
|
4
|
+
* @typedef {object} RalmaComponentDefinition
|
|
5
|
+
* @property {string} template
|
|
6
|
+
* @property {boolean} [isolated]
|
|
7
|
+
* @property {() => Record<string, unknown>} [data]
|
|
8
|
+
* @property {() => void} [oninit]
|
|
9
|
+
* @property {Record<string, () => unknown>} [computed]
|
|
10
|
+
*/
|
|
11
|
+
export type RalmaComponentDefinition = {
|
|
12
|
+
template: string;
|
|
13
|
+
isolated?: boolean;
|
|
14
|
+
data?: () => Record<string, unknown>;
|
|
15
|
+
oninit?: () => void;
|
|
16
|
+
computed?: Record<string, () => unknown>;
|
|
17
|
+
};
|
|
18
|
+
export type RactiveLike = {
|
|
19
|
+
extend: (definition: RalmaComponentDefinition) => unknown;
|
|
20
|
+
components: Record<string | symbol, unknown>;
|
|
21
|
+
};
|
|
22
|
+
export type RactiveInstance = {
|
|
23
|
+
get: (keypath: string) => any;
|
|
24
|
+
set: (keypath: string, value: unknown) => unknown;
|
|
25
|
+
observe: (keypath: string, handler: (value: any) => void, options?: {
|
|
26
|
+
init?: boolean;
|
|
27
|
+
}) => unknown;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Component names whose `href` runs through {@link sanitizeHref}. A component that renders
|
|
31
|
+
* an `href` and is missing from this set skips sanitizing entirely.
|
|
32
|
+
*/
|
|
33
|
+
export declare const hrefAwareComponentNames: Set<string>;
|
|
34
|
+
export declare const componentNames: readonly string[];
|
|
35
|
+
/**
|
|
36
|
+
* Registers Ralma components onto a Ractive constructor.
|
|
37
|
+
*
|
|
38
|
+
* @param {unknown} ractive - The `Ractive` constructor (global or imported).
|
|
39
|
+
* @param {{overwrite?: boolean, warnOnCollision?: boolean}} [options]
|
|
40
|
+
* - `overwrite`: overwrite already-registered component names.
|
|
41
|
+
* - `warnOnCollision`: emit console warnings when a name is skipped.
|
|
42
|
+
* @returns {unknown} The same `Ractive` reference.
|
|
43
|
+
*/
|
|
44
|
+
export declare function registerRalma(ractive: unknown, options?: {
|
|
45
|
+
overwrite?: boolean;
|
|
46
|
+
warnOnCollision?: boolean;
|
|
47
|
+
}): unknown;
|