@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,251 @@
|
|
|
1
|
+
import { LitElement, css, html } from "lit";
|
|
2
|
+
import { property } 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
|
+
class OkTimeline extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.items = [];
|
|
17
|
+
this.align = "left";
|
|
18
|
+
}
|
|
19
|
+
static {
|
|
20
|
+
this.styles = css`
|
|
21
|
+
:host {
|
|
22
|
+
/* Vars overridable (estilo Ionic), default = cadena --ok-* -> --ion-* -> hex */
|
|
23
|
+
--color: var(--ok-text, var(--ion-text-color, #1c1b17));
|
|
24
|
+
--color-muted: var(--ok-text-muted, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.55));
|
|
25
|
+
--primary-color: var(--ok-primary, var(--ion-color-primary, #3880ff));
|
|
26
|
+
--primary-contrast: var(--ok-primary-contrast, var(--ion-color-primary-contrast, #ffffff));
|
|
27
|
+
--done-color: var(--ok-success, var(--ion-color-success, #2dd36f));
|
|
28
|
+
--pending-color: var(--ok-medium, var(--ion-color-medium, #92949c));
|
|
29
|
+
--line-color: var(--ok-border-soft, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.14));
|
|
30
|
+
--hover-bg: var(--ok-hover, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.06));
|
|
31
|
+
--current-bg: var(
|
|
32
|
+
--ok-current-bg,
|
|
33
|
+
rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.1)
|
|
34
|
+
);
|
|
35
|
+
--border-radius: var(--ok-radius, 8px);
|
|
36
|
+
--dot-size: var(--ok-timeline-dot, 28px);
|
|
37
|
+
--gutter: var(--ok-timeline-gutter, 14px);
|
|
38
|
+
--font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
|
|
39
|
+
|
|
40
|
+
/* Por defecto ocupa el ancho del contenedor y es responsive. */
|
|
41
|
+
display: block;
|
|
42
|
+
width: 100%;
|
|
43
|
+
color: var(--color);
|
|
44
|
+
font-family: var(--font);
|
|
45
|
+
font-size: 0.95rem;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.timeline {
|
|
49
|
+
position: relative;
|
|
50
|
+
margin: 0;
|
|
51
|
+
padding: 0;
|
|
52
|
+
list-style: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Item: rejilla [punto | contenido]. La línea vertical se dibuja en la columna del punto. */
|
|
56
|
+
.item {
|
|
57
|
+
position: relative;
|
|
58
|
+
display: grid;
|
|
59
|
+
grid-template-columns: var(--dot-size) 1fr;
|
|
60
|
+
column-gap: var(--gutter);
|
|
61
|
+
padding: 0.15rem 0 0.9rem;
|
|
62
|
+
}
|
|
63
|
+
.item:last-child {
|
|
64
|
+
padding-bottom: 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Columna del punto: contiene el dot y el segmento de línea que baja al siguiente. */
|
|
68
|
+
.marker {
|
|
69
|
+
position: relative;
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
}
|
|
73
|
+
/* Segmento de línea: arranca bajo el dot y llega al final del item. */
|
|
74
|
+
.marker::before {
|
|
75
|
+
content: '';
|
|
76
|
+
position: absolute;
|
|
77
|
+
top: var(--dot-size);
|
|
78
|
+
bottom: calc(-0.9rem);
|
|
79
|
+
left: 50%;
|
|
80
|
+
width: 2px;
|
|
81
|
+
transform: translateX(-50%);
|
|
82
|
+
background: var(--line-color);
|
|
83
|
+
}
|
|
84
|
+
.item:last-child .marker::before {
|
|
85
|
+
display: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.dot {
|
|
89
|
+
position: relative;
|
|
90
|
+
z-index: 1;
|
|
91
|
+
flex: 0 0 auto;
|
|
92
|
+
display: inline-flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
width: var(--dot-size);
|
|
96
|
+
height: var(--dot-size);
|
|
97
|
+
border-radius: 50%;
|
|
98
|
+
background: var(--dot-color, var(--pending-color));
|
|
99
|
+
color: var(--dot-contrast, #ffffff);
|
|
100
|
+
box-shadow: 0 0 0 3px var(--ok-surface, var(--ion-background-color, #ffffff));
|
|
101
|
+
}
|
|
102
|
+
.dot ion-icon {
|
|
103
|
+
font-size: calc(var(--dot-size) * 0.5);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Contenido del hito; es un botón accesible para emitir el click. */
|
|
107
|
+
.content {
|
|
108
|
+
min-width: 0;
|
|
109
|
+
text-align: left;
|
|
110
|
+
width: 100%;
|
|
111
|
+
margin: 0;
|
|
112
|
+
padding: 0.35rem 0.55rem;
|
|
113
|
+
border: 0;
|
|
114
|
+
background: none;
|
|
115
|
+
color: inherit;
|
|
116
|
+
font: inherit;
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
border-radius: var(--border-radius);
|
|
119
|
+
transition: background-color var(--ok-transition, 150ms ease),
|
|
120
|
+
color var(--ok-transition, 150ms ease), border-color var(--ok-transition, 150ms ease),
|
|
121
|
+
box-shadow var(--ok-transition, 150ms ease), transform 120ms ease;
|
|
122
|
+
}
|
|
123
|
+
@media (hover: hover) {
|
|
124
|
+
.content:hover {
|
|
125
|
+
background: var(--hover-bg);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
.content:active {
|
|
129
|
+
transform: scale(var(--ok-press-scale, 0.97));
|
|
130
|
+
}
|
|
131
|
+
@media (prefers-reduced-motion: reduce) {
|
|
132
|
+
.content:active {
|
|
133
|
+
transform: none;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
.item.current .content {
|
|
137
|
+
background: var(--current-bg);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.head {
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: baseline;
|
|
143
|
+
gap: 0.5rem;
|
|
144
|
+
flex-wrap: wrap;
|
|
145
|
+
}
|
|
146
|
+
.title {
|
|
147
|
+
font-weight: 600;
|
|
148
|
+
min-width: 0;
|
|
149
|
+
}
|
|
150
|
+
.item.current .title {
|
|
151
|
+
color: var(--primary-color);
|
|
152
|
+
}
|
|
153
|
+
.time {
|
|
154
|
+
font-size: 0.8rem;
|
|
155
|
+
color: var(--color-muted);
|
|
156
|
+
white-space: nowrap;
|
|
157
|
+
}
|
|
158
|
+
.desc {
|
|
159
|
+
margin-top: 0.2rem;
|
|
160
|
+
color: var(--color-muted);
|
|
161
|
+
font-size: 0.88rem;
|
|
162
|
+
line-height: 1.35;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* Modo alternado (solo en pantallas anchas): los items pares van a la derecha. */
|
|
166
|
+
@media (min-width: 640px) {
|
|
167
|
+
.timeline.alternate .item {
|
|
168
|
+
grid-template-columns: 1fr var(--dot-size) 1fr;
|
|
169
|
+
}
|
|
170
|
+
.timeline.alternate .marker {
|
|
171
|
+
grid-column: 2;
|
|
172
|
+
order: 0;
|
|
173
|
+
}
|
|
174
|
+
.timeline.alternate .item .content {
|
|
175
|
+
grid-column: 3;
|
|
176
|
+
}
|
|
177
|
+
.timeline.alternate .item.alt .content {
|
|
178
|
+
grid-column: 1;
|
|
179
|
+
text-align: right;
|
|
180
|
+
}
|
|
181
|
+
.timeline.alternate .item.alt .head {
|
|
182
|
+
justify-content: flex-end;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
`;
|
|
186
|
+
}
|
|
187
|
+
// Resuelve el color del punto: explícito en el item, o derivado del status.
|
|
188
|
+
dotColor(item) {
|
|
189
|
+
if (item.color) {
|
|
190
|
+
return /^[a-z-]+$/.test(item.color) ? `var(--ion-color-${item.color}, ${item.color})` : item.color;
|
|
191
|
+
}
|
|
192
|
+
switch (item.status) {
|
|
193
|
+
case "done":
|
|
194
|
+
return "var(--done-color)";
|
|
195
|
+
case "current":
|
|
196
|
+
return "var(--primary-color)";
|
|
197
|
+
default:
|
|
198
|
+
return "var(--pending-color)";
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// Emite `ok-item-click` con el item pulsado.
|
|
202
|
+
emitClick(item) {
|
|
203
|
+
this.dispatchEvent(
|
|
204
|
+
new CustomEvent("ok-item-click", {
|
|
205
|
+
detail: { id: item.id, item },
|
|
206
|
+
bubbles: true,
|
|
207
|
+
composed: true
|
|
208
|
+
})
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
renderItem(item, index) {
|
|
212
|
+
const isCurrent = item.status === "current";
|
|
213
|
+
const isAlt = this.align === "alternate" && index % 2 === 1;
|
|
214
|
+
const classes = ["item", isCurrent ? "current" : "", isAlt ? "alt" : ""].filter(Boolean).join(" ");
|
|
215
|
+
const dotStyle = `--dot-color: ${this.dotColor(item)}`;
|
|
216
|
+
return html`<li class=${classes}>
|
|
217
|
+
<span class="marker">
|
|
218
|
+
<span class="dot" style=${dotStyle}>
|
|
219
|
+
${item.icon ? html`<ion-icon .name=${item.icon}></ion-icon>` : ""}
|
|
220
|
+
</span>
|
|
221
|
+
</span>
|
|
222
|
+
<button
|
|
223
|
+
type="button"
|
|
224
|
+
class="content"
|
|
225
|
+
@click=${() => this.emitClick(item)}
|
|
226
|
+
>
|
|
227
|
+
<span class="head">
|
|
228
|
+
<span class="title">${item.title}</span>
|
|
229
|
+
${item.time ? html`<span class="time">${item.time}</span>` : ""}
|
|
230
|
+
</span>
|
|
231
|
+
${item.description ? html`<div class="desc">${item.description}</div>` : ""}
|
|
232
|
+
</button>
|
|
233
|
+
</li>`;
|
|
234
|
+
}
|
|
235
|
+
render() {
|
|
236
|
+
const listClass = `timeline ${this.align === "alternate" ? "alternate" : ""}`.trim();
|
|
237
|
+
return html`<ul class=${listClass}>
|
|
238
|
+
${this.items.map((item, i) => this.renderItem(item, i))}
|
|
239
|
+
</ul>`;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
__decorateClass([
|
|
243
|
+
property({ attribute: false })
|
|
244
|
+
], OkTimeline.prototype, "items");
|
|
245
|
+
__decorateClass([
|
|
246
|
+
property()
|
|
247
|
+
], OkTimeline.prototype, "align");
|
|
248
|
+
define("ok-timeline", OkTimeline);
|
|
249
|
+
export {
|
|
250
|
+
OkTimeline
|
|
251
|
+
};
|
package/dist/ok-tree.js
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { LitElement, css, html } 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 DEFAULT_LABELS = {
|
|
14
|
+
expand: "Expand",
|
|
15
|
+
collapse: "Collapse"
|
|
16
|
+
};
|
|
17
|
+
class OkTree extends LitElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.nodes = [];
|
|
21
|
+
this.selectable = false;
|
|
22
|
+
this.activeId = "";
|
|
23
|
+
this.labels = {};
|
|
24
|
+
this.expandedIds = /* @__PURE__ */ new Set();
|
|
25
|
+
this.seeded = false;
|
|
26
|
+
}
|
|
27
|
+
static {
|
|
28
|
+
this.styles = css`
|
|
29
|
+
:host {
|
|
30
|
+
/* Vars overridable (estilo Ionic), default = cadena --ok-* → --ion-* → hex */
|
|
31
|
+
--color: var(--ok-text, var(--ion-text-color, #1c1b17));
|
|
32
|
+
--color-muted: var(--ok-text-muted, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.55));
|
|
33
|
+
--primary-color: var(--ok-primary, var(--ion-color-primary, #3880ff));
|
|
34
|
+
--primary-contrast: var(--ok-primary-contrast, var(--ion-color-primary-contrast, #ffffff));
|
|
35
|
+
--hover-bg: var(--ok-hover, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.06));
|
|
36
|
+
--guide-color: var(--ok-border-soft, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.12));
|
|
37
|
+
--border-radius: var(--ok-radius, 8px);
|
|
38
|
+
--indent: var(--ok-tree-indent, 18px);
|
|
39
|
+
--font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
|
|
40
|
+
|
|
41
|
+
/* Por defecto ocupa el ancho del contenedor y es responsive. */
|
|
42
|
+
display: block;
|
|
43
|
+
width: 100%;
|
|
44
|
+
color: var(--color);
|
|
45
|
+
font-family: var(--font);
|
|
46
|
+
font-size: 0.95rem;
|
|
47
|
+
}
|
|
48
|
+
[role='tree'],
|
|
49
|
+
[role='group'] {
|
|
50
|
+
margin: 0;
|
|
51
|
+
padding: 0;
|
|
52
|
+
list-style: none;
|
|
53
|
+
}
|
|
54
|
+
/* Cada subnivel se indenta y dibuja una línea guía sutil a la izquierda. */
|
|
55
|
+
[role='group'] {
|
|
56
|
+
margin-left: calc(var(--indent) / 2 + 8px);
|
|
57
|
+
padding-left: calc(var(--indent) / 2);
|
|
58
|
+
border-left: 1px solid var(--guide-color);
|
|
59
|
+
}
|
|
60
|
+
.row {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: 0.4rem;
|
|
64
|
+
width: 100%;
|
|
65
|
+
box-sizing: border-box;
|
|
66
|
+
padding: 0.38rem 0.5rem;
|
|
67
|
+
border-radius: var(--border-radius);
|
|
68
|
+
cursor: default;
|
|
69
|
+
user-select: none;
|
|
70
|
+
transition: background-color var(--ok-transition, 150ms ease), color var(--ok-transition, 150ms ease),
|
|
71
|
+
border-color var(--ok-transition, 150ms ease), box-shadow var(--ok-transition, 150ms ease),
|
|
72
|
+
transform 120ms ease;
|
|
73
|
+
}
|
|
74
|
+
.row.selectable {
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
}
|
|
77
|
+
@media (hover: hover) {
|
|
78
|
+
.row.selectable:hover {
|
|
79
|
+
background: var(--hover-bg);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
.row.selectable:active {
|
|
83
|
+
transform: scale(var(--ok-press-scale, 0.97));
|
|
84
|
+
}
|
|
85
|
+
.row.active {
|
|
86
|
+
background: var(--primary-color);
|
|
87
|
+
color: var(--primary-contrast);
|
|
88
|
+
}
|
|
89
|
+
.row.disabled {
|
|
90
|
+
opacity: 0.45;
|
|
91
|
+
cursor: not-allowed;
|
|
92
|
+
pointer-events: none;
|
|
93
|
+
}
|
|
94
|
+
/* Botón del chevron: expande/colapsa. Reserva hueco aunque el nodo sea hoja. */
|
|
95
|
+
.chevron {
|
|
96
|
+
flex: 0 0 auto;
|
|
97
|
+
display: inline-flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
justify-content: center;
|
|
100
|
+
width: 20px;
|
|
101
|
+
height: 20px;
|
|
102
|
+
padding: 0;
|
|
103
|
+
margin: 0;
|
|
104
|
+
border: 0;
|
|
105
|
+
background: none;
|
|
106
|
+
color: inherit;
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
border-radius: 4px;
|
|
109
|
+
transition: background-color var(--ok-transition, 150ms ease), color var(--ok-transition, 150ms ease),
|
|
110
|
+
border-color var(--ok-transition, 150ms ease), box-shadow var(--ok-transition, 150ms ease),
|
|
111
|
+
transform 120ms ease;
|
|
112
|
+
}
|
|
113
|
+
@media (hover: hover) {
|
|
114
|
+
.chevron:not(.leaf):hover {
|
|
115
|
+
background: var(--hover-bg);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
.chevron:not(.leaf):active {
|
|
119
|
+
transform: scale(var(--ok-press-scale, 0.97));
|
|
120
|
+
}
|
|
121
|
+
.chevron.leaf {
|
|
122
|
+
visibility: hidden;
|
|
123
|
+
cursor: default;
|
|
124
|
+
}
|
|
125
|
+
.chevron ion-icon {
|
|
126
|
+
font-size: 1rem;
|
|
127
|
+
transition: transform 0.18s ease;
|
|
128
|
+
}
|
|
129
|
+
.chevron.open ion-icon {
|
|
130
|
+
transform: rotate(90deg);
|
|
131
|
+
}
|
|
132
|
+
.icon {
|
|
133
|
+
flex: 0 0 auto;
|
|
134
|
+
display: inline-flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
font-size: 1.05rem;
|
|
137
|
+
color: var(--color-muted);
|
|
138
|
+
}
|
|
139
|
+
.row.active .icon {
|
|
140
|
+
color: inherit;
|
|
141
|
+
}
|
|
142
|
+
.label {
|
|
143
|
+
flex: 1 1 auto;
|
|
144
|
+
min-width: 0;
|
|
145
|
+
overflow: hidden;
|
|
146
|
+
text-overflow: ellipsis;
|
|
147
|
+
white-space: nowrap;
|
|
148
|
+
}
|
|
149
|
+
@media (prefers-reduced-motion: reduce) {
|
|
150
|
+
.row.selectable:hover,
|
|
151
|
+
.row.selectable:active,
|
|
152
|
+
.chevron:not(.leaf):hover,
|
|
153
|
+
.chevron:not(.leaf):active {
|
|
154
|
+
transform: none;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
`;
|
|
158
|
+
}
|
|
159
|
+
// Textos efectivos: defaults en inglés + overrides del consumidor.
|
|
160
|
+
get t() {
|
|
161
|
+
return { ...DEFAULT_LABELS, ...this.labels };
|
|
162
|
+
}
|
|
163
|
+
// Siembra el estado de expansión a partir del campo `expanded` de cada nodo (una sola vez).
|
|
164
|
+
seedExpanded(nodes) {
|
|
165
|
+
for (const n of nodes) {
|
|
166
|
+
if (n.expanded) this.expandedIds.add(n.id);
|
|
167
|
+
if (n.children?.length) this.seedExpanded(n.children);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
isExpanded(node) {
|
|
171
|
+
return this.expandedIds.has(node.id);
|
|
172
|
+
}
|
|
173
|
+
// Expande/colapsa un nodo y emite `ok-toggle`.
|
|
174
|
+
toggle(node) {
|
|
175
|
+
if (node.disabled) return;
|
|
176
|
+
const next = new Set(this.expandedIds);
|
|
177
|
+
const open = !next.has(node.id);
|
|
178
|
+
if (open) next.add(node.id);
|
|
179
|
+
else next.delete(node.id);
|
|
180
|
+
this.expandedIds = next;
|
|
181
|
+
this.dispatchEvent(
|
|
182
|
+
new CustomEvent("ok-toggle", {
|
|
183
|
+
detail: { id: node.id, expanded: open },
|
|
184
|
+
bubbles: true,
|
|
185
|
+
composed: true
|
|
186
|
+
})
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
// Selecciona un nodo (si `selectable`) y emite `ok-select`.
|
|
190
|
+
select(node) {
|
|
191
|
+
if (node.disabled || !this.selectable) return;
|
|
192
|
+
this.dispatchEvent(
|
|
193
|
+
new CustomEvent("ok-select", {
|
|
194
|
+
detail: { id: node.id, node },
|
|
195
|
+
bubbles: true,
|
|
196
|
+
composed: true
|
|
197
|
+
})
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
// Render recursivo de un nodo (li[treeitem] + grupo de hijos si está expandido).
|
|
201
|
+
renderNode(node) {
|
|
202
|
+
const hasChildren = !!node.children?.length;
|
|
203
|
+
const expanded = hasChildren && this.isExpanded(node);
|
|
204
|
+
const active = this.selectable && node.id === this.activeId;
|
|
205
|
+
const rowClasses = [
|
|
206
|
+
"row",
|
|
207
|
+
this.selectable ? "selectable" : "",
|
|
208
|
+
active ? "active" : "",
|
|
209
|
+
node.disabled ? "disabled" : ""
|
|
210
|
+
].filter(Boolean).join(" ");
|
|
211
|
+
return html`<li
|
|
212
|
+
role="treeitem"
|
|
213
|
+
aria-expanded=${hasChildren ? String(expanded) : ""}
|
|
214
|
+
aria-disabled=${node.disabled ? "true" : "false"}
|
|
215
|
+
>
|
|
216
|
+
<div class=${rowClasses}>
|
|
217
|
+
<button
|
|
218
|
+
type="button"
|
|
219
|
+
class=${`chevron ${hasChildren ? "" : "leaf"} ${expanded ? "open" : ""}`.trim()}
|
|
220
|
+
aria-hidden=${hasChildren ? "false" : "true"}
|
|
221
|
+
tabindex=${hasChildren ? "0" : "-1"}
|
|
222
|
+
aria-label=${expanded ? this.t.collapse : this.t.expand}
|
|
223
|
+
@click=${(e) => {
|
|
224
|
+
e.stopPropagation();
|
|
225
|
+
this.toggle(node);
|
|
226
|
+
}}
|
|
227
|
+
>
|
|
228
|
+
<ion-icon name="chevron-forward-outline"></ion-icon>
|
|
229
|
+
</button>
|
|
230
|
+
${node.icon ? html`<span class="icon"><ion-icon .name=${node.icon}></ion-icon></span>` : ""}
|
|
231
|
+
<span class="label" @click=${() => this.select(node)}>${node.label}</span>
|
|
232
|
+
</div>
|
|
233
|
+
${expanded ? html`<ul role="group">
|
|
234
|
+
${node.children.map((child) => this.renderNode(child))}
|
|
235
|
+
</ul>` : ""}
|
|
236
|
+
</li>`;
|
|
237
|
+
}
|
|
238
|
+
render() {
|
|
239
|
+
if (!this.seeded && this.nodes.length) {
|
|
240
|
+
this.seedExpanded(this.nodes);
|
|
241
|
+
this.seeded = true;
|
|
242
|
+
}
|
|
243
|
+
return html`<ul role="tree">
|
|
244
|
+
${this.nodes.map((node) => this.renderNode(node))}
|
|
245
|
+
</ul>`;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
__decorateClass([
|
|
249
|
+
property({ attribute: false })
|
|
250
|
+
], OkTree.prototype, "nodes");
|
|
251
|
+
__decorateClass([
|
|
252
|
+
property({ type: Boolean })
|
|
253
|
+
], OkTree.prototype, "selectable");
|
|
254
|
+
__decorateClass([
|
|
255
|
+
property({ attribute: "active-id" })
|
|
256
|
+
], OkTree.prototype, "activeId");
|
|
257
|
+
__decorateClass([
|
|
258
|
+
property({ attribute: false })
|
|
259
|
+
], OkTree.prototype, "labels");
|
|
260
|
+
__decorateClass([
|
|
261
|
+
state()
|
|
262
|
+
], OkTree.prototype, "expandedIds");
|
|
263
|
+
define("ok-tree", OkTree);
|
|
264
|
+
export {
|
|
265
|
+
OkTree
|
|
266
|
+
};
|