@startinblox/components-ds4go 1.0.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 (56) hide show
  1. package/.gitlab-ci.yml +57 -0
  2. package/.storybook/main.ts +17 -0
  3. package/.storybook/preview-head.html +8 -0
  4. package/.storybook/preview.ts +22 -0
  5. package/LICENSE +21 -0
  6. package/README.md +129 -0
  7. package/biome.json +50 -0
  8. package/cypress/component/solid-boilerplate.cy.ts +9 -0
  9. package/cypress/support/component-index.html +12 -0
  10. package/cypress/support/component.ts +17 -0
  11. package/cypress.config.ts +11 -0
  12. package/dist/components-ds4go.css +1 -0
  13. package/dist/index.js +1634 -0
  14. package/lit-localize.json +15 -0
  15. package/locales/en.xlf +28 -0
  16. package/package.json +93 -0
  17. package/postcss.config.js +8 -0
  18. package/src/component.d.ts +167 -0
  19. package/src/components/catalog/ds4go-fact-bundle-holder.ts +162 -0
  20. package/src/components/modal/ds4go-fact-bundle-modal.ts +82 -0
  21. package/src/components/solid-fact-bundle.ts +225 -0
  22. package/src/context.json +1 -0
  23. package/src/helpers/components/ResourceMapper.ts +450 -0
  24. package/src/helpers/components/componentObjectHandler.ts +22 -0
  25. package/src/helpers/components/componentObjectsHandler.ts +14 -0
  26. package/src/helpers/components/dspComponent.ts +243 -0
  27. package/src/helpers/components/orbitComponent.ts +273 -0
  28. package/src/helpers/components/setupCacheInvalidation.ts +44 -0
  29. package/src/helpers/components/setupCacheOnResourceReady.ts +39 -0
  30. package/src/helpers/components/setupComponentSubscriptions.ts +73 -0
  31. package/src/helpers/components/setupOnSaveReset.ts +20 -0
  32. package/src/helpers/datas/dataBuilder.ts +43 -0
  33. package/src/helpers/datas/filterGenerator.ts +29 -0
  34. package/src/helpers/datas/filterObjectByDateAfter.ts +80 -0
  35. package/src/helpers/datas/filterObjectById.ts +54 -0
  36. package/src/helpers/datas/filterObjectByInterval.ts +133 -0
  37. package/src/helpers/datas/filterObjectByNamedValue.ts +103 -0
  38. package/src/helpers/datas/filterObjectByType.ts +30 -0
  39. package/src/helpers/datas/filterObjectByValue.ts +81 -0
  40. package/src/helpers/datas/sort.ts +40 -0
  41. package/src/helpers/i18n/configureLocalization.ts +17 -0
  42. package/src/helpers/index.ts +43 -0
  43. package/src/helpers/mappings/dsp-mapping-config.ts +545 -0
  44. package/src/helpers/ui/formatDate.ts +18 -0
  45. package/src/helpers/ui/lipsum.ts +12 -0
  46. package/src/helpers/utils/requestNavigation.ts +12 -0
  47. package/src/helpers/utils/uniq.ts +6 -0
  48. package/src/index.ts +14 -0
  49. package/src/initializer.ts +11 -0
  50. package/src/mocks/orbit.mock.ts +33 -0
  51. package/src/mocks/user.mock.ts +67 -0
  52. package/src/styles/_helpers/flex.scss +39 -0
  53. package/src/styles/index.scss +14 -0
  54. package/src/styles/modal/ds4go-fact-bundle-modal.scss +89 -0
  55. package/tsconfig.json +36 -0
  56. package/vite.config.ts +48 -0
