@bccampus/ui-components 0.5.0 → 0.5.2
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/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.10.3.cjs +942 -0
- package/.yarnrc.yml +3 -0
- package/dist/_chunks/createLucideIcon.js +0 -24
- package/dist/_chunks/index.js +16 -38
- package/dist/_chunks/index3.js +26 -520
- package/dist/_chunks/index4.js +615 -0
- package/dist/_chunks/utils.js +199 -143
- package/dist/components/index.js +2 -2
- package/dist/components/ui/banner.js +0 -6
- package/dist/components/ui/composite/CompositeData.js +1 -1
- package/dist/components/ui/composite/CompositeDataItem.js +109 -3
- package/dist/components/ui/composite/FocusProvider/AbstractFocusProvider.js +2 -1
- package/dist/components/ui/composite/SelectionProvider/AbstractSelectionProvider.js +2 -1
- package/dist/components/ui/composite/SelectionProvider/MultipleSelectionProvider.js +1 -1
- package/dist/components/ui/composite/SelectionProvider/SingleSelectionProvider.js +1 -1
- package/dist/components/ui/composite/composite-component-item.js +2 -24
- package/dist/components/ui/composite/index.d.ts +1 -0
- package/dist/components/ui/composite/index.js +2 -2
- package/dist/components/ui/composite/listbox.js +1 -0
- package/dist/components/ui/horizontal-list.js +0 -12
- package/dist/components/ui/navigation-menu.js +86 -10
- package/dist/components/ui/popover.js +85 -3
- package/dist/components/ui/search-input.js +0 -6
- package/package.json +75 -67
- package/src/App.tsx +44 -14
- package/src/components/ui/composite/index.ts +2 -1
- package/src/components/ui/page-header.tsx +6 -9
- package/src/main.tsx +12 -12
- package/vite.config.ts +6 -2
- package/dist/_chunks/CompositeDataItem.js +0 -204
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { omit } from "../lib/object.js";
|
|
2
|
-
let clean = Symbol("clean");
|
|
3
|
-
let listenerQueue = [];
|
|
4
|
-
let lqIndex = 0;
|
|
5
|
-
const QUEUE_ITEMS_PER_LISTENER = 4;
|
|
6
|
-
let atom = (initialValue) => {
|
|
7
|
-
let listeners = [];
|
|
8
|
-
let $atom = {
|
|
9
|
-
get() {
|
|
10
|
-
if (!$atom.lc) {
|
|
11
|
-
$atom.listen(() => {
|
|
12
|
-
})();
|
|
13
|
-
}
|
|
14
|
-
return $atom.value;
|
|
15
|
-
},
|
|
16
|
-
lc: 0,
|
|
17
|
-
listen(listener) {
|
|
18
|
-
$atom.lc = listeners.push(listener);
|
|
19
|
-
return () => {
|
|
20
|
-
for (let i = lqIndex + QUEUE_ITEMS_PER_LISTENER; i < listenerQueue.length; ) {
|
|
21
|
-
if (listenerQueue[i] === listener) {
|
|
22
|
-
listenerQueue.splice(i, QUEUE_ITEMS_PER_LISTENER);
|
|
23
|
-
} else {
|
|
24
|
-
i += QUEUE_ITEMS_PER_LISTENER;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
let index = listeners.indexOf(listener);
|
|
28
|
-
if (~index) {
|
|
29
|
-
listeners.splice(index, 1);
|
|
30
|
-
if (!--$atom.lc) $atom.off();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
notify(oldValue, changedKey) {
|
|
35
|
-
let runListenerQueue = !listenerQueue.length;
|
|
36
|
-
for (let listener of listeners) {
|
|
37
|
-
listenerQueue.push(listener, $atom.value, oldValue, changedKey);
|
|
38
|
-
}
|
|
39
|
-
if (runListenerQueue) {
|
|
40
|
-
for (lqIndex = 0; lqIndex < listenerQueue.length; lqIndex += QUEUE_ITEMS_PER_LISTENER) {
|
|
41
|
-
listenerQueue[lqIndex](
|
|
42
|
-
listenerQueue[lqIndex + 1],
|
|
43
|
-
listenerQueue[lqIndex + 2],
|
|
44
|
-
listenerQueue[lqIndex + 3]
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
listenerQueue.length = 0;
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
/* It will be called on last listener unsubscribing.
|
|
51
|
-
We will redefine it in onMount and onStop. */
|
|
52
|
-
off() {
|
|
53
|
-
},
|
|
54
|
-
set(newValue) {
|
|
55
|
-
let oldValue = $atom.value;
|
|
56
|
-
if (oldValue !== newValue) {
|
|
57
|
-
$atom.value = newValue;
|
|
58
|
-
$atom.notify(oldValue);
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
subscribe(listener) {
|
|
62
|
-
let unbind = $atom.listen(listener);
|
|
63
|
-
listener($atom.value);
|
|
64
|
-
return unbind;
|
|
65
|
-
},
|
|
66
|
-
value: initialValue
|
|
67
|
-
};
|
|
68
|
-
if (process.env.NODE_ENV !== "production") {
|
|
69
|
-
$atom[clean] = () => {
|
|
70
|
-
listeners = [];
|
|
71
|
-
$atom.lc = 0;
|
|
72
|
-
$atom.off();
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return $atom;
|
|
76
|
-
};
|
|
77
|
-
let map = (initial = {}) => {
|
|
78
|
-
let $map = atom(initial);
|
|
79
|
-
$map.setKey = function(key, value) {
|
|
80
|
-
let oldMap = $map.value;
|
|
81
|
-
if (typeof value === "undefined" && key in $map.value) {
|
|
82
|
-
$map.value = { ...$map.value };
|
|
83
|
-
delete $map.value[key];
|
|
84
|
-
$map.notify(oldMap, key);
|
|
85
|
-
} else if ($map.value[key] !== value) {
|
|
86
|
-
$map.value = {
|
|
87
|
-
...$map.value,
|
|
88
|
-
[key]: value
|
|
89
|
-
};
|
|
90
|
-
$map.notify(oldMap, key);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
return $map;
|
|
94
|
-
};
|
|
95
|
-
class CompositeDataItem {
|
|
96
|
-
#key;
|
|
97
|
-
parent = null;
|
|
98
|
-
children;
|
|
99
|
-
level;
|
|
100
|
-
data;
|
|
101
|
-
state;
|
|
102
|
-
pointers;
|
|
103
|
-
childrenProp;
|
|
104
|
-
constructor(item, options, parent) {
|
|
105
|
-
this.#key = options.getItemKey(item);
|
|
106
|
-
this.data = map(omit(item, [options.itemChildrenProp]));
|
|
107
|
-
this.state = map({
|
|
108
|
-
focused: false,
|
|
109
|
-
selected: false,
|
|
110
|
-
disabled: false,
|
|
111
|
-
...options.initialState
|
|
112
|
-
});
|
|
113
|
-
this.pointers = {};
|
|
114
|
-
this.parent = parent;
|
|
115
|
-
this.level = parent ? parent.level + 1 : 0;
|
|
116
|
-
this.childrenProp = options.itemChildrenProp;
|
|
117
|
-
const children = options.getItemChildren(item);
|
|
118
|
-
if (children) {
|
|
119
|
-
this.children = children.map((child) => {
|
|
120
|
-
const childItem = new CompositeDataItem(child, options, this);
|
|
121
|
-
return childItem;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
get key() {
|
|
126
|
-
return this.#key;
|
|
127
|
-
}
|
|
128
|
-
*[Symbol.iterator]() {
|
|
129
|
-
if (this.key !== "ALL") yield this;
|
|
130
|
-
if (this.children)
|
|
131
|
-
for (const child of this.children)
|
|
132
|
-
for (const item of child) yield item;
|
|
133
|
-
}
|
|
134
|
-
toJSON() {
|
|
135
|
-
const json = { ...this.data.get() };
|
|
136
|
-
if (this.children) {
|
|
137
|
-
json[this.childrenProp] = [];
|
|
138
|
-
for (const child of this.children)
|
|
139
|
-
json[this.childrenProp].push(child.toJSON());
|
|
140
|
-
}
|
|
141
|
-
return json;
|
|
142
|
-
}
|
|
143
|
-
descendants() {
|
|
144
|
-
if (!this.children) return [];
|
|
145
|
-
const descendants = [];
|
|
146
|
-
this.children.forEach(
|
|
147
|
-
(child) => {
|
|
148
|
-
descendants.push(child);
|
|
149
|
-
const childDescendants = child.descendants();
|
|
150
|
-
if (childDescendants) descendants.push(...childDescendants);
|
|
151
|
-
}
|
|
152
|
-
);
|
|
153
|
-
return descendants;
|
|
154
|
-
}
|
|
155
|
-
ancestors() {
|
|
156
|
-
const ancestors = [];
|
|
157
|
-
let parent = this.parent;
|
|
158
|
-
while (parent) {
|
|
159
|
-
ancestors.push(parent);
|
|
160
|
-
parent = parent.parent;
|
|
161
|
-
}
|
|
162
|
-
return ancestors;
|
|
163
|
-
}
|
|
164
|
-
toggleSelect(recursive = false) {
|
|
165
|
-
if (this.state.get().selected) this.deselect(recursive);
|
|
166
|
-
else this.select(recursive);
|
|
167
|
-
}
|
|
168
|
-
select(recursive = false) {
|
|
169
|
-
this.state.setKey("selected", true);
|
|
170
|
-
if (recursive && this.children) {
|
|
171
|
-
const selectedChildKeys = this.children.map((child) => child.select(true)).flat();
|
|
172
|
-
return [this.key, ...selectedChildKeys];
|
|
173
|
-
}
|
|
174
|
-
return [this.key];
|
|
175
|
-
}
|
|
176
|
-
deselect(recursive = false) {
|
|
177
|
-
this.state.setKey("selected", false);
|
|
178
|
-
if (recursive && this.children) {
|
|
179
|
-
const deselectedChildKeys = this.children.map((child) => child.deselect(true)).flat();
|
|
180
|
-
return [this.key, ...deselectedChildKeys];
|
|
181
|
-
}
|
|
182
|
-
return [this.key];
|
|
183
|
-
}
|
|
184
|
-
disable(recursive = false) {
|
|
185
|
-
this.state.setKey("disabled", true);
|
|
186
|
-
if (recursive && this.children) {
|
|
187
|
-
const disabledChildKeys = this.children.map((child) => child.disable(true)).flat();
|
|
188
|
-
return [this.key, ...disabledChildKeys];
|
|
189
|
-
}
|
|
190
|
-
return [this.key];
|
|
191
|
-
}
|
|
192
|
-
enable(recursive = false) {
|
|
193
|
-
this.state.setKey("disabled", false);
|
|
194
|
-
if (recursive && this.children) {
|
|
195
|
-
const enabledChildKeys = this.children.map((child) => child.enable(true)).flat();
|
|
196
|
-
return [this.key, ...enabledChildKeys];
|
|
197
|
-
}
|
|
198
|
-
return [this.key];
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
export {
|
|
202
|
-
CompositeDataItem as C,
|
|
203
|
-
atom as a
|
|
204
|
-
};
|