@incursa/ui-kit 1.0.1 → 1.4.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/AI-AGENT-INSTRUCTIONS.md +49 -28
- package/LLMS.txt +58 -42
- package/README.md +181 -68
- package/dist/inc-design-language.css +655 -251
- package/dist/inc-design-language.css.map +1 -1
- package/dist/inc-design-language.js +520 -0
- package/dist/inc-design-language.min.css +1 -1
- package/dist/inc-design-language.min.css.map +1 -1
- package/dist/web-components/README.md +92 -0
- package/dist/web-components/RUNTIME-NOTES.md +40 -0
- package/dist/web-components/base-element.js +193 -0
- package/dist/web-components/components/feedback.js +1074 -0
- package/dist/web-components/components/forms.js +979 -0
- package/dist/web-components/components/layout.js +408 -0
- package/dist/web-components/components/navigation.js +854 -0
- package/dist/web-components/components/overlays.js +634 -0
- package/dist/web-components/controllers/focus.js +101 -0
- package/dist/web-components/controllers/overlay.js +128 -0
- package/dist/web-components/controllers/selection.js +145 -0
- package/dist/web-components/controllers/theme.js +173 -0
- package/dist/web-components/index.js +887 -0
- package/dist/web-components/package.json +3 -0
- package/dist/web-components/registry.js +74 -0
- package/dist/web-components/shared.js +186 -0
- package/dist/web-components/style.css +6 -0
- package/package.json +11 -2
- package/src/inc-design-language.js +520 -0
- package/src/inc-design-language.scss +692 -258
- package/src/web-components/README.md +92 -0
- package/src/web-components/RUNTIME-NOTES.md +40 -0
- package/src/web-components/base-element.js +193 -0
- package/src/web-components/components/feedback.js +1074 -0
- package/src/web-components/components/forms.js +979 -0
- package/src/web-components/components/layout.js +408 -0
- package/src/web-components/components/navigation.js +854 -0
- package/src/web-components/components/overlays.js +634 -0
- package/src/web-components/controllers/focus.js +101 -0
- package/src/web-components/controllers/overlay.js +128 -0
- package/src/web-components/controllers/selection.js +145 -0
- package/src/web-components/controllers/theme.js +173 -0
- package/src/web-components/index.js +887 -0
- package/src/web-components/package.json +3 -0
- package/src/web-components/registry.js +74 -0
- package/src/web-components/shared.js +186 -0
- package/src/web-components/style.css +6 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { defineCustomElement, getIncWebComponentsNamespace } from "./shared.js";
|
|
2
|
+
|
|
3
|
+
const registryEntries = new Map();
|
|
4
|
+
|
|
5
|
+
function registerComponent(name, constructor) {
|
|
6
|
+
if (typeof name !== "string" || !name.startsWith("inc-")) {
|
|
7
|
+
throw new TypeError(`Web Component name must use the "inc-" prefix. Received "${name}".`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (typeof constructor !== "function") {
|
|
11
|
+
throw new TypeError(`Constructor for "${name}" must be a function.`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
registryEntries.set(name, constructor);
|
|
15
|
+
return constructor;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function registerComponents(entries) {
|
|
19
|
+
if (!entries || typeof entries !== "object") {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const registered = [];
|
|
24
|
+
Object.entries(entries).forEach(([name, constructor]) => {
|
|
25
|
+
registerComponent(name, constructor);
|
|
26
|
+
registered.push(name);
|
|
27
|
+
});
|
|
28
|
+
return registered;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getRegisteredComponents() {
|
|
32
|
+
return [...registryEntries.entries()].map(([name, constructor]) => ({ name, constructor }));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function defineAll(options = {}) {
|
|
36
|
+
const results = [];
|
|
37
|
+
const registry = options.registry || null;
|
|
38
|
+
|
|
39
|
+
registryEntries.forEach((constructor, name) => {
|
|
40
|
+
results.push(defineCustomElement(name, constructor, registry));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return results;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function hasRegisteredComponent(name) {
|
|
47
|
+
return registryEntries.has(name);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function installRegistryNamespace() {
|
|
51
|
+
const namespace = getIncWebComponentsNamespace();
|
|
52
|
+
if (!namespace) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
namespace.registry = {
|
|
57
|
+
registerComponent,
|
|
58
|
+
registerComponents,
|
|
59
|
+
getRegisteredComponents,
|
|
60
|
+
hasRegisteredComponent,
|
|
61
|
+
defineAll,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return namespace.registry;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
defineAll,
|
|
69
|
+
getRegisteredComponents,
|
|
70
|
+
hasRegisteredComponent,
|
|
71
|
+
installRegistryNamespace,
|
|
72
|
+
registerComponent,
|
|
73
|
+
registerComponents,
|
|
74
|
+
};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
const BOOLEAN_FALSE_TOKENS = new Set(["false", "0", "off", "no"]);
|
|
2
|
+
|
|
3
|
+
function isClientEnvironment() {
|
|
4
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function isCustomElementsAvailable() {
|
|
8
|
+
return typeof globalThis !== "undefined" && "customElements" in globalThis;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function toKebabCase(value) {
|
|
12
|
+
return String(value)
|
|
13
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
14
|
+
.replace(/[_\s]+/g, "-")
|
|
15
|
+
.toLowerCase();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function normalizeAttributeConfig(propertyName, config) {
|
|
19
|
+
const normalized = typeof config === "string"
|
|
20
|
+
? { attribute: config }
|
|
21
|
+
: { ...config };
|
|
22
|
+
const type = normalized.type || "string";
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
property: propertyName,
|
|
26
|
+
attribute: normalized.attribute || toKebabCase(propertyName),
|
|
27
|
+
type,
|
|
28
|
+
reflect: normalized.reflect !== false,
|
|
29
|
+
defaultValue: normalized.defaultValue,
|
|
30
|
+
parse: normalized.parse,
|
|
31
|
+
serialize: normalized.serialize,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function parseBoolean(value) {
|
|
36
|
+
if (value == null) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return !BOOLEAN_FALSE_TOKENS.has(String(value).toLowerCase());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function parseNumber(value, fallback = null) {
|
|
44
|
+
if (value == null || value === "") {
|
|
45
|
+
return fallback;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const parsed = Number(value);
|
|
49
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function parseValueFromAttribute(rawValue, config) {
|
|
53
|
+
if (typeof config.parse === "function") {
|
|
54
|
+
return config.parse(rawValue);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (config.type === "boolean") {
|
|
58
|
+
return parseBoolean(rawValue);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (config.type === "number") {
|
|
62
|
+
return parseNumber(rawValue, config.defaultValue ?? null);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return rawValue ?? config.defaultValue ?? "";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function serializeValueForAttribute(value, config) {
|
|
69
|
+
if (typeof config.serialize === "function") {
|
|
70
|
+
return config.serialize(value);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (config.type === "boolean") {
|
|
74
|
+
return value ? "" : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (value == null) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return String(value);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function reflectAttributeValue(host, attribute, serializedValue) {
|
|
85
|
+
if (!host || typeof host.setAttribute !== "function") {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (serializedValue == null) {
|
|
90
|
+
host.removeAttribute(attribute);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
host.setAttribute(attribute, serializedValue);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function readReflectedAttribute(host, config) {
|
|
98
|
+
const rawValue = host.getAttribute(config.attribute);
|
|
99
|
+
return parseValueFromAttribute(rawValue, config);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function getAssignedSlotElements(host, slotName = "") {
|
|
103
|
+
if (!host || typeof host.querySelector !== "function") {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const selector = slotName ? `slot[name="${slotName}"]` : "slot:not([name])";
|
|
108
|
+
const slot = host.querySelector(selector);
|
|
109
|
+
|
|
110
|
+
if (typeof HTMLSlotElement === "undefined" || !(slot instanceof HTMLSlotElement)) {
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return slot.assignedElements({ flatten: true });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function dispatchComponentEvent(host, type, detail = {}, options = {}) {
|
|
118
|
+
if (!host || typeof host.dispatchEvent !== "function") {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const event = new CustomEvent(type, {
|
|
123
|
+
bubbles: options.bubbles !== false,
|
|
124
|
+
composed: options.composed !== false,
|
|
125
|
+
cancelable: options.cancelable === true,
|
|
126
|
+
detail,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return host.dispatchEvent(event);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function createUniqueId(prefix = "inc-wc") {
|
|
133
|
+
const random = Math.random().toString(36).slice(2, 8);
|
|
134
|
+
return `${prefix}-${random}`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function getIncWebComponentsNamespace() {
|
|
138
|
+
if (typeof globalThis === "undefined") {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (!globalThis.IncWebComponents || typeof globalThis.IncWebComponents !== "object") {
|
|
143
|
+
globalThis.IncWebComponents = {};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return globalThis.IncWebComponents;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function defineCustomElement(name, constructor, registry = null) {
|
|
150
|
+
if (!isCustomElementsAvailable()) {
|
|
151
|
+
return { defined: false, reason: "custom-elements-unavailable", name };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const targetRegistry = registry || globalThis.customElements;
|
|
155
|
+
const existing = targetRegistry.get(name);
|
|
156
|
+
|
|
157
|
+
if (existing) {
|
|
158
|
+
return {
|
|
159
|
+
defined: existing === constructor,
|
|
160
|
+
reason: existing === constructor ? "already-defined" : "name-conflict",
|
|
161
|
+
name,
|
|
162
|
+
constructor: existing,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
targetRegistry.define(name, constructor);
|
|
167
|
+
return { defined: true, reason: "defined", name, constructor };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
createUniqueId,
|
|
172
|
+
defineCustomElement,
|
|
173
|
+
dispatchComponentEvent,
|
|
174
|
+
getAssignedSlotElements,
|
|
175
|
+
getIncWebComponentsNamespace,
|
|
176
|
+
isClientEnvironment,
|
|
177
|
+
isCustomElementsAvailable,
|
|
178
|
+
normalizeAttributeConfig,
|
|
179
|
+
parseBoolean,
|
|
180
|
+
parseNumber,
|
|
181
|
+
parseValueFromAttribute,
|
|
182
|
+
readReflectedAttribute,
|
|
183
|
+
reflectAttributeValue,
|
|
184
|
+
serializeValueForAttribute,
|
|
185
|
+
toKebabCase,
|
|
186
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@incursa/ui-kit",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Reusable UI kit for data-heavy business applications.",
|
|
6
6
|
"keywords": [
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"style": "./dist/inc-design-language.css",
|
|
30
30
|
"sass": "./src/inc-design-language.scss"
|
|
31
31
|
},
|
|
32
|
+
"./web-components": {
|
|
33
|
+
"default": "./dist/web-components/index.js",
|
|
34
|
+
"style": "./dist/web-components/style.css"
|
|
35
|
+
},
|
|
36
|
+
"./web-components/style.css": "./dist/web-components/style.css",
|
|
32
37
|
"./dist/inc-design-language.css": "./dist/inc-design-language.css",
|
|
33
38
|
"./dist/inc-design-language.min.css": "./dist/inc-design-language.min.css",
|
|
34
39
|
"./src/inc-design-language.scss": "./src/inc-design-language.scss",
|
|
@@ -48,7 +53,10 @@
|
|
|
48
53
|
"build:css": "sass --load-path=node_modules --quiet-deps --silence-deprecation=import src/inc-design-language.scss dist/inc-design-language.css --style=expanded",
|
|
49
54
|
"build:css:min": "sass --load-path=node_modules --quiet-deps --silence-deprecation=import src/inc-design-language.scss dist/inc-design-language.min.css --style=compressed",
|
|
50
55
|
"build:js": "node -e \"require('fs').copyFileSync('src/inc-design-language.js', 'dist/inc-design-language.js')\"",
|
|
51
|
-
"build": "
|
|
56
|
+
"build:wc": "node scripts/build-web-components.mjs",
|
|
57
|
+
"build": "npm run build:css && npm run build:css:min && npm run build:js && npm run build:wc",
|
|
58
|
+
"test:browser:install": "playwright install chromium",
|
|
59
|
+
"test:browser": "playwright test",
|
|
52
60
|
"smoke": "node scripts/verify-ui-kit.mjs",
|
|
53
61
|
"verify": "npm run build && npm run smoke && npm pack --dry-run",
|
|
54
62
|
"preversion": "npm run verify",
|
|
@@ -59,6 +67,7 @@
|
|
|
59
67
|
"package": "npm run build && npm run smoke && npm run pack:tarball"
|
|
60
68
|
},
|
|
61
69
|
"devDependencies": {
|
|
70
|
+
"@playwright/test": "^1.58.2",
|
|
62
71
|
"bootstrap": "^5.3.3",
|
|
63
72
|
"linkedom": "^0.18.12",
|
|
64
73
|
"sass": "^1.93.2"
|