@incursa/ui-kit 1.0.0 → 1.2.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.
Files changed (45) hide show
  1. package/AI-AGENT-INSTRUCTIONS.md +42 -28
  2. package/LLMS.txt +56 -40
  3. package/README.md +190 -73
  4. package/dist/inc-design-language.css +430 -247
  5. package/dist/inc-design-language.css.map +1 -1
  6. package/dist/inc-design-language.js +520 -0
  7. package/dist/inc-design-language.min.css +1 -1
  8. package/dist/inc-design-language.min.css.map +1 -1
  9. package/dist/web-components/README.md +92 -0
  10. package/dist/web-components/RUNTIME-NOTES.md +40 -0
  11. package/dist/web-components/base-element.js +193 -0
  12. package/dist/web-components/components/feedback.js +1074 -0
  13. package/dist/web-components/components/forms.js +979 -0
  14. package/dist/web-components/components/layout.js +408 -0
  15. package/dist/web-components/components/navigation.js +854 -0
  16. package/dist/web-components/components/overlays.js +634 -0
  17. package/dist/web-components/controllers/focus.js +101 -0
  18. package/dist/web-components/controllers/overlay.js +128 -0
  19. package/dist/web-components/controllers/selection.js +145 -0
  20. package/dist/web-components/controllers/theme.js +173 -0
  21. package/dist/web-components/index.js +886 -0
  22. package/dist/web-components/package.json +3 -0
  23. package/dist/web-components/registry.js +74 -0
  24. package/dist/web-components/shared.js +186 -0
  25. package/dist/web-components/style.css +6 -0
  26. package/package.json +16 -4
  27. package/src/inc-design-language.js +520 -0
  28. package/src/inc-design-language.scss +456 -257
  29. package/src/web-components/README.md +92 -0
  30. package/src/web-components/RUNTIME-NOTES.md +40 -0
  31. package/src/web-components/base-element.js +193 -0
  32. package/src/web-components/components/feedback.js +1074 -0
  33. package/src/web-components/components/forms.js +979 -0
  34. package/src/web-components/components/layout.js +408 -0
  35. package/src/web-components/components/navigation.js +854 -0
  36. package/src/web-components/components/overlays.js +634 -0
  37. package/src/web-components/controllers/focus.js +101 -0
  38. package/src/web-components/controllers/overlay.js +128 -0
  39. package/src/web-components/controllers/selection.js +145 -0
  40. package/src/web-components/controllers/theme.js +173 -0
  41. package/src/web-components/index.js +886 -0
  42. package/src/web-components/package.json +3 -0
  43. package/src/web-components/registry.js +74 -0
  44. package/src/web-components/shared.js +186 -0
  45. package/src/web-components/style.css +6 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -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
+ };
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Convenience stylesheet entrypoint for the optional Web Components layer.
3
+ * This aliases the shared compiled UI kit stylesheet so consumers can pair
4
+ * one package-local CSS import with the custom-elements runtime.
5
+ */
6
+ @import "../inc-design-language.css";