@bccampus/ui-components 0.8.0 → 0.8.1
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/README.md
CHANGED
|
@@ -1,69 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @bccampus/ui-components
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Currently, two official plugins are available:
|
|
6
|
-
|
|
7
|
-
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
8
|
-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
-
|
|
10
|
-
## Expanding the ESLint configuration
|
|
11
|
-
|
|
12
|
-
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
13
|
-
|
|
14
|
-
```js
|
|
15
|
-
export default defineConfig([
|
|
16
|
-
globalIgnores(['dist']),
|
|
17
|
-
{
|
|
18
|
-
files: ['**/*.{ts,tsx}'],
|
|
19
|
-
extends: [
|
|
20
|
-
// Other configs...
|
|
21
|
-
|
|
22
|
-
// Remove tseslint.configs.recommended and replace with this
|
|
23
|
-
tseslint.configs.recommendedTypeChecked,
|
|
24
|
-
// Alternatively, use this for stricter rules
|
|
25
|
-
tseslint.configs.strictTypeChecked,
|
|
26
|
-
// Optionally, add this for stylistic rules
|
|
27
|
-
tseslint.configs.stylisticTypeChecked,
|
|
28
|
-
|
|
29
|
-
// Other configs...
|
|
30
|
-
],
|
|
31
|
-
languageOptions: {
|
|
32
|
-
parserOptions: {
|
|
33
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
34
|
-
tsconfigRootDir: import.meta.dirname,
|
|
35
|
-
},
|
|
36
|
-
// other options...
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
])
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
// eslint.config.js
|
|
46
|
-
import reactX from 'eslint-plugin-react-x'
|
|
47
|
-
import reactDom from 'eslint-plugin-react-dom'
|
|
48
|
-
|
|
49
|
-
export default defineConfig([
|
|
50
|
-
globalIgnores(['dist']),
|
|
51
|
-
{
|
|
52
|
-
files: ['**/*.{ts,tsx}'],
|
|
53
|
-
extends: [
|
|
54
|
-
// Other configs...
|
|
55
|
-
// Enable lint rules for React
|
|
56
|
-
reactX.configs['recommended-typescript'],
|
|
57
|
-
// Enable lint rules for React DOM
|
|
58
|
-
reactDom.configs.recommended,
|
|
59
|
-
],
|
|
60
|
-
languageOptions: {
|
|
61
|
-
parserOptions: {
|
|
62
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
63
|
-
tsconfigRootDir: import.meta.dirname,
|
|
64
|
-
},
|
|
65
|
-
// other options...
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
])
|
|
69
|
-
```
|
|
3
|
+
BCcampus React components
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { atom } from "nanostores";
|
|
1
|
+
import { atom, onSet } from "nanostores";
|
|
2
2
|
import { CompositeDataItem } from "../CompositeDataItem.js";
|
|
3
|
+
import { symmetricDifference } from "../../../../lib/set-operations.js";
|
|
3
4
|
class AbstractSelectionManager {
|
|
4
5
|
data;
|
|
5
6
|
dataOptions;
|
|
@@ -16,6 +17,10 @@ class AbstractSelectionManager {
|
|
|
16
17
|
} else {
|
|
17
18
|
this.dataOptions.selectedKeys.forEach((selectedKey) => this.select(selectedKey));
|
|
18
19
|
}
|
|
20
|
+
onSet(this.selectedKeys, ({ newValue, abort }) => {
|
|
21
|
+
const diff = symmetricDifference(this.selectedKeys.get(), newValue);
|
|
22
|
+
if (diff.size === 0) abort();
|
|
23
|
+
});
|
|
19
24
|
}
|
|
20
25
|
getSelectedKeys() {
|
|
21
26
|
return this.selectedKeys.get();
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bccampus/ui-components",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
|
+
"description": "BCcampus React components",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"exports": {
|
|
6
7
|
".": {
|
|
@@ -74,4 +75,4 @@
|
|
|
74
75
|
"vite": "^7.3.1",
|
|
75
76
|
"vite-plugin-dts": "^4.5.4"
|
|
76
77
|
}
|
|
77
|
-
}
|
|
78
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { atom, type PreinitializedWritableAtom } from "nanostores";
|
|
1
|
+
import { atom, onSet, type PreinitializedWritableAtom } from "nanostores";
|
|
2
2
|
import type { CompositeData } from "../CompositeData";
|
|
3
3
|
import { CompositeDataItem } from "../CompositeDataItem";
|
|
4
4
|
import type { CompositeDataOptions, CompositeItemKey } from "../types";
|
|
5
5
|
import type { SelectionManager, SelectionManagerOptions } from "./types";
|
|
6
|
+
import { symmetricDifference } from "@/lib";
|
|
6
7
|
|
|
7
8
|
export abstract class AbstractSelectionManager<T extends object> implements SelectionManager<T> {
|
|
8
9
|
protected data!: CompositeData<T>;
|
|
@@ -27,6 +28,11 @@ export abstract class AbstractSelectionManager<T extends object> implements Sele
|
|
|
27
28
|
// Set default selected items
|
|
28
29
|
this.dataOptions.selectedKeys.forEach((selectedKey) => this.select(selectedKey));
|
|
29
30
|
}
|
|
31
|
+
|
|
32
|
+
onSet(this.selectedKeys, ({ newValue, abort }) => {
|
|
33
|
+
const diff = symmetricDifference(this.selectedKeys.get(), newValue);
|
|
34
|
+
if (diff.size === 0) abort();
|
|
35
|
+
});
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
getSelectedKeys() {
|