hamzus-ui 0.0.192 → 0.0.194

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/index.d.ts CHANGED
@@ -44,6 +44,7 @@ export { default as Caroussel } from "./src/components/hamzus-ui/Caroussel/Carou
44
44
  export { default as Image } from "./src/components/hamzus-ui/Image/Image.svelte"
45
45
  export * as Table from "./src/components/hamzus-ui/Table"
46
46
  export * as DataList from "./src/components/hamzus-ui/DataList"
47
+ export { default as Object } from "./src/components/hamzus-ui/Object/Object.svelte"
47
48
  export * as ResponsiveTable from "./src/components/hamzus-ui/ResponsiveTable"
48
49
  export { default as Skeleton } from "./src/components/hamzus-ui/Skeleton/Skeleton.svelte"
49
50
  export { default as LineLoader } from "./src/components/hamzus-ui/LineLoader/LineLoader.svelte"
@@ -63,6 +64,7 @@ export * as Sidebar from "./src/layout/Sidebar"
63
64
 
64
65
  // special
65
66
  export { default as Portal } from "./src/components/hamzus-ui/Portal/Portal.svelte"
67
+ export { default as SvgLine } from "./src/components/hamzus-ui/SvgLine/SvgLine.svelte"
66
68
 
67
69
  // utils
68
70
  export { config, init } from "./src/utils/hamzus.config.js";
package/index.js CHANGED
@@ -41,6 +41,7 @@ export { default as Caroussel } from "./src/components/hamzus-ui/Caroussel/Carou
41
41
  export { default as Image } from "./src/components/hamzus-ui/Image/Image.svelte"
42
42
  export * as Table from "./src/components/hamzus-ui/Table"
43
43
  export * as DataList from "./src/components/hamzus-ui/DataList"
44
+ export { default as Object } from "./src/components/hamzus-ui/Object/Object.svelte"
44
45
  export * as ResponsiveTable from "./src/components/hamzus-ui/ResponsiveTable"
45
46
  export { default as Skeleton } from "./src/components/hamzus-ui/Skeleton/Skeleton.svelte"
46
47
  export { default as LineLoader } from "./src/components/hamzus-ui/LineLoader/LineLoader.svelte"
@@ -60,6 +61,7 @@ export * as Sidebar from "./src/layout/Sidebar"
60
61
 
61
62
  // special
62
63
  export { default as Portal } from "./src/components/hamzus-ui/Portal/Portal.svelte"
64
+ export { default as SvgLine } from "./src/components/hamzus-ui/SvgLine/SvgLine.svelte"
63
65
 
64
66
  // utils
65
67
  export { config, init } from "./src/utils/hamzus.config.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hamzus-ui",
