@erplora/outfitkit 0.1.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/LICENSE +21 -0
- package/README.md +457 -0
- package/dist/base/anchor.d.ts +13 -0
- package/dist/base/define.d.ts +1 -0
- package/dist/base/relay.d.ts +1 -0
- package/dist/cdn.d.ts +96 -0
- package/dist/components/ok-app-launcher/ok-app-launcher.d.ts +57 -0
- package/dist/components/ok-audio/ok-audio.d.ts +45 -0
- package/dist/components/ok-avatar/ok-avatar.d.ts +36 -0
- package/dist/components/ok-avatar-group/ok-avatar-group.d.ts +38 -0
- package/dist/components/ok-bar-list/ok-bar-list.d.ts +36 -0
- package/dist/components/ok-bento/ok-bento.d.ts +17 -0
- package/dist/components/ok-bento-item/ok-bento-item.d.ts +34 -0
- package/dist/components/ok-calculator/ok-calculator.d.ts +46 -0
- package/dist/components/ok-calendar/ok-calendar.d.ts +63 -0
- package/dist/components/ok-carousel/ok-carousel.d.ts +48 -0
- package/dist/components/ok-chart/ok-chart.d.ts +55 -0
- package/dist/components/ok-chat/ok-chat.d.ts +54 -0
- package/dist/components/ok-coachmark/ok-coachmark.d.ts +69 -0
- package/dist/components/ok-code/ok-code.d.ts +28 -0
- package/dist/components/ok-color-picker/ok-color-picker.d.ts +63 -0
- package/dist/components/ok-combo/ok-combo.d.ts +46 -0
- package/dist/components/ok-command-palette/ok-command-palette.d.ts +72 -0
- package/dist/components/ok-contact-form/ok-contact-form.d.ts +54 -0
- package/dist/components/ok-cropper/ok-cropper.d.ts +60 -0
- package/dist/components/ok-cta-band/ok-cta-band.d.ts +18 -0
- package/dist/components/ok-currency/ok-currency.d.ts +31 -0
- package/dist/components/ok-data-table/ok-data-table.d.ts +312 -0
- package/dist/components/ok-date-picker/ok-date-picker.d.ts +81 -0
- package/dist/components/ok-detail-list/ok-detail-list.d.ts +30 -0
- package/dist/components/ok-diff/ok-diff.d.ts +38 -0
- package/dist/components/ok-donut/ok-donut.d.ts +38 -0
- package/dist/components/ok-drawer/ok-drawer.d.ts +56 -0
- package/dist/components/ok-dropzone/ok-dropzone.d.ts +48 -0
- package/dist/components/ok-empty-state/ok-empty-state.d.ts +16 -0
- package/dist/components/ok-error-page/ok-error-page.d.ts +77 -0
- package/dist/components/ok-event-card/ok-event-card.d.ts +56 -0
- package/dist/components/ok-feature-card/ok-feature-card.d.ts +23 -0
- package/dist/components/ok-file-item/ok-file-item.d.ts +31 -0
- package/dist/components/ok-file-manager/ok-file-manager.d.ts +145 -0
- package/dist/components/ok-footer/ok-footer.d.ts +10 -0
- package/dist/components/ok-funnel/ok-funnel.d.ts +31 -0
- package/dist/components/ok-gallery/ok-gallery.d.ts +34 -0
- package/dist/components/ok-gauge/ok-gauge.d.ts +49 -0
- package/dist/components/ok-heatmap/ok-heatmap.d.ts +45 -0
- package/dist/components/ok-hero/ok-hero.d.ts +10 -0
- package/dist/components/ok-hover-card/ok-hover-card.d.ts +76 -0
- package/dist/components/ok-icon-tile/ok-icon-tile.d.ts +24 -0
- package/dist/components/ok-image/ok-image.d.ts +56 -0
- package/dist/components/ok-inline-feedback/ok-inline-feedback.d.ts +33 -0
- package/dist/components/ok-invoice/ok-invoice.d.ts +137 -0
- package/dist/components/ok-json-viewer/ok-json-viewer.d.ts +31 -0
- package/dist/components/ok-kanban/ok-kanban.d.ts +56 -0
- package/dist/components/ok-kbd/ok-kbd.d.ts +21 -0
- package/dist/components/ok-keyboard/ok-keyboard.d.ts +35 -0
- package/dist/components/ok-kpi/ok-kpi.d.ts +24 -0
- package/dist/components/ok-language-select/ok-language-select.d.ts +31 -0
- package/dist/components/ok-lightbox/ok-lightbox.d.ts +59 -0
- package/dist/components/ok-logo-cloud/ok-logo-cloud.d.ts +14 -0
- package/dist/components/ok-loyalty-card/ok-loyalty-card.d.ts +35 -0
- package/dist/components/ok-mail/ok-mail.d.ts +117 -0
- package/dist/components/ok-menu/ok-menu.d.ts +75 -0
- package/dist/components/ok-menubar/ok-menubar.d.ts +75 -0
- package/dist/components/ok-navbar/ok-navbar.d.ts +42 -0
- package/dist/components/ok-notification-center/ok-notification-center.d.ts +79 -0
- package/dist/components/ok-org-chart/ok-org-chart.d.ts +67 -0
- package/dist/components/ok-otp/ok-otp.d.ts +31 -0
- package/dist/components/ok-page-header/ok-page-header.d.ts +23 -0
- package/dist/components/ok-pagination/ok-pagination.d.ts +44 -0
- package/dist/components/ok-pdf/ok-pdf.d.ts +32 -0
- package/dist/components/ok-phone/ok-phone.d.ts +48 -0
- package/dist/components/ok-pinpad/ok-pinpad.d.ts +29 -0
- package/dist/components/ok-pricing-card/ok-pricing-card.d.ts +31 -0
- package/dist/components/ok-product-card/ok-product-card.d.ts +25 -0
- package/dist/components/ok-qr/ok-qr.d.ts +24 -0
- package/dist/components/ok-qty-stepper/ok-qty-stepper.d.ts +35 -0
- package/dist/components/ok-range-dual/ok-range-dual.d.ts +38 -0
- package/dist/components/ok-rating/ok-rating.d.ts +33 -0
- package/dist/components/ok-receipt/ok-receipt.d.ts +103 -0
- package/dist/components/ok-reveal/ok-reveal.d.ts +21 -0
- package/dist/components/ok-rich-text/ok-rich-text.d.ts +46 -0
- package/dist/components/ok-scheduler/ok-scheduler.d.ts +74 -0
- package/dist/components/ok-select-card/ok-select-card.d.ts +37 -0
- package/dist/components/ok-signature/ok-signature.d.ts +55 -0
- package/dist/components/ok-skeleton/ok-skeleton.d.ts +40 -0
- package/dist/components/ok-sparkline/ok-sparkline.d.ts +27 -0
- package/dist/components/ok-split-button/ok-split-button.d.ts +49 -0
- package/dist/components/ok-splitter/ok-splitter.d.ts +36 -0
- package/dist/components/ok-stat/ok-stat.d.ts +16 -0
- package/dist/components/ok-status-dot/ok-status-dot.d.ts +24 -0
- package/dist/components/ok-status-pill/ok-status-pill.d.ts +22 -0
- package/dist/components/ok-stepper/ok-stepper.d.ts +33 -0
- package/dist/components/ok-store/ok-store.d.ts +33 -0
- package/dist/components/ok-tag-input/ok-tag-input.d.ts +39 -0
- package/dist/components/ok-testimonial/ok-testimonial.d.ts +21 -0
- package/dist/components/ok-time-picker/ok-time-picker.d.ts +50 -0
- package/dist/components/ok-timeline/ok-timeline.d.ts +33 -0
- package/dist/components/ok-tree/ok-tree.d.ts +46 -0
- package/dist/components/ok-video/ok-video.d.ts +49 -0
- package/dist/components/ok-widget-board/ok-widget-board.d.ts +71 -0
- package/dist/components/ok-wizard/ok-wizard.d.ts +30 -0
- package/dist/define.js +8 -0
- package/dist/erplora.css +112 -0
- package/dist/index.d.ts +158 -0
- package/dist/index.js +197 -0
- package/dist/layout.css +338 -0
- package/dist/ok-app-launcher.js +396 -0
- package/dist/ok-audio.js +308 -0
- package/dist/ok-avatar-group.js +158 -0
- package/dist/ok-avatar.js +179 -0
- package/dist/ok-bar-list.js +189 -0
- package/dist/ok-bento-item.js +168 -0
- package/dist/ok-bento.js +63 -0
- package/dist/ok-calculator.js +406 -0
- package/dist/ok-calendar.js +541 -0
- package/dist/ok-carousel.js +352 -0
- package/dist/ok-chart.js +325 -0
- package/dist/ok-chat.js +320 -0
- package/dist/ok-coachmark.js +500 -0
- package/dist/ok-code.js +190 -0
- package/dist/ok-color-picker.js +569 -0
- package/dist/ok-combo.js +294 -0
- package/dist/ok-command-palette.js +448 -0
- package/dist/ok-contact-form.js +288 -0
- package/dist/ok-cropper.js +404 -0
- package/dist/ok-cta-band.js +134 -0
- package/dist/ok-currency.js +172 -0
- package/dist/ok-data-table.js +1281 -0
- package/dist/ok-date-picker.js +736 -0
- package/dist/ok-detail-list.js +156 -0
- package/dist/ok-diff.js +200 -0
- package/dist/ok-donut.js +280 -0
- package/dist/ok-drawer.js +357 -0
- package/dist/ok-dropzone.js +376 -0
- package/dist/ok-empty-state.js +104 -0
- package/dist/ok-error-page.js +547 -0
- package/dist/ok-event-card.js +384 -0
- package/dist/ok-feature-card.js +152 -0
- package/dist/ok-file-item.js +259 -0
- package/dist/ok-file-manager.js +1116 -0
- package/dist/ok-footer.js +67 -0
- package/dist/ok-funnel.js +181 -0
- package/dist/ok-gallery.js +293 -0
- package/dist/ok-gauge.js +385 -0
- package/dist/ok-heatmap.js +268 -0
- package/dist/ok-hero.js +43 -0
- package/dist/ok-hover-card.js +480 -0
- package/dist/ok-icon-tile.js +123 -0
- package/dist/ok-image.js +471 -0
- package/dist/ok-inline-feedback.js +221 -0
- package/dist/ok-invoice.js +229 -0
- package/dist/ok-json-viewer.js +330 -0
- package/dist/ok-kanban.js +427 -0
- package/dist/ok-kbd.js +159 -0
- package/dist/ok-keyboard.js +402 -0
- package/dist/ok-kpi.js +147 -0
- package/dist/ok-language-select.js +188 -0
- package/dist/ok-lightbox.js +490 -0
- package/dist/ok-logo-cloud.js +92 -0
- package/dist/ok-loyalty-card.js +353 -0
- package/dist/ok-mail.js +562 -0
- package/dist/ok-menu.js +529 -0
- package/dist/ok-menubar.js +628 -0
- package/dist/ok-navbar.js +306 -0
- package/dist/ok-notification-center.js +545 -0
- package/dist/ok-org-chart.js +619 -0
- package/dist/ok-otp.js +199 -0
- package/dist/ok-page-header.js +202 -0
- package/dist/ok-pagination.js +366 -0
- package/dist/ok-pdf.js +160 -0
- package/dist/ok-phone.js +225 -0
- package/dist/ok-pinpad.js +171 -0
- package/dist/ok-pricing-card.js +184 -0
- package/dist/ok-product-card.js +178 -0
- package/dist/ok-qr.js +652 -0
- package/dist/ok-qty-stepper.js +212 -0
- package/dist/ok-range-dual.js +280 -0
- package/dist/ok-rating.js +199 -0
- package/dist/ok-receipt.js +183 -0
- package/dist/ok-reveal.js +94 -0
- package/dist/ok-rich-text.js +538 -0
- package/dist/ok-scheduler.js +518 -0
- package/dist/ok-select-card.js +231 -0
- package/dist/ok-signature.js +267 -0
- package/dist/ok-skeleton.js +345 -0
- package/dist/ok-sparkline.js +150 -0
- package/dist/ok-split-button.js +251 -0
- package/dist/ok-splitter.js +289 -0
- package/dist/ok-stat.js +77 -0
- package/dist/ok-status-dot.js +163 -0
- package/dist/ok-status-pill.js +123 -0
- package/dist/ok-stepper.js +299 -0
- package/dist/ok-store.js +83 -0
- package/dist/ok-tag-input.js +358 -0
- package/dist/ok-testimonial.js +136 -0
- package/dist/ok-time-picker.js +472 -0
- package/dist/ok-timeline.js +251 -0
- package/dist/ok-tree.js +266 -0
- package/dist/ok-video.js +362 -0
- package/dist/ok-widget-board.js +265 -0
- package/dist/ok-wizard.js +153 -0
- package/dist/outfitkit.js +96 -0
- package/dist/shared/anchor.js +14 -0
- package/dist/store/controller.d.ts +17 -0
- package/dist/store/idb.d.ts +16 -0
- package/dist/store/store.d.ts +39 -0
- package/dist/store-controller.js +31 -0
- package/dist/store.js +182 -0
- package/dist/theme.example.css +70 -0
- package/package.json +147 -0
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
import { LitElement, css, html, nothing, svg } from "lit";
|
|
2
|
+
import { property, state } from "lit/decorators.js";
|
|
3
|
+
import { define } from "./define.js";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
6
|
+
var result = void 0;
|
|
7
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8
|
+
if (decorator = decorators[i])
|
|
9
|
+
result = decorator(target, key, result) || result;
|
|
10
|
+
if (result) __defProp(target, key, result);
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
const NODE_W = 184;
|
|
14
|
+
const NODE_H = 120;
|
|
15
|
+
const H_GAP = 28;
|
|
16
|
+
const V_GAP = 56;
|
|
17
|
+
const LEAF_STEP = NODE_W + H_GAP;
|
|
18
|
+
const LEVEL_H = NODE_H + V_GAP;
|
|
19
|
+
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
20
|
+
const MIN_K = 0.2;
|
|
21
|
+
const MAX_K = 2.5;
|
|
22
|
+
class OkOrgChart extends LitElement {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.root = null;
|
|
26
|
+
this.maxAvatars = 3;
|
|
27
|
+
this.height = 460;
|
|
28
|
+
this.tx = 0;
|
|
29
|
+
this.ty = 0;
|
|
30
|
+
this.k = 1;
|
|
31
|
+
this.grabbing = false;
|
|
32
|
+
this.collapsed = /* @__PURE__ */ new Set();
|
|
33
|
+
this.contentW = 0;
|
|
34
|
+
this.contentH = 0;
|
|
35
|
+
this.fitted = false;
|
|
36
|
+
this.pointers = /* @__PURE__ */ new Map();
|
|
37
|
+
this.panStart = null;
|
|
38
|
+
this.pinchStart = null;
|
|
39
|
+
this.wrapEl = null;
|
|
40
|
+
this.ro = null;
|
|
41
|
+
this.userMoved = false;
|
|
42
|
+
this.onWheel = (e) => {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
this.userMoved = true;
|
|
45
|
+
const rect = this.wrapEl.getBoundingClientRect();
|
|
46
|
+
const factor = e.deltaY < 0 ? 1.12 : 1 / 1.12;
|
|
47
|
+
this.zoomAround(e.clientX - rect.left, e.clientY - rect.top, factor);
|
|
48
|
+
};
|
|
49
|
+
this.onPointerDown = (e) => {
|
|
50
|
+
this.userMoved = true;
|
|
51
|
+
this.wrapEl.setPointerCapture(e.pointerId);
|
|
52
|
+
this.pointers.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
53
|
+
if (this.pointers.size === 1) {
|
|
54
|
+
this.panStart = { x: e.clientX, y: e.clientY, tx: this.tx, ty: this.ty };
|
|
55
|
+
this.grabbing = true;
|
|
56
|
+
} else if (this.pointers.size === 2) {
|
|
57
|
+
this.panStart = null;
|
|
58
|
+
const pts = [...this.pointers.values()];
|
|
59
|
+
const rect = this.wrapEl.getBoundingClientRect();
|
|
60
|
+
this.pinchStart = {
|
|
61
|
+
dist: Math.hypot(pts[0].x - pts[1].x, pts[0].y - pts[1].y) || 1,
|
|
62
|
+
k: this.k,
|
|
63
|
+
cx: (pts[0].x + pts[1].x) / 2 - rect.left,
|
|
64
|
+
cy: (pts[0].y + pts[1].y) / 2 - rect.top,
|
|
65
|
+
tx: this.tx,
|
|
66
|
+
ty: this.ty
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
this.onPointerMove = (e) => {
|
|
71
|
+
if (!this.pointers.has(e.pointerId)) return;
|
|
72
|
+
this.pointers.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
73
|
+
if (this.pinchStart && this.pointers.size >= 2) {
|
|
74
|
+
const pts = [...this.pointers.values()];
|
|
75
|
+
const dist = Math.hypot(pts[0].x - pts[1].x, pts[0].y - pts[1].y) || 1;
|
|
76
|
+
const newK = clamp(this.pinchStart.k * (dist / this.pinchStart.dist), MIN_K, MAX_K);
|
|
77
|
+
const wx = (this.pinchStart.cx - this.pinchStart.tx) / this.pinchStart.k;
|
|
78
|
+
const wy = (this.pinchStart.cy - this.pinchStart.ty) / this.pinchStart.k;
|
|
79
|
+
this.k = newK;
|
|
80
|
+
this.tx = this.pinchStart.cx - wx * newK;
|
|
81
|
+
this.ty = this.pinchStart.cy - wy * newK;
|
|
82
|
+
} else if (this.panStart) {
|
|
83
|
+
this.tx = this.panStart.tx + (e.clientX - this.panStart.x);
|
|
84
|
+
this.ty = this.panStart.ty + (e.clientY - this.panStart.y);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
this.onPointerUp = (e) => {
|
|
88
|
+
this.pointers.delete(e.pointerId);
|
|
89
|
+
if (this.pointers.size < 2) this.pinchStart = null;
|
|
90
|
+
if (this.pointers.size === 0) {
|
|
91
|
+
this.panStart = null;
|
|
92
|
+
this.grabbing = false;
|
|
93
|
+
} else {
|
|
94
|
+
const [, pos] = [...this.pointers.entries()][0];
|
|
95
|
+
this.panStart = { x: pos.x, y: pos.y, tx: this.tx, ty: this.ty };
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
static {
|
|
100
|
+
this.styles = css`
|
|
101
|
+
:host {
|
|
102
|
+
display: block;
|
|
103
|
+
width: 100%;
|
|
104
|
+
/* Tokens propios estilo Ionic (overridables): --ok-* → --ion-* → hex. */
|
|
105
|
+
--bg: var(--ok-surface, var(--ion-background-color, #fff));
|
|
106
|
+
--node-bg: var(--ok-card-background, var(--ion-card-background, #f7f8fa));
|
|
107
|
+
--root-bg-top: var(--ok-surface-2, var(--ion-color-light, #eef0f4));
|
|
108
|
+
--line: var(--ok-border-color, var(--ion-border-color, #d7dade));
|
|
109
|
+
--line-2: var(--ok-border-color, var(--ion-border-color, #c9ccd2));
|
|
110
|
+
--brand: var(--ok-color-primary, var(--ion-color-primary, #3880ff));
|
|
111
|
+
--brand-soft-line: var(--ok-color-primary-tint, var(--ion-color-primary-tint, #5a98ff));
|
|
112
|
+
--name-color: var(--ok-text-color, var(--ion-text-color, #1f2933));
|
|
113
|
+
--role-color: var(--ok-color-medium, var(--ion-color-medium, #92949c));
|
|
114
|
+
--avatar-bg: var(--ok-surface-3, var(--ion-color-light-shade, #d7dade));
|
|
115
|
+
--avatar-fg: var(--ok-text-color, var(--ion-text-color, #1f2933));
|
|
116
|
+
--radius: var(--ok-radius-md, 10px);
|
|
117
|
+
--dur: 160ms;
|
|
118
|
+
--ease: cubic-bezier(0.4, 0, 0.2, 1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* Viewport: recorta el lienzo y captura los gestos de pan/zoom. */
|
|
122
|
+
.wrap {
|
|
123
|
+
position: relative;
|
|
124
|
+
width: 100%;
|
|
125
|
+
overflow: hidden;
|
|
126
|
+
background: var(--bg);
|
|
127
|
+
border-radius: var(--radius);
|
|
128
|
+
touch-action: none; /* gestionamos pan/zoom nosotros */
|
|
129
|
+
cursor: grab;
|
|
130
|
+
box-sizing: border-box;
|
|
131
|
+
}
|
|
132
|
+
.wrap.grabbing {
|
|
133
|
+
cursor: grabbing;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Lienzo del "mundo": se mueve/escala con transform (origen 0,0). */
|
|
137
|
+
.canvas {
|
|
138
|
+
position: absolute;
|
|
139
|
+
top: 0;
|
|
140
|
+
left: 0;
|
|
141
|
+
transform-origin: 0 0;
|
|
142
|
+
will-change: transform;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* Capa de conectores (SVG vectorial), bajo los nodos. */
|
|
146
|
+
.links {
|
|
147
|
+
position: absolute;
|
|
148
|
+
top: 0;
|
|
149
|
+
left: 0;
|
|
150
|
+
overflow: visible;
|
|
151
|
+
pointer-events: none;
|
|
152
|
+
}
|
|
153
|
+
.link {
|
|
154
|
+
fill: none;
|
|
155
|
+
stroke: var(--line-2);
|
|
156
|
+
stroke-width: 1.25;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.node {
|
|
160
|
+
position: absolute;
|
|
161
|
+
display: flex;
|
|
162
|
+
flex-direction: column;
|
|
163
|
+
align-items: center;
|
|
164
|
+
justify-content: center;
|
|
165
|
+
gap: 4px;
|
|
166
|
+
background: var(--node-bg);
|
|
167
|
+
border: 1px solid var(--line);
|
|
168
|
+
border-radius: var(--radius);
|
|
169
|
+
padding: 10px 14px;
|
|
170
|
+
box-sizing: border-box;
|
|
171
|
+
text-align: center;
|
|
172
|
+
transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease),
|
|
173
|
+
box-shadow var(--dur) var(--ease);
|
|
174
|
+
}
|
|
175
|
+
.node:hover {
|
|
176
|
+
border-color: var(--brand);
|
|
177
|
+
transform: translateY(-2px);
|
|
178
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
179
|
+
z-index: 1;
|
|
180
|
+
}
|
|
181
|
+
.node.root {
|
|
182
|
+
background: linear-gradient(180deg, var(--root-bg-top), var(--node-bg));
|
|
183
|
+
border-color: var(--brand-soft-line);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* Avatar del propio nodo: imagen si la hay, si no las iniciales del nombre. */
|
|
187
|
+
.node-avatar {
|
|
188
|
+
width: 40px;
|
|
189
|
+
height: 40px;
|
|
190
|
+
border-radius: 50%;
|
|
191
|
+
display: grid;
|
|
192
|
+
place-items: center;
|
|
193
|
+
background: var(--avatar-bg);
|
|
194
|
+
color: var(--avatar-fg);
|
|
195
|
+
font-size: 14px;
|
|
196
|
+
font-weight: 700;
|
|
197
|
+
letter-spacing: -0.02em;
|
|
198
|
+
overflow: hidden;
|
|
199
|
+
flex-shrink: 0;
|
|
200
|
+
border: 1px solid var(--line);
|
|
201
|
+
box-sizing: border-box;
|
|
202
|
+
}
|
|
203
|
+
.node.root .node-avatar {
|
|
204
|
+
border-color: var(--brand-soft-line);
|
|
205
|
+
}
|
|
206
|
+
.node-avatar img {
|
|
207
|
+
width: 100%;
|
|
208
|
+
height: 100%;
|
|
209
|
+
object-fit: cover;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* Botón recoger/expandir, anclado al borde inferior del nodo con hijos. */
|
|
213
|
+
.toggle {
|
|
214
|
+
position: absolute;
|
|
215
|
+
bottom: -11px;
|
|
216
|
+
left: 50%;
|
|
217
|
+
transform: translateX(-50%);
|
|
218
|
+
width: 22px;
|
|
219
|
+
height: 22px;
|
|
220
|
+
border-radius: 50%;
|
|
221
|
+
border: 1px solid var(--line);
|
|
222
|
+
background: var(--node-bg);
|
|
223
|
+
color: var(--name-color);
|
|
224
|
+
font-size: 11px;
|
|
225
|
+
font-weight: 700;
|
|
226
|
+
line-height: 1;
|
|
227
|
+
display: grid;
|
|
228
|
+
place-items: center;
|
|
229
|
+
cursor: pointer;
|
|
230
|
+
padding: 0;
|
|
231
|
+
z-index: 2;
|
|
232
|
+
transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease),
|
|
233
|
+
color var(--dur) var(--ease);
|
|
234
|
+
}
|
|
235
|
+
.toggle:hover {
|
|
236
|
+
border-color: var(--brand);
|
|
237
|
+
}
|
|
238
|
+
/* Colapsado: resaltado en color de marca y mostrando cuántos oculta. */
|
|
239
|
+
.toggle.is-collapsed {
|
|
240
|
+
background: var(--brand);
|
|
241
|
+
color: #fff;
|
|
242
|
+
border-color: var(--brand);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.name {
|
|
246
|
+
font-size: 13px;
|
|
247
|
+
font-weight: 600;
|
|
248
|
+
color: var(--name-color);
|
|
249
|
+
line-height: 1.2;
|
|
250
|
+
}
|
|
251
|
+
.role {
|
|
252
|
+
font-size: 11px;
|
|
253
|
+
color: var(--role-color);
|
|
254
|
+
line-height: 1.2;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* Stack de avatares solapados para el tamaño de equipo. */
|
|
258
|
+
.team {
|
|
259
|
+
display: inline-flex;
|
|
260
|
+
align-items: center;
|
|
261
|
+
margin-top: 4px;
|
|
262
|
+
}
|
|
263
|
+
.avatar {
|
|
264
|
+
display: inline-grid;
|
|
265
|
+
place-items: center;
|
|
266
|
+
width: 20px;
|
|
267
|
+
height: 20px;
|
|
268
|
+
border-radius: 50%;
|
|
269
|
+
background: var(--avatar-bg);
|
|
270
|
+
color: var(--avatar-fg);
|
|
271
|
+
font-size: 9px;
|
|
272
|
+
font-weight: 600;
|
|
273
|
+
letter-spacing: -0.02em;
|
|
274
|
+
overflow: hidden;
|
|
275
|
+
flex-shrink: 0;
|
|
276
|
+
border: 1px solid var(--bg);
|
|
277
|
+
box-sizing: border-box;
|
|
278
|
+
}
|
|
279
|
+
.avatar + .avatar {
|
|
280
|
+
margin-left: -4px;
|
|
281
|
+
}
|
|
282
|
+
.avatar.more {
|
|
283
|
+
background: var(--avatar-bg);
|
|
284
|
+
color: var(--role-color);
|
|
285
|
+
}
|
|
286
|
+
.avatar img {
|
|
287
|
+
width: 100%;
|
|
288
|
+
height: 100%;
|
|
289
|
+
object-fit: cover;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/* Controles flotantes (zoom / ajustar). */
|
|
293
|
+
.ctrls {
|
|
294
|
+
position: absolute;
|
|
295
|
+
top: 10px;
|
|
296
|
+
right: 10px;
|
|
297
|
+
display: flex;
|
|
298
|
+
flex-direction: column;
|
|
299
|
+
gap: 6px;
|
|
300
|
+
z-index: 2;
|
|
301
|
+
}
|
|
302
|
+
.ctrls button {
|
|
303
|
+
width: 32px;
|
|
304
|
+
height: 32px;
|
|
305
|
+
display: grid;
|
|
306
|
+
place-items: center;
|
|
307
|
+
border: 1px solid var(--line);
|
|
308
|
+
border-radius: 8px;
|
|
309
|
+
background: var(--node-bg);
|
|
310
|
+
color: var(--name-color);
|
|
311
|
+
font-size: 16px;
|
|
312
|
+
line-height: 1;
|
|
313
|
+
cursor: pointer;
|
|
314
|
+
padding: 0;
|
|
315
|
+
transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
|
|
316
|
+
}
|
|
317
|
+
.ctrls button:hover {
|
|
318
|
+
border-color: var(--brand);
|
|
319
|
+
}
|
|
320
|
+
.empty {
|
|
321
|
+
display: grid;
|
|
322
|
+
place-items: center;
|
|
323
|
+
width: 100%;
|
|
324
|
+
height: 100%;
|
|
325
|
+
color: var(--role-color);
|
|
326
|
+
font-size: 13px;
|
|
327
|
+
}
|
|
328
|
+
`;
|
|
329
|
+
}
|
|
330
|
+
// ---- Layout tidy-tree: x/y por nodo + rutas de conectores ----
|
|
331
|
+
layout(root) {
|
|
332
|
+
const nodes = [];
|
|
333
|
+
const placed = /* @__PURE__ */ new Map();
|
|
334
|
+
let cursor = 0;
|
|
335
|
+
let maxDepth = 0;
|
|
336
|
+
const place = (n, depth) => {
|
|
337
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
338
|
+
const kids = this.collapsed.has(n) ? [] : n.children ?? [];
|
|
339
|
+
let x;
|
|
340
|
+
if (!kids.length) {
|
|
341
|
+
x = cursor * LEAF_STEP;
|
|
342
|
+
cursor += 1;
|
|
343
|
+
} else {
|
|
344
|
+
const kp = kids.map((c) => place(c, depth + 1));
|
|
345
|
+
x = (kp[0].x + kp[kp.length - 1].x) / 2;
|
|
346
|
+
}
|
|
347
|
+
const p = { node: n, x, y: depth * LEVEL_H, depth };
|
|
348
|
+
nodes.push(p);
|
|
349
|
+
placed.set(n, p);
|
|
350
|
+
return p;
|
|
351
|
+
};
|
|
352
|
+
place(root, 0);
|
|
353
|
+
const links = [];
|
|
354
|
+
for (const p of nodes) {
|
|
355
|
+
const kids = this.collapsed.has(p.node) ? [] : p.node.children ?? [];
|
|
356
|
+
if (!kids.length) continue;
|
|
357
|
+
const kp = kids.map((c) => placed.get(c));
|
|
358
|
+
const parentCx = p.x + NODE_W / 2;
|
|
359
|
+
const parentBottom = p.y + NODE_H;
|
|
360
|
+
const busY = parentBottom + V_GAP / 2;
|
|
361
|
+
links.push(`M${parentCx},${parentBottom}L${parentCx},${busY}`);
|
|
362
|
+
const firstCx = kp[0].x + NODE_W / 2;
|
|
363
|
+
const lastCx = kp[kp.length - 1].x + NODE_W / 2;
|
|
364
|
+
if (kp.length > 1) links.push(`M${firstCx},${busY}L${lastCx},${busY}`);
|
|
365
|
+
for (const c of kp) {
|
|
366
|
+
const cx = c.x + NODE_W / 2;
|
|
367
|
+
links.push(`M${cx},${busY}L${cx},${c.y}`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const maxX = nodes.reduce((m, p) => Math.max(m, p.x), 0);
|
|
371
|
+
return { nodes, links, width: maxX + NODE_W, height: maxDepth * LEVEL_H + NODE_H };
|
|
372
|
+
}
|
|
373
|
+
/** Renderiza el stack de avatares (+N) para el tamaño de equipo de un nodo. */
|
|
374
|
+
renderTeam(node) {
|
|
375
|
+
const total = node.team ?? 0;
|
|
376
|
+
if (total <= 0) return null;
|
|
377
|
+
const shown = Math.min(this.maxAvatars, total);
|
|
378
|
+
const rest = total - shown;
|
|
379
|
+
const initials = (node.role ?? node.name).replace(/[^A-Za-zÀ-ÿ ]/g, "").split(/\s+/).filter(Boolean);
|
|
380
|
+
return html`
|
|
381
|
+
<div class="team" aria-label="Equipo de ${total}">
|
|
382
|
+
${Array.from({ length: shown }, (_v, i) => {
|
|
383
|
+
const seed = initials[i % Math.max(initials.length, 1)] ?? "";
|
|
384
|
+
const label = seed ? seed.slice(0, 2).toUpperCase() : "·";
|
|
385
|
+
return html`<span class="avatar" aria-hidden="true">${label}</span>`;
|
|
386
|
+
})}
|
|
387
|
+
${rest > 0 ? html`<span class="avatar more" aria-hidden="true">+${rest}</span>` : null}
|
|
388
|
+
</div>
|
|
389
|
+
`;
|
|
390
|
+
}
|
|
391
|
+
/** Iniciales del nombre (1ª letra del primer y último término), para el avatar sin imagen. */
|
|
392
|
+
initialsOf(name) {
|
|
393
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
394
|
+
if (!parts.length) return "·";
|
|
395
|
+
const first = parts[0][0] ?? "";
|
|
396
|
+
const last = parts.length > 1 ? parts[parts.length - 1][0] ?? "" : "";
|
|
397
|
+
return (first + last).toUpperCase();
|
|
398
|
+
}
|
|
399
|
+
/** Recoge/expande la rama de un nodo y emite `ok-node-toggle`. */
|
|
400
|
+
toggle(n) {
|
|
401
|
+
const next = new Set(this.collapsed);
|
|
402
|
+
if (next.has(n)) next.delete(n);
|
|
403
|
+
else next.add(n);
|
|
404
|
+
this.collapsed = next;
|
|
405
|
+
this.userMoved = true;
|
|
406
|
+
this.dispatchEvent(
|
|
407
|
+
new CustomEvent("ok-node-toggle", {
|
|
408
|
+
detail: { node: n, collapsed: next.has(n) },
|
|
409
|
+
bubbles: true,
|
|
410
|
+
composed: true
|
|
411
|
+
})
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
/** Renderiza un nodo posicionado (HTML absoluto en coordenadas del mundo). */
|
|
415
|
+
renderNode(p) {
|
|
416
|
+
const n = p.node;
|
|
417
|
+
const childCount = n.children?.length ?? 0;
|
|
418
|
+
const isCollapsed = this.collapsed.has(n);
|
|
419
|
+
return html`
|
|
420
|
+
<div
|
|
421
|
+
class="node ${p.depth === 0 ? "root" : ""}"
|
|
422
|
+
role="treeitem"
|
|
423
|
+
aria-expanded=${childCount ? String(!isCollapsed) : nothing}
|
|
424
|
+
style=${`left:${p.x}px;top:${p.y}px;width:${NODE_W}px;height:${NODE_H}px;`}
|
|
425
|
+
>
|
|
426
|
+
<span class="node-avatar">
|
|
427
|
+
${n.avatar ? html`<img src=${n.avatar} alt="" />` : html`<span aria-hidden="true">${this.initialsOf(n.name)}</span>`}
|
|
428
|
+
</span>
|
|
429
|
+
<span class="name">${n.name}</span>
|
|
430
|
+
${n.role ? html`<span class="role">${n.role}</span>` : null}
|
|
431
|
+
${this.renderTeam(n)}
|
|
432
|
+
${childCount ? html`<button
|
|
433
|
+
type="button"
|
|
434
|
+
class="toggle ${isCollapsed ? "is-collapsed" : ""}"
|
|
435
|
+
title=${isCollapsed ? `Expandir (${childCount})` : "Recoger"}
|
|
436
|
+
aria-label=${isCollapsed ? `Expandir ${childCount} subordinados` : "Recoger rama"}
|
|
437
|
+
@pointerdown=${(e) => e.stopPropagation()}
|
|
438
|
+
@click=${(e) => {
|
|
439
|
+
e.stopPropagation();
|
|
440
|
+
this.toggle(n);
|
|
441
|
+
}}
|
|
442
|
+
>
|
|
443
|
+
${isCollapsed ? childCount : "−"}
|
|
444
|
+
</button>` : null}
|
|
445
|
+
</div>
|
|
446
|
+
`;
|
|
447
|
+
}
|
|
448
|
+
// ---- Cámara: ajustar a pantalla y zoom ----
|
|
449
|
+
/** Encuadra todo el organigrama en el viewport con un pequeño margen. */
|
|
450
|
+
fit() {
|
|
451
|
+
if (!this.wrapEl || !this.contentW || !this.contentH) return;
|
|
452
|
+
const vw = this.wrapEl.clientWidth;
|
|
453
|
+
const vh = this.wrapEl.clientHeight;
|
|
454
|
+
const pad = 24;
|
|
455
|
+
const k = clamp(
|
|
456
|
+
Math.min((vw - pad * 2) / this.contentW, (vh - pad * 2) / this.contentH),
|
|
457
|
+
MIN_K,
|
|
458
|
+
1.2
|
|
459
|
+
);
|
|
460
|
+
this.k = k;
|
|
461
|
+
this.tx = (vw - this.contentW * k) / 2;
|
|
462
|
+
this.ty = pad;
|
|
463
|
+
}
|
|
464
|
+
/** Recentra el organigrama en el viewport MANTENIENDO el zoom actual. */
|
|
465
|
+
center() {
|
|
466
|
+
if (!this.wrapEl || !this.contentW || !this.contentH) return;
|
|
467
|
+
this.userMoved = true;
|
|
468
|
+
const vw = this.wrapEl.clientWidth;
|
|
469
|
+
const vh = this.wrapEl.clientHeight;
|
|
470
|
+
this.tx = (vw - this.contentW * this.k) / 2;
|
|
471
|
+
this.ty = Math.max(24, (vh - this.contentH * this.k) / 2);
|
|
472
|
+
}
|
|
473
|
+
// Zoom alrededor de un punto del viewport (mantiene ese punto fijo).
|
|
474
|
+
zoomAround(vx, vy, factor) {
|
|
475
|
+
const newK = clamp(this.k * factor, MIN_K, MAX_K);
|
|
476
|
+
const wx = (vx - this.tx) / this.k;
|
|
477
|
+
const wy = (vy - this.ty) / this.k;
|
|
478
|
+
this.k = newK;
|
|
479
|
+
this.tx = vx - wx * newK;
|
|
480
|
+
this.ty = vy - wy * newK;
|
|
481
|
+
}
|
|
482
|
+
zoomBy(factor) {
|
|
483
|
+
if (!this.wrapEl) return;
|
|
484
|
+
this.userMoved = true;
|
|
485
|
+
this.zoomAround(this.wrapEl.clientWidth / 2, this.wrapEl.clientHeight / 2, factor);
|
|
486
|
+
}
|
|
487
|
+
firstUpdated() {
|
|
488
|
+
this.wrapEl = this.renderRoot.querySelector(".wrap");
|
|
489
|
+
this.fitted = true;
|
|
490
|
+
this.ro = new ResizeObserver(() => {
|
|
491
|
+
if (!this.userMoved) this.fit();
|
|
492
|
+
});
|
|
493
|
+
if (this.wrapEl) this.ro.observe(this.wrapEl);
|
|
494
|
+
this.fit();
|
|
495
|
+
}
|
|
496
|
+
updated(changed) {
|
|
497
|
+
if (changed.has("root")) {
|
|
498
|
+
if (this.collapsed.size) this.collapsed = /* @__PURE__ */ new Set();
|
|
499
|
+
this.userMoved = false;
|
|
500
|
+
}
|
|
501
|
+
if ((changed.has("root") || changed.has("height")) && this.fitted) {
|
|
502
|
+
this.fit();
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
disconnectedCallback() {
|
|
506
|
+
super.disconnectedCallback();
|
|
507
|
+
this.ro?.disconnect();
|
|
508
|
+
this.ro = null;
|
|
509
|
+
}
|
|
510
|
+
render() {
|
|
511
|
+
if (!this.root) {
|
|
512
|
+
return html`<div
|
|
513
|
+
class="wrap"
|
|
514
|
+
style=${`height:${this.height}px;`}
|
|
515
|
+
role="tree"
|
|
516
|
+
aria-label="Organigrama"
|
|
517
|
+
>
|
|
518
|
+
<div class="empty">Sin datos</div>
|
|
519
|
+
</div>`;
|
|
520
|
+
}
|
|
521
|
+
const lay = this.layout(this.root);
|
|
522
|
+
this.contentW = lay.width;
|
|
523
|
+
this.contentH = lay.height;
|
|
524
|
+
return html`
|
|
525
|
+
<div
|
|
526
|
+
class="wrap ${this.grabbing ? "grabbing" : ""}"
|
|
527
|
+
style=${`height:${this.height}px;`}
|
|
528
|
+
role="tree"
|
|
529
|
+
aria-label="Organigrama"
|
|
530
|
+
@wheel=${this.onWheel}
|
|
531
|
+
@pointerdown=${this.onPointerDown}
|
|
532
|
+
@pointermove=${this.onPointerMove}
|
|
533
|
+
@pointerup=${this.onPointerUp}
|
|
534
|
+
@pointercancel=${this.onPointerUp}
|
|
535
|
+
>
|
|
536
|
+
<div
|
|
537
|
+
class="canvas"
|
|
538
|
+
style=${`transform: translate(${this.tx}px, ${this.ty}px) scale(${this.k});`}
|
|
539
|
+
>
|
|
540
|
+
<svg
|
|
541
|
+
class="links"
|
|
542
|
+
width=${lay.width}
|
|
543
|
+
height=${lay.height}
|
|
544
|
+
viewBox=${`0 0 ${lay.width} ${lay.height}`}
|
|
545
|
+
>
|
|
546
|
+
${lay.links.map((d) => svg`<path class="link" d=${d}></path>`)}
|
|
547
|
+
</svg>
|
|
548
|
+
${lay.nodes.map((p) => this.renderNode(p))}
|
|
549
|
+
</div>
|
|
550
|
+
|
|
551
|
+
<div class="ctrls">
|
|
552
|
+
<button type="button" title="Acercar" aria-label="Acercar" @click=${() => this.zoomBy(1.2)}>
|
|
553
|
+
+
|
|
554
|
+
</button>
|
|
555
|
+
<button
|
|
556
|
+
type="button"
|
|
557
|
+
title="Alejar"
|
|
558
|
+
aria-label="Alejar"
|
|
559
|
+
@click=${() => this.zoomBy(1 / 1.2)}
|
|
560
|
+
>
|
|
561
|
+
−
|
|
562
|
+
</button>
|
|
563
|
+
<button
|
|
564
|
+
type="button"
|
|
565
|
+
title="Centrar"
|
|
566
|
+
aria-label="Centrar"
|
|
567
|
+
@click=${() => this.center()}
|
|
568
|
+
>
|
|
569
|
+
<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true">
|
|
570
|
+
<circle cx="12" cy="12" r="3.2" fill="currentColor" />
|
|
571
|
+
<g stroke="currentColor" stroke-width="1.6" stroke-linecap="round">
|
|
572
|
+
<line x1="12" y1="3" x2="12" y2="7" />
|
|
573
|
+
<line x1="12" y1="17" x2="12" y2="21" />
|
|
574
|
+
<line x1="3" y1="12" x2="7" y2="12" />
|
|
575
|
+
<line x1="17" y1="12" x2="21" y2="12" />
|
|
576
|
+
</g>
|
|
577
|
+
</svg>
|
|
578
|
+
</button>
|
|
579
|
+
<button
|
|
580
|
+
type="button"
|
|
581
|
+
title="Ajustar a pantalla"
|
|
582
|
+
aria-label="Ajustar a pantalla"
|
|
583
|
+
@click=${() => this.fit()}
|
|
584
|
+
>
|
|
585
|
+
⤢
|
|
586
|
+
</button>
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
`;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
__decorateClass([
|
|
593
|
+
property({ attribute: false })
|
|
594
|
+
], OkOrgChart.prototype, "root");
|
|
595
|
+
__decorateClass([
|
|
596
|
+
property({ type: Number })
|
|
597
|
+
], OkOrgChart.prototype, "maxAvatars");
|
|
598
|
+
__decorateClass([
|
|
599
|
+
property({ type: Number })
|
|
600
|
+
], OkOrgChart.prototype, "height");
|
|
601
|
+
__decorateClass([
|
|
602
|
+
state()
|
|
603
|
+
], OkOrgChart.prototype, "tx");
|
|
604
|
+
__decorateClass([
|
|
605
|
+
state()
|
|
606
|
+
], OkOrgChart.prototype, "ty");
|
|
607
|
+
__decorateClass([
|
|
608
|
+
state()
|
|
609
|
+
], OkOrgChart.prototype, "k");
|
|
610
|
+
__decorateClass([
|
|
611
|
+
state()
|
|
612
|
+
], OkOrgChart.prototype, "grabbing");
|
|
613
|
+
__decorateClass([
|
|
614
|
+
state()
|
|
615
|
+
], OkOrgChart.prototype, "collapsed");
|
|
616
|
+
define("ok-org-chart", OkOrgChart);
|
|
617
|
+
export {
|
|
618
|
+
OkOrgChart
|
|
619
|
+
};
|