@directo-ui/astro 1.1.0 → 1.2.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.
package/README.md CHANGED
@@ -29,6 +29,8 @@ import { WariStatusSelect, MultiSelect, StatusTag, WariSchedule, WariTripAttribu
29
29
  ---
30
30
  <WariStatusSelect name="estado" value={['libre']} />
31
31
  <StatusTag status="aceptado" />
32
+ <WariClientSearch action="/clientes" createHref="/clientes/nuevo" /> <!-- o escucha ds-search / ds-create; carga: aria-busy="true" -->
33
+ <WariClientDetails name="Mori Suarez, Victor Manuel (VIP)" phone="985985985" /> <!-- ds-rates / ds-info / ds-edit -->
32
34
  <WariTripAttributes name="trip" /> <!-- envía trip.service, trip.mode, trip.extras, trip.vehicles, trip.payment -->
33
35
  <WariSchedule date="2026-05-27" time="23:50" dateName="fecha" timeName="hora" />
34
36
  ```
package/components.css CHANGED
@@ -1119,8 +1119,9 @@ dialog.ds-sheet[open] { animation: ds-sheet-up 280ms var(--ds-ease-out) both; }
1119
1119
  display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; min-height: 36px; padding: 6px 12px;
1120
1120
  color: #676F88; font: 500 14px/1.2 var(--ds-font-sans); letter-spacing: -.02em; cursor: pointer;
1121
1121
  }
1122
- .ds-wswitch + .ds-wswitch { border-top: 1px solid var(--ds-border-secondary, #DADBDE); }
1123
- .ds-wswitches[data-orientation="horizontal"] > .ds-wswitch + .ds-wswitch { border-top: 0; border-left: 1px solid var(--ds-border-secondary, #DADBDE); }
1122
+ .ds-wswitch-item { display: flex; flex: 1; flex-direction: column; min-width: 0; }
1123
+ .ds-wswitch-item + .ds-wswitch-item { border-top: 1px solid var(--ds-border-secondary, #DADBDE); }
1124
+ .ds-wswitches[data-orientation="horizontal"] > .ds-wswitch-item + .ds-wswitch-item { border-top: 0; border-left: 1px solid var(--ds-border-secondary, #DADBDE); }
1124
1125
  .ds-wswitch:has(input:checked) { color: var(--ds-text-primary); }
1125
1126
  .ds-wswitch:has(input:disabled) { opacity: .5; cursor: not-allowed; }
1126
1127
  .dark .ds-wswitch, [data-theme="dark"] .ds-wswitch { color: var(--ds-text-secondary); }
@@ -1157,3 +1158,337 @@ dialog.ds-sheet[open] { animation: ds-sheet-up 280ms var(--ds-ease-out) both; }
1157
1158
  .ds-wselect .ds-wselect-list { padding-block: 0; }
1158
1159
  .ds-multiselect .ds-multiselect-list { padding: 8px; }
1159
1160
  .ds-wselect .ds-wselect-option, .ds-multiselect .ds-multiselect-option, .ds-multiselect .ds-multiselect-empty { margin: 0; }
1161
+
1162
+ /* ==========================================================================
1163
+ Wari: Cliente / usuario (WariClientSearch)
1164
+ ========================================================================== */
1165
+ .ds-wcard[data-hover="lift"] { transition: box-shadow var(--ds-duration-base, 200ms) var(--ds-ease-out); }
1166
+ .ds-wcard[data-hover="lift"]:hover, .ds-wcard[data-hover="lift"]:focus-within { box-shadow: 0 8px 36px rgb(0 0 0 / .17); }
1167
+ .ds-wclient .ds-wcard-header { padding-left: 8px; padding-right: 4px; gap: 10px; }
1168
+ .ds-wclient .ds-wcard-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1169
+ .ds-wcard-action {
1170
+ display: inline-flex; flex: none; align-items: center; gap: 4px; height: 32px; padding: 0 4px; border: 0; border-radius: 8px;
1171
+ color: var(--ds-bg-brand-primary); background: transparent; font: 500 14px/1 var(--ds-font-sans); text-decoration: none; cursor: pointer;
1172
+ transition: background-color var(--ds-duration-fast);
1173
+ }
1174
+ .ds-wcard-action:hover { background: color-mix(in srgb, var(--ds-bg-brand-primary) 8%, transparent); }
1175
+ .ds-wcard-action:focus-visible { outline: 2px solid var(--ds-bg-brand-primary); outline-offset: 1px; }
1176
+ .ds-wcard-action > svg { width: 16px; height: 16px; flex: none; }
1177
+ .ds-wsearch { margin: 0; }
1178
+ .ds-wsearch .ds-input-shell { min-height: 34px; padding: 0 8px; border: 1px solid var(--ds-border-secondary, #DADBDE); background: var(--ds-bg-primary); }
1179
+ .ds-wsearch .ds-input-shell:hover { border-color: var(--ds-color-neutral-400); }
1180
+ .ds-wsearch .ds-input-shell:focus-within { border-color: var(--ds-bg-brand-primary); box-shadow: 0 0 0 1px var(--ds-bg-brand-primary); }
1181
+ .ds-wsearch .ds-input-shell > svg { flex: none; width: 24px; height: 24px; color: #676F88; }
1182
+ .ds-wsearch .ds-input-shell > input { height: 32px; font-size: 14px; letter-spacing: -.02em; }
1183
+ .ds-wsearch .ds-input-shell > input::placeholder { color: #676F88; }
1184
+ .ds-wsearch .ds-input-shell > input::-webkit-search-cancel-button { cursor: pointer; }
1185
+ .ds-wclient-results:empty { display: none; }
1186
+
1187
+ /* Cliente / usuario: estados (enfocado fino como en Figma, cargando) */
1188
+ .ds-wsearch .ds-input-shell:focus-within { box-shadow: none; }
1189
+ .ds-wclient-progress {
1190
+ position: relative; height: 8px; overflow: hidden; border-radius: 8px; background: #D0EDFF;
1191
+ }
1192
+ .ds-wclient-progress::after {
1193
+ content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 24%; border-radius: 4px; background: #73C9FF;
1194
+ animation: ds-wclient-progress 1.2s ease-in-out infinite;
1195
+ }
1196
+ @keyframes ds-wclient-progress { from { transform: translateX(-100%); } to { transform: translateX(420%); } }
1197
+ @media (prefers-reduced-motion: reduce) { .ds-wclient-progress::after { animation: none; width: 40%; } }
1198
+ .dark .ds-wclient-progress, [data-theme="dark"] .ds-wclient-progress { background: rgb(115 201 255 / .18); }
1199
+
1200
+ /* Ficha del cliente elegido (WariClientDetails) */
1201
+ .ds-wclient-details { display: flex; flex-direction: column; gap: 12px; min-width: 0; color: var(--ds-text-secondary, #474D59); font-family: var(--ds-font-sans); }
1202
+ .ds-wclient-summary { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
1203
+ .ds-wclient-banner {
1204
+ --ds-wclient-tone: #B1510C; --ds-wclient-tone-bg: #FDF1C8;
1205
+ display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; padding: 10px 12px;
1206
+ border: 1px solid var(--ds-wclient-tone-border, var(--ds-wclient-tone)); border-left-width: 5px; border-radius: 4px;
1207
+ color: var(--ds-wclient-tone); background: var(--ds-wclient-tone-bg); font-size: 14px; line-height: 1.5; letter-spacing: -.02em;
1208
+ }
1209
+ /* Sin VIP (Figma "Usuario VIP / sin VIP"): texto azul oscuro, borde celeste. */
1210
+ .ds-wclient-banner[data-tone="info"] { --ds-wclient-tone: #11278F; --ds-wclient-tone-bg: #E8F6FF; --ds-wclient-tone-border: #73C9FF; }
1211
+ .ds-wclient-banner[data-tone="neutral"] { --ds-wclient-tone: #474D59; --ds-wclient-tone-bg: #F2F4FA; }
1212
+ .dark .ds-wclient-banner, [data-theme="dark"] .ds-wclient-banner {
1213
+ color: color-mix(in srgb, var(--ds-wclient-tone) 45%, #fff); background: color-mix(in srgb, var(--ds-wclient-tone) 20%, transparent);
1214
+ }
1215
+ .ds-wclient-name { margin: 0; overflow: hidden; font-size: 16px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
1216
+ .ds-wclient-company { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1217
+ .ds-wclient-phone { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; color: inherit; text-decoration: underline; text-underline-offset: 2px; }
1218
+ .ds-wclient-phone > svg { flex: none; width: 16px; height: 16px; }
1219
+ .ds-wclient-phone:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; border-radius: 2px; }
1220
+ .ds-wclient-actions { display: flex; flex: none; flex-direction: column; gap: 4px; }
1221
+ .ds-wclient-actions > div { display: flex; gap: 4px; }
1222
+ .ds-wclient-rates {
1223
+ height: 32px; padding: 0 14px; border: 0; border-radius: 8px; color: #F2F4FA; background: var(--ds-bg-brand-primary);
1224
+ font: 500 14px/1 var(--ds-font-sans); cursor: pointer;
1225
+ }
1226
+ .ds-wclient-rates:hover { background: var(--ds-color-primary-600, #0843C2); }
1227
+ .ds-wclient-icon {
1228
+ display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px;
1229
+ color: var(--ds-bg-brand-primary); background: #E8F6FF; cursor: pointer;
1230
+ }
1231
+ .ds-wclient-icon:hover { background: #D0EDFF; }
1232
+ .ds-wclient-icon > svg { width: 16px; height: 16px; }
1233
+ .dark .ds-wclient-icon, [data-theme="dark"] .ds-wclient-icon { background: rgb(64 123 255 / .18); color: #A9C1F7; }
1234
+ .ds-wclient-rates:focus-visible, .ds-wclient-icon:focus-visible { outline: 2px solid var(--ds-bg-brand-primary); outline-offset: 2px; }
1235
+ .ds-wclient-rates:disabled, .ds-wclient-icon:disabled { opacity: .5; cursor: not-allowed; }
1236
+
1237
+ /* Panel de campos de la cuenta: campos compactos con fondo blanco sobre gris */
1238
+ .ds-wclient-fields {
1239
+ display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px; border-radius: 8px; background: #E3E7F1;
1240
+ }
1241
+ .dark .ds-wclient-fields, [data-theme="dark"] .ds-wclient-fields { background: var(--ds-bg-secondary); }
1242
+ .ds-wclient-fields .ds-input { gap: 2px; }
1243
+ .ds-wclient-fields .ds-input > label { color: #474D59; font-size: 12px; font-weight: 400; }
1244
+ .dark .ds-wclient-fields .ds-input > label, [data-theme="dark"] .ds-wclient-fields .ds-input > label { color: var(--ds-text-secondary); }
1245
+ .ds-wclient-fields .ds-input-shell { min-height: 26px; padding: 0 4px 0 8px; border: 1px solid transparent; background: var(--ds-bg-primary); }
1246
+ .ds-wclient-fields .ds-input-shell > input, .ds-wclient-fields .ds-input-shell > select { height: 24px; font-size: 14px; }
1247
+ .ds-wclient-fields .ds-wselect .ds-input-shell { min-height: 26px; padding-left: 8px; border-color: transparent; }
1248
+ .ds-wclient-fields .ds-wselect-value { font-size: 14px; }
1249
+ .ds-wclient-fields .ds-wselect-caret svg { width: 16px; height: 16px; }
1250
+
1251
+ /* Observaciones de solo lectura */
1252
+ .ds-wclient-notes { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
1253
+ .ds-wclient-notes > span > em { color: #11278F; font-style: normal; }
1254
+ .dark .ds-wclient-notes > span > em, [data-theme="dark"] .ds-wclient-notes > span > em { color: #A9C1F7; }
1255
+ .ds-wclient-notes > p {
1256
+ margin: 0; min-height: 64px; padding: 12px; border: 1px solid var(--ds-border-secondary, #DADBDE); border-radius: 8px;
1257
+ color: var(--ds-text-secondary, #474D59); white-space: pre-wrap;
1258
+ }
1259
+ .ds-wclient-fields:empty { display: none; }
1260
+ .ds-wclient-progress[data-ds-progress] { display: none; }
1261
+ .ds-wclient[aria-busy="true"] .ds-wclient-progress[data-ds-progress] { display: block; }
1262
+ /* Párrafos propios: no heredan márgenes de estilos de texto de la página (p. ej. `.prose p`). */
1263
+ .ds-wclient-details .ds-wclient-name, .ds-wclient-details .ds-wclient-notes > p { margin: 0; }
1264
+ .ds-wclient-banner .ds-wclient-phone { color: inherit; text-decoration: underline; }
1265
+
1266
+ /* Extras desplegables (Booster: descripción, cantidad y nota al activarlo) */
1267
+ .ds-wswitch-panel { display: flex; flex-direction: column; gap: 8px; padding: 0 12px 12px; }
1268
+ .ds-wswitch-panel[hidden] { display: none; }
1269
+ .ds-wswitch-desc { margin: -4px 0 0; color: #474D59; font-size: 14px; line-height: 1.5; letter-spacing: -.02em; }
1270
+ .dark .ds-wswitch-desc, [data-theme="dark"] .ds-wswitch-desc { color: var(--ds-text-secondary); }
1271
+ .ds-wswitch-note {
1272
+ margin: 0; padding: 8px 16px; border-radius: 8px; color: #fff; background: #2C313A; box-shadow: 0 8px 36px rgb(0 0 0 / .17);
1273
+ font-size: 12px; line-height: 1.5; letter-spacing: -.01em;
1274
+ }
1275
+ .dark .ds-wswitch-note, [data-theme="dark"] .ds-wswitch-note { background: #3A4152; }
1276
+
1277
+ /* Contador con botones con borde (variante del diseño del Booster) */
1278
+ .ds-wstepper[data-variant="outlined"] .ds-input-shell { min-height: 48px; padding: 8px; gap: 8px; border: 0; }
1279
+ .ds-wstepper[data-variant="outlined"] .ds-wstepper-button {
1280
+ width: 32px; height: 32px; border: 1px solid var(--ds-bg-brand-primary); border-radius: 8px; color: var(--ds-bg-brand-primary);
1281
+ background: transparent;
1282
+ }
1283
+ .ds-wstepper[data-variant="outlined"] .ds-wstepper-button:hover:not(:disabled) { background: color-mix(in srgb, var(--ds-bg-brand-primary) 8%, transparent); }
1284
+ .ds-wstepper[data-variant="outlined"] .ds-wstepper-button:disabled { border-color: #DADBDE; color: #B8BDC9; }
1285
+ .ds-wstepper[data-variant="outlined"] .ds-input-shell > input { color: #474D59; }
1286
+ .dark .ds-wstepper[data-variant="outlined"] .ds-input-shell > input, [data-theme="dark"] .ds-wstepper[data-variant="outlined"] .ds-input-shell > input { color: var(--ds-text-primary); }
1287
+ /* El aviso y la descripción de los extras no heredan colores ni márgenes de estilos de texto de la página (p. ej. `.prose p`). */
1288
+ .ds-wswitches .ds-wswitch-note { margin: 0; color: #fff; }
1289
+ .ds-wswitches .ds-wswitch-desc { margin: -4px 0 0; color: #474D59; }
1290
+ .dark .ds-wswitches .ds-wswitch-desc, [data-theme="dark"] .ds-wswitches .ds-wswitch-desc { color: var(--ds-text-secondary); }
1291
+ /* Títulos y textos propios de Wari: ignoran estilos de texto de la página (`.prose h3`, `.prose p`…). */
1292
+ .ds-wcard-header > .ds-wcard-title, .ds-wschedule-header > .ds-wschedule-title { margin: 0; color: inherit; font: 500 16px/1.5 var(--ds-font-sans); letter-spacing: -.02em; }
1293
+ .ds-wclient-banner > .ds-wclient-name { margin: 0; color: inherit; font-size: 16px; font-weight: 500; line-height: 1.5; }
1294
+ .ds-wclient-details .ds-wclient-notes > p { color: var(--ds-text-secondary, #474D59); }
1295
+
1296
+ /* Extras con una opción por unidad (Carseat: una edad por carseat, + para agregar, papelera para quitar) */
1297
+ .ds-wswitch-units { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 8px; background: #F2F4FA; }
1298
+ .dark .ds-wswitch-units, [data-theme="dark"] .ds-wswitch-units { background: var(--ds-bg-secondary); }
1299
+ .ds-wswitch-unit { display: flex; align-items: flex-start; gap: 8px; }
1300
+ .ds-wswitch-unit > .ds-wselect { flex: 1; min-width: 0; }
1301
+ .ds-wswitch-unit .ds-wselect .ds-input-shell { min-height: 32px; }
1302
+ .ds-wswitch-unit-button {
1303
+ display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; margin-top: 1px; padding: 0;
1304
+ border: 1px solid var(--ds-bg-brand-primary); border-radius: 8px; color: var(--ds-bg-brand-primary); background: var(--ds-bg-primary); cursor: pointer;
1305
+ }
1306
+ .ds-wswitch-unit-button:hover { background: color-mix(in srgb, var(--ds-bg-brand-primary) 8%, var(--ds-bg-primary)); }
1307
+ .ds-wswitch-unit-button:focus-visible { outline: 2px solid var(--ds-bg-brand-primary); outline-offset: 2px; }
1308
+ .ds-wswitch-unit-button:disabled { border-color: #DADBDE; color: #B8BDC9; cursor: not-allowed; }
1309
+ .ds-wswitch-unit-button > svg { width: 16px; height: 16px; }
1310
+
1311
+ /* Extras con campos propios (Carga: peso aproximado y valor estimado) */
1312
+ .ds-wswitch-fields { display: flex; gap: 8px; padding: 12px; border-radius: 8px; background: #F2F4FA; }
1313
+ .dark .ds-wswitch-fields, [data-theme="dark"] .ds-wswitch-fields { background: var(--ds-bg-secondary); }
1314
+ .ds-wswitch-fields .ds-wswitch-field {
1315
+ flex: 1; min-width: 0; height: 32px; margin: 0; padding: 0 8px; border: 1px solid var(--ds-border-secondary, #DADBDE); border-radius: 8px;
1316
+ color: var(--ds-text-secondary, #474D59); background: var(--ds-bg-primary); font: 400 14px/1 var(--ds-font-sans); letter-spacing: -.02em; outline: none;
1317
+ transition: border-color var(--ds-duration-fast);
1318
+ }
1319
+ .ds-wswitch-fields .ds-wswitch-field[data-fixed="true"] { flex: none; }
1320
+ .ds-wswitch-fields .ds-wswitch-field::placeholder { color: var(--ds-text-placeholder, #8A92A6); opacity: 1; }
1321
+ .ds-wswitch-fields .ds-wswitch-field:hover:not(:disabled) { border-color: var(--ds-color-neutral-400); }
1322
+ .ds-wswitch-fields .ds-wswitch-field:focus-visible { border-color: var(--ds-bg-brand-primary); }
1323
+ .ds-wswitch-fields .ds-wswitch-field:disabled { background: var(--ds-bg-secondary); cursor: not-allowed; }
1324
+
1325
+ /* ==========================================================================
1326
+ Wari: Rutas (WariRoute) — paradas reordenables, pasajeros, peajes e invertir
1327
+ ========================================================================== */
1328
+ .ds-wroute .ds-wcard-header { gap: 12px; }
1329
+ .ds-wroute .ds-wcard-title { flex: none; }
1330
+ .ds-wroute-header-spacer { flex: 1; }
1331
+ .ds-wroute-pill, .ds-wroute-link, .ds-wroute-add, .ds-wroute-toll-add, .ds-wroute-stop-passenger {
1332
+ display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px; border: 0; border-radius: 8px;
1333
+ background: transparent; font: 500 14px/1 var(--ds-font-sans); letter-spacing: -.02em; cursor: pointer; white-space: nowrap;
1334
+ transition: background-color var(--ds-duration-fast);
1335
+ }
1336
+ .ds-wroute-pill { color: var(--ds-bg-brand-primary); background: #E8F6FF; }
1337
+ .ds-wroute-pill:hover { background: #D0EDFF; }
1338
+ .ds-wroute-link, .ds-wroute-add { color: var(--ds-bg-brand-primary); }
1339
+ .ds-wroute-link:hover, .ds-wroute-add:hover, .ds-wroute-stop-passenger:hover, .ds-wroute-toll-add:hover {
1340
+ background: color-mix(in srgb, var(--ds-bg-brand-primary) 8%, transparent);
1341
+ }
1342
+ .ds-wroute-toll-add { height: 28px; padding: 0 8px; color: var(--ds-text-primary); }
1343
+ .ds-wroute-stop-passenger { height: 28px; color: var(--ds-text-secondary, #474D59); font-weight: 500; }
1344
+ .ds-wroute :is(.ds-wroute-pill, .ds-wroute-link, .ds-wroute-add, .ds-wroute-toll-add, .ds-wroute-stop-passenger) > svg { flex: none; width: 16px; height: 16px; }
1345
+ .ds-wroute :is(button):focus-visible, .ds-wroute input:focus-visible { outline: 2px solid var(--ds-bg-brand-primary); outline-offset: 1px; }
1346
+ .ds-wroute :is(button):disabled { opacity: .45; cursor: not-allowed; }
1347
+ .dark .ds-wroute-pill, [data-theme="dark"] .ds-wroute-pill { background: rgb(64 123 255 / .16); color: #A9C1F7; }
1348
+
1349
+ /* Inputs propios (sin borde, sobre fondos grises) */
1350
+ .ds-wroute input.ds-wroute-input {
1351
+ min-width: 0; height: 28px; margin: 0; padding: 0 4px; border: 0; border-radius: 6px; outline: none;
1352
+ color: var(--ds-text-primary); background: transparent; font: 400 14px/1 var(--ds-font-sans); letter-spacing: -.02em;
1353
+ }
1354
+ .ds-wroute input.ds-wroute-input::placeholder { color: #8A92A6; opacity: 1; }
1355
+ .ds-wroute input.ds-wroute-input.ds-wroute-input-sm { font-size: 12px; }
1356
+
1357
+ /* Pasajero (ruta completa o de una parada) */
1358
+ .ds-wroute-passenger-block { display: flex; flex-direction: column; gap: 4px; padding-left: 40px; }
1359
+ .ds-wroute-passenger { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 8px; border-radius: 8px; background: #E3E7F1; }
1360
+ .ds-wroute-passenger > label { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; color: #676F88; }
1361
+ .ds-wroute-passenger > label > svg { flex: none; width: 16px; height: 16px; }
1362
+ .ds-wroute-passenger .ds-wroute-input { flex: 1; font-size: 12px; }
1363
+ .ds-wroute-clear { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px; color: #474D59; background: transparent; cursor: pointer; }
1364
+ .ds-wroute-clear:hover { background: rgb(0 0 0 / .06); }
1365
+ .ds-wroute-clear > svg { width: 16px; height: 16px; }
1366
+ .ds-wroute-info { margin: 0; padding: 8px 16px; border-radius: 8px; color: #11278F; background: #CEDCFA; font: 400 12px/1.5 var(--ds-font-sans); }
1367
+ .dark .ds-wroute .ds-wroute-passenger, [data-theme="dark"] .ds-wroute .ds-wroute-passenger { background: var(--ds-bg-tertiary, #2A2F3A); }
1368
+ .dark .ds-wroute-passenger > label, [data-theme="dark"] .ds-wroute-passenger > label, .dark .ds-wroute-clear, [data-theme="dark"] .ds-wroute-clear { color: var(--ds-text-secondary); }
1369
+ .dark .ds-wroute-info, [data-theme="dark"] .ds-wroute-info { color: #CFDEFC; background: rgb(64 123 255 / .2); }
1370
+
1371
+ /* Paradas */
1372
+ .ds-wroute-stops { display: flex; flex-direction: column; gap: 12px; max-height: var(--ds-wroute-max-height, 340px); margin: 0; padding: 0 4px 0 0; overflow-y: auto; list-style: none; scrollbar-width: thin; scrollbar-color: #DADBDE transparent; }
1373
+ .ds-wroute-stop { display: flex; align-items: flex-start; gap: 8px; }
1374
+ .ds-wroute-stop[data-dragging="true"] { opacity: .45; }
1375
+ .ds-wroute-stop[data-drop="true"] > .ds-wroute-stop-box { box-shadow: 0 -2px 0 var(--ds-bg-brand-primary); }
1376
+ .ds-wroute-handle, .ds-wroute-remove {
1377
+ display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px;
1378
+ color: var(--ds-bg-brand-primary); background: transparent; cursor: grab;
1379
+ }
1380
+ .ds-wroute-handle:active { cursor: grabbing; }
1381
+ .ds-wroute-remove { background: #F2F4FA; cursor: pointer; }
1382
+ .ds-wroute-remove:hover { background: #E3E7F1; }
1383
+ .ds-wroute-handle > svg, .ds-wroute-remove > svg { width: 18px; height: 18px; }
1384
+ .ds-wroute-stop-box { display: flex; flex: 1; flex-direction: column; gap: 4px; min-width: 0; padding: 4px 8px 4px 0; border-radius: 8px; background: #F2F4FA; }
1385
+ .dark .ds-wroute-stop-box, [data-theme="dark"] .ds-wroute-stop-box, .dark .ds-wroute-remove, [data-theme="dark"] .ds-wroute-remove { background: var(--ds-bg-secondary); }
1386
+ .ds-wroute-stop-main { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding-bottom: 4px; border-bottom: 1px solid #DADBDE; }
1387
+ .ds-wroute-address { display: flex; flex: 1 1 220px; align-items: center; gap: 8px; min-width: 0; padding-left: 12px; }
1388
+ .ds-wroute-address > .ds-wroute-input { flex: 1; }
1389
+ .ds-wroute-address > svg { flex: none; width: 16px; height: 16px; color: var(--ds-bg-brand-primary); }
1390
+ .ds-wroute-zone { display: inline-flex; align-items: center; gap: 4px; padding: 0 12px; color: #676F88; font: 400 12px/1.5 var(--ds-font-sans); white-space: nowrap; }
1391
+ .ds-wroute-zone > strong { color: #11278F; font-weight: 500; }
1392
+ .ds-wroute-price { padding: 0 12px; color: var(--ds-text-primary); font: 500 12px/1.5 var(--ds-font-sans); white-space: nowrap; }
1393
+ .dark .ds-wroute-zone > strong, [data-theme="dark"] .ds-wroute-zone > strong { color: #A9C1F7; }
1394
+ .ds-wroute-stop-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding-left: 32px; }
1395
+ .ds-wroute-stop-extra > .ds-wroute-input { flex: 1 1 200px; }
1396
+ .ds-wroute-stop-box .ds-wroute-passenger { margin-left: 32px; background: #E3E7F1; }
1397
+
1398
+ /* Agregar destino y peajes */
1399
+ .ds-wroute-add { align-self: flex-start; margin-left: 32px; }
1400
+ .ds-wroute-tolls { display: flex; flex-direction: column; gap: 8px; width: min(331px, 100%); margin-left: 40px; padding: 8px 12px; border-radius: 8px; background: #F2F4FA; }
1401
+ .dark .ds-wroute-tolls, [data-theme="dark"] .ds-wroute-tolls { background: var(--ds-bg-secondary); }
1402
+ .ds-wroute-toll { display: flex; align-items: center; gap: 12px; color: var(--ds-text-secondary, #474D59); font: 400 14px/1.5 var(--ds-font-sans); }
1403
+ .ds-wroute-toll > label { width: 56px; flex: none; }
1404
+ .ds-wroute-toll > input.ds-wroute-input { flex: 1; height: 32px; padding: 0 8px; border: 1px solid #DADBDE; border-radius: 8px; background: var(--ds-bg-primary); }
1405
+ .ds-wroute-toll > .ds-wroute-clear { width: 24px; height: 24px; }
1406
+ .ds-wroute-toll-add { align-self: flex-start; }
1407
+
1408
+ /* Invertir: cargando y éxito */
1409
+ .ds-wroute-status { display: flex; flex-direction: column; gap: 8px; color: #2F6BF2; font: 400 14px/1.5 var(--ds-font-sans); }
1410
+ .ds-wroute-success {
1411
+ margin: 0 16px 0 40px; padding: 8px 16px; border-radius: 8px; color: #166534; background: #DCFCE7; box-shadow: 0 8px 36px rgb(0 0 0 / .17);
1412
+ font: 400 12px/1.5 var(--ds-font-sans);
1413
+ }
1414
+ .dark .ds-wroute-success, [data-theme="dark"] .ds-wroute-success { color: #A7F3C4; background: rgb(22 101 52 / .35); }
1415
+ /* Párrafos y listas propias: ignoran estilos de texto de la página (`.prose p`, `.prose ul`…). */
1416
+ .ds-wroute .ds-wroute-info, .ds-wroute .ds-wroute-success { margin-top: 0; margin-bottom: 0; }
1417
+ .ds-wroute .ds-wroute-stops { margin: 0; padding-left: 0; }
1418
+ .ds-wroute .ds-wroute-stops > li { margin: 0; }
1419
+ @media (max-width: 560px) {
1420
+ .ds-wroute-passenger-block, .ds-wroute-tolls { margin-left: 0; padding-left: 0; }
1421
+ .ds-wroute-passenger { flex-wrap: wrap; }
1422
+ .ds-wroute .ds-wcard-header { flex-wrap: wrap; }
1423
+ }
1424
+ .dark .ds-wroute-stop-main, [data-theme="dark"] .ds-wroute-stop-main { border-bottom-color: var(--ds-border-primary); }
1425
+ .dark .ds-wroute-toll > input.ds-wroute-input, [data-theme="dark"] .ds-wroute-toll > input.ds-wroute-input { border-color: var(--ds-border-primary); }
1426
+ .ds-wroute :is(.ds-wroute-add, .ds-wroute-toll-add) > svg path { stroke: var(--ds-bg-primary, #fff); }
1427
+
1428
+ /* Wari Rutas: movimiento (deslizar al reordenar, aparecer y desvanecer lo hacen motion.ts; aquí los estados) */
1429
+ .ds-wroute-stop-box { transition: background-color var(--ds-duration-fast, .15s) ease, box-shadow .2s ease, transform .2s ease; }
1430
+ .ds-wroute-stop:hover > .ds-wroute-stop-box { background: #ECEFF7; }
1431
+ .ds-wroute-stop:focus-within > .ds-wroute-stop-box { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ds-bg-brand-primary) 45%, transparent); }
1432
+ .dark .ds-wroute-stop:hover > .ds-wroute-stop-box, [data-theme="dark"] .ds-wroute-stop:hover > .ds-wroute-stop-box { background: var(--ds-bg-tertiary); }
1433
+ .ds-wroute-stop[data-dragging="true"] { opacity: 1; }
1434
+ .ds-wroute-stop[data-dragging="true"] > .ds-wroute-stop-box { opacity: .55; transform: scale(.985); box-shadow: 0 0 0 1px var(--ds-bg-brand-primary); }
1435
+ .ds-wroute-stop[data-drop="true"] > .ds-wroute-stop-box { box-shadow: 0 -3px 0 var(--ds-bg-brand-primary); transform: translateY(3px); }
1436
+ .ds-wroute-handle { transition: background-color .15s ease, transform .15s ease; }
1437
+ .ds-wroute-handle:hover { background: color-mix(in srgb, var(--ds-bg-brand-primary) 10%, transparent); }
1438
+ .ds-wroute-remove, .ds-wroute-clear { transition: background-color .15s ease, color .15s ease, transform .15s ease; }
1439
+ .ds-wroute-remove:hover { color: #C2410C; }
1440
+ .ds-wroute :is(.ds-wroute-pill, .ds-wroute-link, .ds-wroute-add, .ds-wroute-toll-add, .ds-wroute-stop-passenger, .ds-wroute-handle, .ds-wroute-remove, .ds-wroute-clear) { transition-property: background-color, color, transform; transition-duration: .15s; }
1441
+ .ds-wroute :is(.ds-wroute-pill, .ds-wroute-link, .ds-wroute-add, .ds-wroute-toll-add, .ds-wroute-stop-passenger, .ds-wroute-remove, .ds-wroute-clear):active:not(:disabled) { transform: scale(.95); }
1442
+ .ds-wroute-link > svg { transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
1443
+ .ds-wroute-link:hover:not(:disabled) > svg { transform: rotate(180deg); }
1444
+ .ds-wroute :is(.ds-wroute-add, .ds-wroute-toll-add) > svg { transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
1445
+ .ds-wroute :is(.ds-wroute-add, .ds-wroute-toll-add):hover:not(:disabled) > svg { transform: rotate(90deg); }
1446
+ .ds-wroute input.ds-wroute-input { transition: background-color .15s ease, box-shadow .15s ease; }
1447
+ .ds-wroute .ds-wroute-toll > input.ds-wroute-input { transition: border-color .15s ease, box-shadow .15s ease; }
1448
+ .ds-wroute .ds-wroute-toll > input.ds-wroute-input:focus { border-color: var(--ds-bg-brand-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-bg-brand-primary) 18%, transparent); outline: none; }
1449
+ .ds-wroute-status { animation: ds-wroute-fade .25s ease both; }
1450
+ .ds-wroute-success { animation: ds-wroute-toast 3s cubic-bezier(.2, .8, .2, 1) both; }
1451
+ @keyframes ds-wroute-fade { from { opacity: 0; } to { opacity: 1; } }
1452
+ @keyframes ds-wroute-toast {
1453
+ 0% { opacity: 0; transform: translateY(-8px) scale(.97); }
1454
+ 8%, 88% { opacity: 1; transform: none; }
1455
+ 100% { opacity: 0; transform: translateY(-4px); }
1456
+ }
1457
+ @media (prefers-reduced-motion: reduce) {
1458
+ .ds-wroute *, .ds-wroute *::before, .ds-wroute *::after { transition: none !important; animation-duration: .01ms !important; }
1459
+ .ds-wroute-success { animation: none; }
1460
+ }
1461
+
1462
+ /* Pasajero (WariPassengerField): nombre y número en una fila gris, ⓧ para vaciarla y barra de carga debajo. */
1463
+ .ds-wpassenger {
1464
+ display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 4px; border-radius: 8px;
1465
+ color: #676F88; background: #E3E7F1; font-family: var(--ds-font-sans);
1466
+ }
1467
+ .ds-wpassenger-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
1468
+ .ds-wpassenger-field { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; padding: 4px 8px; border-radius: 8px; cursor: text; }
1469
+ .ds-wpassenger-field > svg { flex: none; width: 16px; height: 16px; margin: 4px; }
1470
+ .ds-wpassenger input.ds-wpassenger-input {
1471
+ flex: 1; min-width: 0; height: 24px; margin: 0; padding: 0; border: 0; outline: none; color: #474D59; background: transparent;
1472
+ caret-color: var(--ds-bg-brand-primary, #0A50E6); font: 400 12px/1.5 var(--ds-font-sans); letter-spacing: -.5px; text-overflow: ellipsis;
1473
+ }
1474
+ .ds-wpassenger input.ds-wpassenger-input::placeholder { color: #676F88; opacity: 1; }
1475
+ .ds-wpassenger-field:focus-within { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ds-bg-brand-primary, #0A50E6) 35%, transparent); }
1476
+ .ds-wpassenger-field:has(input:focus-visible) { box-shadow: inset 0 0 0 2px var(--ds-bg-brand-primary, #0A50E6); }
1477
+ .ds-wpassenger-clear {
1478
+ display: inline-flex; flex: none; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0;
1479
+ border-radius: 8px; color: #676F88; background: transparent; cursor: pointer; transition: background-color .15s ease, color .15s ease, transform .15s ease;
1480
+ }
1481
+ .ds-wpassenger-clear > svg { width: 16px; height: 16px; }
1482
+ .ds-wpassenger-clear:hover:not(:disabled) { color: #474D59; background: rgb(0 0 0 / .06); }
1483
+ .ds-wpassenger-clear:active:not(:disabled) { transform: scale(.92); }
1484
+ .ds-wpassenger-clear:focus-visible { outline: 2px solid var(--ds-bg-brand-primary, #0A50E6); outline-offset: 1px; }
1485
+ .ds-wpassenger :disabled { opacity: .5; cursor: not-allowed; }
1486
+ .ds-wpassenger-progress { animation: ds-wroute-fade .2s ease both; }
1487
+ .ds-wpassenger-progress[data-ds-progress] { display: none; }
1488
+ .ds-wpassenger[aria-busy="true"] .ds-wpassenger-progress[data-ds-progress] { display: block; }
1489
+ .ds-wpassenger-field > svg[hidden] { display: none; }
1490
+ @media (max-width: 480px) { .ds-wpassenger-row { flex-wrap: wrap; } .ds-wpassenger-field { flex-basis: calc(100% - 42px); } }
1491
+ .dark .ds-wpassenger, [data-theme="dark"] .ds-wpassenger { color: var(--ds-text-secondary); background: var(--ds-bg-tertiary, #2A2F3A); }
1492
+ .dark .ds-wpassenger input.ds-wpassenger-input, [data-theme="dark"] .ds-wpassenger input.ds-wpassenger-input { color: var(--ds-text-primary); }
1493
+ .dark .ds-wpassenger input.ds-wpassenger-input::placeholder, [data-theme="dark"] .ds-wpassenger input.ds-wpassenger-input::placeholder { color: var(--ds-text-tertiary, #8A92A6); }
1494
+ .dark .ds-wpassenger-clear, [data-theme="dark"] .ds-wpassenger-clear { color: var(--ds-text-secondary); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directo-ui/astro",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Componentes Astro del sistema de diseño Directo (HTML semántico, sin framework en el cliente)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -24,6 +24,10 @@
24
24
  "types": "./src/wari/trip-client.d.ts",
25
25
  "default": "./src/wari/trip-client.js"
26
26
  },
27
+ "./wari/route": {
28
+ "types": "./src/wari/route-client.d.ts",
29
+ "default": "./src/wari/route-client.js"
30
+ },
27
31
  "./toast": {
28
32
  "types": "./src/toast.d.ts",
29
33
  "default": "./src/toast.js"
@@ -57,15 +61,15 @@
57
61
  "design-system",
58
62
  "directo"
59
63
  ],
60
- "scripts": {
61
- "build": "node ../../tokens/scripts/build-tokens.js && node ../../scripts/stage-astro-assets.mjs",
62
- "pack:dist": "corepack pnpm build && corepack pnpm pack --pack-destination ../../artifacts"
63
- },
64
64
  "peerDependencies": {
65
65
  "astro": ">=4.0.0"
66
66
  },
67
67
  "sideEffects": [
68
68
  "**/*.css"
69
69
  ],
70
- "license": "UNLICENSED"
71
- }
70
+ "license": "UNLICENSED",
71
+ "scripts": {
72
+ "build": "node ../../tokens/scripts/build-tokens.js && node ../../scripts/stage-astro-assets.mjs",
73
+ "pack:dist": "corepack pnpm build && corepack pnpm pack --pack-destination ../../artifacts"
74
+ }
75
+ }
@@ -0,0 +1,87 @@
1
+ ---
2
+ interface Props {
3
+ /** Nombre del cliente; se recorta con "…" y el texto completo queda en `title`. */
4
+ name: string;
5
+ company?: string;
6
+ /** Teléfono: se muestra como enlace `tel:`. */
7
+ phone?: string;
8
+ /** Cliente VIP: franja amarilla. vip={false}: franja celeste ("sin VIP" en Figma). */
9
+ vip?: boolean;
10
+ /** Color de la ficha a mano; si no se indica, lo decide `vip` (por defecto amarillo). */
11
+ tone?: 'warning' | 'info' | 'neutral';
12
+ showRates?: boolean;
13
+ showInfo?: boolean;
14
+ showEdit?: boolean;
15
+ ratesLabel?: string;
16
+ infoLabel?: string;
17
+ editLabel?: string;
18
+ /** Observaciones de solo lectura. */
19
+ notes?: string;
20
+ notesLabel?: string;
21
+ notesHint?: string;
22
+ disabled?: boolean;
23
+ class?: string;
24
+ }
25
+
26
+ const {
27
+ name, company, phone, vip, tone, showRates = true, showInfo = true, showEdit = true, ratesLabel = 'Tarifas',
28
+ infoLabel = 'Ver información del cliente', editLabel = 'Editar cliente', notes, notesLabel = 'Observaciones del cliente',
29
+ notesHint = '(no editable)', disabled = false, class: className,
30
+ } = Astro.props;
31
+ const hasFields = Astro.slots.has('default');
32
+ const bannerTone = tone ?? (vip === false ? 'info' : 'warning');
33
+ ---
34
+ <div class:list={['ds-wclient-details', className]} data-ds-wclient-details>
35
+ <div class="ds-wclient-summary">
36
+ <div class="ds-wclient-banner" data-tone={bannerTone}>
37
+ <p class="ds-wclient-name" title={name}>{name}</p>
38
+ {company && <span class="ds-wclient-company" title={company}>{company}</span>}
39
+ {phone && (
40
+ <a class="ds-wclient-phone" href={`tel:${phone.replace(/[^\d+]/g, '')}`}>
41
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 3.5h3.2l1.6 4-2 1.3a10.5 10.5 0 0 0 5.4 5.4l1.3-2 4 1.6V17a2 2 0 0 1-2 2A15.5 15.5 0 0 1 3 5.5a2 2 0 0 1 2-2Z"/></svg>{phone}
42
+ </a>
43
+ )}
44
+ </div>
45
+ {(showRates || showInfo || showEdit) && (
46
+ <div class="ds-wclient-actions">
47
+ {showRates && <button type="button" class="ds-wclient-rates" data-ds-action="rates" disabled={disabled}>{ratesLabel}</button>}
48
+ {(showInfo || showEdit) && (
49
+ <div>
50
+ {showInfo && (
51
+ <button type="button" class="ds-wclient-icon" data-ds-action="info" aria-label={infoLabel} title={infoLabel} disabled={disabled}>
52
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="12" r="9" fill="currentColor" stroke="none"/><path d="M12 11v5.5M12 7.6v.1" stroke="#fff" stroke-width="2.4"/></svg>
53
+ </button>
54
+ )}
55
+ {showEdit && (
56
+ <button type="button" class="ds-wclient-icon" data-ds-action="edit" aria-label={editLabel} title={editLabel} disabled={disabled}>
57
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M4 20h4.5L19 9.5 14.5 5 4 15.5z" fill="currentColor" stroke="none"/><path d="M13 20h7"/></svg>
58
+ </button>
59
+ )}
60
+ </div>
61
+ )}
62
+ </div>
63
+ )}
64
+ </div>
65
+ {hasFields && <div class="ds-wclient-fields"><slot /></div>}
66
+ {notes != null && (
67
+ <div class="ds-wclient-notes">
68
+ <span>{notesLabel} <em>{notesHint}</em></span>
69
+ <p>{notes}</p>
70
+ </div>
71
+ )}
72
+ </div>
73
+
74
+ <script>
75
+ // Emits on the details element: "ds-rates", "ds-info" and "ds-edit".
76
+ function initClientDetails() {
77
+ document.querySelectorAll<HTMLElement>('[data-ds-wclient-details]:not([data-ds-ready])').forEach(root => {
78
+ root.dataset.dsReady = '';
79
+ root.addEventListener('click', event => {
80
+ const action = (event.target as Element).closest<HTMLElement>('[data-ds-action]')?.dataset.dsAction;
81
+ if (action) root.dispatchEvent(new CustomEvent(`ds-${action}`, { bubbles: true }));
82
+ });
83
+ });
84
+ }
85
+ initClientDetails();
86
+ document.addEventListener('astro:page-load', initClientDetails);
87
+ </script>
@@ -0,0 +1,88 @@
1
+ ---
2
+ interface Props {
3
+ title?: string;
4
+ headingLevel?: 2 | 3 | 4;
5
+ /** Texto inicial del buscador. */
6
+ value?: string;
7
+ /** Muestra "Crear usuario" como botón (emite `ds-create`). */
8
+ showCreate?: boolean;
9
+ /** Convierte "Crear usuario" en un enlace. */
10
+ createHref?: string;
11
+ createLabel?: string;
12
+ placeholder?: string;
13
+ searchLabel?: string;
14
+ /** Nombre del campo (por defecto "q"). */
15
+ name?: string;
16
+ /** Si se indica, el formulario se envía de forma nativa a esa URL (GET). */
17
+ action?: string;
18
+ /** Barra de carga al cargar la página. En el cliente, activa o quita `aria-busy="true"` en la tarjeta. */
19
+ loading?: boolean;
20
+ loadingLabel?: string;
21
+ /** "auto" (por defecto): "Crear usuario" solo con el buscador vacío y sin cargar, como en Figma. */
22
+ createMode?: 'auto' | 'always' | 'never';
23
+ /** Oculta el buscador (estado bloqueado: solo se ven los datos del cliente). */
24
+ showSearch?: boolean;
25
+ hoverable?: boolean;
26
+ disabled?: boolean;
27
+ class?: string;
28
+ }
29
+
30
+ const {
31
+ title = 'Cliente / usuario', headingLevel = 3, value = '', showCreate = true, createHref, createLabel = 'Crear usuario',
32
+ placeholder = 'Puedes filtrar por nombre o número', searchLabel = 'Buscar cliente por nombre o número', name = 'q', action,
33
+ hoverable = true, disabled = false, loading = false, loadingLabel = 'Buscando cliente…', createMode = 'auto', showSearch = true,
34
+ class: className,
35
+ } = Astro.props;
36
+ const createHidden = createMode === 'never' || (createMode === 'auto' && (value.trim() !== '' || loading));
37
+ const id = `ds-wclient-${Math.random().toString(36).slice(2, 9)}`;
38
+ const Heading = `h${headingLevel}`;
39
+ const plus = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M12 4v16M4 12h16"/></svg>';
40
+ ---
41
+ <section class:list={['ds-wcard', 'ds-wclient', className]} aria-labelledby={`${id}-title`} data-hover={hoverable ? 'lift' : undefined}
42
+ aria-busy={loading ? 'true' : undefined} data-create={createMode} data-ds-wclient>
43
+ <header class="ds-wcard-header">
44
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3.5" y="3.5" width="17" height="17" rx="2.5"/><circle cx="12" cy="10" r="3"/><path d="M6.5 20c.9-2.7 3-4 5.5-4s4.6 1.3 5.5 4"/></svg>
45
+ <Heading id={`${id}-title`} class="ds-wcard-title" title={title}>{title}</Heading>
46
+ {createHref
47
+ ? <a class="ds-wcard-action" href={createHref} data-ds-create hidden={createHidden}><Fragment set:html={plus} />{createLabel}</a>
48
+ : showCreate && <button type="button" class="ds-wcard-action" data-ds-create hidden={createHidden} disabled={disabled}><Fragment set:html={plus} />{createLabel}</button>}
49
+ </header>
50
+ {showSearch && <form role="search" class="ds-input ds-wsearch" action={action} data-native={action ? 'true' : undefined}>
51
+ <label for={id} class="ds-wvisually-hidden">{searchLabel}</label>
52
+ <div class="ds-input-shell">
53
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><circle cx="10.5" cy="10.5" r="6.5"/><path d="m20 20-4.8-4.8"/></svg>
54
+ <input id={id} type="search" name={name} value={value} placeholder={placeholder} autocomplete="off" enterkeyhint="search" disabled={disabled} />
55
+ </div>
56
+ </form>}
57
+ <div class="ds-wclient-progress" role="progressbar" aria-label={loadingLabel} data-ds-progress></div>
58
+ <div class="ds-wclient-results"><slot /></div>
59
+ </section>
60
+
61
+ <script>
62
+ // Emits on the card: "ds-change" (texto en cada tecla), "ds-search" (Enter) and "ds-create" (botón).
63
+ function initClientSearch() {
64
+ document.querySelectorAll<HTMLElement>('[data-ds-wclient]:not([data-ds-ready])').forEach(root => {
65
+ root.dataset.dsReady = '';
66
+ const form = root.querySelector<HTMLFormElement>('form');
67
+ const input = form?.querySelector<HTMLInputElement>('input');
68
+ const create = root.querySelector<HTMLElement>('[data-ds-create]');
69
+ const emit = (type: string, detail?: string) => root.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));
70
+ // "Crear usuario": data-create="auto" lo oculta al escribir o mientras carga; "never" / "always" lo fuerzan.
71
+ // Puedes cambiar data-create o aria-busy desde tu código y el botón se actualiza solo.
72
+ const syncCreate = () => {
73
+ if (!create) return;
74
+ const mode = root.dataset.create;
75
+ create.hidden = mode === 'never' || (mode === 'auto' && (Boolean(input?.value.trim()) || root.getAttribute('aria-busy') === 'true'));
76
+ };
77
+ new MutationObserver(syncCreate).observe(root, { attributes: true, attributeFilter: ['aria-busy', 'data-create'] });
78
+ input?.addEventListener('input', () => { syncCreate(); emit('ds-change', input.value); });
79
+ form?.addEventListener('submit', event => {
80
+ if (!form.dataset.native) event.preventDefault();
81
+ emit('ds-search', input?.value.trim() ?? '');
82
+ });
83
+ create?.addEventListener('click', () => emit('ds-create'));
84
+ });
85
+ }
86
+ initClientSearch();
87
+ document.addEventListener('astro:page-load', initClientSearch);
88
+ </script>