@@ -0,0 +1,67 @@
1
+ import { dataBuilder } from "@helpers/datas/dataBuilder";
2
+ import { lorem } from "@helpers/ui/lipsum";
3
+ import type { User } from "@src/component";
4
+
5
+ export const user: User = {
6
+ "@id": "_:b1",
7
+ first_name: "John",
8
+ last_name: "Doe",
9
+ username: "johndoe42",
10
+ email: "john@doe.com",
11
+ account: {
12
+ "@id": "_:b2",
13
+ picture: "https://placehold.co/30x30",
14
+ user: {
15
+ "@id": "_b:1",
16
+ "@type": "foaf:user",
17
+ "@context": { get_full_name: "rdfs:label" },
18
+ },
19
+ },
20
+ name: "John Doe",
21
+ inbox: { "@id": "_:b3" },
22
+ "@type": "foaf:user",
23
+ "@context": [
24
+ "https://cdn.startinblox.com/owl/context.jsonld",
25
+ { get_full_name: "rdfs:label" },
26
+ ],
27
+ permissions: ["view", "add", "control", "delete", "change"],
28
+ };
29
+
30
+ export const userWithoutPicture = dataBuilder(user, ["account.picture"]);
31
+
32
+ export const userWithoutEmail = dataBuilder(user, ["email"]);
33
+
34
+ export const minimalUser = dataBuilder(user, [
35
+ "first_name",
36
+ "last_name",
37
+ "email",
38
+ "account.picture",
39
+ "name",
40
+ ]);
41
+
42
+ export const get_random_user = (): User => {
43
+ const removables: string[] = [];
44
+ const replacements: User = {
45
+ "@id": `store://local.sample-object/${Math.floor(Math.random() * 1000)}/`,
46
+ first_name: lorem.generateWords(1),
47
+ last_name: lorem.generateWords(1),
48
+ username: lorem.generateWords(1).toLocaleLowerCase(),
49
+ email: `${lorem.generateWords(1).toLocaleLowerCase()}@example.com`,
50
+ name: "",
51
+ };
52
+ replacements.name = `${replacements.first_name} ${replacements.last_name}`;
53
+ const removableGenerator = (key: string) => {
54
+ // Between 0 and 25% chance
55
+ if (Math.random() < Math.random() * 0.25) {
56
+ removables.push(key);
57
+ }
58
+ };
59
+ removableGenerator("account");
60
+ removableGenerator("first_name");
61
+ removableGenerator("last_name");
62
+ removableGenerator("name");
63
+ removableGenerator("email");
64
+ removableGenerator("username");
65
+
66
+ return dataBuilder(user, removables, replacements, true) as User;
67
+ };
@@ -0,0 +1,39 @@
1
+ // Global flex utility classes
2
+ .flex {
3
+ display: flex;
4
+ &.flex-row {
5
+ flex-direction: row;
6
+ }
7
+ &.flex-column {
8
+ flex-direction: column;
9
+ }
10
+ &.wrap {
11
+ flex-wrap: wrap;
12
+ }
13
+ &.flex-1 {
14
+ flex: 1;
15
+ }
16
+ &.half {
17
+ flex-basis: 50%;
18
+ }
19
+ .half {
20
+ flex-basis: 50%;
21
+ }
22
+ &.justify-content-center{
23
+ justify-content: center;
24
+ }
25
+ &.justify-content-space-between{
26
+ justify-content: space-between;
27
+ }
28
+ &.align-items-center{
29
+ align-items: center;
30
+ }
31
+ &.align-items-flex-start{
32
+ align-items: flex-start;
33
+ }
34
+
35
+ }
36
+
37
+ .full-width {
38
+ width: 100%;
39
+ }
@@ -0,0 +1,14 @@
1
+ @charset "UTF-8";
2
+ @use "sass:meta";
3
+
4
+ @import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap");
5
+
6
+ :root {
7
+ --font-family: "Inter", sans-serif;
8
+ --color-text: #181d27;
9
+ --color-primary: #001aff;
10
+ --color-secondary: #001aff;
11
+ --color-third: #e4f0ff;
12
+ --color-heading: #181d27;
13
+ font-family: var(--font-family);
14
+ }
@@ -0,0 +1,89 @@
1
+ @use "sass:meta";
2
+
3
+ @include meta.load-css("../_helpers/flex");
4
+
5
+ .modal {
6
+ width: 90vw;
7
+ height: 90vh;
8
+ border-radius: var(--border-radius-lg);
9
+ background-color: var(--color-surface-primary);
10
+ border: var(--border-width-sm) solid var(--color-border-primary);
11
+ display: flex;
12
+ flex-direction: column;
13
+ gap: var(--scale-600);
14
+ padding: var(--scale-600) var(--scale-900);
15
+
16
+ color: var(--color-text-body);
17
+ font-family: var(--font-family-body);
18
+ font-size: var(--typography-size-body-md);
19
+ font-style: normal;
20
+ font-weight: var(--font-weight-regular);
21
+ line-height: var(--line-height-body-md);
22
+ letter-spacing: var(--font-letter-spacing-default);
23
+
24
+ .topbar {
25
+ width: 100%;
26
+ display: flex;
27
+ flex-direction: row;
28
+ gap: var(--scale-400);
29
+
30
+ tems-button:nth-child(2) {
31
+ margin-left: auto;
32
+ }
33
+ }
34
+
35
+ .modal-content-wrapper {
36
+ overflow: hidden;
37
+ flex: 1;
38
+ display: flex;
39
+ flex-direction: column;
40
+
41
+ .modal-box {
42
+ flex: 1;
43
+ display: flex;
44
+ overflow-y: scroll;
45
+ overflow-x: hidden;
46
+ }
47
+
48
+ .modal-content {
49
+ display: flex;
50
+ flex-direction: column;
51
+ gap: var(--scale-400);
52
+ height: fit-content;
53
+ width: 100%;
54
+ }
55
+
56
+ tems-division {
57
+ width: fit-content;
58
+ div {
59
+ display: block;
60
+ height: auto;
61
+ overflow: hidden;
62
+ text-overflow: ellipsis;
63
+ }
64
+ }
65
+
66
+ .card-grid {
67
+ display: flex;
68
+ flex-direction: row;
69
+ flex-wrap: wrap;
70
+ gap: 20px;
71
+ }
72
+
73
+ .card-grid-vertical {
74
+ justify-content: stretch;
75
+ }
76
+
77
+ .card-grid-vertical tems-card-catalog {
78
+ width: 354px;
79
+ height: auto;
80
+ }
81
+ }
82
+ }
83
+
84
+ @media screen and (min-width: 1100px) {
85
+ div.modal {
86
+ width: 80vw;
87
+ height: 80vh;
88
+ }
89
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "paths": {
5
+ "@components/*": ["./src/components/*"],
6
+ "@cypress/*": ["./cypress/*"],
7
+ "@helpers/*": ["./src/helpers/*"],
8
+ "@helpers": ["./src/helpers/index.ts"],
9
+ "@mocks/*": ["./src/mocks/*"],
10
+ "@stories/*": ["./stories/*"],
11
+ "@styles/*": ["./src/styles/*"],
12
+ "@src/*": ["./src/*"]
13
+ },
14
+ "target": "ES2020",
15
+ "experimentalDecorators": true,
16
+ "useDefineForClassFields": false,
17
+ "module": "ESNext",
18
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
19
+ "types": ["cypress", "node"],
20
+ "skipLibCheck": true,
21
+
22
+ /* Bundler mode */
23
+ "moduleResolution": "bundler",
24
+ "allowImportingTsExtensions": true,
25
+ "resolveJsonModule": true,
26
+ "isolatedModules": true,
27
+ "noEmit": true,
28
+
29
+ /* Linting */
30
+ "strict": true,
31
+ "noUnusedLocals": true,
32
+ "noUnusedParameters": true,
33
+ "noFallthroughCasesInSwitch": true
34
+ },
35
+ "include": ["src", "cypress/**/*.ts", "stories/**/*.ts", "*.config.ts"]
36
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { resolve } from "node:path";
2
+ import Icons from "unplugin-icons/vite";
3
+ import { defineConfig } from "vite";
4
+
5
+ export default defineConfig({
6
+ css: {
7
+ preprocessorOptions: {
8
+ scss: {
9
+ quietDeps: true,
10
+ },
11
+ },
12
+ },
13
+ build: {
14
+ lib: {
15
+ entry: resolve(__dirname, "src/index.ts"),
16
+ name: JSON.stringify(process.env.npm_package_name),
17
+ fileName: () => "index.js",
18
+ formats: ["es"],
19
+ },
20
+ target: "esnext",
21
+ },
22
+ plugins: [
23
+ Icons({
24
+ compiler: "web-components",
25
+ webComponents: {
26
+ autoDefine: true,
27
+ },
28
+ autoInstall: true,
29
+ scale: 1,
30
+ }),
31
+ ],
32
+ resolve: {
33
+ alias: {
34
+ "@components": "/src/components",
35
+ "@cypress": "/cypress",
36
+ "@helpers": "/src/helpers",
37
+ "@mocks": "/src/mocks",
38
+ "@stories": "/stories",
39
+ "@styles": "/src/styles",
40
+ "@src": "/src",
41
+ "@startinblox/core":
42
+ "https://cdn.jsdelivr.net/npm/@startinblox/core@beta/dist/index.js",
43
+ // Node.js polyfills for sib-core
44
+ stream: "stream-browserify",
45
+ buffer: "buffer",
46
+ },
47
+ },
48
+ });