@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.
Files changed (45) hide show
  1. package/AI-AGENT-INSTRUCTIONS.md +49 -28
  2. package/LLMS.txt +58 -42
  3. package/README.md +181 -68
  4. package/dist/inc-design-language.css +655 -251
  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 +887 -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 +11 -2
  27. package/src/inc-design-language.js +520 -0
  28. package/src/inc-design-language.scss +692 -258
  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 +887 -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,193 @@
1
+ import {
2
+ dispatchComponentEvent,
3
+ getAssignedSlotElements,
4
+ normalizeAttributeConfig,
5
+ parseValueFromAttribute,
6
+ readReflectedAttribute,
7
+ reflectAttributeValue,
8
+ serializeValueForAttribute,
9
+ } from "./shared.js";
10
+
11
+ const HostElement = typeof HTMLElement === "undefined" ? class {} : HTMLElement;
12
+ const metadataByConstructor = new WeakMap();
13
+
14
+ function buildMetadata(constructor) {
15
+ if (metadataByConstructor.has(constructor)) {
16
+ return metadataByConstructor.get(constructor);
17
+ }
18
+
19
+ const reflectedConfig = constructor.reflectedAttributes || {};
20
+ const propertyToConfig = new Map();
21
+ const attributeToConfig = new Map();
22
+
23
+ Object.keys(reflectedConfig).forEach((property) => {
24
+ const normalized = normalizeAttributeConfig(property, reflectedConfig[property]);
25
+ propertyToConfig.set(property, normalized);
26
+ attributeToConfig.set(normalized.attribute, normalized);
27
+
28
+ if (Object.prototype.hasOwnProperty.call(constructor.prototype, property)) {
29
+ return;
30
+ }
31
+
32
+ Object.defineProperty(constructor.prototype, property, {
33
+ configurable: true,
34
+ enumerable: true,
35
+ get() {
36
+ return this._propertyValues.get(property);
37
+ },
38
+ set(value) {
39
+ this._setReflectedPropertyValue(property, value, { reflect: true });
40
+ },
41
+ });
42
+ });
43
+
44
+ const metadata = {
45
+ propertyToConfig,
46
+ attributeToConfig,
47
+ };
48
+
49
+ metadataByConstructor.set(constructor, metadata);
50
+ return metadata;
51
+ }
52
+
53
+ class IncElement extends HostElement {
54
+ static reflectedAttributes = {};
55
+
56
+ static get observedAttributes() {
57
+ const metadata = buildMetadata(this);
58
+ return [...metadata.attributeToConfig.keys()];
59
+ }
60
+
61
+ constructor() {
62
+ super();
63
+ this._propertyValues = new Map();
64
+ this._slotListeners = new Map();
65
+ this._isReflectingAttribute = false;
66
+ this._isConnected = false;
67
+
68
+ const metadata = buildMetadata(this.constructor);
69
+
70
+ metadata.propertyToConfig.forEach((config, property) => {
71
+ if (this.hasAttribute(config.attribute)) {
72
+ this._propertyValues.set(property, readReflectedAttribute(this, config));
73
+ return;
74
+ }
75
+
76
+ this._propertyValues.set(property, config.defaultValue);
77
+ });
78
+ }
79
+
80
+ connectedCallback() {
81
+ this._isConnected = true;
82
+ if (typeof this.onConnected === "function") {
83
+ this.onConnected();
84
+ }
85
+ }
86
+
87
+ disconnectedCallback() {
88
+ this._isConnected = false;
89
+ this._slotListeners.forEach((listener, slot) => {
90
+ slot.removeEventListener("slotchange", listener);
91
+ });
92
+ this._slotListeners.clear();
93
+
94
+ if (typeof this.onDisconnected === "function") {
95
+ this.onDisconnected();
96
+ }
97
+ }
98
+
99
+ attributeChangedCallback(name, oldValue, newValue) {
100
+ if (oldValue === newValue) {
101
+ return;
102
+ }
103
+
104
+ const metadata = buildMetadata(this.constructor);
105
+ const config = metadata.attributeToConfig.get(name);
106
+
107
+ if (config) {
108
+ const parsed = parseValueFromAttribute(newValue, config);
109
+ this._setReflectedPropertyValue(config.property, parsed, { reflect: false });
110
+ }
111
+
112
+ if (typeof this.onAttributeValueChanged === "function") {
113
+ this.onAttributeValueChanged(name, oldValue, newValue);
114
+ }
115
+ }
116
+
117
+ emit(type, detail = {}, options = {}) {
118
+ return dispatchComponentEvent(this, type, detail, options);
119
+ }
120
+
121
+ getSlotElements(slotName = "") {
122
+ return getAssignedSlotElements(this, slotName);
123
+ }
124
+
125
+ observeSlot(slotName = "", callback = null) {
126
+ const selector = slotName ? `slot[name="${slotName}"]` : "slot:not([name])";
127
+ const slot = this.querySelector(selector);
128
+
129
+ if (typeof HTMLSlotElement === "undefined" || !(slot instanceof HTMLSlotElement)) {
130
+ return () => {};
131
+ }
132
+
133
+ const listener = () => {
134
+ if (typeof callback === "function") {
135
+ callback(this.getSlotElements(slotName));
136
+ }
137
+ };
138
+
139
+ slot.addEventListener("slotchange", listener);
140
+ this._slotListeners.set(slot, listener);
141
+ listener();
142
+
143
+ return () => {
144
+ slot.removeEventListener("slotchange", listener);
145
+ this._slotListeners.delete(slot);
146
+ };
147
+ }
148
+
149
+ reflectAllProperties() {
150
+ const metadata = buildMetadata(this.constructor);
151
+ metadata.propertyToConfig.forEach((config, property) => {
152
+ const value = this._propertyValues.get(property);
153
+ if (!config.reflect) {
154
+ return;
155
+ }
156
+
157
+ const serialized = serializeValueForAttribute(value, config);
158
+ reflectAttributeValue(this, config.attribute, serialized);
159
+ });
160
+ }
161
+
162
+ _setReflectedPropertyValue(property, value, options = {}) {
163
+ const metadata = buildMetadata(this.constructor);
164
+ const config = metadata.propertyToConfig.get(property);
165
+
166
+ if (!config) {
167
+ this._propertyValues.set(property, value);
168
+ return;
169
+ }
170
+
171
+ const previousValue = this._propertyValues.get(property);
172
+ if (Object.is(previousValue, value)) {
173
+ return;
174
+ }
175
+
176
+ this._propertyValues.set(property, value);
177
+
178
+ if (options.reflect !== false && config.reflect && !this._isReflectingAttribute) {
179
+ const serialized = serializeValueForAttribute(value, config);
180
+ this._isReflectingAttribute = true;
181
+ reflectAttributeValue(this, config.attribute, serialized);
182
+ this._isReflectingAttribute = false;
183
+ }
184
+
185
+ if (typeof this.onPropertyValueChanged === "function") {
186
+ this.onPropertyValueChanged(property, previousValue, value);
187
+ }
188
+ }
189
+ }
190
+
191
+ export {
192
+ IncElement,
193
+ };