@molecule/app-ui 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 +115 -0
- package/dist/automation.d.ts +45 -0
- package/dist/automation.d.ts.map +1 -0
- package/dist/automation.js +56 -0
- package/dist/automation.js.map +1 -0
- package/dist/components.d.ts +10 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.js +13 -0
- package/dist/components.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +68 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +82 -0
- package/dist/provider.js.map +1 -0
- package/dist/types.d.ts +2085 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/dist/utilities.d.ts +76 -0
- package/dist/utilities.d.ts.map +1 -0
- package/dist/utilities.js +54 -0
- package/dist/utilities.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the
|
|
45
|
+
original version of the Work and any modifications or additions
|
|
46
|
+
to that Work, that is intentionally submitted to the Licensor for
|
|
47
|
+
inclusion in the Work by the copyright owner or by an individual or
|
|
48
|
+
Legal Entity authorized to submit on behalf of the copyright owner.
|
|
49
|
+
|
|
50
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
51
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
52
|
+
subsequently incorporated within the Work.
|
|
53
|
+
|
|
54
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
55
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
56
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
57
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
58
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
59
|
+
Work and such Derivative Works in Source or Object form.
|
|
60
|
+
|
|
61
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
62
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
63
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
64
|
+
patent license to make, have made, use, offer to sell, sell, import,
|
|
65
|
+
and otherwise transfer the Work.
|
|
66
|
+
|
|
67
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
68
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
69
|
+
modifications, and in Source or Object form, provided that You
|
|
70
|
+
meet the following conditions:
|
|
71
|
+
|
|
72
|
+
(a) You must give any other recipients of the Work or
|
|
73
|
+
Derivative Works a copy of this License; and
|
|
74
|
+
|
|
75
|
+
(b) You must cause any modified files to carry prominent notices
|
|
76
|
+
stating that You changed the files; and
|
|
77
|
+
|
|
78
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
79
|
+
that You distribute, all copyright, patent, trademark, and
|
|
80
|
+
attribution notices from the Source form of the Work,
|
|
81
|
+
excluding those notices that do not pertain to any part of
|
|
82
|
+
the Derivative Works; and
|
|
83
|
+
|
|
84
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
85
|
+
distribution, then any Derivative Works that You distribute must
|
|
86
|
+
include a readable copy of the attribution notices contained
|
|
87
|
+
within such NOTICE file.
|
|
88
|
+
|
|
89
|
+
5. Submission of Contributions.
|
|
90
|
+
|
|
91
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
92
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
93
|
+
|
|
94
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
95
|
+
agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
|
|
96
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
|
|
97
|
+
|
|
98
|
+
8. Limitation of Liability. In no event and under no legal theory shall
|
|
99
|
+
any Contributor be liable to You for damages.
|
|
100
|
+
|
|
101
|
+
9. Accepting Warranty or Additional Liability.
|
|
102
|
+
|
|
103
|
+
Copyright 2026 Molecule Dev, Inc.
|
|
104
|
+
|
|
105
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
106
|
+
you may not use this file except in compliance with the License.
|
|
107
|
+
You may obtain a copy of the License at
|
|
108
|
+
|
|
109
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
110
|
+
|
|
111
|
+
Unless required by applicable law or agreed to in writing, software
|
|
112
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
113
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
114
|
+
See the License for the specific language governing permissions and
|
|
115
|
+
limitations under the License.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automation ID system for molecule UI components.
|
|
3
|
+
*
|
|
4
|
+
* Every component gets a `data-mol-id` attribute that AI agents and E2E
|
|
5
|
+
* tests (Playwright) can use to interact with the app. (It is a tooling
|
|
6
|
+
* hook only — assistive technology such as screen readers does NOT expose
|
|
7
|
+
* `data-*` attributes; accessible names come from labels/`aria-*`.)
|
|
8
|
+
*
|
|
9
|
+
* The ID follows a semantic pattern: `{component}-{context}-{qualifier}`
|
|
10
|
+
* Examples: `button-login-submit`, `input-email-field`, `card-product-123`
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Generate a semantic automation ID for a component.
|
|
16
|
+
* @param component - Component type (e.g., 'button', 'input', 'card')
|
|
17
|
+
* @param context - Context within the page (e.g., 'login', 'product', 'settings')
|
|
18
|
+
* @param qualifier - Optional qualifier (e.g., 'submit', 'cancel', item ID)
|
|
19
|
+
* @returns The joined automation ID string.
|
|
20
|
+
*/
|
|
21
|
+
export declare function molId(component: string, context: string, qualifier?: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* The HTML attribute name for automation IDs.
|
|
24
|
+
*/
|
|
25
|
+
export declare const MOL_ID_ATTR: "data-mol-id";
|
|
26
|
+
/**
|
|
27
|
+
* Generate the props object for spreading onto an element.
|
|
28
|
+
* @param id - The automation ID string.
|
|
29
|
+
* @returns An object with the `data-mol-id` attribute set.
|
|
30
|
+
*/
|
|
31
|
+
export declare function molIdProps(id: string): Record<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Playwright/testing selector for finding elements by automation ID.
|
|
34
|
+
* @param id - The automation ID to find.
|
|
35
|
+
* @returns A CSS attribute selector string.
|
|
36
|
+
*/
|
|
37
|
+
export declare function molSelector(id: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Playwright/testing selector for finding elements by partial automation ID.
|
|
40
|
+
* Useful for finding all elements of a type: molSelectorPrefix('button-login')
|
|
41
|
+
* @param prefix - The automation ID prefix to match.
|
|
42
|
+
* @returns A CSS attribute prefix selector string.
|
|
43
|
+
*/
|
|
44
|
+
export declare function molSelectorPrefix(prefix: string): string;
|
|
45
|
+
//# sourceMappingURL=automation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation.d.ts","sourceRoot":"","sources":["../src/automation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAIpF;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAG,aAAsB,CAAA;AAEjD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAExD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automation ID system for molecule UI components.
|
|
3
|
+
*
|
|
4
|
+
* Every component gets a `data-mol-id` attribute that AI agents and E2E
|
|
5
|
+
* tests (Playwright) can use to interact with the app. (It is a tooling
|
|
6
|
+
* hook only — assistive technology such as screen readers does NOT expose
|
|
7
|
+
* `data-*` attributes; accessible names come from labels/`aria-*`.)
|
|
8
|
+
*
|
|
9
|
+
* The ID follows a semantic pattern: `{component}-{context}-{qualifier}`
|
|
10
|
+
* Examples: `button-login-submit`, `input-email-field`, `card-product-123`
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Generate a semantic automation ID for a component.
|
|
16
|
+
* @param component - Component type (e.g., 'button', 'input', 'card')
|
|
17
|
+
* @param context - Context within the page (e.g., 'login', 'product', 'settings')
|
|
18
|
+
* @param qualifier - Optional qualifier (e.g., 'submit', 'cancel', item ID)
|
|
19
|
+
* @returns The joined automation ID string.
|
|
20
|
+
*/
|
|
21
|
+
export function molId(component, context, qualifier) {
|
|
22
|
+
const parts = [component, context];
|
|
23
|
+
if (qualifier)
|
|
24
|
+
parts.push(qualifier);
|
|
25
|
+
return parts.join('-');
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The HTML attribute name for automation IDs.
|
|
29
|
+
*/
|
|
30
|
+
export const MOL_ID_ATTR = 'data-mol-id';
|
|
31
|
+
/**
|
|
32
|
+
* Generate the props object for spreading onto an element.
|
|
33
|
+
* @param id - The automation ID string.
|
|
34
|
+
* @returns An object with the `data-mol-id` attribute set.
|
|
35
|
+
*/
|
|
36
|
+
export function molIdProps(id) {
|
|
37
|
+
return { [MOL_ID_ATTR]: id };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Playwright/testing selector for finding elements by automation ID.
|
|
41
|
+
* @param id - The automation ID to find.
|
|
42
|
+
* @returns A CSS attribute selector string.
|
|
43
|
+
*/
|
|
44
|
+
export function molSelector(id) {
|
|
45
|
+
return `[${MOL_ID_ATTR}="${id}"]`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Playwright/testing selector for finding elements by partial automation ID.
|
|
49
|
+
* Useful for finding all elements of a type: molSelectorPrefix('button-login')
|
|
50
|
+
* @param prefix - The automation ID prefix to match.
|
|
51
|
+
* @returns A CSS attribute prefix selector string.
|
|
52
|
+
*/
|
|
53
|
+
export function molSelectorPrefix(prefix) {
|
|
54
|
+
return `[${MOL_ID_ATTR}^="${prefix}"]`;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=automation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation.js","sourceRoot":"","sources":["../src/automation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,SAAiB,EAAE,OAAe,EAAE,SAAkB;IAC1E,MAAM,KAAK,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAClC,IAAI,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACpC,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,aAAsB,CAAA;AAEjD;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAA;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,EAAU;IACpC,OAAO,IAAI,WAAW,KAAK,EAAE,IAAI,CAAA;AACnC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,OAAO,IAAI,WAAW,MAAM,MAAM,IAAI,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI component factories and logic for molecule.dev.
|
|
3
|
+
*
|
|
4
|
+
* Provides component-related factories and logic that can be used
|
|
5
|
+
* with different UI library implementations.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
// Component-related logic and factories will be added here as needed.
|
|
11
|
+
// This module serves as a placeholder for component factories that
|
|
12
|
+
// create UI components based on the current provider.
|
|
13
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;;AAEH,sEAAsE;AACtE,mEAAmE;AACnE,sDAAsD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI component interfaces for molecule.dev.
|
|
3
|
+
*
|
|
4
|
+
* Provides standardized prop interfaces for common UI components
|
|
5
|
+
* that can be implemented by different UI libraries (styled-components,
|
|
6
|
+
* Tailwind, Ionic, etc.).
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* **Style through {@link getClassMap} — NEVER write raw CSS/Tailwind class names in a
|
|
10
|
+
* component.** `const cm = getClassMap()` returns the resolver; use its helpers (`cm.flex`,
|
|
11
|
+
* `cm.surface`, `cm.textSize(size)`, the component helpers like `cm.button`/`cm.card`, and
|
|
12
|
+
* `cm.cn(...)` to compose) and pass the result to `className`. Class-name STRINGS live only in
|
|
13
|
+
* the ClassMap bond (`@molecule/app-ui-tailwind`), so swapping the styling library touches
|
|
14
|
+
* only the bond — a literal `"flex p-4"` in a component defeats that and is the #1 styling
|
|
15
|
+
* mistake.
|
|
16
|
+
*
|
|
17
|
+
* - **Inline styles must not fight ClassMap.** An inline `style` has higher specificity and
|
|
18
|
+
* SILENTLY overrides the class controlling the same property (e.g. `style={{ background }}`
|
|
19
|
+
* kills `cm.surface`). Use inline only for what ClassMap can't express (a specific pixel
|
|
20
|
+
* width, an SVG attribute, a one-off accent color).
|
|
21
|
+
* - **Check what a class resolves to before using it** — read the bond definition, don't guess
|
|
22
|
+
* a helper name or option value; an invalid `cm.*` value is a type error or a silent no-op.
|
|
23
|
+
* - **Every interactive element needs a stable `data-mol-id`** — spread {@link molIdProps} (or
|
|
24
|
+
* set {@link MOL_ID_ATTR} via {@link molId}) so AI agents and tests can target it.
|
|
25
|
+
* - **`tabsList`/`tabsTrigger`/`tabsContent` are resolver functions**, not static strings —
|
|
26
|
+
* call `cm.tabsList(opts)`/`cm.tabsTrigger(opts)`/`cm.tabsContent(opts)` with an optional
|
|
27
|
+
* {@link TabsClassOptions} (`variant`/`size`). Active-tab styling stays a `data-state`
|
|
28
|
+
* attribute selector the caller sets, not one of these options. `cm.switchBase(opts)` also
|
|
29
|
+
* accepts a `color` ({@link SwitchClassOptions}) alongside `size`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* import { getClassMap, molIdProps } from '@molecule/app-ui'
|
|
34
|
+
* const cm = getClassMap()
|
|
35
|
+
*
|
|
36
|
+
* <button
|
|
37
|
+
* className={cm.cn(cm.surface, cm.textSize('sm'))} // resolved classes — never a raw "px-3 text-sm"
|
|
38
|
+
* {...molIdProps('save-button')} // data-mol-id for agents/tests
|
|
39
|
+
* >…</button>
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @module
|
|
43
|
+
*/
|
|
44
|
+
export * from './automation.js';
|
|
45
|
+
export * from './components.js';
|
|
46
|
+
export * from './provider.js';
|
|
47
|
+
export * from './types.js';
|
|
48
|
+
export * from './utilities.js';
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI component interfaces for molecule.dev.
|
|
3
|
+
*
|
|
4
|
+
* Provides standardized prop interfaces for common UI components
|
|
5
|
+
* that can be implemented by different UI libraries (styled-components,
|
|
6
|
+
* Tailwind, Ionic, etc.).
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* **Style through {@link getClassMap} — NEVER write raw CSS/Tailwind class names in a
|
|
10
|
+
* component.** `const cm = getClassMap()` returns the resolver; use its helpers (`cm.flex`,
|
|
11
|
+
* `cm.surface`, `cm.textSize(size)`, the component helpers like `cm.button`/`cm.card`, and
|
|
12
|
+
* `cm.cn(...)` to compose) and pass the result to `className`. Class-name STRINGS live only in
|
|
13
|
+
* the ClassMap bond (`@molecule/app-ui-tailwind`), so swapping the styling library touches
|
|
14
|
+
* only the bond — a literal `"flex p-4"` in a component defeats that and is the #1 styling
|
|
15
|
+
* mistake.
|
|
16
|
+
*
|
|
17
|
+
* - **Inline styles must not fight ClassMap.** An inline `style` has higher specificity and
|
|
18
|
+
* SILENTLY overrides the class controlling the same property (e.g. `style={{ background }}`
|
|
19
|
+
* kills `cm.surface`). Use inline only for what ClassMap can't express (a specific pixel
|
|
20
|
+
* width, an SVG attribute, a one-off accent color).
|
|
21
|
+
* - **Check what a class resolves to before using it** — read the bond definition, don't guess
|
|
22
|
+
* a helper name or option value; an invalid `cm.*` value is a type error or a silent no-op.
|
|
23
|
+
* - **Every interactive element needs a stable `data-mol-id`** — spread {@link molIdProps} (or
|
|
24
|
+
* set {@link MOL_ID_ATTR} via {@link molId}) so AI agents and tests can target it.
|
|
25
|
+
* - **`tabsList`/`tabsTrigger`/`tabsContent` are resolver functions**, not static strings —
|
|
26
|
+
* call `cm.tabsList(opts)`/`cm.tabsTrigger(opts)`/`cm.tabsContent(opts)` with an optional
|
|
27
|
+
* {@link TabsClassOptions} (`variant`/`size`). Active-tab styling stays a `data-state`
|
|
28
|
+
* attribute selector the caller sets, not one of these options. `cm.switchBase(opts)` also
|
|
29
|
+
* accepts a `color` ({@link SwitchClassOptions}) alongside `size`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* import { getClassMap, molIdProps } from '@molecule/app-ui'
|
|
34
|
+
* const cm = getClassMap()
|
|
35
|
+
*
|
|
36
|
+
* <button
|
|
37
|
+
* className={cm.cn(cm.surface, cm.textSize('sm'))} // resolved classes — never a raw "px-3 text-sm"
|
|
38
|
+
* {...molIdProps('save-button')} // data-mol-id for agents/tests
|
|
39
|
+
* >…</button>
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @module
|
|
43
|
+
*/
|
|
44
|
+
export * from './automation.js';
|
|
45
|
+
export * from './components.js';
|
|
46
|
+
export * from './provider.js';
|
|
47
|
+
export * from './types.js';
|
|
48
|
+
export * from './utilities.js';
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI bond accessor and class-map resolution.
|
|
3
|
+
*
|
|
4
|
+
* Bond packages (e.g. `@molecule/app-ui-tailwind`) call `setProvider()`
|
|
5
|
+
* and `setClassMap()` during setup. Application code uses `getClassMap()`
|
|
6
|
+
* to resolve styling-agnostic CSS class names from the bonded styling
|
|
7
|
+
* library (Tailwind, Bootstrap, etc.).
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import type { UIClassMap } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Identifies the bonded UI styling library. Providers set `name`
|
|
14
|
+
* to indicate which library is active (e.g. `"tailwind"`, `"bootstrap"`).
|
|
15
|
+
*/
|
|
16
|
+
export interface UIProvider {
|
|
17
|
+
/**
|
|
18
|
+
* Identifier for the styling library (e.g. `"tailwind"`, `"ionic"`).
|
|
19
|
+
*/
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Registers a UI provider as the active singleton.
|
|
24
|
+
*
|
|
25
|
+
* @param provider - The UI provider implementation to bond.
|
|
26
|
+
*/
|
|
27
|
+
export declare function setProvider(provider: UIProvider): void;
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves the bonded UI provider, or `undefined` if none is configured.
|
|
30
|
+
*
|
|
31
|
+
* @returns The bonded UI provider, or `undefined`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getProvider(): UIProvider | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Checks whether a UI provider is currently bonded.
|
|
36
|
+
*
|
|
37
|
+
* @returns `true` if a UI provider is bonded.
|
|
38
|
+
*/
|
|
39
|
+
export declare function hasProvider(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Registers a UIClassMap as the active styling resolver. Called at
|
|
42
|
+
* app startup to wire a styling library (e.g. Tailwind, Bootstrap).
|
|
43
|
+
*
|
|
44
|
+
* @param classMap - The UIClassMap implementation to bond.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* import { setClassMap } from '@molecule/app-ui'
|
|
49
|
+
* import { classMap } from '@molecule/app-ui-tailwind'
|
|
50
|
+
* setClassMap(classMap)
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function setClassMap(classMap: UIClassMap): void;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves the bonded UIClassMap, throwing if none is configured.
|
|
56
|
+
* Use this to resolve styling-agnostic class names in components.
|
|
57
|
+
*
|
|
58
|
+
* @returns The bonded UIClassMap implementation.
|
|
59
|
+
* @throws {Error} If no UIClassMap has been bonded via `setClassMap()`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getClassMap(): UIClassMap;
|
|
62
|
+
/**
|
|
63
|
+
* Checks whether a UIClassMap is currently bonded.
|
|
64
|
+
*
|
|
65
|
+
* @returns `true` if a UIClassMap is bonded.
|
|
66
|
+
*/
|
|
67
|
+
export declare function hasClassMap(): boolean;
|
|
68
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;CACb;AAKD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,UAAU,GAAG,SAAS,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,UAAU,CAWxC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAErC"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI bond accessor and class-map resolution.
|
|
3
|
+
*
|
|
4
|
+
* Bond packages (e.g. `@molecule/app-ui-tailwind`) call `setProvider()`
|
|
5
|
+
* and `setClassMap()` during setup. Application code uses `getClassMap()`
|
|
6
|
+
* to resolve styling-agnostic CSS class names from the bonded styling
|
|
7
|
+
* library (Tailwind, Bootstrap, etc.).
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { bond, get as bondGet, isBonded } from '@molecule/app-bond';
|
|
12
|
+
import { t } from '@molecule/app-i18n';
|
|
13
|
+
const BOND_TYPE = 'ui';
|
|
14
|
+
const BOND_TYPE_CLASSMAP = 'ui-classmap';
|
|
15
|
+
/**
|
|
16
|
+
* Registers a UI provider as the active singleton.
|
|
17
|
+
*
|
|
18
|
+
* @param provider - The UI provider implementation to bond.
|
|
19
|
+
*/
|
|
20
|
+
export function setProvider(provider) {
|
|
21
|
+
bond(BOND_TYPE, provider);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves the bonded UI provider, or `undefined` if none is configured.
|
|
25
|
+
*
|
|
26
|
+
* @returns The bonded UI provider, or `undefined`.
|
|
27
|
+
*/
|
|
28
|
+
export function getProvider() {
|
|
29
|
+
return bondGet(BOND_TYPE);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks whether a UI provider is currently bonded.
|
|
33
|
+
*
|
|
34
|
+
* @returns `true` if a UI provider is bonded.
|
|
35
|
+
*/
|
|
36
|
+
export function hasProvider() {
|
|
37
|
+
return isBonded(BOND_TYPE);
|
|
38
|
+
}
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// CLASS MAP — STYLING-AGNOSTIC CLASS RESOLUTION
|
|
41
|
+
// ============================================================================
|
|
42
|
+
/**
|
|
43
|
+
* Registers a UIClassMap as the active styling resolver. Called at
|
|
44
|
+
* app startup to wire a styling library (e.g. Tailwind, Bootstrap).
|
|
45
|
+
*
|
|
46
|
+
* @param classMap - The UIClassMap implementation to bond.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* import { setClassMap } from '@molecule/app-ui'
|
|
51
|
+
* import { classMap } from '@molecule/app-ui-tailwind'
|
|
52
|
+
* setClassMap(classMap)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export function setClassMap(classMap) {
|
|
56
|
+
bond(BOND_TYPE_CLASSMAP, classMap);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves the bonded UIClassMap, throwing if none is configured.
|
|
60
|
+
* Use this to resolve styling-agnostic class names in components.
|
|
61
|
+
*
|
|
62
|
+
* @returns The bonded UIClassMap implementation.
|
|
63
|
+
* @throws {Error} If no UIClassMap has been bonded via `setClassMap()`.
|
|
64
|
+
*/
|
|
65
|
+
export function getClassMap() {
|
|
66
|
+
const classMap = bondGet(BOND_TYPE_CLASSMAP);
|
|
67
|
+
if (!classMap) {
|
|
68
|
+
throw new Error(t('ui.error.noClassMap', undefined, {
|
|
69
|
+
defaultValue: 'No UIClassMap has been set. Call setClassMap() at app startup with a styling library implementation (e.g., @molecule/app-ui-tailwind).',
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
return classMap;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Checks whether a UIClassMap is currently bonded.
|
|
76
|
+
*
|
|
77
|
+
* @returns `true` if a UIClassMap is bonded.
|
|
78
|
+
*/
|
|
79
|
+
export function hasClassMap() {
|
|
80
|
+
return isBonded(BOND_TYPE_CLASSMAP);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AAetC,MAAM,SAAS,GAAG,IAAI,CAAA;AACtB,MAAM,kBAAkB,GAAG,aAAa,CAAA;AAExC;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,QAAoB;IAC9C,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,OAAO,CAAa,SAAS,CAAC,CAAA;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAA;AAC5B,CAAC;AAED,+EAA+E;AAC/E,gDAAgD;AAChD,+EAA+E;AAE/E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,QAAoB;IAC9C,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,OAAO,CAAa,kBAAkB,CAAC,CAAA;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,CAAC,CAAC,qBAAqB,EAAE,SAAS,EAAE;YAClC,YAAY,EACV,wIAAwI;SAC3I,CAAC,CACH,CAAA;IACH,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,QAAQ,CAAC,kBAAkB,CAAC,CAAA;AACrC,CAAC"}
|