@wirecore/wirelayer-recipes 0.8.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/avatar.d.ts.map +1 -1
  2. package/dist/avatar.js +2 -1
  3. package/dist/avatar.js.map +1 -1
  4. package/dist/button.d.ts.map +1 -1
  5. package/dist/button.js +18 -13
  6. package/dist/button.js.map +1 -1
  7. package/dist/i18n.d.ts +4 -0
  8. package/dist/i18n.d.ts.map +1 -1
  9. package/dist/i18n.js +4 -0
  10. package/dist/i18n.js.map +1 -1
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/locales/ar.d.ts.map +1 -1
  16. package/dist/locales/ar.js +4 -0
  17. package/dist/locales/ar.js.map +1 -1
  18. package/dist/locales/cs.d.ts.map +1 -1
  19. package/dist/locales/cs.js +4 -0
  20. package/dist/locales/cs.js.map +1 -1
  21. package/dist/locales/de.d.ts +4 -0
  22. package/dist/locales/de.d.ts.map +1 -1
  23. package/dist/locales/de.js +4 -0
  24. package/dist/locales/de.js.map +1 -1
  25. package/dist/locales/es.d.ts.map +1 -1
  26. package/dist/locales/es.js +4 -0
  27. package/dist/locales/es.js.map +1 -1
  28. package/dist/locales/fr.d.ts.map +1 -1
  29. package/dist/locales/fr.js +4 -0
  30. package/dist/locales/fr.js.map +1 -1
  31. package/dist/locales/hu.d.ts.map +1 -1
  32. package/dist/locales/hu.js +4 -0
  33. package/dist/locales/hu.js.map +1 -1
  34. package/dist/locales/it.d.ts.map +1 -1
  35. package/dist/locales/it.js +4 -0
  36. package/dist/locales/it.js.map +1 -1
  37. package/dist/locales/lv.d.ts.map +1 -1
  38. package/dist/locales/lv.js +4 -0
  39. package/dist/locales/lv.js.map +1 -1
  40. package/dist/locales/nl.d.ts.map +1 -1
  41. package/dist/locales/nl.js +4 -0
  42. package/dist/locales/nl.js.map +1 -1
  43. package/dist/locales/pl.d.ts.map +1 -1
  44. package/dist/locales/pl.js +4 -0
  45. package/dist/locales/pl.js.map +1 -1
  46. package/dist/locales/pt-BR.d.ts.map +1 -1
  47. package/dist/locales/pt-BR.js +1 -0
  48. package/dist/locales/pt-BR.js.map +1 -1
  49. package/dist/locales/pt.d.ts.map +1 -1
  50. package/dist/locales/pt.js +4 -0
  51. package/dist/locales/pt.js.map +1 -1
  52. package/dist/locales/tr.d.ts.map +1 -1
  53. package/dist/locales/tr.js +4 -0
  54. package/dist/locales/tr.js.map +1 -1
  55. package/dist/native/index.d.ts +1 -0
  56. package/dist/native/index.d.ts.map +1 -1
  57. package/dist/native/index.js +1 -0
  58. package/dist/native/index.js.map +1 -1
  59. package/dist/primitives.d.ts +16 -13
  60. package/dist/primitives.d.ts.map +1 -1
  61. package/dist/primitives.js +8 -5
  62. package/dist/primitives.js.map +1 -1
  63. package/dist/shell.d.ts +6 -0
  64. package/dist/shell.d.ts.map +1 -1
  65. package/dist/shell.js +2 -0
  66. package/dist/shell.js.map +1 -1
  67. package/dist/sortable.d.ts +7 -0
  68. package/dist/sortable.d.ts.map +1 -1
  69. package/dist/sortable.js +76 -17
  70. package/dist/sortable.js.map +1 -1
  71. package/dist/sources/affix.css +1 -1
  72. package/dist/sources/avatar.css +1 -1
  73. package/dist/sources/button.css +1 -1
  74. package/dist/sources/iconButton.css +1 -1
  75. package/dist/sources/notificationCenter.css +1 -1
  76. package/dist/tour-steps.d.ts +21 -0
  77. package/dist/tour-steps.d.ts.map +1 -0
  78. package/dist/tour-steps.js +41 -0
  79. package/dist/tour-steps.js.map +1 -0
  80. package/package.json +1 -1
  81. package/src/avatar.ts +2 -1
  82. package/src/button.ts +19 -13
  83. package/src/i18n.ts +5 -0
  84. package/src/index.ts +1 -0
  85. package/src/locales/ar.ts +5 -0
  86. package/src/locales/cs.ts +5 -0
  87. package/src/locales/de.ts +5 -0
  88. package/src/locales/es.ts +5 -0
  89. package/src/locales/fr.ts +5 -0
  90. package/src/locales/hu.ts +5 -0
  91. package/src/locales/it.ts +5 -0
  92. package/src/locales/lv.ts +5 -0
  93. package/src/locales/nl.ts +5 -0
  94. package/src/locales/pl.ts +5 -0
  95. package/src/locales/pt-BR.ts +2 -0
  96. package/src/locales/pt.ts +5 -0
  97. package/src/locales/tr.ts +5 -0
  98. package/src/native/index.ts +1 -0
  99. package/src/primitives.ts +12 -5
  100. package/src/shell.ts +2 -0
  101. package/src/sortable.ts +78 -17
  102. package/src/tour-steps.ts +52 -0