3
- "version": "0.0.192",
3
+ "version": "0.0.194",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "svelte": "index.js",
@@ -0,0 +1,107 @@
1
+ <script>
2
+ import IconButton from '../IconButton/IconButton.svelte';
3
+ import { dataTypes, nextColor } from './object';
4
+ import { onMount } from 'svelte';
5
+
6
+ export let value = null;
7
+
8
+ $: if (value !== null && value.isOpen === undefined) value.isOpen = true;
9
+
10
+ function getColor() {
11
+ if (!value.color) return 'var(--blue)';
12
+
13
+ return nextColor[value.color];
14
+ }
15
+
16
+ function getNextColor(color, index) {
17
+ for (let i = 0; i < index; i++) {
18
+ color = nextColor[color];
19
+ }
20
+ return color;
21
+ }
22
+ </script>
23
+
24
+ {#if value !== null}
25
+ {@const color = getColor()}
26
+ <div class="object" style="border:1px solid {color}">
27
+ <span class="color-bar" style="background-color:{color}"></span>
28
+ <div class="top-bar">
29
+ <h4>{value.label ?? ''} <span style="color:var(--green)">Object</span></h4>
30
+ <IconButton
31
+ onClick={() => {
32
+ value.isOpen = !value.isOpen;
33
+ }}
34
+ variant="secondary"
35
+ >
36
+ {#if value.isOpen}
37
+ <svg
38
+ width="24"
39
+ height="24"
40
+ viewBox="0 0 24 24"
41
+ fill="none"
42
+ xmlns="http://www.w3.org/2000/svg"
43
+ >
44
+ <path
45
+ d="M19.9195 15.8001C19.7295 15.8001 19.5395 15.7301 19.3895 15.5801L12.8695 9.06008C12.3895 8.58008 11.6095 8.58008 11.1295 9.06008L4.60953 15.5801C4.31953 15.8701 3.83953 15.8701 3.54953 15.5801C3.25953 15.2901 3.25953 14.8101 3.54953 14.5201L10.0695 8.00008C11.1295 6.94008 12.8595 6.94008 13.9295 8.00008L20.4495 14.5201C20.7395 14.8101 20.7395 15.2901 20.4495 15.5801C20.2995 15.7201 20.1095 15.8001 19.9195 15.8001Z"
46
+ fill="#292D32"
47
+ />
48
+ </svg>
49
+ {:else}
50
+ <svg
51
+ width="24"
52
+ height="24"
53
+ viewBox="0 0 24 24"
54
+ fill="none"
55
+ xmlns="http://www.w3.org/2000/svg"
56
+ >
57
+ <path
58
+ d="M11.9995 16.8001C11.2995 16.8001 10.5995 16.5301 10.0695 16.0001L3.54953 9.48014C3.25953 9.19014 3.25953 8.71014 3.54953 8.42014C3.83953 8.13014 4.31953 8.13014 4.60953 8.42014L11.1295 14.9401C11.6095 15.4201 12.3895 15.4201 12.8695 14.9401L19.3895 8.42014C19.6795 8.13014 20.1595 8.13014 20.4495 8.42014C20.7395 8.71014 20.7395 9.19014 20.4495 9.48014L13.9295 16.0001C13.3995 16.5301 12.6995 16.8001 11.9995 16.8001Z"
59
+ fill="#292D32"
60
+ />
61
+ </svg>
62
+ {/if}
63
+ </IconButton>
64
+ </div>
65
+ {#if value.isOpen}
66
+ {#each Object.entries(value.childs) as [label, data], index}
67
+ {@const nextColord = getNextColor(color, index)}
68
+ {#if dataTypes.hasOwnProperty(data.type)}
69
+ <svelte:component
70
+ this={dataTypes[data.type]}
71
+ value={{ ...data, color: nextColord }}
72
+ {label}
73
+ defaultValue={data.default}
74
+ type={data.allowedTypes}
75
+ ></svelte:component>
76
+ {/if}
77
+ {/each}
78
+ {/if}
79
+ </div>
80
+ {/if}
81
+
82
+ <style>
83
+ .object {
84
+ position: relative;
85
+ display: flex;
86
+ flex-direction: column;
87
+ padding: var(--pad-m) var(--pad-m) var(--pad-m) var(--pad-xl);
88
+ row-gap: var(--pad-m);
89
+ border: 1px solid var(--stroke);
90
+ border-radius: var(--radius-m);
91
+ overflow: hidden;
92
+ }
93
+
94
+ .color-bar {
95
+ position: absolute;
96
+ top: 0px;
97
+ left: 0px;
98
+ height: 100%;
99
+ width: 5px;
100
+ }
101
+
102
+ .top-bar {
103
+ display: flex;
104
+ align-items: center;
105
+ justify-content: space-between;
106
+ }
107
+ </style>
@@ -0,0 +1,21 @@
1
+ <script>
2
+ export let label = '';
3
+ export let defaultValue = '';
4
+ export let type = '';
5
+ </script>
6
+
7
+ <div class="line">
8
+ <h4>{label} <span style="color:var(--blue)">{type}</span></h4>
9
+ <h4>{defaultValue}</h4>
10
+ </div>
11
+
12
+ <style>
13
+ .line {
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: space-between;
17
+ padding: var(--pad-s) var(--pad-m);
18
+ background-color: var(--bg-2);
19
+ border-radius: var(--radius-s);
20
+ }
21
+ </style>
@@ -0,0 +1,108 @@
1
+ <script>
2
+ import IconButton from '../../IconButton/IconButton.svelte';
3
+ import { dataTypes, nextColor } from '../object';
4
+ import { onMount } from 'svelte';
5
+
6
+ export let value = null;
7
+
8
+ $: if (value !== null && value.isOpen === undefined) value.isOpen = true;
9
+
10
+ function getColor() {
11
+ if (!value.color) return 'var(--blue)';
12
+
13
+ return nextColor[value.color];
14
+ }
15
+
16
+ function getNextColor(color, index) {
17
+ for (let i = 0; i < index; i++) {
18
+ color = nextColor[color];
19
+ }
20
+
21
+ return color;
22
+ }
23
+ </script>
24
+
25
+ {#if value !== null}
26
+ {@const color = getColor()}
27
+ <div class="object" style="border:1px solid {color}">
28
+ <span class="color-bar" style="background-color:{color}"></span>
29
+ <div class="top-bar">
30
+ <h4>{value.label ?? ''} <span style="color:var(--green)">Object</span></h4>
31
+ <IconButton
32
+ onClick={() => {
33
+ value.isOpen = !value.isOpen;
34
+ }}
35
+ variant="secondary"
36
+ >
37
+ {#if value.isOpen}
38
+ <svg
39
+ width="24"
40
+ height="24"
41
+ viewBox="0 0 24 24"
42
+ fill="none"
43
+ xmlns="http://www.w3.org/2000/svg"
44
+ >
45
+ <path
46
+ d="M19.9195 15.8001C19.7295 15.8001 19.5395 15.7301 19.3895 15.5801L12.8695 9.06008C12.3895 8.58008 11.6095 8.58008 11.1295 9.06008L4.60953 15.5801C4.31953 15.8701 3.83953 15.8701 3.54953 15.5801C3.25953 15.2901 3.25953 14.8101 3.54953 14.5201L10.0695 8.00008C11.1295 6.94008 12.8595 6.94008 13.9295 8.00008L20.4495 14.5201C20.7395 14.8101 20.7395 15.2901 20.4495 15.5801C20.2995 15.7201 20.1095 15.8001 19.9195 15.8001Z"
47
+ fill="#292D32"
48
+ />
49
+ </svg>
50
+ {:else}
51
+ <svg
52
+ width="24"
53
+ height="24"
54
+ viewBox="0 0 24 24"
55
+ fill="none"
56
+ xmlns="http://www.w3.org/2000/svg"
57
+ >
58
+ <path
59
+ d="M11.9995 16.8001C11.2995 16.8001 10.5995 16.5301 10.0695 16.0001L3.54953 9.48014C3.25953 9.19014 3.25953 8.71014 3.54953 8.42014C3.83953 8.13014 4.31953 8.13014 4.60953 8.42014L11.1295 14.9401C11.6095 15.4201 12.3895 15.4201 12.8695 14.9401L19.3895 8.42014C19.6795 8.13014 20.1595 8.13014 20.4495 8.42014C20.7395 8.71014 20.7395 9.19014 20.4495 9.48014L13.9295 16.0001C13.3995 16.5301 12.6995 16.8001 11.9995 16.8001Z"
60
+ fill="#292D32"
61
+ />
62
+ </svg>
63
+ {/if}
64
+ </IconButton>
65
+ </div>
66
+ {#if value.isOpen}
67
+ {#each Object.entries(value.childs) as [label, data], index}
68
+ {@const nextColord = getNextColor(color, index)}
69
+ {#if dataTypes.hasOwnProperty(data.type)}
70
+ <svelte:component
71
+ this={dataTypes[data.type]}
72
+ value={{ ...data, color: nextColord }}
73
+ {label}
74
+ defaultValue={data.default}
75
+ type={data.allowedTypes}
76
+ ></svelte:component>
77
+ {/if}
78
+ {/each}
79
+ {/if}
80
+ </div>
81
+ {/if}
82
+
83
+ <style>
84
+ .object {
85
+ position: relative;
86
+ display: flex;
87
+ flex-direction: column;
88
+ padding: var(--pad-m) var(--pad-m) var(--pad-m) var(--pad-xl);
89
+ row-gap: var(--pad-m);
90
+ border: 1px solid var(--stroke);
91
+ border-radius: var(--radius-m);
92
+ overflow: hidden;
93
+ }
94
+
95
+ .color-bar {
96
+ position: absolute;
97
+ top: 0px;
98
+ left: 0px;
99
+ height: 100%;
100
+ width: 5px;
101
+ }
102
+
103
+ .top-bar {
104
+ display: flex;
105
+ align-items: center;
106
+ justify-content: space-between;
107
+ }
108
+ </style>
@@ -0,0 +1,18 @@
1
+ import Object from "./dataTypes/Object.svelte"
2
+ import Line from "./dataTypes/Line.svelte"
3
+
4
+ export const dataTypes = {
5
+ "object":Object,
6
+ "line":Line
7
+ }
8
+
9
+ // cycle de couleur
10
+ export const nextColor = {
11
+ "var(--blue)":"var(--mauve)",
12
+ "var(--mauve)":"var(--violet)",
13
+ "var(--violet)":"var(--red)",
14
+ "var(--red)":"var(--orange)",
15
+ "var(--orange)":"var(--yellow)",
16
+ "var(--yellow)":"var(--green)",
17
+ "var(--green)":"var(--blue)",// --> revenir a la premiere couleur
18
+ }
@@ -0,0 +1,31 @@
1
+ <script>
2
+ import { generatePathWithRoundedCorners } from "../../../utils/svg";
3
+
4
+ export let steps = {
5
+ dir: "up" | "down" | "left" | "right",
6
+ distance: 0
7
+ }
8
+ export let radius = 10
9
+ export let strokeWidth = 5
10
+ export let startX = 0
11
+ export let startY = 0
12
+ export let color = "var(--accent-b)"
13
+
14
+ $: data = generatePathWithRoundedCorners(steps, radius, strokeWidth, startX, startY)
15
+ </script>
16
+
17
+ <svg
18
+ width={data.width}
19
+ height={data.height}
20
+ viewBox="0 0 {data.width} {data.height}"
21
+ style="transform:translate({data.startX}px, {data.startY}px);"
22
+ >
23
+ <path
24
+ d={data.d}
25
+ stroke="{color}"
26
+ fill="transparent"
27
+ stroke-width={data.strokeWidth}
28
+ stroke-linecap="butt"
29
+ stroke-linejoin="round"
30
+ />
31
+ </svg>
@@ -221,6 +221,10 @@ export const data = {
221
221
  label:"liste de données",
222
222
  href:"/data-list",
223
223
  },
224
+ {
225
+ label:"objet",
226
+ href:"/object",
227
+ },
224
228
  {
225
229
  label:"tableau responsive",
226
230
  href:"/responsive-table",
@@ -0,0 +1,105 @@
1
+
2
+
3
+
4
+ export function generatePathWithRoundedCorners(
5
+ steps = {
6
+ dir: "up" | "down" | "left" | "right",
7
+ distance: 0
8
+ },
9
+ radius = 10,
10
+ strokeWidth = 5,
11
+ startX = 0,
12
+ startY = 0
13
+ ) {
14
+ if (!steps || steps.length === 0) return "";
15
+
16
+ const halfStroke = strokeWidth / 2;
17
+
18
+ // --- Génération des points ---
19
+ let x = startX;
20
+ let y = startY;
21
+ const points = [{ x, y }];
22
+
23
+ for (const step of steps) {
24
+ switch (step.dir.toLowerCase()) {
25
+ case "right": x += step.distance; break;
26
+ case "left": x -= step.distance; break;
27
+ case "down": y += step.distance; break;
28
+ case "up": y -= step.distance; break;
29
+ }
30
+ points.push({ x, y });
31
+ }
32
+
33
+ // --- Bounding box ---
34
+ const xs = points.map(p => p.x);
35
+ const ys = points.map(p => p.y);
36
+ const minX = Math.min(...xs) - halfStroke;
37
+ const minY = Math.min(...ys) - halfStroke;
38
+ const maxX = Math.max(...xs) + halfStroke;
39
+ const maxY = Math.max(...ys) + halfStroke;
40
+ const width = maxX - minX;
41
+ const height = maxY - minY;
42
+
43
+ // --- Transformation SVG ---
44
+ const transformed = points.map(p => ({ x: p.x - minX, y: p.y - minY }));
45
+
46
+ // --- Path avec arrondis ---
47
+ let d = `M ${transformed[0].x} ${transformed[0].y} `;
48
+
49
+ for (let i = 1; i < transformed.length - 1; i++) {
50
+ const p0 = transformed[i - 1];
51
+ const p1 = transformed[i];
52
+ const p2 = transformed[i + 1];
53
+
54
+ // Si coin
55
+ const isCorner =
56
+ (p0.x !== p1.x || p0.y !== p1.y) &&
57
+ (p1.x !== p2.x || p1.y !== p2.y) &&
58
+ !(p0.x === p2.x && p0.y === p2.y);
59
+
60
+ if (isCorner) {
61
+ // Vecteur p0->p1
62
+ let dx1 = p1.x - p0.x;
63
+ let dy1 = p1.y - p0.y;
64
+ const len1 = Math.hypot(dx1, dy1);
65
+ dx1 /= len1;
66
+ dy1 /= len1;
67
+
68
+ // Vecteur p1->p2
69
+ let dx2 = p2.x - p1.x;
70
+ let dy2 = p2.y - p1.y;
71
+ const len2 = Math.hypot(dx2, dy2);
72
+ dx2 /= len2;
73
+ dy2 /= len2;
74
+
75
+ const r = Math.min(radius, len1 / 2, len2 / 2);
76
+
77
+ const startX = p1.x - dx1 * r;
78
+ const startY = p1.y - dy1 * r;
79
+ const endX = p1.x + dx2 * r;
80
+ const endY = p1.y + dy2 * r;
81
+
82
+ d += `L ${startX} ${startY} `;
83
+ d += `Q ${p1.x} ${p1.y} ${endX} ${endY} `;
84
+ } else {
85
+ d += `L ${p1.x} ${p1.y} `;
86
+ }
87
+ }
88
+
89
+ // Dernier point
90
+ const last = transformed[transformed.length - 1];
91
+ d += `L ${last.x} ${last.y}`;
92
+
93
+ // calculer la position du svg en fonction du point de depart
94
+ let posX = transformed[0].x
95
+ let posY = transformed[0].y
96
+
97
+ return {
98
+ width,
99
+ height,
100
+ d,
101
+ strokeWidth,
102
+ startX: -posX,
103
+ startY: -posY
104
+ };
105
+ }