package/src/button.ts CHANGED
@@ -32,8 +32,14 @@ export type ButtonColorKey = `color${Capitalize<ButtonColor>}`;
32
32
  export const buttonColorKey = (color: ButtonColor | undefined): ButtonColorKey | undefined =>
33
33
  color && (`color${color[0]!.toUpperCase()}${color.slice(1)}` as ButtonColorKey);
34
34
 
35
+ /**
36
+ * Hover of solid primary buttons: the theme's `primary-hover`, else the fill fades to 85 % like the other solid
37
+ * variants (the text stays opaque). The token contrast test checks both.
38
+ */
39
+ const primaryHoverFill = 'hover:bg-[var(--wc-primary-hover,color-mix(in_srgb,var(--wc-primary)_85%,transparent))]';
40
+
35
41
  const colors: Record<IconButtonVariant, string> = {
36
- primary: 'bg-primary text-on-primary hover:opacity-85',
42
+ primary: `bg-primary text-on-primary ${primaryHoverFill}`,
37
43
  secondary: 'bg-line text-fg hover:bg-line-2',
38
44
  success: 'bg-success text-on-success hover:opacity-85',
39
45
  // Info and warn fade less on hover: at 85 % their text would drop below 4.5:1 (see the token contrast test)
@@ -42,8 +48,8 @@ const colors: Record<IconButtonVariant, string> = {
42
48
  danger: 'bg-danger text-on-danger hover:opacity-85',
43
49
  outline: 'border border-line-2 text-fg hover:border-fg',
44
50
  text: 'text-fg hover:bg-line',
45
- /** Tinted background in the primary colour (or the `color`) */
46
- soft: 'bg-primary/10 text-primary hover:bg-primary/14',
51
+ /** Tinted background in the primary colour (or the `color`); on hover the text takes `primary-hover` */
52
+ soft: 'bg-primary/10 text-primary hover:bg-primary/14 hover:text-primary-hover',
47
53
  /** On inverted (fg) surfaces, e.g. the CTA section */
48
54
  inverted: 'bg-bg text-fg hover:opacity-85',
49
55
  };
@@ -57,52 +63,52 @@ const colorStyles: Record<
57
63
  { filled: string; outline: string; text: string; soft: string; link: string }
58
64
  > = {
59
65
  colorPrimary: {
60
- filled: 'bg-primary text-on-primary hover:bg-primary hover:opacity-85',
61
- outline: 'border-primary text-primary hover:border-primary hover:bg-primary/8',
62
- text: 'text-primary hover:bg-primary/8',
63
- soft: 'bg-primary/10 text-primary hover:bg-primary/14',
66
+ filled: `bg-primary text-on-primary ${primaryHoverFill} hover:opacity-100`,
67
+ outline: 'border-primary text-primary hover:border-primary hover:bg-primary/8 hover:text-primary-hover',
68
+ text: 'text-primary hover:bg-primary/8 hover:text-primary-hover',
69
+ soft: 'bg-primary/10 text-primary hover:bg-primary/14 hover:text-primary-hover',
64
70
  link: 'text-primary',
65
71
  },
66
72
  colorSecondary: {
67
73
  filled: 'bg-line text-fg hover:bg-line-2 hover:opacity-100',
68
74
  outline: 'border-line-2 text-muted hover:border-fg hover:text-fg',
69
75
  text: 'text-muted hover:bg-line hover:text-fg',
70
- soft: 'bg-line text-fg hover:bg-line-2',
76
+ soft: 'bg-line text-fg hover:bg-line-2 hover:text-fg',
71
77
  link: 'text-muted hover:text-fg',
72
78
  },
73
79
  colorSuccess: {
74
80
  filled: 'bg-success text-on-success hover:bg-success hover:opacity-85',
75
81
  outline: 'border-success text-success hover:border-success hover:bg-success/8',
76
82
  text: 'text-success hover:bg-success/8',
77
- soft: 'bg-success/10 text-success hover:bg-success/14',
83
+ soft: 'bg-success/10 text-success hover:bg-success/14 hover:text-success',
78
84
  link: 'text-success',
79
85
  },
80
86
  colorInfo: {
81
87
  filled: 'bg-info text-on-info hover:bg-info hover:opacity-90',
82
88
  outline: 'border-info text-info hover:border-info hover:bg-info/8',
83
89
  text: 'text-info hover:bg-info/8',
84
- soft: 'bg-info/10 text-info hover:bg-info/14',
90
+ soft: 'bg-info/10 text-info hover:bg-info/14 hover:text-info',
85
91
  link: 'text-info',
86
92
  },
87
93
  colorWarn: {
88
94
  filled: 'bg-warn text-on-warn hover:bg-warn hover:opacity-90',
89
95
  outline: 'border-warn text-warn hover:border-warn hover:bg-warn/8',
90
96
  text: 'text-warn hover:bg-warn/8',
91
- soft: 'bg-warn/10 text-warn hover:bg-warn/14',
97
+ soft: 'bg-warn/10 text-warn hover:bg-warn/14 hover:text-warn',
92
98
  link: 'text-warn',
93
99
  },
94
100
  colorDanger: {
95
101
  filled: 'bg-danger text-on-danger hover:bg-danger hover:opacity-85',
96
102
  outline: 'border-danger text-danger hover:border-danger hover:bg-danger/8',
97
103
  text: 'text-danger hover:bg-danger/8',
98
- soft: 'bg-danger/10 text-danger hover:bg-danger/14',
104
+ soft: 'bg-danger/10 text-danger hover:bg-danger/14 hover:text-danger',
99
105
  link: 'text-danger',
100
106
  },
101
107
  colorContrast: {
102
108
  filled: 'bg-fg text-bg hover:bg-fg hover:opacity-85',
103
109
  outline: 'border-fg text-fg hover:border-fg hover:bg-line',
104
110
  text: 'text-fg hover:bg-line',
105
- soft: 'bg-fg/10 text-fg hover:bg-fg/14',
111
+ soft: 'bg-fg/10 text-fg hover:bg-fg/14 hover:text-fg',
106
112
  link: 'text-fg',
107
113
  },
108
114
  };
package/src/i18n.ts CHANGED
@@ -1073,6 +1073,11 @@ const en: Translations = {
1073
1073
  movedTo: (item, container, position, count) => `${item} in ${container}, position ${position} of ${count}.`,
1074
1074
  dropped: (item, position, count) => `${item} dropped, position ${position} of ${count}.`,
1075
1075
  cancelled: (item, position, count) => `Move cancelled. ${item} back at position ${position} of ${count}.`,
1076
+ copyHandle: (item) => `Copy ${item}`,
1077
+ copyInstructions:
1078
+ 'Press Space or Enter to pick up a copy. Then move it into a list with the arrow keys, press Space to drop or Escape to cancel. With a mouse: drag, or click and click again at the target.',
1079
+ copyCancelled: (item) => `Copy of ${item} cancelled.`,
1080
+ copyTo: (list) => `Copy to “${list}”`,
1076
1081
  },
1077
1082
  logViewer: {
1078
1083
  label: 'Log',
package/src/index.ts CHANGED
@@ -1039,6 +1039,7 @@ export {
1039
1039
  type SortableState,
1040
1040
  type SortableTexts,
1041
1041
  } from './sortable.js';
1042
+ export { prepareTourStep, tourSkipTarget, type TourStepPreparation } from './tour-steps.js';
1042
1043
  export {
1043
1044
  insertMention,
1044
1045
  mentionQuery,
package/src/locales/ar.ts CHANGED
@@ -1399,6 +1399,11 @@ export const ar: Translations = {
1399
1399
  movedTo: (item, container, position, count) => `${item} في ${container}، الموضع ${position} من ${count}.`,
1400
1400
  dropped: (item, position, count) => `تم إفلات ${item}، الموضع ${position} من ${count}.`,
1401
1401
  cancelled: (item, position, count) => `تم إلغاء النقل. عاد ${item} إلى الموضع ${position} من ${count}.`,
1402
+ copyHandle: (item) => `نسخ ${item}`,
1403
+ copyInstructions:
1404
+ 'اضغط مفتاح المسافة أو Enter لالتقاط نسخة، ثم انقلها إلى قائمة بمفاتيح الأسهم، واضغط مفتاح المسافة لإفلاتها أو Esc للإلغاء. باستخدام الماوس: اسحب العنصر، أو انقر عليه ثم انقر مرة أخرى في الموضع المطلوب.',
1405
+ copyCancelled: (item) => `تم إلغاء نسخ ${item}.`,
1406
+ copyTo: (list) => `نسخ إلى «${list}»`,
1402
1407
  },
1403
1408
  logViewer: {
1404
1409
  label: 'السجل',
package/src/locales/cs.ts CHANGED
@@ -1230,6 +1230,11 @@ export const cs: Translations = {
1230
1230
  movedTo: (item, container, position, count) => `${item}: ${container}, pozice ${position} z ${count}.`,
1231
1231
  dropped: (item, position, count) => `${item}: umístěno, pozice ${position} z ${count}.`,
1232
1232
  cancelled: (item, position, count) => `Přesun zrušen. ${item} je zpět na pozici ${position} z ${count}.`,
1233
+ copyHandle: (item) => `Kopírovat ${item}`,
1234
+ copyInstructions:
1235
+ 'Mezerníkem nebo Enterem uchopíte kopii. Pak ji šipkami přesuňte do seznamu a mezerníkem umístěte, nebo klávesou Esc akci zrušte. Myší: přetáhněte, nebo klikněte a znovu klikněte na cílovém místě.',
1236
+ copyCancelled: (item) => `Kopírování položky ${item} zrušeno.`,
1237
+ copyTo: (list) => `Kopírovat do „${list}“`,
1233
1238
  },
1234
1239
  logViewer: {
1235
1240
  label: 'Protokol',
package/src/locales/de.ts CHANGED
@@ -1680,6 +1680,11 @@ export const de = {
1680
1680
  `${item} abgelegt, Position ${position} von ${count}.`,
1681
1681
  cancelled: (item: string, position: number, count: number) =>
1682
1682
  `Verschieben abgebrochen. ${item} wieder an Position ${position} von ${count}.`,
1683
+ copyHandle: (item: string) => `${item} kopieren`,
1684
+ copyInstructions:
1685
+ 'Leertaste oder Eingabetaste nimmt eine Kopie auf. Dann mit den Pfeiltasten in eine Liste verschieben, mit Leertaste ablegen oder mit Escape abbrechen. Mit der Maus: ziehen, oder klicken und an der Zielstelle erneut klicken.',
1686
+ copyCancelled: (item: string) => `Kopieren von ${item} abgebrochen.`,
1687
+ copyTo: (list: string) => `Nach „${list}“ kopieren`,
1683
1688
  },
1684
1689
  logViewer: {
1685
1690
  label: 'Protokoll',
package/src/locales/es.ts CHANGED
@@ -1114,6 +1114,11 @@ export const es: Translations = {
1114
1114
  dropped: (item, position, count) => `Se ha soltado ${item}, posición ${position} de ${count}.`,
1115
1115
  cancelled: (item, position, count) =>
1116
1116
  `Movimiento cancelado. ${item} vuelve a la posición ${position} de ${count}.`,
1117
+ copyHandle: (item) => `Copiar ${item}`,
1118
+ copyInstructions:
1119
+ 'Presione Espacio o Entrar para tomar una copia. Después, muévala a una lista con las teclas de flecha y presione Espacio para soltarla o Esc para cancelar. Con el ratón: arrástrela, o haga clic y vuelva a hacer clic en el destino.',
1120
+ copyCancelled: (item) => `Copia de ${item} cancelada.`,
1121
+ copyTo: (list) => `Copiar a «${list}»`,
1117
1122
  },
1118
1123
  logViewer: {
1119
1124
  label: 'Registro',
package/src/locales/fr.ts CHANGED
@@ -1142,6 +1142,11 @@ export const fr: Translations = {
1142
1142
  dropped: (item, position, count) => `${item} déposé, position ${position} sur ${count}.`,
1143
1143
  cancelled: (item, position, count) =>
1144
1144
  `Déplacement annulé. ${item} revient en position ${position} sur ${count}.`,
1145
+ copyHandle: (item) => `Copier ${item}`,
1146
+ copyInstructions:
1147
+ "Appuyez sur Espace ou Entrée pour saisir une copie. Déplacez-la ensuite dans une liste avec les flèches, puis appuyez sur Espace pour la déposer ou sur Échap pour annuler. À la souris\u00a0: faites-la glisser, ou cliquez dessus puis cliquez à nouveau à l'emplacement cible.",
1148
+ copyCancelled: (item) => `Copie de ${item} annulée.`,
1149
+ copyTo: (list) => `Copier vers « ${list} »`,
1145
1150
  },
1146
1151
  logViewer: {
1147
1152
  label: 'Journal',
package/src/locales/hu.ts CHANGED
@@ -1144,6 +1144,11 @@ export const hu: Translations = {
1144
1144
  movedTo: (item, container, index, count) => `${item} áthelyezve ide: ${container}, ${position(index, count)}.`,
1145
1145
  dropped: (item, index, count) => `${item} letéve, ${position(index, count)}.`,
1146
1146
  cancelled: (item, index, count) => `Áthelyezés megszakítva. ${item} visszakerült: ${position(index, count)}.`,
1147
+ copyHandle: (item) => `${item} másolása`,
1148
+ copyInstructions:
1149
+ 'Egy másolat felvételéhez nyomja meg a Szóköz vagy az Enter billentyűt. Ezután a nyílbillentyűkkel vigye egy listába, a Szóközzel tegye le, vagy az Esc billentyűvel szakítsa meg. Egérrel: húzza, vagy kattintson rá, majd kattintson újra a célhelyen.',
1150
+ copyCancelled: (item) => `${item} másolása megszakítva.`,
1151
+ copyTo: (list) => `Másolás ide: „${list}”`,
1147
1152
  },
1148
1153
  logViewer: {
1149
1154
  label: 'Napló',
package/src/locales/it.ts CHANGED
@@ -1132,6 +1132,11 @@ export const it: Translations = {
1132
1132
  dropped: (item, position, count) => `${item} rilasciato, posizione ${position} di ${count}.`,
1133
1133
  cancelled: (item, position, count) =>
1134
1134
  `Spostamento annullato. ${item} di nuovo in posizione ${position} di ${count}.`,
1135
+ copyHandle: (item) => `Copia ${item}`,
1136
+ copyInstructions:
1137
+ 'Premere Spazio o Invio per afferrare una copia. Spostarla in un elenco con i tasti freccia, premere Spazio per rilasciarla o Esc per annullare. Con il mouse: trascinare, oppure fare clic e poi di nuovo clic nella posizione di destinazione.',
1138
+ copyCancelled: (item) => `Copia di ${item} annullata.`,
1139
+ copyTo: (list) => `Copia in «${list}»`,
1135
1140
  },
1136
1141
  logViewer: {
1137
1142
  label: 'Registro',
package/src/locales/lv.ts CHANGED
@@ -1145,6 +1145,11 @@ export const lv: Translations = {
1145
1145
  movedTo: (item, container, position, count) => `${item}: ${container}, pozīcija ${position} no ${count}.`,
1146
1146
  dropped: (item, position, count) => `${item}: nomests, pozīcija ${position} no ${count}.`,
1147
1147
  cancelled: (item, position, count) => `Pārvietošana atcelta. ${item}: atkal pozīcija ${position} no ${count}.`,
1148
+ copyHandle: (item) => `Kopēt: ${item}`,
1149
+ copyInstructions:
1150
+ 'Lai paceltu kopiju, nospiediet atstarpes taustiņu vai Enter. Pēc tam pārvietojiet to uz sarakstu ar bulttaustiņiem, nospiediet atstarpes taustiņu, lai nomestu, vai Esc, lai atceltu. Ar peli: velciet vai noklikšķiniet un vēlreiz noklikšķiniet mērķa vietā.',
1151
+ copyCancelled: (item) => `Kopēšana atcelta: ${item}.`,
1152
+ copyTo: (list) => `Kopēt uz “${list}”`,
1148
1153
  },
1149
1154
  logViewer: {
1150
1155
  label: 'Žurnāls',
package/src/locales/nl.ts CHANGED
@@ -1095,6 +1095,11 @@ export const nl: Translations = {
1095
1095
  dropped: (item, position, count) => `${item} neergezet, positie ${position} van ${count}.`,
1096
1096
  cancelled: (item, position, count) =>
1097
1097
  `Verplaatsen geannuleerd. ${item} terug op positie ${position} van ${count}.`,
1098
+ copyHandle: (item) => `${item} kopiëren`,
1099
+ copyInstructions:
1100
+ 'Druk op de spatiebalk of Enter om een kopie op te pakken. Verplaats deze daarna met de pijltoetsen naar een lijst, druk op de spatiebalk om neer te zetten of op Esc om te annuleren. Met de muis: slepen, of klikken en op de doelpositie opnieuw klikken.',
1101
+ copyCancelled: (item) => `Kopiëren van ${item} geannuleerd.`,
1102
+ copyTo: (list) => `Kopiëren naar ‘${list}’`,
1098
1103
  },
1099
1104
  logViewer: {
1100
1105
  label: 'Logboek',
package/src/locales/pl.ts CHANGED
@@ -1264,6 +1264,11 @@ export const pl: Translations = {
1264
1264
  dropped: (item, position, count) => `Upuszczono: ${item}, pozycja ${position} z ${count}.`,
1265
1265
  cancelled: (item, position, count) =>
1266
1266
  `Anulowano przenoszenie. ${item} wraca na pozycję ${position} z ${count}.`,
1267
+ copyHandle: (item) => `Kopiuj: ${item}`,
1268
+ copyInstructions:
1269
+ 'Naciśnij Spację lub Enter, aby podnieść kopię. Następnie przesuń ją strzałkami do listy, naciśnij Spację, aby upuścić, lub Esc, aby anulować. Myszą: przeciągnij albo kliknij i kliknij ponownie w miejscu docelowym.',
1270
+ copyCancelled: (item) => `Anulowano kopiowanie: ${item}.`,
1271
+ copyTo: (list) => `Kopiuj do „${list}”`,
1267
1272
  },
1268
1273
  logViewer: {
1269
1274
  label: 'Dziennik',
@@ -289,6 +289,8 @@ export const ptBR: Translations = {
289
289
  empty: 'Nenhum item – mova para cá',
290
290
  picked: (item, position, count) => `${item} pego, posição ${position} de ${count}.`,
291
291
  dropped: (item, position, count) => `${item} solto, posição ${position} de ${count}.`,
292
+ copyInstructions:
293
+ 'Pressione Espaço ou Enter para pegar uma cópia. Depois mova-a para uma lista com as teclas de seta, pressione Espaço para soltar ou Escape para cancelar. Com o mouse: arraste, ou clique e clique novamente no destino.',
292
294
  },
293
295
  logViewer: {
294
296
  ...pt.logViewer,
package/src/locales/pt.ts CHANGED
@@ -1100,6 +1100,11 @@ export const pt: Translations = {
1100
1100
  dropped: (item, position, count) => `${item} largado, posição ${position} de ${count}.`,
1101
1101
  cancelled: (item, position, count) =>
1102
1102
  `Movimento cancelado. ${item} de volta à posição ${position} de ${count}.`,
1103
+ copyHandle: (item) => `Copiar ${item}`,
1104
+ copyInstructions:
1105
+ 'Prima Espaço ou Enter para agarrar uma cópia. Depois mova-a para uma lista com as teclas de seta, prima Espaço para largar ou Escape para cancelar. Com o rato: arraste, ou clique e volte a clicar no destino.',
1106
+ copyCancelled: (item) => `Cópia de ${item} cancelada.`,
1107
+ copyTo: (list) => `Copiar para «${list}»`,
1103
1108
  },
1104
1109
  logViewer: {
1105
1110
  label: 'Registo',
package/src/locales/tr.ts CHANGED
@@ -1089,6 +1089,11 @@ export const tr: Translations = {
1089
1089
  dropped: (item, position, count) => `${item} bırakıldı, konum ${position} / ${count}.`,
1090
1090
  cancelled: (item, position, count) =>
1091
1091
  `Taşıma iptal edildi. ${item} eski yerine döndü, konum ${position} / ${count}.`,
1092
+ copyHandle: (item) => `Kopyala: ${item}`,
1093
+ copyInstructions:
1094
+ 'Bir kopya almak için Boşluk veya Enter tuşuna basın. Ardından ok tuşlarıyla bir listeye taşıyın, bırakmak için Boşluk, iptal etmek için Escape tuşuna basın. Fareyle: sürükleyin ya da tıklayıp hedef konumda tekrar tıklayın.',
1095
+ copyCancelled: (item) => `${item} kopyalanması iptal edildi.`,
1096
+ copyTo: (list) => `“${list}” listesine kopyala`,
1092
1097
  },
1093
1098
  logViewer: {
1094
1099
  label: 'Günlük',
@@ -472,6 +472,7 @@ export {
472
472
  type SortableTexts,
473
473
  } from '../sortable.js';
474
474
  export { moveItem } from '../data-table.js';
475
+ export { prepareTourStep, tourSkipTarget, type TourStepPreparation } from '../tour-steps.js';
475
476
  export { kanbanLimitState } from '../apps.js';
476
477
  // RN part 3: scheduler and gantt
477
478
  export { gantt, scheduler } from './scheduler.js';
package/src/primitives.ts CHANGED
@@ -143,15 +143,22 @@ export const aspectRatio = tv({
143
143
  ],
144
144
  });
145
145
 
146
- /** Fixed in a corner of the window (`--wc-affix-offset`, default 24px) */
146
+ /**
147
+ * Fixed in a corner of the window: `--wc-affix-offset` (default 24px) from both edges, `--wc-affix-offset-x` (start/end)
148
+ * and `--wc-affix-offset-y` (top/bottom) for one of them
149
+ */
147
150
  export const affix = tv({
148
151
  base: 'fixed z-40',
149
152
  variants: {
150
153
  position: {
151
- 'bottom-end': 'inset-e-[var(--wc-affix-offset,1.5rem)] bottom-[var(--wc-affix-offset,1.5rem)]',
152
- 'bottom-start': 'inset-s-[var(--wc-affix-offset,1.5rem)] bottom-[var(--wc-affix-offset,1.5rem)]',
153
- 'top-end': 'inset-e-[var(--wc-affix-offset,1.5rem)] top-[var(--wc-affix-offset,1.5rem)]',
154
- 'top-start': 'inset-s-[var(--wc-affix-offset,1.5rem)] top-[var(--wc-affix-offset,1.5rem)]',
154
+ 'bottom-end':
155
+ 'inset-e-[var(--wc-affix-offset-x,var(--wc-affix-offset,1.5rem))] bottom-[var(--wc-affix-offset-y,var(--wc-affix-offset,1.5rem))]',
156
+ 'bottom-start':
157
+ 'inset-s-[var(--wc-affix-offset-x,var(--wc-affix-offset,1.5rem))] bottom-[var(--wc-affix-offset-y,var(--wc-affix-offset,1.5rem))]',
158
+ 'top-end':
159
+ 'inset-e-[var(--wc-affix-offset-x,var(--wc-affix-offset,1.5rem))] top-[var(--wc-affix-offset-y,var(--wc-affix-offset,1.5rem))]',
160
+ 'top-start':
161
+ 'inset-s-[var(--wc-affix-offset-x,var(--wc-affix-offset,1.5rem))] top-[var(--wc-affix-offset-y,var(--wc-affix-offset,1.5rem))]',
155
162
  },
156
163
  },
157
164
  defaultVariants: {
package/src/shell.ts CHANGED
@@ -258,6 +258,8 @@ export const notificationCenter = tv({
258
258
  body: 'flex min-w-0 flex-1 flex-col gap-0.5',
259
259
  title: 'text-sm text-fg',
260
260
  titleLink: ['rounded-sm text-fg no-underline hover:underline', focusRing],
261
+ /** The title of a `clickable` item without href: a button that looks like the title link */
262
+ titleButton: 'cursor-pointer border-0 bg-transparent p-0 text-start',
261
263
  description: 'text-[13px] leading-snug text-muted',
262
264
  time: 'font-mono text-[11px] text-muted',
263
265
  actions: 'flex shrink-0 items-start gap-1',
package/src/sortable.ts CHANGED
@@ -77,6 +77,8 @@ export interface SortableTexts {
77
77
  movedTo: (item: string, container: string, position: number, count: number) => string;
78
78
  dropped: (item: string, position: number, count: number) => string;
79
79
  cancelled: (item: string, position: number, count: number) => string;
80
+ /** A copy out of a source list was dropped nowhere (or Escape) */
81
+ copyCancelled: (item: string) => string;
80
82
  }
81
83
 
82
84
  /** A move that changed the order: from and to which container (its `id`) and index */
@@ -105,6 +107,11 @@ export interface SortableContainer<T = unknown> {
105
107
  disabled: () => boolean;
106
108
  /** Whether an item from another container may come in (default: yes) */
107
109
  accepts?: (item: T, from: string) => boolean;
110
+ /**
111
+ * Makes the container a source (e.g. a palette): its items are copied out – this function makes the copy – and
112
+ * it keeps them, takes none in and is not sorted
113
+ */
114
+ clone?: () => ((item: T) => unknown) | undefined;
108
115
  texts: () => SortableTexts;
109
116
  /** Focuses the handle at `index` once the new order is rendered (default: in the next task) */
110
117
  focus?: (index: number) => void;
@@ -123,6 +130,8 @@ export interface SortableState {
123
130
  type Mode = 'keyboard' | 'pointer' | 'click';
124
131
  interface Active {
125
132
  item: unknown;
133
+ /** The item of a source the carried copy was made of (undefined: the item itself is carried) */
134
+ copyOf: unknown;
126
135
  origin: { container: SortableContainer; index: number };
127
136
  current: { container: SortableContainer; index: number; count: number };
128
137
  mode: Mode;
@@ -132,6 +141,8 @@ const idleState: SortableState = { grabbed: null, dragging: false, active: false
132
141
  const DRAG_THRESHOLD = 5;
133
142
  /** Attribute of the drag handles: the id of their container (several Sortables can be nested) */
134
143
  export const SORTABLE_HANDLE = 'data-sortable-handle';
144
+ const CONTAINER = '[data-sortable-container]';
145
+ const INDEX = 'data-sortable-index';
135
146
 
136
147
  /** Pick-up, keyboard and pointer moves of all Sortables on the page (one item at a time) */
137
148
  export class SortableController {
@@ -170,11 +181,11 @@ export class SortableController {
170
181
  const active = this.#active;
171
182
  if (!active) return idleState;
172
183
  const container = this.#containers.get(id);
173
- const sameGroup = !!container && (container === active.current.container || this.#sameGroup(container));
174
184
  return {
175
185
  grabbed: active.current.container.id === id ? active.current.index : null,
176
186
  dragging: active.mode === 'pointer' && active.current.container.id === id,
177
- active: sameGroup,
187
+ // Takes the item (a source only takes its copy back – not shown as a target)
188
+ active: !!container && !container.clone?.() && this.#accepts(container),
178
189
  };
179
190
  }
180
191
 
@@ -271,18 +282,30 @@ export class SortableController {
271
282
  const container = this.#containers.get(id);
272
283
  const active = this.#active;
273
284
  if (!container || !active || active.mode !== 'click') return;
274
- if ((event.target as Element | null)?.closest(`[${SORTABLE_HANDLE}]`)) return;
285
+ const target = event.target as Element | null;
286
+ if (target?.closest(`[${SORTABLE_HANDLE}]`)) return;
287
+ // A click in a nested container belongs to that one (it bubbles up here)
288
+ if (target?.closest(CONTAINER) !== container.element()) return;
275
289
  if (!this.#accepts(container)) return;
276
290
  if (container !== active.current.container) this.#moveTo(container, container.items().length);
277
291
  this.drop();
278
292
  }
279
293
 
280
294
  pickUp(container: SortableContainer, index: number, mode: Mode) {
281
- const item = container.items()[index];
282
- if (item === undefined) return;
295
+ const original = container.items()[index];
296
+ if (original === undefined) return;
297
+ // A source carries a copy – made now, so the targets decide on it (`accepts`)
298
+ const clone = container.clone?.();
299
+ const item = clone ? clone(original) : original;
283
300
  const count = container.items().length;
284
- this.#active = { item, origin: { container, index }, current: { container, index, count }, mode };
285
- announce(container.texts().picked(container.itemLabel(item), index + 1, count));
301
+ this.#active = {
302
+ item,
303
+ copyOf: clone ? original : undefined,
304
+ origin: { container, index },
305
+ current: { container, index, count },
306
+ mode,
307
+ };
308
+ announce(container.texts().picked(container.itemLabel(original), index + 1, count));
286
309
  this.#notify();
287
310
  }
288
311
 
@@ -292,6 +315,12 @@ export class SortableController {
292
315
  this.#active = null;
293
316
  const { container, index, count } = active.current;
294
317
  const { origin } = active;
318
+ // A copy still at its source was not put anywhere
319
+ if (active.copyOf !== undefined && container === origin.container) {
320
+ announce(container.texts().copyCancelled(container.itemLabel(active.copyOf)));
321
+ this.#notify();
322
+ return;
323
+ }
295
324
  announce(container.texts().dropped(container.itemLabel(active.item), index + 1, count));
296
325
  if (origin.container !== container || origin.index !== index) {
297
326
  container.onMove?.({
@@ -311,8 +340,9 @@ export class SortableController {
311
340
  this.#moveTo(origin.container, origin.index, false);
312
341
  const count = active.current.count;
313
342
  this.#active = null;
314
- const label = origin.container.itemLabel(active.item);
315
- announce(origin.container.texts().cancelled(label, origin.index + 1, count));
343
+ const texts = origin.container.texts();
344
+ if (active.copyOf !== undefined) announce(texts.copyCancelled(origin.container.itemLabel(active.copyOf)));
345
+ else announce(texts.cancelled(origin.container.itemLabel(active.item), origin.index + 1, count));
316
346
  this.#focus(origin.container, origin.index);
317
347
  this.#notify();
318
348
  }
@@ -328,16 +358,36 @@ export class SortableController {
328
358
  const active = this.#active;
329
359
  if (!active) return;
330
360
  const { container, index: from } = active.current;
361
+ const origin = active.origin;
362
+ if (active.copyOf !== undefined && target === origin.container) {
363
+ // A source is not sorted; a copy that comes back leaves the container it was put in
364
+ if (container === target) return;
365
+ const rest = [...container.items()];
366
+ rest.splice(from, 1);
367
+ container.setItems(rest);
368
+ const count = target.items().length;
369
+ active.current = { container: target, index: origin.index, count };
370
+ if (speak) announce(target.texts().picked(target.itemLabel(active.copyOf), origin.index + 1, count));
371
+ if (active.mode !== 'pointer') this.#focus(target, origin.index);
372
+ this.#notify();
373
+ return;
374
+ }
331
375
  let next: unknown[];
332
376
  if (target === container) {
333
377
  next = moveItem(target.items(), from, index);
334
378
  target.setItems(next);
335
379
  } else {
336
380
  if (!this.#accepts(target)) return;
337
- const moved = moveBetween(container.items(), target.items(), from, index);
338
- container.setItems(moved.from);
339
- target.setItems(moved.to);
340
- next = moved.to;
381
+ if (active.copyOf !== undefined && container === origin.container) {
382
+ // The copy leaves its source: put into the target, the source keeps its item
383
+ next = [...target.items()];
384
+ next.splice(Math.max(0, Math.min(index, next.length)), 0, active.item);
385
+ } else {
386
+ const moved = moveBetween(container.items(), target.items(), from, index);
387
+ container.setItems(moved.from);
388
+ next = moved.to;
389
+ }
390
+ target.setItems(next);
341
391
  }
342
392
  const position = Math.max(0, Math.min(index, next.length - 1));
343
393
  active.current = { container: target, index: position, count: next.length };
@@ -357,10 +407,20 @@ export class SortableController {
357
407
  const active = this.#active;
358
408
  if (!active || container.disabled()) return false;
359
409
  if (container === active.current.container) return true;
360
- if (!this.#sameGroup(container)) return false;
410
+ // A source takes nothing – only its own copy back
411
+ if (container.clone?.()) return active.copyOf !== undefined && container === active.origin.container;
412
+ if (!this.#sameGroup(container) || this.#inside(container)) return false;
361
413
  return container.accepts?.(active.item, active.current.container.id) ?? true;
362
414
  }
363
415
 
416
+ /** The container is nested in the carried item – it cannot take the item it is part of */
417
+ #inside(container: SortableContainer): boolean {
418
+ const { current } = this.#active!;
419
+ const item = current.container.element()?.querySelector(`:scope > [${INDEX}="${current.index}"]`);
420
+ const element = container.element();
421
+ return !!item && !!element && item.contains(element);
422
+ }
423
+
364
424
  #sameGroup(container: SortableContainer) {
365
425
  const group = this.#active?.current.container.group();
366
426
  return group !== undefined && container.group() === group;
@@ -386,12 +446,13 @@ export class SortableController {
386
446
  /** Container and index under the pointer: an item (its place) or the empty area of a container (the end) */
387
447
  #targetAt(x: number, y: number): { container: SortableContainer; index: number } | undefined {
388
448
  const element = document.elementFromPoint(x, y);
389
- const item = element?.closest<HTMLElement>('[data-sortable-index]');
390
- const owner = (item ?? element)?.closest<HTMLElement>('[data-sortable-container]');
449
+ // The innermost container: over a nested one (also its empty area) the item goes there, not to its parent
450
+ const owner = element?.closest<HTMLElement>(CONTAINER);
391
451
  const container = owner ? this.#containers.get(owner.dataset.sortableContainer ?? '') : undefined;
392
452
  if (!container || !this.#accepts(container)) return undefined;
393
453
  const active = this.#active!;
394
- if (item && owner?.contains(item)) return { container, index: Number(item.dataset.sortableIndex) };
454
+ const item = element?.closest<HTMLElement>(`[${INDEX}]`);
455
+ if (item && item.parentElement === owner) return { container, index: Number(item.dataset.sortableIndex) };
395
456
  const end = container.items().length - (container === active.current.container ? 1 : 0);
396
457
  return { container, index: end };
397
458
  }
@@ -0,0 +1,52 @@
1
+ // Steps of a tour (Tour) that need the app first: `before` runs (e.g. switches a tab), then the target is awaited
2
+ // for up to `waitFor` ms. Framework-neutral – Vue, React and React Native show the step once it is ready.
3
+
4
+ /** What a step needs before it is shown */
5
+ export interface TourStepPreparation<E> {
6
+ /** Runs first, may be async */
7
+ before?: () => void | Promise<void>;
8
+ /** Finds the target; without it the step has none */
9
+ find?: () => E | null | undefined;
10
+ /** How long (ms) to wait for the target after `before` (default 0: look once) */
11
+ waitFor?: number;
12
+ }
13
+
14
+ const POLL = 50;
15
+
16
+ /**
17
+ * Prepares a step: runs `before`, then looks for the target until it is there or `waitFor` has passed. `ready` gets
18
+ * the target – null without one or when it did not appear (`missing`). Returns the cancel function (the tour moved
19
+ * on or ended): `ready` is not called after it.
20
+ */
21
+ export function prepareTourStep<E>(
22
+ step: TourStepPreparation<E>,
23
+ ready: (target: E | null, missing: boolean) => void
24
+ ): () => void {
25
+ let cancelled = false;
26
+ let timer: ReturnType<typeof setTimeout> | undefined;
27
+ const look = (until: number) => {
28
+ if (cancelled) return;
29
+ const target = step.find?.() ?? null;
30
+ if (target || !step.find) return ready(target, false);
31
+ if (Date.now() >= until) return ready(null, true);
32
+ timer = setTimeout(() => look(until), Math.min(POLL, until - Date.now()));
33
+ };
34
+ Promise.resolve()
35
+ .then(step.before)
36
+ // A failing `before` does not stop the tour – the target decides
37
+ .catch((error: unknown) => console.error(error))
38
+ .then(() => look(Date.now() + (step.waitFor ?? 0)));
39
+ return () => {
40
+ cancelled = true;
41
+ clearTimeout(timer);
42
+ };
43
+ }
44
+
45
+ /**
46
+ * The step to go to instead of a skipped one at `index`, in the direction the tour was moving (from `current`):
47
+ * the next or previous index, `'end'` past the last step, undefined before the first (stay)
48
+ */
49
+ export function tourSkipTarget(index: number, current: number, count: number): number | 'end' | undefined {
50
+ if (index > current) return index + 1 < count ? index + 1 : 'end';
51
+ return index > 0 ? index - 1 : undefined;
52
+ }