@kirana-ui/web 0.2.0 → 0.3.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 (72) hide show
  1. package/llms.txt +248 -74
  2. package/package.json +6 -2
  3. package/skills/kirana-ui-primitives/SKILL.md +29 -8
  4. package/src/alert-dialog.d.ts +2 -2
  5. package/src/alert-dialog.js +6 -2
  6. package/src/alert-dialog.js.map +1 -1
  7. package/src/around.d.ts +21 -4
  8. package/src/around.js +34 -12
  9. package/src/around.js.map +1 -1
  10. package/src/autocomplete.d.ts +6 -3
  11. package/src/autocomplete.js +8 -4
  12. package/src/autocomplete.js.map +1 -1
  13. package/src/avatar.d.ts +11 -5
  14. package/src/avatar.js +39 -10
  15. package/src/avatar.js.map +1 -1
  16. package/src/calendar.d.ts +9 -5
  17. package/src/calendar.js +21 -9
  18. package/src/calendar.js.map +1 -1
  19. package/src/checkbox-group.d.ts +22 -0
  20. package/src/checkbox-group.js +36 -0
  21. package/src/checkbox-group.js.map +1 -0
  22. package/src/checkbox.d.ts +4 -2
  23. package/src/checkbox.js +10 -4
  24. package/src/checkbox.js.map +1 -1
  25. package/src/combobox.d.ts +17 -4
  26. package/src/combobox.js +43 -6
  27. package/src/combobox.js.map +1 -1
  28. package/src/command.d.ts +1 -1
  29. package/src/command.js +2 -1
  30. package/src/command.js.map +1 -1
  31. package/src/context-menu.d.ts +2 -1
  32. package/src/context-menu.js.map +1 -1
  33. package/src/date-picker.d.ts +7 -4
  34. package/src/date-picker.js +12 -3
  35. package/src/date-picker.js.map +1 -1
  36. package/src/dates.d.ts +5 -2
  37. package/src/dates.js +50 -15
  38. package/src/dates.js.map +1 -1
  39. package/src/dialog.d.ts +2 -2
  40. package/src/dialog.js +6 -2
  41. package/src/dialog.js.map +1 -1
  42. package/src/hover-card.d.ts +2 -1
  43. package/src/hover-card.js.map +1 -1
  44. package/src/index.d.ts +7 -3
  45. package/src/index.js +1 -0
  46. package/src/menu.d.ts +2 -1
  47. package/src/menu.js.map +1 -1
  48. package/src/navigation-menu.d.ts +2 -1
  49. package/src/navigation-menu.js.map +1 -1
  50. package/src/number-field.d.ts +5 -2
  51. package/src/number-field.js +23 -3
  52. package/src/number-field.js.map +1 -1
  53. package/src/otp.d.ts +1 -1
  54. package/src/otp.js +2 -1
  55. package/src/otp.js.map +1 -1
  56. package/src/popover.d.ts +8 -7
  57. package/src/popover.js +33 -5
  58. package/src/popover.js.map +1 -1
  59. package/src/radio-group.d.ts +2 -1
  60. package/src/radio-group.js +9 -2
  61. package/src/radio-group.js.map +1 -1
  62. package/src/runtime.d.ts +7 -2
  63. package/src/runtime.js +7 -4
  64. package/src/runtime.js.map +1 -1
  65. package/src/select.d.ts +3 -2
  66. package/src/select.js +2 -1
  67. package/src/select.js.map +1 -1
  68. package/src/slider.d.ts +2 -2
  69. package/src/slider.js +3 -2
  70. package/src/slider.js.map +1 -1
  71. package/src/tooltip.d.ts +2 -1
  72. package/src/tooltip.js.map +1 -1
package/src/dates.js CHANGED
@@ -21,29 +21,36 @@ function fieldParts(of) {
21
21
  }) }
22
22
  };
23
23
  }
24
+ const isMonth = (entry) => typeof entry === "object" && entry !== null && "weeks" in entry && "title" in entry;
25
+ /** The month a part is written in, in a `months` template: its place among those shown. */
26
+ const monthAround = (element) => entryAround(element, isMonth)?.index;
24
27
  /** A calendar's parts and its lists, for a component that is one or holds one. */
25
28
  function calendarParts(of) {
26
29
  const date = (element) => entryAround(element)?.date;
30
+ const month = (controller, element) => of(controller).monthAt(monthAround(element) ?? 0);
27
31
  return {
28
32
  parts: {
29
- heading: (controller) => ({
30
- part: of(controller).heading,
31
- text: of(controller).title
32
- }),
33
+ heading(controller, element) {
34
+ const shown = month(controller, element);
35
+ return {
36
+ part: shown.heading,
37
+ text: shown.title
38
+ };
39
+ },
33
40
  previous: (controller) => of(controller).previous,
34
41
  next: (controller) => of(controller).next,
35
- grid: (controller) => of(controller).grid,
42
+ grid: (controller, element) => month(controller, element).grid,
36
43
  "head-cell"(controller, element) {
37
44
  const weekday = entryAround(element);
38
45
  return weekday && of(controller).headCell(weekday);
39
46
  },
40
47
  cell(controller, element) {
41
48
  const day = date(element);
42
- return day === void 0 ? void 0 : of(controller).cell(day);
49
+ return day === void 0 ? void 0 : of(controller).cell(day, monthAround(element));
43
50
  },
44
51
  day(controller, element) {
45
52
  const day = date(element);
46
- return day === void 0 ? void 0 : of(controller).day(day);
53
+ return day === void 0 ? void 0 : of(controller).day(day, monthAround(element));
47
54
  }
48
55
  },
49
56
  lists: {
@@ -51,20 +58,48 @@ function calendarParts(of) {
51
58
  entries: of(controller).weekdays,
52
59
  key: (weekday) => weekday.index
53
60
  }),
54
- weeks: (controller) => ({
55
- entries: of(controller).weeks,
61
+ months: (controller) => ({
62
+ entries: of(controller).months,
63
+ key: (shown) => shown.index,
64
+ values: (shown) => ({
65
+ index: shown.index,
66
+ month: shown.month,
67
+ title: shown.title
68
+ })
69
+ }),
70
+ weeks: (controller, around) => ({
71
+ entries: isMonth(around) ? of(controller).monthAt(around.index).weeks : of(controller).weeks,
56
72
  key: (week) => week[0].date,
57
73
  values: () => ({})
58
74
  }),
59
- days: (_controller, week) => ({
60
- entries: week ?? [],
61
- key: (day) => day.date
62
- })
75
+ days(controller, week) {
76
+ const row = week ?? [];
77
+ const shown = of(controller).months.peek().find((each) => each.weeks.includes(row));
78
+ return {
79
+ entries: row,
80
+ key: (day) => day.date,
81
+ values: (day) => ({
82
+ ...day,
83
+ monthIndex: shown?.index ?? 0
84
+ })
85
+ };
86
+ }
63
87
  }
64
88
  };
65
89
  }
66
- /** A calendar's value as an attribute writes it: a day, or several with commas between. */
67
- const days = (given) => typeof given === "string" && given.includes(",") ? given.split(",") : given;
90
+ /**
91
+ * A calendar's value as an attribute writes it: a day, or several with commas between (a
92
+ * range's first and last, or a list's days).
93
+ */
94
+ function days(given, mode) {
95
+ const list = typeof given === "string" && given.includes(",") ? given.split(",") : given;
96
+ if (mode === "range" && Array.isArray(list)) return {
97
+ start: list[0],
98
+ end: list[1] ?? list[0]
99
+ };
100
+ if (mode === "multiple" && typeof list === "string") return list === "" ? [] : [list];
101
+ return list;
102
+ }
68
103
  export { calendarParts, days, fieldParts };
69
104
 
70
105
  //# sourceMappingURL=dates.js.map
package/src/dates.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dates.js","names":[],"sources":["../../../../packages/web/src/dates.ts"],"sourcesContent":["import type { Calendar, CalendarDay, CalendarWeekday } from \"@kirana-ui/core/calendar\"\nimport type { DateField, DateFieldSegment } from \"@kirana-ui/core/date-field\"\n\nimport { entryAround } from \"./runtime.ts\"\nimport type { Drawn, Each } from \"./runtime.ts\"\n\ntype Parts<Controller> = Record<\n string,\n (controller: Controller, element: HTMLElement) => Drawn[\"part\"] | Drawn | undefined\n>\ntype Lists<Controller> = Record<string, (controller: Controller, around: unknown) => Each>\n\n/** A date field's parts and its list, for a component that is one or holds one. */\nexport function fieldParts<Controller>(of: (controller: Controller) => DateField) {\n const parts: Parts<Controller> = {\n segment(controller, element) {\n const segment = entryAround<DateFieldSegment>(element)\n if (!segment) return undefined\n const { part, text } = of(controller).segment(segment)\n return { part, text }\n },\n input: (controller) => of(controller).input,\n }\n const lists: Lists<Controller> = {\n segments: (controller) => ({\n entries: of(controller).segments,\n key: (segment: DateFieldSegment) => `${segment.index}-${segment.type}`,\n }),\n }\n return { parts, lists }\n}\n\n/** A calendar's parts and its lists, for a component that is one or holds one. */\nexport function calendarParts<Controller>(of: (controller: Controller) => Calendar) {\n const date = (element: HTMLElement) => entryAround<CalendarDay>(element)?.date\n const parts: Parts<Controller> = {\n heading: (controller) => ({ part: of(controller).heading, text: of(controller).title }),\n previous: (controller) => of(controller).previous,\n next: (controller) => of(controller).next,\n grid: (controller) => of(controller).grid,\n \"head-cell\"(controller, element) {\n const weekday = entryAround<CalendarWeekday>(element)\n return weekday && of(controller).headCell(weekday)\n },\n cell(controller, element) {\n const day = date(element)\n return day === undefined ? undefined : of(controller).cell(day)\n },\n day(controller, element) {\n const day = date(element)\n return day === undefined ? undefined : of(controller).day(day)\n },\n }\n const lists: Lists<Controller> = {\n weekdays: (controller) => ({\n entries: of(controller).weekdays,\n key: (weekday: CalendarWeekday) => weekday.index,\n }),\n weeks: (controller) => ({\n entries: of(controller).weeks,\n key: (week: readonly CalendarDay[]) => week[0]!.date,\n values: () => ({}),\n }),\n // Written in a week's row: that week's days.\n days: (_controller, week) => ({\n entries: (week as readonly CalendarDay[] | undefined) ?? [],\n key: (day: CalendarDay) => day.date,\n }),\n }\n return { parts, lists }\n}\n\n/** A calendar's value as an attribute writes it: a day, or several with commas between. */\nexport const days = (given: unknown): unknown =>\n typeof given === \"string\" && given.includes(\",\") ? given.split(\",\") : given\n"],"mappings":";;;AAaA,SAAgB,WAAuB,IAA2C;CAgBhF,OAAO;EAAE,OAAA;GAdP,QAAQ,YAAY,SAAS;IAC3B,MAAM,UAAU,YAA8B,OAAO;IACrD,IAAI,CAAC,SAAS,OAAO,KAAA;IACrB,MAAM,EAAE,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,QAAQ,OAAO;IACrD,OAAO;KAAE;KAAM;IAAK;GACtB;GACA,QAAQ,eAAe,GAAG,UAAU,CAAC,CAAC;EAQ3B;EAAG,OAAA,EALd,WAAW,gBAAgB;GACzB,SAAS,GAAG,UAAU,CAAC,CAAC;GACxB,MAAM,YAA8B,GAAG,QAAQ,MAAM,GAAG,QAAQ;EAClE,GAEkB;CAAE;AACxB;;AAGA,SAAgB,cAA0B,IAA0C;CAClF,MAAM,QAAQ,YAAyB,YAAyB,OAAO,CAAC,EAAE;CAmC1E,OAAO;EAAE,OAAA;GAjCP,UAAU,gBAAgB;IAAE,MAAM,GAAG,UAAU,CAAC,CAAC;IAAS,MAAM,GAAG,UAAU,CAAC,CAAC;GAAM;GACrF,WAAW,eAAe,GAAG,UAAU,CAAC,CAAC;GACzC,OAAO,eAAe,GAAG,UAAU,CAAC,CAAC;GACrC,OAAO,eAAe,GAAG,UAAU,CAAC,CAAC;GACrC,YAAY,YAAY,SAAS;IAC/B,MAAM,UAAU,YAA6B,OAAO;IACpD,OAAO,WAAW,GAAG,UAAU,CAAC,CAAC,SAAS,OAAO;GACnD;GACA,KAAK,YAAY,SAAS;IACxB,MAAM,MAAM,KAAK,OAAO;IACxB,OAAO,QAAQ,KAAA,IAAY,KAAA,IAAY,GAAG,UAAU,CAAC,CAAC,KAAK,GAAG;GAChE;GACA,IAAI,YAAY,SAAS;IACvB,MAAM,MAAM,KAAK,OAAO;IACxB,OAAO,QAAQ,KAAA,IAAY,KAAA,IAAY,GAAG,UAAU,CAAC,CAAC,IAAI,GAAG;GAC/D;EAkBW;EAAG,OAAA;GAfd,WAAW,gBAAgB;IACzB,SAAS,GAAG,UAAU,CAAC,CAAC;IACxB,MAAM,YAA6B,QAAQ;GAC7C;GACA,QAAQ,gBAAgB;IACtB,SAAS,GAAG,UAAU,CAAC,CAAC;IACxB,MAAM,SAAiC,KAAK,EAAE,CAAE;IAChD,eAAe,CAAC;GAClB;GAEA,OAAO,aAAa,UAAU;IAC5B,SAAU,QAA+C,CAAC;IAC1D,MAAM,QAAqB,IAAI;GACjC;EAEkB;CAAE;AACxB;;AAGA,MAAa,QAAQ,UACnB,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG,IAAI,MAAM,MAAM,GAAG,IAAI"}
1
+ {"version":3,"file":"dates.js","names":[],"sources":["../../../../packages/web/src/dates.ts"],"sourcesContent":["import type {\n Calendar,\n CalendarDay,\n CalendarMonth,\n CalendarWeekday,\n} from \"@kirana-ui/core/calendar\"\nimport type { DateField, DateFieldSegment } from \"@kirana-ui/core/date-field\"\n\nimport { entryAround } from \"./runtime.ts\"\nimport type { Drawn, Each } from \"./runtime.ts\"\n\ntype Parts<Controller> = Record<\n string,\n (controller: Controller, element: HTMLElement) => Drawn[\"part\"] | Drawn | undefined\n>\ntype Lists<Controller> = Record<string, (controller: Controller, around: unknown) => Each>\n\n/** A date field's parts and its list, for a component that is one or holds one. */\nexport function fieldParts<Controller>(of: (controller: Controller) => DateField) {\n const parts: Parts<Controller> = {\n segment(controller, element) {\n const segment = entryAround<DateFieldSegment>(element)\n if (!segment) return undefined\n const { part, text } = of(controller).segment(segment)\n return { part, text }\n },\n input: (controller) => of(controller).input,\n }\n const lists: Lists<Controller> = {\n segments: (controller) => ({\n entries: of(controller).segments,\n key: (segment: DateFieldSegment) => `${segment.index}-${segment.type}`,\n }),\n }\n return { parts, lists }\n}\n\nconst isMonth = (entry: unknown) =>\n typeof entry === \"object\" && entry !== null && \"weeks\" in entry && \"title\" in entry\n\n/** The month a part is written in, in a `months` template: its place among those shown. */\nconst monthAround = (element: Node) => entryAround<CalendarMonth>(element, isMonth)?.index\n\n/** A calendar's parts and its lists, for a component that is one or holds one. */\nexport function calendarParts<Controller>(of: (controller: Controller) => Calendar) {\n const date = (element: HTMLElement) => entryAround<CalendarDay>(element)?.date\n const month = (controller: Controller, element: HTMLElement) =>\n of(controller).monthAt(monthAround(element) ?? 0)\n const parts: Parts<Controller> = {\n heading(controller, element) {\n const shown = month(controller, element)\n return { part: shown.heading, text: shown.title }\n },\n previous: (controller) => of(controller).previous,\n next: (controller) => of(controller).next,\n grid: (controller, element) => month(controller, element).grid,\n \"head-cell\"(controller, element) {\n const weekday = entryAround<CalendarWeekday>(element)\n return weekday && of(controller).headCell(weekday)\n },\n cell(controller, element) {\n const day = date(element)\n return day === undefined ? undefined : of(controller).cell(day, monthAround(element))\n },\n day(controller, element) {\n const day = date(element)\n return day === undefined ? undefined : of(controller).day(day, monthAround(element))\n },\n }\n const lists: Lists<Controller> = {\n weekdays: (controller) => ({\n entries: of(controller).weekdays,\n key: (weekday: CalendarWeekday) => weekday.index,\n }),\n months: (controller) => ({\n entries: of(controller).months,\n key: (shown: CalendarMonth) => shown.index,\n values: (shown: CalendarMonth) => ({\n index: shown.index,\n month: shown.month,\n title: shown.title,\n }),\n }),\n // Written in a month's copy: that month's weeks; else the first month's.\n weeks: (controller, around) => ({\n entries: isMonth(around)\n ? of(controller).monthAt((around as CalendarMonth).index).weeks\n : of(controller).weeks,\n key: (week: readonly CalendarDay[]) => week[0]!.date,\n values: () => ({}),\n }),\n // Written in a week's row: that week's days, each with the place of its month\n // (`{monthIndex}`), for a page that names a day where it is drawn twice.\n days(controller, week) {\n const row = (week as readonly CalendarDay[] | undefined) ?? []\n const shown = of(controller)\n .months.peek()\n .find((each) => each.weeks.includes(row))\n return {\n entries: row,\n key: (day: CalendarDay) => day.date,\n values: (day: CalendarDay) => ({ ...day, monthIndex: shown?.index ?? 0 }),\n }\n },\n }\n return { parts, lists }\n}\n\n/**\n * A calendar's value as an attribute writes it: a day, or several with commas between (a\n * range's first and last, or a list's days).\n */\nexport function days(given: unknown, mode?: unknown): unknown {\n const list = typeof given === \"string\" && given.includes(\",\") ? given.split(\",\") : given\n if (mode === \"range\" && Array.isArray(list)) return { start: list[0], end: list[1] ?? list[0] }\n if (mode === \"multiple\" && typeof list === \"string\") return list === \"\" ? [] : [list]\n return list\n}\n"],"mappings":";;;AAkBA,SAAgB,WAAuB,IAA2C;CAgBhF,OAAO;EAAE,OAAA;GAdP,QAAQ,YAAY,SAAS;IAC3B,MAAM,UAAU,YAA8B,OAAO;IACrD,IAAI,CAAC,SAAS,OAAO,KAAA;IACrB,MAAM,EAAE,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,QAAQ,OAAO;IACrD,OAAO;KAAE;KAAM;IAAK;GACtB;GACA,QAAQ,eAAe,GAAG,UAAU,CAAC,CAAC;EAQ3B;EAAG,OAAA,EALd,WAAW,gBAAgB;GACzB,SAAS,GAAG,UAAU,CAAC,CAAC;GACxB,MAAM,YAA8B,GAAG,QAAQ,MAAM,GAAG,QAAQ;EAClE,GAEkB;CAAE;AACxB;AAEA,MAAM,WAAW,UACf,OAAO,UAAU,YAAY,UAAU,QAAQ,WAAW,SAAS,WAAW;;AAGhF,MAAM,eAAe,YAAkB,YAA2B,SAAS,OAAO,CAAC,EAAE;;AAGrF,SAAgB,cAA0B,IAA0C;CAClF,MAAM,QAAQ,YAAyB,YAAyB,OAAO,CAAC,EAAE;CAC1E,MAAM,SAAS,YAAwB,YACrC,GAAG,UAAU,CAAC,CAAC,QAAQ,YAAY,OAAO,KAAK,CAAC;CA0DlD,OAAO;EAAE,OAAA;GAxDP,QAAQ,YAAY,SAAS;IAC3B,MAAM,QAAQ,MAAM,YAAY,OAAO;IACvC,OAAO;KAAE,MAAM,MAAM;KAAS,MAAM,MAAM;IAAM;GAClD;GACA,WAAW,eAAe,GAAG,UAAU,CAAC,CAAC;GACzC,OAAO,eAAe,GAAG,UAAU,CAAC,CAAC;GACrC,OAAO,YAAY,YAAY,MAAM,YAAY,OAAO,CAAC,CAAC;GAC1D,YAAY,YAAY,SAAS;IAC/B,MAAM,UAAU,YAA6B,OAAO;IACpD,OAAO,WAAW,GAAG,UAAU,CAAC,CAAC,SAAS,OAAO;GACnD;GACA,KAAK,YAAY,SAAS;IACxB,MAAM,MAAM,KAAK,OAAO;IACxB,OAAO,QAAQ,KAAA,IAAY,KAAA,IAAY,GAAG,UAAU,CAAC,CAAC,KAAK,KAAK,YAAY,OAAO,CAAC;GACtF;GACA,IAAI,YAAY,SAAS;IACvB,MAAM,MAAM,KAAK,OAAO;IACxB,OAAO,QAAQ,KAAA,IAAY,KAAA,IAAY,GAAG,UAAU,CAAC,CAAC,IAAI,KAAK,YAAY,OAAO,CAAC;GACrF;EAsCW;EAAG,OAAA;GAnCd,WAAW,gBAAgB;IACzB,SAAS,GAAG,UAAU,CAAC,CAAC;IACxB,MAAM,YAA6B,QAAQ;GAC7C;GACA,SAAS,gBAAgB;IACvB,SAAS,GAAG,UAAU,CAAC,CAAC;IACxB,MAAM,UAAyB,MAAM;IACrC,SAAS,WAA0B;KACjC,OAAO,MAAM;KACb,OAAO,MAAM;KACb,OAAO,MAAM;IACf;GACF;GAEA,QAAQ,YAAY,YAAY;IAC9B,SAAS,QAAQ,MAAM,IACnB,GAAG,UAAU,CAAC,CAAC,QAAS,OAAyB,KAAK,CAAC,CAAC,QACxD,GAAG,UAAU,CAAC,CAAC;IACnB,MAAM,SAAiC,KAAK,EAAE,CAAE;IAChD,eAAe,CAAC;GAClB;GAGA,KAAK,YAAY,MAAM;IACrB,MAAM,MAAO,QAA+C,CAAC;IAC7D,MAAM,QAAQ,GAAG,UAAU,CAAC,CACzB,OAAO,KAAK,CAAC,CACb,MAAM,SAAS,KAAK,MAAM,SAAS,GAAG,CAAC;IAC1C,OAAO;KACL,SAAS;KACT,MAAM,QAAqB,IAAI;KAC/B,SAAS,SAAsB;MAAE,GAAG;MAAK,YAAY,OAAO,SAAS;KAAE;IACzE;GACF;EAEkB;CAAE;AACxB;;;;;AAMA,SAAgB,KAAK,OAAgB,MAAyB;CAC5D,MAAM,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG,IAAI,MAAM,MAAM,GAAG,IAAI;CACnF,IAAI,SAAS,WAAW,MAAM,QAAQ,IAAI,GAAG,OAAO;EAAE,OAAO,KAAK;EAAI,KAAK,KAAK,MAAM,KAAK;CAAG;CAC9F,IAAI,SAAS,cAAc,OAAO,SAAS,UAAU,OAAO,SAAS,KAAK,CAAC,IAAI,CAAC,IAAI;CACpF,OAAO;AACT"}
package/src/dialog.d.ts CHANGED
@@ -3,8 +3,8 @@ import { DialogProps } from "@kirana-ui/core/dialog";
3
3
  /**
4
4
  * `<kui-dialog>` around a `kui-part="trigger"` button and a `portal`, which is drawn at the
5
5
  * end of the page while the dialog is open and holds its `backdrop` and its `popup`, with a
6
- * `title`, a `description` and a `close` button. `open`, `default-open`, `modal`,
7
- * `dismissible`; it tells `open-change`.
6
+ * `title`, a `description` and a `close` button. A long dialog's popup is in a `viewport`,
7
+ * which scrolls. `open`, `default-open`, `modal`, `dismissible`; it tells `open-change`.
8
8
  */
9
9
  export declare const tag: Tag<{
10
10
  id: string;
package/src/dialog.js CHANGED
@@ -4,8 +4,8 @@ import { createDialog } from "@kirana-ui/core/dialog";
4
4
  /**
5
5
  * `<kui-dialog>` around a `kui-part="trigger"` button and a `portal`, which is drawn at the
6
6
  * end of the page while the dialog is open and holds its `backdrop` and its `popup`, with a
7
- * `title`, a `description` and a `close` button. `open`, `default-open`, `modal`,
8
- * `dismissible`; it tells `open-change`.
7
+ * `title`, a `description` and a `close` button. A long dialog's popup is in a `viewport`,
8
+ * which scrolls. `open`, `default-open`, `modal`, `dismissible`; it tells `open-change`.
9
9
  */
10
10
  const tag = defineElement({
11
11
  tag: "kui-dialog",
@@ -26,6 +26,10 @@ const tag = defineElement({
26
26
  mounted: controller.mounted,
27
27
  part: controller.backdrop
28
28
  }),
29
+ viewport: (controller) => ({
30
+ mounted: controller.mounted,
31
+ part: controller.viewport
32
+ }),
29
33
  popup: (controller) => ({
30
34
  mounted: controller.mounted,
31
35
  part: controller.popup
package/src/dialog.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.js","names":[],"sources":["../../../../packages/web/src/dialog.ts"],"sourcesContent":["import { createDialog } from \"@kirana-ui/core/dialog\"\nimport type { DialogProps } from \"@kirana-ui/core/dialog\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-dialog>` around a `kui-part=\"trigger\"` button and a `portal`, which is drawn at the\n * end of the page while the dialog is open and holds its `backdrop` and its `popup`, with a\n * `title`, a `description` and a `close` button. `open`, `default-open`, `modal`,\n * `dismissible`; it tells `open-change`.\n */\nexport const tag = defineElement({\n tag: \"kui-dialog\",\n props: {\n open: \"boolean\",\n \"default-open\": \"boolean\",\n modal: \"boolean\",\n dismissible: \"boolean\",\n },\n create: (props) => createDialog(props),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: {\n trigger: (controller) => controller.trigger,\n backdrop: (controller) => ({ mounted: controller.mounted, part: controller.backdrop }),\n popup: (controller) => ({ mounted: controller.mounted, part: controller.popup }),\n title: (controller) => controller.title,\n description: (controller) => controller.description,\n close: (controller) => controller.close,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-dialog\": ElementOf<\n As<typeof tag, DialogProps>,\n { \"open-change\": [\"onOpenChange\", \"open\"] }\n >\n }\n}\n"],"mappings":";;;;;;;;;AAYA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EACL,MAAM;EACN,gBAAgB;EAChB,OAAO;EACP,aAAa;CACf;CACA,SAAS,UAAU,aAAa,KAAK;CACrC,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO;EACL,UAAU,eAAe,WAAW;EACpC,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;EACpF,QAAQ,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAM;EAC9E,QAAQ,eAAe,WAAW;EAClC,cAAc,eAAe,WAAW;EACxC,QAAQ,eAAe,WAAW;CACpC;AACF,CAAC"}
1
+ {"version":3,"file":"dialog.js","names":[],"sources":["../../../../packages/web/src/dialog.ts"],"sourcesContent":["import { createDialog } from \"@kirana-ui/core/dialog\"\nimport type { DialogProps } from \"@kirana-ui/core/dialog\"\n\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-dialog>` around a `kui-part=\"trigger\"` button and a `portal`, which is drawn at the\n * end of the page while the dialog is open and holds its `backdrop` and its `popup`, with a\n * `title`, a `description` and a `close` button. A long dialog's popup is in a `viewport`,\n * which scrolls. `open`, `default-open`, `modal`, `dismissible`; it tells `open-change`.\n */\nexport const tag = defineElement({\n tag: \"kui-dialog\",\n props: {\n open: \"boolean\",\n \"default-open\": \"boolean\",\n modal: \"boolean\",\n dismissible: \"boolean\",\n },\n create: (props) => createDialog(props),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: {\n trigger: (controller) => controller.trigger,\n backdrop: (controller) => ({ mounted: controller.mounted, part: controller.backdrop }),\n viewport: (controller) => ({ mounted: controller.mounted, part: controller.viewport }),\n popup: (controller) => ({ mounted: controller.mounted, part: controller.popup }),\n title: (controller) => controller.title,\n description: (controller) => controller.description,\n close: (controller) => controller.close,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-dialog\": ElementOf<\n As<typeof tag, DialogProps>,\n { \"open-change\": [\"onOpenChange\", \"open\"] }\n >\n }\n}\n"],"mappings":";;;;;;;;;AAYA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EACL,MAAM;EACN,gBAAgB;EAChB,OAAO;EACP,aAAa;CACf;CACA,SAAS,UAAU,aAAa,KAAK;CACrC,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO;EACL,UAAU,eAAe,WAAW;EACpC,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;EACpF,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;EACpF,QAAQ,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAM;EAC9E,QAAQ,eAAe,WAAW;EAClC,cAAc,eAAe,WAAW;EACxC,QAAQ,eAAe,WAAW;CACpC;AACF,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { ElementOf, Tag } from "./runtime.js";
2
+ import { Placed } from "./around.js";
2
3
  /**
3
4
  * `<kui-hover-card>` around a `kui-part="trigger"` link and a `portal` with a `positioner`
4
5
  * around the `popup`, which the pointer may enter. `open`, `default-open`, `delay`,
@@ -9,7 +10,7 @@ declare global {
9
10
  interface HTMLElementTagNameMap {
10
11
  "kui-hover-card": ElementOf<typeof tag, {
11
12
  "open-change": ["onOpenChange", "open"];
12
- }>;
13
+ }> & Placed;
13
14
  }
14
15
  }
15
16
  //# sourceMappingURL=hover-card.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hover-card.js","names":[],"sources":["../../../../packages/web/src/hover-card.ts"],"sourcesContent":["import { createHoverCard } from \"@kirana-ui/core/hover-card\"\n\nimport { hoverPopup } from \"./hover-popup.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-hover-card>` around a `kui-part=\"trigger\"` link and a `portal` with a `positioner`\n * around the `popup`, which the pointer may enter. `open`, `default-open`, `delay`,\n * `close-delay`, `disabled`; it tells `open-change`.\n */\nexport const tag = hoverPopup(\"kui-hover-card\", createHoverCard)\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-hover-card\": ElementOf<typeof tag, { \"open-change\": [\"onOpenChange\", \"open\"] }>\n }\n}\n"],"mappings":";;;;;;;;AAUA,MAAa,MAAM,WAAW,kBAAkB,eAAe"}
1
+ {"version":3,"file":"hover-card.js","names":[],"sources":["../../../../packages/web/src/hover-card.ts"],"sourcesContent":["import { createHoverCard } from \"@kirana-ui/core/hover-card\"\n\nimport { hoverPopup } from \"./hover-popup.ts\"\nimport type { Placed } from \"./around.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-hover-card>` around a `kui-part=\"trigger\"` link and a `portal` with a `positioner`\n * around the `popup`, which the pointer may enter. `open`, `default-open`, `delay`,\n * `close-delay`, `disabled`; it tells `open-change`.\n */\nexport const tag = hoverPopup(\"kui-hover-card\", createHoverCard)\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-hover-card\": ElementOf<typeof tag, { \"open-change\": [\"onOpenChange\", \"open\"] }> & Placed\n }\n}\n"],"mappings":";;;;;;;;AAWA,MAAa,MAAM,WAAW,kBAAkB,eAAe"}
package/src/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import "./button.js";
7
7
  import "./calendar.js";
8
8
  import "./carousel.js";
9
9
  import "./checkbox.js";
10
+ import "./checkbox-group.js";
10
11
  import "./collapsible.js";
11
12
  import "./combobox.js";
12
13
  import "./command.js";
@@ -47,14 +48,17 @@ import "./toggle-group.js";
47
48
  import "./toolbar.js";
48
49
  import "./tooltip.js";
49
50
  import { Drawn, Each, ElementSpec, controllerAround, defineElement, entryAround, hostAround, partAround, partProps } from "./runtime.js";
50
- import { Align, Anchor, AnchorOption, Bindable, ChangeDetails, ChangeSource, ComponentDefinition, Direction, ItemLabels, ListCollection, Orientation, Part, PartDefinition, PartProps, PartState, PartStyle, PhysicalSide, PositionOptions, ReadonlySignal, Side, Signal, StateDefinition, StateOf } from "@kirana-ui/core";
51
+ import { Placed } from "./around.js";
52
+ import { Align, Anchor, AnchorOption, Bindable, ChangeDetails, ChangeSource, CollisionAvoidance, CollisionBoundary, CollisionPadding, ComponentDefinition, Direction, ItemLabels, ListCollection, OffsetData, OffsetFunction, Orientation, Part, PartDefinition, PartProps, PartState, PartStyle, PhysicalSide, PositionOptions, ReadonlySignal, Side, Signal, StateDefinition, StateOf } from "@kirana-ui/core";
53
+ import { ComboboxEntry, ComboboxGroupData, ComboboxGroupEntry, ComboboxItemData, ComboboxItemEntry, ComboboxShown } from "@kirana-ui/core/combobox";
51
54
  import { DrawerSide, DrawerSnapPoint } from "@kirana-ui/core/drawer";
52
55
  import { PaginationEntry } from "@kirana-ui/core/pagination";
53
- import { CalendarDay, CalendarValue, CalendarWeekday, DateRange, IsoDate } from "@kirana-ui/core/calendar";
56
+ import { ImageStatus } from "@kirana-ui/core/avatar";
57
+ import { CalendarDay, CalendarMode, CalendarMonth, CalendarValue, CalendarValueOf, CalendarWeekday, DateRange, IsoDate } from "@kirana-ui/core/calendar";
54
58
  import { DateFieldSegment, DateUnit } from "@kirana-ui/core/date-field";
55
59
  import { FieldValidity, ValidityKey } from "@kirana-ui/core/field";
56
60
  import { FormErrors, FormValues, ValidationMode } from "@kirana-ui/core/form";
57
61
  import { QrCorrection } from "@kirana-ui/core/qr-code";
58
62
  import { SelectShown } from "@kirana-ui/core/select";
59
63
  import { SliderChangeDetails, SliderTold } from "@kirana-ui/core/slider";
60
- export { type Align, type Anchor, type AnchorOption, type Bindable, type CalendarDay, type CalendarValue, type CalendarWeekday, type ChangeDetails, type ChangeSource, type ComponentDefinition, type DateFieldSegment, type DateRange, type DateUnit, type Direction, type DrawerSide, type DrawerSnapPoint, type Drawn, type Each, type ElementSpec, type FieldValidity, type FormErrors, type FormValues, type IsoDate, type ItemLabels, type ListCollection, type Orientation, type PaginationEntry, type Part, type PartDefinition, type PartProps, type PartState, type PartStyle, type PhysicalSide, type PositionOptions, type QrCorrection, type ReadonlySignal, type SelectShown, type Side, type Signal, type SliderChangeDetails, type SliderTold, type StateDefinition, type StateOf, type ValidationMode, type ValidityKey, controllerAround, defineElement, entryAround, hostAround, partAround, partProps };
64
+ export { type Align, type Anchor, type AnchorOption, type Bindable, type CalendarDay, type CalendarMode, type CalendarMonth, type CalendarValue, type CalendarValueOf, type CalendarWeekday, type ChangeDetails, type ChangeSource, type CollisionAvoidance, type CollisionBoundary, type CollisionPadding, type ComboboxEntry, type ComboboxGroupData, type ComboboxGroupEntry, type ComboboxItemData, type ComboboxItemEntry, type ComboboxShown, type ComponentDefinition, type DateFieldSegment, type DateRange, type DateUnit, type Direction, type DrawerSide, type DrawerSnapPoint, type Drawn, type Each, type ElementSpec, type FieldValidity, type FormErrors, type FormValues, type ImageStatus, type IsoDate, type ItemLabels, type ListCollection, type OffsetData, type OffsetFunction, type Orientation, type PaginationEntry, type Part, type PartDefinition, type PartProps, type PartState, type PartStyle, type PhysicalSide, type Placed, type PositionOptions, type QrCorrection, type ReadonlySignal, type SelectShown, type Side, type Signal, type SliderChangeDetails, type SliderTold, type StateDefinition, type StateOf, type ValidationMode, type ValidityKey, controllerAround, defineElement, entryAround, hostAround, partAround, partProps };
package/src/index.js CHANGED
@@ -7,6 +7,7 @@ import "./button.js";
7
7
  import "./calendar.js";
8
8
  import "./carousel.js";
9
9
  import "./checkbox.js";
10
+ import "./checkbox-group.js";
10
11
  import "./collapsible.js";
11
12
  import "./combobox.js";
12
13
  import "./command.js";
package/src/menu.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Drawn, ElementOf, Tag, Told } from "./runtime.js";
2
+ import { Placed } from "./around.js";
2
3
  import { Menu, MenuAround, MenuProps } from "@kirana-ui/core/menu";
3
4
  declare const menu: (tag: string, around: (host: HTMLElement) => MenuAround, trigger: (controller: Menu) => Drawn["part"]) => Tag<MenuProps, Menu>;
4
5
  /**
@@ -19,7 +20,7 @@ declare global {
19
20
  }, {
20
21
  "checked-change": Told<"checked", boolean>;
21
22
  "value-change": Told<"value", string>;
22
- }>;
23
+ }> & Placed;
23
24
  }
24
25
  }
25
26
  export { menu as defineMenu };
package/src/menu.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","names":[],"sources":["../../../../packages/web/src/menu.ts"],"sourcesContent":["import type { ReadonlySignal } from \"@kirana-ui/core\"\nimport { createMenu } from \"@kirana-ui/core/menu\"\nimport type {\n Menu,\n MenuAround,\n MenuCheckboxItem,\n MenuCheckboxItemProps,\n MenuGroup,\n MenuProps,\n MenuRadioGroup,\n MenuRadioGroupProps,\n} from \"@kirana-ui/core/menu\"\n\nimport { once, positioner, valueOf } from \"./around.ts\"\nimport { defineElement, hostAround, partAround, partProps } from \"./runtime.ts\"\nimport type { Drawn, ElementOf, Told } from \"./runtime.ts\"\n\nconst MENUS = [\"kui-menu\", \"kui-context-menu\"]\n\n/** An item's own options: `kui-disabled`, `kui-label`, `kui-close-on-click=\"false\"`. */\nconst options = (element: HTMLElement) => () => ({\n ...(element.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}),\n ...(element.hasAttribute(\"kui-label\") ? { label: element.getAttribute(\"kui-label\")! } : {}),\n ...(element.hasAttribute(\"kui-close-on-click\")\n ? { closeOnClick: element.getAttribute(\"kui-close-on-click\") !== \"false\" }\n : {}),\n})\n\ninterface Made<Controller> {\n controller: Controller\n mount(): () => void\n}\nconst groups = new WeakMap<HTMLElement, MenuGroup>()\nconst boxes = new WeakMap<HTMLElement, Made<MenuCheckboxItem>>()\nconst radios = new WeakMap<HTMLElement, Made<MenuRadioGroup<string>>>()\nlet made = 0\n\nconst ITEM = { disabled: \"boolean\", label: \"string\", \"close-on-click\": \"boolean\" } as const\n\nconst boxOf = (menu: Menu, element: HTMLElement | null) =>\n once(boxes, element, (item) => {\n const { props, mount } = partProps<MenuCheckboxItemProps>(\n item,\n { ...ITEM, checked: \"boolean\", \"default-checked\": \"boolean\" },\n { onCheckedChange: { event: \"checked-change\", prop: \"checked\" } }\n )\n const controller = menu.checkboxItem(props)\n return { controller, mount: both(mount, () => controller.mount()) }\n })\n\nconst radioOf = (menu: Menu, element: HTMLElement | null) =>\n once(radios, element, (group) => {\n const { props, mount } = partProps<MenuRadioGroupProps<string>>(\n group,\n { value: \"string\", \"default-value\": \"string\", disabled: \"boolean\" },\n { onValueChange: { event: \"value-change\", prop: \"value\" } }\n )\n const controller = menu.radioGroup<string>(props)\n return { controller, mount: both(mount, () => controller.mount()) }\n })\n\nconst both = (one: () => () => void, other: () => () => void) => () => {\n const stops = [one(), other()]\n return () => stops.forEach((stop) => stop())\n}\n\ntype Parts = Record<\n string,\n (controller: Menu, element: HTMLElement) => Drawn[\"part\"] | Drawn | undefined\n>\n\n/** A menu's parts but for its trigger, which a context menu has as an area. */\nconst PARTS: Parts = {\n positioner,\n popup: (controller) => controller.popup,\n arrow: (controller) => controller.arrow,\n separator: (controller) => controller.separator,\n item: (controller, element) => controller.item(options(element)),\n group: (controller, element) =>\n once(groups, element, (group) =>\n controller.group(group.getAttribute(\"kui-id\") ?? `kui-menu-group-${++made}`)\n )?.root,\n // With no group around it, it is plain text.\n \"group-label\": (controller, element) =>\n groups.get(partAround(element, \"group\")!)?.label ?? controller.label,\n \"checkbox-item\"(controller, element) {\n const box = boxOf(controller, element)!\n return { part: box.controller.part, mount: box.mount }\n },\n \"checkbox-item-indicator\"(controller, element) {\n const box = boxOf(controller, partAround(element, \"checkbox-item\"))\n return box && { part: box.controller.indicator, mounted: box.controller.checked }\n },\n \"radio-group\"(controller, element) {\n const group = radioOf(controller, element)!\n return { part: group.controller.root, mount: group.mount }\n },\n \"radio-item\"(controller, element) {\n const group = radioOf(controller, partAround(element, \"radio-group\"))\n return group?.controller.item(valueOf(element), options(element))\n },\n \"radio-item-indicator\"(controller, element) {\n const group = radioOf(controller, partAround(element, \"radio-group\"))?.controller\n const value = valueOf(partAround(element, \"radio-item\"))\n return group && { part: group.indicator(value), mounted: group.checked(value) }\n },\n}\n\nconst PROPS = {\n open: \"boolean\",\n \"default-open\": \"boolean\",\n disabled: \"boolean\",\n loop: \"boolean\",\n modal: \"boolean\",\n} as const\n\nconst menu = (\n tag: string,\n around: (host: HTMLElement) => MenuAround,\n trigger: (controller: Menu) => Drawn[\"part\"]\n) =>\n defineElement<MenuProps, Menu>({\n tag,\n props: PROPS,\n create: (props: ReadonlySignal<MenuProps>, host) => createMenu(props, around(host)),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: { ...PARTS, trigger },\n })\n\n/**\n * `<kui-menu>` around a `kui-part=\"trigger\"` and a `portal` with a `positioner` (its\n * `kui-side` and the like) around the `popup`, which holds its `item`s (`kui-disabled`,\n * `kui-label`, `kui-close-on-click=\"false\"`), `separator`s, `group`s with a `group-label`,\n * `checkbox-item`s (`kui-checked`, `kui-default-checked`; it tells `checked-change`) with a\n * `checkbox-item-indicator`, and a `radio-group` (`kui-value`, `kui-default-value`; it tells\n * `value-change`) of `radio-item`s (`kui-value`) with a `radio-item-indicator`. A `<kui-menu>`\n * inside a menu is its submenu, its trigger an item of the menu; inside a `<kui-menubar>`, one\n * of the bar's. `open`, `default-open`, `disabled`, `loop`, `modal`; it tells `open-change`.\n */\nexport const tag = menu(\n \"kui-menu\",\n (host) => {\n // The nearest: a menu written inside a bar's menu is that menu's, not the bar's.\n const around = hostAround(host, [...MENUS, \"kui-menubar\"])\n return around?.tag === \"kui-menubar\"\n ? { menubar: around.controller as NonNullable<MenuAround[\"menubar\"]> }\n : around\n ? { parent: around.controller as Menu }\n : {}\n },\n (controller) => controller.trigger\n)\n\nexport { menu as defineMenu }\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-menu\": ElementOf<\n typeof tag,\n { \"open-change\": [\"onOpenChange\", \"open\"] },\n { \"checked-change\": Told<\"checked\", boolean>; \"value-change\": Told<\"value\", string> }\n >\n }\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"menu.js","names":[],"sources":["../../../../packages/web/src/menu.ts"],"sourcesContent":["import type { ReadonlySignal } from \"@kirana-ui/core\"\nimport { createMenu } from \"@kirana-ui/core/menu\"\nimport type {\n Menu,\n MenuAround,\n MenuCheckboxItem,\n MenuCheckboxItemProps,\n MenuGroup,\n MenuProps,\n MenuRadioGroup,\n MenuRadioGroupProps,\n} from \"@kirana-ui/core/menu\"\n\nimport { once, positioner, valueOf } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { defineElement, hostAround, partAround, partProps } from \"./runtime.ts\"\nimport type { Drawn, ElementOf, Told } from \"./runtime.ts\"\n\nconst MENUS = [\"kui-menu\", \"kui-context-menu\"]\n\n/** An item's own options: `kui-disabled`, `kui-label`, `kui-close-on-click=\"false\"`. */\nconst options = (element: HTMLElement) => () => ({\n ...(element.hasAttribute(\"kui-disabled\") ? { disabled: true } : {}),\n ...(element.hasAttribute(\"kui-label\") ? { label: element.getAttribute(\"kui-label\")! } : {}),\n ...(element.hasAttribute(\"kui-close-on-click\")\n ? { closeOnClick: element.getAttribute(\"kui-close-on-click\") !== \"false\" }\n : {}),\n})\n\ninterface Made<Controller> {\n controller: Controller\n mount(): () => void\n}\nconst groups = new WeakMap<HTMLElement, MenuGroup>()\nconst boxes = new WeakMap<HTMLElement, Made<MenuCheckboxItem>>()\nconst radios = new WeakMap<HTMLElement, Made<MenuRadioGroup<string>>>()\nlet made = 0\n\nconst ITEM = { disabled: \"boolean\", label: \"string\", \"close-on-click\": \"boolean\" } as const\n\nconst boxOf = (menu: Menu, element: HTMLElement | null) =>\n once(boxes, element, (item) => {\n const { props, mount } = partProps<MenuCheckboxItemProps>(\n item,\n { ...ITEM, checked: \"boolean\", \"default-checked\": \"boolean\" },\n { onCheckedChange: { event: \"checked-change\", prop: \"checked\" } }\n )\n const controller = menu.checkboxItem(props)\n return { controller, mount: both(mount, () => controller.mount()) }\n })\n\nconst radioOf = (menu: Menu, element: HTMLElement | null) =>\n once(radios, element, (group) => {\n const { props, mount } = partProps<MenuRadioGroupProps<string>>(\n group,\n { value: \"string\", \"default-value\": \"string\", disabled: \"boolean\" },\n { onValueChange: { event: \"value-change\", prop: \"value\" } }\n )\n const controller = menu.radioGroup<string>(props)\n return { controller, mount: both(mount, () => controller.mount()) }\n })\n\nconst both = (one: () => () => void, other: () => () => void) => () => {\n const stops = [one(), other()]\n return () => stops.forEach((stop) => stop())\n}\n\ntype Parts = Record<\n string,\n (controller: Menu, element: HTMLElement) => Drawn[\"part\"] | Drawn | undefined\n>\n\n/** A menu's parts but for its trigger, which a context menu has as an area. */\nconst PARTS: Parts = {\n positioner,\n popup: (controller) => controller.popup,\n arrow: (controller) => controller.arrow,\n separator: (controller) => controller.separator,\n item: (controller, element) => controller.item(options(element)),\n group: (controller, element) =>\n once(groups, element, (group) =>\n controller.group(group.getAttribute(\"kui-id\") ?? `kui-menu-group-${++made}`)\n )?.root,\n // With no group around it, it is plain text.\n \"group-label\": (controller, element) =>\n groups.get(partAround(element, \"group\")!)?.label ?? controller.label,\n \"checkbox-item\"(controller, element) {\n const box = boxOf(controller, element)!\n return { part: box.controller.part, mount: box.mount }\n },\n \"checkbox-item-indicator\"(controller, element) {\n const box = boxOf(controller, partAround(element, \"checkbox-item\"))\n return box && { part: box.controller.indicator, mounted: box.controller.checked }\n },\n \"radio-group\"(controller, element) {\n const group = radioOf(controller, element)!\n return { part: group.controller.root, mount: group.mount }\n },\n \"radio-item\"(controller, element) {\n const group = radioOf(controller, partAround(element, \"radio-group\"))\n return group?.controller.item(valueOf(element), options(element))\n },\n \"radio-item-indicator\"(controller, element) {\n const group = radioOf(controller, partAround(element, \"radio-group\"))?.controller\n const value = valueOf(partAround(element, \"radio-item\"))\n return group && { part: group.indicator(value), mounted: group.checked(value) }\n },\n}\n\nconst PROPS = {\n open: \"boolean\",\n \"default-open\": \"boolean\",\n disabled: \"boolean\",\n loop: \"boolean\",\n modal: \"boolean\",\n} as const\n\nconst menu = (\n tag: string,\n around: (host: HTMLElement) => MenuAround,\n trigger: (controller: Menu) => Drawn[\"part\"]\n) =>\n defineElement<MenuProps, Menu>({\n tag,\n props: PROPS,\n create: (props: ReadonlySignal<MenuProps>, host) => createMenu(props, around(host)),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: { ...PARTS, trigger },\n })\n\n/**\n * `<kui-menu>` around a `kui-part=\"trigger\"` and a `portal` with a `positioner` (its\n * `kui-side` and the like) around the `popup`, which holds its `item`s (`kui-disabled`,\n * `kui-label`, `kui-close-on-click=\"false\"`), `separator`s, `group`s with a `group-label`,\n * `checkbox-item`s (`kui-checked`, `kui-default-checked`; it tells `checked-change`) with a\n * `checkbox-item-indicator`, and a `radio-group` (`kui-value`, `kui-default-value`; it tells\n * `value-change`) of `radio-item`s (`kui-value`) with a `radio-item-indicator`. A `<kui-menu>`\n * inside a menu is its submenu, its trigger an item of the menu; inside a `<kui-menubar>`, one\n * of the bar's. `open`, `default-open`, `disabled`, `loop`, `modal`; it tells `open-change`.\n */\nexport const tag = menu(\n \"kui-menu\",\n (host) => {\n // The nearest: a menu written inside a bar's menu is that menu's, not the bar's.\n const around = hostAround(host, [...MENUS, \"kui-menubar\"])\n return around?.tag === \"kui-menubar\"\n ? { menubar: around.controller as NonNullable<MenuAround[\"menubar\"]> }\n : around\n ? { parent: around.controller as Menu }\n : {}\n },\n (controller) => controller.trigger\n)\n\nexport { menu as defineMenu }\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-menu\": ElementOf<\n typeof tag,\n { \"open-change\": [\"onOpenChange\", \"open\"] },\n { \"checked-change\": Told<\"checked\", boolean>; \"value-change\": Told<\"value\", string> }\n > &\n Placed\n }\n}\n"],"mappings":"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"}
@@ -1,4 +1,5 @@
1
1
  import { ElementOf, Tag } from "./runtime.js";
2
+ import { Placed } from "./around.js";
2
3
  import { NavigationMenu, NavigationMenuProps } from "@kirana-ui/core/navigation-menu";
3
4
  /**
4
5
  * `<kui-navigation-menu>` around a `kui-part="root"` nav with its `list`. An `item` has a
@@ -14,7 +15,7 @@ declare global {
14
15
  interface HTMLElementTagNameMap {
15
16
  "kui-navigation-menu": ElementOf<typeof tag, {
16
17
  "value-change": ["onValueChange", "value"];
17
- }>;
18
+ }> & Placed;
18
19
  }
19
20
  }
20
21
  //# sourceMappingURL=navigation-menu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation-menu.js","names":[],"sources":["../../../../packages/web/src/navigation-menu.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createNavigationMenu } from \"@kirana-ui/core/navigation-menu\"\nimport type {\n NavigationMenu,\n NavigationMenuItem,\n NavigationMenuProps,\n} from \"@kirana-ui/core/navigation-menu\"\n\nimport { once, ownValue, positioner } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst NOTHING = computed(() => ({}))\nconst items = new WeakMap<HTMLElement, NavigationMenuItem>()\nconst itemOf = (controller: NavigationMenu<string>, element: HTMLElement) =>\n once(items, partAround(element, \"item\"), (item) =>\n controller.item(item.getAttribute(\"kui-value\") ?? ownValue(item))\n )\n\n/**\n * `<kui-navigation-menu>` around a `kui-part=\"root\"` nav with its `list`. An `item` has a\n * `trigger` (with an `icon` if it has one) and a `content`, which is drawn in the menu's one\n * `viewport` while its item is open; its `kui-value` tells it from the others, and an item\n * that is given none makes its own. A `link` is a link (`kui-active`,\n * `kui-close-on-click=\"false\"`). The viewport is in a `portal` with a `positioner` around\n * the `popup`, with an `arrow` and a `backdrop` if it has them. `value`, `default-value`,\n * `delay`, `close-delay`, `orientation`; it tells `value-change`.\n */\nexport const tag = defineElement<NavigationMenuProps<string>, NavigationMenu<string>>({\n tag: \"kui-navigation-menu\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n delay: \"number\",\n \"close-delay\": \"number\",\n orientation: \"string\",\n },\n create: (props) => createNavigationMenu<string>(props),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n list: (controller) => controller.list,\n // The item's own element takes nothing: it is where the item is in the page.\n item(controller, element) {\n const item = itemOf(controller, element)!\n return { part: { props: NOTHING, attach: () => () => {} }, mount: () => item.mount() }\n },\n trigger: (controller, element) => itemOf(controller, element)?.trigger,\n icon: (controller, element) => itemOf(controller, element)?.icon,\n content(controller, element) {\n const item = itemOf(controller, element)\n return item && { part: item.content, mounted: item.mounted, into: controller.viewportElement }\n },\n link: (controller, element) =>\n controller.link(() => ({\n ...(element.hasAttribute(\"kui-active\") ? { active: true } : {}),\n ...(element.hasAttribute(\"kui-close-on-click\")\n ? { closeOnClick: element.getAttribute(\"kui-close-on-click\") !== \"false\" }\n : {}),\n })),\n positioner,\n popup: (controller) => controller.popup,\n viewport: (controller) => controller.viewport,\n arrow: (controller) => controller.arrow,\n backdrop: (controller) => ({ mounted: controller.mounted, part: controller.backdrop }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-navigation-menu\": ElementOf<typeof tag, { \"value-change\": [\"onValueChange\", \"value\"] }>\n }\n}\n"],"mappings":";;;;;AAYA,MAAM,UAAU,gBAAgB,CAAC,EAAE;AACnC,MAAM,wBAAQ,IAAI,QAAyC;AAC3D,MAAM,UAAU,YAAoC,YAClD,KAAK,OAAO,WAAW,SAAS,MAAM,IAAI,SACxC,WAAW,KAAK,KAAK,aAAa,WAAW,KAAK,SAAS,IAAI,CAAC,CAClE;;;;;;;;;;AAWF,MAAa,MAAM,cAAmE;CACpF,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,OAAO;EACP,eAAe;EACf,aAAa;CACf;CACA,SAAS,UAAU,qBAA6B,KAAK;CACrD,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,OAAO,eAAe,WAAW;EAEjC,KAAK,YAAY,SAAS;GACxB,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO;IAAE,MAAM;KAAE,OAAO;KAAS,oBAAoB,CAAC;IAAE;IAAG,aAAa,KAAK,MAAM;GAAE;EACvF;EACA,UAAU,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC/D,OAAO,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC5D,QAAQ,YAAY,SAAS;GAC3B,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO,QAAQ;IAAE,MAAM,KAAK;IAAS,SAAS,KAAK;IAAS,MAAM,WAAW;GAAgB;EAC/F;EACA,OAAO,YAAY,YACjB,WAAW,YAAY;GACrB,GAAI,QAAQ,aAAa,YAAY,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;GAC7D,GAAI,QAAQ,aAAa,oBAAoB,IACzC,EAAE,cAAc,QAAQ,aAAa,oBAAoB,MAAM,QAAQ,IACvE,CAAC;EACP,EAAE;EACJ;EACA,QAAQ,eAAe,WAAW;EAClC,WAAW,eAAe,WAAW;EACrC,QAAQ,eAAe,WAAW;EAClC,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;CACtF;AACF,CAAC"}
1
+ {"version":3,"file":"navigation-menu.js","names":[],"sources":["../../../../packages/web/src/navigation-menu.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createNavigationMenu } from \"@kirana-ui/core/navigation-menu\"\nimport type {\n NavigationMenu,\n NavigationMenuItem,\n NavigationMenuProps,\n} from \"@kirana-ui/core/navigation-menu\"\n\nimport { once, ownValue, positioner } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst NOTHING = computed(() => ({}))\nconst items = new WeakMap<HTMLElement, NavigationMenuItem>()\nconst itemOf = (controller: NavigationMenu<string>, element: HTMLElement) =>\n once(items, partAround(element, \"item\"), (item) =>\n controller.item(item.getAttribute(\"kui-value\") ?? ownValue(item))\n )\n\n/**\n * `<kui-navigation-menu>` around a `kui-part=\"root\"` nav with its `list`. An `item` has a\n * `trigger` (with an `icon` if it has one) and a `content`, which is drawn in the menu's one\n * `viewport` while its item is open; its `kui-value` tells it from the others, and an item\n * that is given none makes its own. A `link` is a link (`kui-active`,\n * `kui-close-on-click=\"false\"`). The viewport is in a `portal` with a `positioner` around\n * the `popup`, with an `arrow` and a `backdrop` if it has them. `value`, `default-value`,\n * `delay`, `close-delay`, `orientation`; it tells `value-change`.\n */\nexport const tag = defineElement<NavigationMenuProps<string>, NavigationMenu<string>>({\n tag: \"kui-navigation-menu\",\n props: {\n value: \"string\",\n \"default-value\": \"string\",\n delay: \"number\",\n \"close-delay\": \"number\",\n orientation: \"string\",\n },\n create: (props) => createNavigationMenu<string>(props),\n changes: { onValueChange: { event: \"value-change\", prop: \"value\" } },\n parts: {\n root: (controller) => controller.root,\n list: (controller) => controller.list,\n // The item's own element takes nothing: it is where the item is in the page.\n item(controller, element) {\n const item = itemOf(controller, element)!\n return { part: { props: NOTHING, attach: () => () => {} }, mount: () => item.mount() }\n },\n trigger: (controller, element) => itemOf(controller, element)?.trigger,\n icon: (controller, element) => itemOf(controller, element)?.icon,\n content(controller, element) {\n const item = itemOf(controller, element)\n return item && { part: item.content, mounted: item.mounted, into: controller.viewportElement }\n },\n link: (controller, element) =>\n controller.link(() => ({\n ...(element.hasAttribute(\"kui-active\") ? { active: true } : {}),\n ...(element.hasAttribute(\"kui-close-on-click\")\n ? { closeOnClick: element.getAttribute(\"kui-close-on-click\") !== \"false\" }\n : {}),\n })),\n positioner,\n popup: (controller) => controller.popup,\n viewport: (controller) => controller.viewport,\n arrow: (controller) => controller.arrow,\n backdrop: (controller) => ({ mounted: controller.mounted, part: controller.backdrop }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-navigation-menu\": ElementOf<typeof tag, { \"value-change\": [\"onValueChange\", \"value\"] }> &\n Placed\n }\n}\n"],"mappings":";;;;;AAaA,MAAM,UAAU,gBAAgB,CAAC,EAAE;AACnC,MAAM,wBAAQ,IAAI,QAAyC;AAC3D,MAAM,UAAU,YAAoC,YAClD,KAAK,OAAO,WAAW,SAAS,MAAM,IAAI,SACxC,WAAW,KAAK,KAAK,aAAa,WAAW,KAAK,SAAS,IAAI,CAAC,CAClE;;;;;;;;;;AAWF,MAAa,MAAM,cAAmE;CACpF,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,OAAO;EACP,eAAe;EACf,aAAa;CACf;CACA,SAAS,UAAU,qBAA6B,KAAK;CACrD,SAAS,EAAE,eAAe;EAAE,OAAO;EAAgB,MAAM;CAAQ,EAAE;CACnE,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,OAAO,eAAe,WAAW;EAEjC,KAAK,YAAY,SAAS;GACxB,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO;IAAE,MAAM;KAAE,OAAO;KAAS,oBAAoB,CAAC;IAAE;IAAG,aAAa,KAAK,MAAM;GAAE;EACvF;EACA,UAAU,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC/D,OAAO,YAAY,YAAY,OAAO,YAAY,OAAO,CAAC,EAAE;EAC5D,QAAQ,YAAY,SAAS;GAC3B,MAAM,OAAO,OAAO,YAAY,OAAO;GACvC,OAAO,QAAQ;IAAE,MAAM,KAAK;IAAS,SAAS,KAAK;IAAS,MAAM,WAAW;GAAgB;EAC/F;EACA,OAAO,YAAY,YACjB,WAAW,YAAY;GACrB,GAAI,QAAQ,aAAa,YAAY,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;GAC7D,GAAI,QAAQ,aAAa,oBAAoB,IACzC,EAAE,cAAc,QAAQ,aAAa,oBAAoB,MAAM,QAAQ,IACvE,CAAC;EACP,EAAE;EACJ;EACA,QAAQ,eAAe,WAAW;EAClC,WAAW,eAAe,WAAW;EACrC,QAAQ,eAAe,WAAW;EAClC,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;CACtF;AACF,CAAC"}
@@ -2,8 +2,11 @@ import { As, ElementOf, Tag } from "./runtime.js";
2
2
  import { NumberFieldProps } from "@kirana-ui/core/number-field";
3
3
  /**
4
4
  * `<kui-number-field>` around `kui-part="root"`, a `group`, an `input`, and `increment` and
5
- * `decrement` buttons. With a name, the root draws the hidden input a form reads. `value`,
6
- * `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,
5
+ * `decrement` buttons. With a name, the root draws the hidden input a form reads. A
6
+ * `scrub-area` (a label, as a rule) is pressed and dragged to change the number, with
7
+ * `kui-direction="vertical"`, `kui-pixel-sensitivity` and `kui-teleport-distance` on it; a
8
+ * `scrub-area-cursor` inside it is drawn at the end of the page while the pointer is locked.
9
+ * `value`, `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,
7
10
  * `allow-wheel-scrub`, `locale`, `disabled`, `read-only`, `required`, `name`, `form`; `format`
8
11
  * as a property; it tells `value-change` and `value-committed`.
9
12
  */
@@ -1,11 +1,16 @@
1
1
  import { fieldAround } from "./around.js";
2
2
  import { defineElement } from "./runtime.js";
3
+ import { signal } from "@kirana-ui/core";
3
4
  import { createNumberField } from "@kirana-ui/core/number-field";
4
5
  // src/number-field.ts
6
+ const number = (text) => text === null ? void 0 : Number(text);
5
7
  /**
6
8
  * `<kui-number-field>` around `kui-part="root"`, a `group`, an `input`, and `increment` and
7
- * `decrement` buttons. With a name, the root draws the hidden input a form reads. `value`,
8
- * `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,
9
+ * `decrement` buttons. With a name, the root draws the hidden input a form reads. A
10
+ * `scrub-area` (a label, as a rule) is pressed and dragged to change the number, with
11
+ * `kui-direction="vertical"`, `kui-pixel-sensitivity` and `kui-teleport-distance` on it; a
12
+ * `scrub-area-cursor` inside it is drawn at the end of the page while the pointer is locked.
13
+ * `value`, `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,
9
14
  * `allow-wheel-scrub`, `locale`, `disabled`, `read-only`, `required`, `name`, `form`; `format`
10
15
  * as a property; it tells `value-change` and `value-committed`.
11
16
  */
@@ -49,7 +54,22 @@ const tag = defineElement({
49
54
  group: (controller) => controller.group,
50
55
  input: (controller) => controller.input,
51
56
  increment: (controller) => controller.increment,
52
- decrement: (controller) => controller.decrement
57
+ decrement: (controller) => controller.decrement,
58
+ "scrub-area"(controller, element) {
59
+ const direction = element.getAttribute("kui-direction");
60
+ const pixelSensitivity = number(element.getAttribute("kui-pixel-sensitivity"));
61
+ const teleportDistance = number(element.getAttribute("kui-teleport-distance"));
62
+ controller.scrub.set({
63
+ ...direction === "vertical" || direction === "horizontal" ? { direction } : {},
64
+ ...pixelSensitivity === void 0 ? {} : { pixelSensitivity },
65
+ ...teleportDistance === void 0 ? {} : { teleportDistance }
66
+ });
67
+ return controller.scrubArea;
68
+ },
69
+ "scrub-area-cursor": (controller, element) => ({
70
+ ...controller.scrubAreaCursor,
71
+ into: signal(element.ownerDocument.body)
72
+ })
53
73
  }
54
74
  });
55
75
  export { tag };
@@ -1 +1 @@
1
- {"version":3,"file":"number-field.js","names":[],"sources":["../../../../packages/web/src/number-field.ts"],"sourcesContent":["import { createNumberField } from \"@kirana-ui/core/number-field\"\nimport type { NumberFieldProps } from \"@kirana-ui/core/number-field\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-number-field>` around `kui-part=\"root\"`, a `group`, an `input`, and `increment` and\n * `decrement` buttons. With a name, the root draws the hidden input a form reads. `value`,\n * `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,\n * `allow-wheel-scrub`, `locale`, `disabled`, `read-only`, `required`, `name`, `form`; `format`\n * as a property; it tells `value-change` and `value-committed`.\n */\nexport const tag = defineElement({\n tag: \"kui-number-field\",\n props: {\n value: \"number\",\n \"default-value\": \"number\",\n min: \"number\",\n max: \"number\",\n step: \"number\",\n \"small-step\": \"number\",\n \"large-step\": \"number\",\n \"snap-on-step\": \"boolean\",\n \"allow-wheel-scrub\": \"boolean\",\n locale: \"string\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n properties: [\"format\"],\n create: (props, host) => createNumberField(props, { field: fieldAround(host) }),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onValueCommitted: { event: \"value-committed\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) =>\n controller.named.peek()\n ? { part: controller.root, inner: controller.hidden }\n : controller.root,\n group: (controller) => controller.group,\n input: (controller) => controller.input,\n increment: (controller) => controller.increment,\n decrement: (controller) => controller.decrement,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-number-field\": ElementOf<\n As<typeof tag, NumberFieldProps>,\n {\n \"value-change\": [\"onValueChange\", \"value\"]\n \"value-committed\": [\"onValueCommitted\", \"value\"]\n }\n >\n }\n}\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,KAAK;EACL,KAAK;EACL,MAAM;EACN,cAAc;EACd,cAAc;EACd,gBAAgB;EAChB,qBAAqB;EACrB,QAAQ;EACR,UAAU;EACV,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,YAAY,CAAC,QAAQ;CACrB,SAAS,OAAO,SAAS,kBAAkB,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CAC9E,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,kBAAkB;GAAE,OAAO;GAAmB,MAAM;GAAS,MAAM;EAAM;CAC3E;CACA,OAAO;EACL,OAAO,eACL,WAAW,MAAM,KAAK,IAClB;GAAE,MAAM,WAAW;GAAM,OAAO,WAAW;EAAO,IAClD,WAAW;EACjB,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,YAAY,eAAe,WAAW;CACxC;AACF,CAAC"}
1
+ {"version":3,"file":"number-field.js","names":[],"sources":["../../../../packages/web/src/number-field.ts"],"sourcesContent":["import { signal } from \"@kirana-ui/core\"\nimport { createNumberField } from \"@kirana-ui/core/number-field\"\nimport type { NumberFieldProps } from \"@kirana-ui/core/number-field\"\n\nimport { fieldAround } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\nconst number = (text: string | null) => (text === null ? undefined : Number(text))\n\n/**\n * `<kui-number-field>` around `kui-part=\"root\"`, a `group`, an `input`, and `increment` and\n * `decrement` buttons. With a name, the root draws the hidden input a form reads. A\n * `scrub-area` (a label, as a rule) is pressed and dragged to change the number, with\n * `kui-direction=\"vertical\"`, `kui-pixel-sensitivity` and `kui-teleport-distance` on it; a\n * `scrub-area-cursor` inside it is drawn at the end of the page while the pointer is locked.\n * `value`, `default-value`, `min`, `max`, `step`, `small-step`, `large-step`, `snap-on-step`,\n * `allow-wheel-scrub`, `locale`, `disabled`, `read-only`, `required`, `name`, `form`; `format`\n * as a property; it tells `value-change` and `value-committed`.\n */\nexport const tag = defineElement({\n tag: \"kui-number-field\",\n props: {\n value: \"number\",\n \"default-value\": \"number\",\n min: \"number\",\n max: \"number\",\n step: \"number\",\n \"small-step\": \"number\",\n \"large-step\": \"number\",\n \"snap-on-step\": \"boolean\",\n \"allow-wheel-scrub\": \"boolean\",\n locale: \"string\",\n disabled: \"boolean\",\n \"read-only\": \"boolean\",\n required: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n properties: [\"format\"],\n create: (props, host) => createNumberField(props, { field: fieldAround(host) }),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onValueCommitted: { event: \"value-committed\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) =>\n controller.named.peek()\n ? { part: controller.root, inner: controller.hidden }\n : controller.root,\n group: (controller) => controller.group,\n input: (controller) => controller.input,\n increment: (controller) => controller.increment,\n decrement: (controller) => controller.decrement,\n \"scrub-area\"(controller, element) {\n const direction = element.getAttribute(\"kui-direction\")\n const pixelSensitivity = number(element.getAttribute(\"kui-pixel-sensitivity\"))\n const teleportDistance = number(element.getAttribute(\"kui-teleport-distance\"))\n controller.scrub.set({\n ...(direction === \"vertical\" || direction === \"horizontal\" ? { direction } : {}),\n ...(pixelSensitivity === undefined ? {} : { pixelSensitivity }),\n ...(teleportDistance === undefined ? {} : { teleportDistance }),\n })\n return controller.scrubArea\n },\n // Not where it was written: at the end of the page, over everything.\n \"scrub-area-cursor\": (controller, element) => ({\n ...controller.scrubAreaCursor,\n into: signal(element.ownerDocument.body),\n }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-number-field\": ElementOf<\n As<typeof tag, NumberFieldProps>,\n {\n \"value-change\": [\"onValueChange\", \"value\"]\n \"value-committed\": [\"onValueCommitted\", \"value\"]\n }\n >\n }\n}\n"],"mappings":";;;;;AAQA,MAAM,UAAU,SAAyB,SAAS,OAAO,KAAA,IAAY,OAAO,IAAI;;;;;;;;;;;AAYhF,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EACL,OAAO;EACP,iBAAiB;EACjB,KAAK;EACL,KAAK;EACL,MAAM;EACN,cAAc;EACd,cAAc;EACd,gBAAgB;EAChB,qBAAqB;EACrB,QAAQ;EACR,UAAU;EACV,aAAa;EACb,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,YAAY,CAAC,QAAQ;CACrB,SAAS,OAAO,SAAS,kBAAkB,OAAO,EAAE,OAAO,YAAY,IAAI,EAAE,CAAC;CAC9E,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,kBAAkB;GAAE,OAAO;GAAmB,MAAM;GAAS,MAAM;EAAM;CAC3E;CACA,OAAO;EACL,OAAO,eACL,WAAW,MAAM,KAAK,IAClB;GAAE,MAAM,WAAW;GAAM,OAAO,WAAW;EAAO,IAClD,WAAW;EACjB,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,YAAY,eAAe,WAAW;EACtC,aAAa,YAAY,SAAS;GAChC,MAAM,YAAY,QAAQ,aAAa,eAAe;GACtD,MAAM,mBAAmB,OAAO,QAAQ,aAAa,uBAAuB,CAAC;GAC7E,MAAM,mBAAmB,OAAO,QAAQ,aAAa,uBAAuB,CAAC;GAC7E,WAAW,MAAM,IAAI;IACnB,GAAI,cAAc,cAAc,cAAc,eAAe,EAAE,UAAU,IAAI,CAAC;IAC9E,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB;IAC7D,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB;GAC/D,CAAC;GACD,OAAO,WAAW;EACpB;EAEA,sBAAsB,YAAY,aAAa;GAC7C,GAAG,WAAW;GACd,MAAM,OAAO,QAAQ,cAAc,IAAI;EACzC;CACF;AACF,CAAC"}
package/src/otp.d.ts CHANGED
@@ -4,7 +4,7 @@ import { Otp, OtpProps } from "@kirana-ui/core/otp";
4
4
  * `<kui-otp>` around `kui-part="root"`, the one `input` that is typed in, and a `slot` for
5
5
  * each character (`kui-index`, from 0), which says its character and may hold a `caret`, in
6
6
  * the page while the next character goes there. Slots may be in `group`s with a `separator`
7
- * between. `length`, `value`, `default-value`, `mode`, `disabled`, `name`, `form`; it tells
7
+ * between. `length`, `value`, `default-value`, `mode`, `pattern`, `disabled`, `name`, `form`; it tells
8
8
  * `value-change` and `complete`.
9
9
  */
10
10
  export declare const tag: Tag<OtpProps, Otp>;
package/src/otp.js CHANGED
@@ -7,7 +7,7 @@ const indexOf = (element) => Number(element?.getAttribute("kui-index") ?? 0);
7
7
  * `<kui-otp>` around `kui-part="root"`, the one `input` that is typed in, and a `slot` for
8
8
  * each character (`kui-index`, from 0), which says its character and may hold a `caret`, in
9
9
  * the page while the next character goes there. Slots may be in `group`s with a `separator`
10
- * between. `length`, `value`, `default-value`, `mode`, `disabled`, `name`, `form`; it tells
10
+ * between. `length`, `value`, `default-value`, `mode`, `pattern`, `disabled`, `name`, `form`; it tells
11
11
  * `value-change` and `complete`.
12
12
  */
13
13
  const tag = defineElement({
@@ -17,6 +17,7 @@ const tag = defineElement({
17
17
  value: "string",
18
18
  "default-value": "string",
19
19
  mode: "string",
20
+ pattern: "string",
20
21
  disabled: "boolean",
21
22
  name: "string",
22
23
  form: "string"
package/src/otp.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/web/src/otp.ts"],"sourcesContent":["import { effect } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp, OtpProps } from \"@kirana-ui/core/otp\"\n\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst indexOf = (element: HTMLElement | null) => Number(element?.getAttribute(\"kui-index\") ?? 0)\n\n/**\n * `<kui-otp>` around `kui-part=\"root\"`, the one `input` that is typed in, and a `slot` for\n * each character (`kui-index`, from 0), which says its character and may hold a `caret`, in\n * the page while the next character goes there. Slots may be in `group`s with a `separator`\n * between. `length`, `value`, `default-value`, `mode`, `disabled`, `name`, `form`; it tells\n * `value-change` and `complete`.\n */\nexport const tag = defineElement<OtpProps, Otp>({\n tag: \"kui-otp\",\n props: {\n length: \"number\",\n value: \"string\",\n \"default-value\": \"string\",\n mode: \"string\",\n disabled: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n create: (props) => createOtp(props),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onComplete: { event: \"complete\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) => controller.root,\n input: (controller) => controller.input,\n group: (controller) => controller.group,\n separator: (controller) => controller.separator,\n slot(controller, element) {\n const slot = controller.slot(indexOf(element))\n return {\n part: slot.part,\n // Its character comes before what the page wrote in it: a caret.\n mount() {\n const text = element.ownerDocument.createTextNode(\"\")\n element.prepend(text)\n const stop = effect(() => void (text.data = slot.char.get()))\n return () => {\n stop()\n text.remove()\n }\n },\n }\n },\n caret: (controller, element) => ({\n part: controller.caretPart,\n mounted: controller.slot(indexOf(partAround(element, \"slot\"))).caret,\n }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-otp\": ElementOf<\n typeof tag,\n { \"value-change\": [\"onValueChange\", \"value\"]; complete: [\"onComplete\", \"value\"] }\n >\n }\n}\n"],"mappings":";;;;AAOA,MAAM,WAAW,YAAgC,OAAO,SAAS,aAAa,WAAW,KAAK,CAAC;;;;;;;;AAS/F,MAAa,MAAM,cAA6B;CAC9C,KAAK;CACL,OAAO;EACL,QAAQ;EACR,OAAO;EACP,iBAAiB;EACjB,MAAM;EACN,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,SAAS,UAAU,UAAU,KAAK;CAClC,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,YAAY;GAAE,OAAO;GAAY,MAAM;GAAS,MAAM;EAAM;CAC9D;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,KAAK,YAAY,SAAS;GACxB,MAAM,OAAO,WAAW,KAAK,QAAQ,OAAO,CAAC;GAC7C,OAAO;IACL,MAAM,KAAK;IAEX,QAAQ;KACN,MAAM,OAAO,QAAQ,cAAc,eAAe,EAAE;KACpD,QAAQ,QAAQ,IAAI;KACpB,MAAM,OAAO,aAAa,MAAM,KAAK,OAAO,KAAK,KAAK,IAAI,EAAE;KAC5D,aAAa;MACX,KAAK;MACL,KAAK,OAAO;KACd;IACF;GACF;EACF;EACA,QAAQ,YAAY,aAAa;GAC/B,MAAM,WAAW;GACjB,SAAS,WAAW,KAAK,QAAQ,WAAW,SAAS,MAAM,CAAC,CAAC,CAAC,CAAC;EACjE;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/web/src/otp.ts"],"sourcesContent":["import { effect } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp, OtpProps } from \"@kirana-ui/core/otp\"\n\nimport { defineElement, partAround } from \"./runtime.ts\"\nimport type { ElementOf } from \"./runtime.ts\"\n\nconst indexOf = (element: HTMLElement | null) => Number(element?.getAttribute(\"kui-index\") ?? 0)\n\n/**\n * `<kui-otp>` around `kui-part=\"root\"`, the one `input` that is typed in, and a `slot` for\n * each character (`kui-index`, from 0), which says its character and may hold a `caret`, in\n * the page while the next character goes there. Slots may be in `group`s with a `separator`\n * between. `length`, `value`, `default-value`, `mode`, `pattern`, `disabled`, `name`, `form`; it tells\n * `value-change` and `complete`.\n */\nexport const tag = defineElement<OtpProps, Otp>({\n tag: \"kui-otp\",\n props: {\n length: \"number\",\n value: \"string\",\n \"default-value\": \"string\",\n mode: \"string\",\n pattern: \"string\",\n disabled: \"boolean\",\n name: \"string\",\n form: \"string\",\n },\n create: (props) => createOtp(props),\n changes: {\n onValueChange: { event: \"value-change\", prop: \"value\" },\n onComplete: { event: \"complete\", prop: \"value\", hold: false },\n },\n parts: {\n root: (controller) => controller.root,\n input: (controller) => controller.input,\n group: (controller) => controller.group,\n separator: (controller) => controller.separator,\n slot(controller, element) {\n const slot = controller.slot(indexOf(element))\n return {\n part: slot.part,\n // Its character comes before what the page wrote in it: a caret.\n mount() {\n const text = element.ownerDocument.createTextNode(\"\")\n element.prepend(text)\n const stop = effect(() => void (text.data = slot.char.get()))\n return () => {\n stop()\n text.remove()\n }\n },\n }\n },\n caret: (controller, element) => ({\n part: controller.caretPart,\n mounted: controller.slot(indexOf(partAround(element, \"slot\"))).caret,\n }),\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-otp\": ElementOf<\n typeof tag,\n { \"value-change\": [\"onValueChange\", \"value\"]; complete: [\"onComplete\", \"value\"] }\n >\n }\n}\n"],"mappings":";;;;AAOA,MAAM,WAAW,YAAgC,OAAO,SAAS,aAAa,WAAW,KAAK,CAAC;;;;;;;;AAS/F,MAAa,MAAM,cAA6B;CAC9C,KAAK;CACL,OAAO;EACL,QAAQ;EACR,OAAO;EACP,iBAAiB;EACjB,MAAM;EACN,SAAS;EACT,UAAU;EACV,MAAM;EACN,MAAM;CACR;CACA,SAAS,UAAU,UAAU,KAAK;CAClC,SAAS;EACP,eAAe;GAAE,OAAO;GAAgB,MAAM;EAAQ;EACtD,YAAY;GAAE,OAAO;GAAY,MAAM;GAAS,MAAM;EAAM;CAC9D;CACA,OAAO;EACL,OAAO,eAAe,WAAW;EACjC,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,YAAY,eAAe,WAAW;EACtC,KAAK,YAAY,SAAS;GACxB,MAAM,OAAO,WAAW,KAAK,QAAQ,OAAO,CAAC;GAC7C,OAAO;IACL,MAAM,KAAK;IAEX,QAAQ;KACN,MAAM,OAAO,QAAQ,cAAc,eAAe,EAAE;KACpD,QAAQ,QAAQ,IAAI;KACpB,MAAM,OAAO,aAAa,MAAM,KAAK,OAAO,KAAK,KAAK,IAAI,EAAE;KAC5D,aAAa;MACX,KAAK;MACL,KAAK,OAAO;KACd;IACF;GACF;EACF;EACA,QAAQ,YAAY,aAAa;GAC/B,MAAM,WAAW;GACjB,SAAS,WAAW,KAAK,QAAQ,WAAW,SAAS,MAAM,CAAC,CAAC,CAAC,CAAC;EACjE;CACF;AACF,CAAC"}
package/src/popover.d.ts CHANGED
@@ -1,20 +1,21 @@
1
1
  import { As, ElementOf, Tag } from "./runtime.js";
2
- import { PopoverProps } from "@kirana-ui/core/popover";
2
+ import { Placed } from "./around.js";
3
+ import { Popover, PopoverProps } from "@kirana-ui/core/popover";
3
4
  /**
4
5
  * `<kui-popover>` around a `kui-part="trigger"` button and a `portal`, drawn at the end of the
5
6
  * page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,
6
7
  * `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`: the id of the element it is
7
- * placed against, when that is not the trigger) around the `popup`, which may hold a `title`,
8
- * a `description` and a `close` button. `open`, `default-open`; it tells `open-change`.
8
+ * placed against, when that is not the trigger) around the `popup`, which may hold an `arrow`,
9
+ * a `title`, a `description` and a `close` button; the portal may hold a `backdrop` too. The
10
+ * trigger takes `kui-open-on-hover`, with `kui-delay` and `kui-close-delay`. `open`,
11
+ * `default-open`, `modal` (there, or `"trap-focus"`); it tells `open-change`.
9
12
  */
10
- export declare const tag: Tag<{
11
- id: string;
12
- }, import("@kirana-ui/core/popover").Popover>;
13
+ export declare const tag: Tag<PopoverProps, Popover>;
13
14
  declare global {
14
15
  interface HTMLElementTagNameMap {
15
16
  "kui-popover": ElementOf<As<typeof tag, PopoverProps>, {
16
17
  "open-change": ["onOpenChange", "open"];
17
- }>;
18
+ }> & Placed;
18
19
  }
19
20
  }
20
21
  //# sourceMappingURL=popover.d.ts.map
package/src/popover.js CHANGED
@@ -1,29 +1,57 @@
1
1
  import { positioner } from "./around.js";
2
2
  import { defineElement } from "./runtime.js";
3
+ import { computed } from "@kirana-ui/core";
3
4
  import { createPopover } from "@kirana-ui/core/popover";
4
5
  // src/popover.ts
6
+ const number = (text) => text === null ? void 0 : Number(text);
7
+ /** `modal` as its attribute writes it: there or not, `"false"`, or `"trap-focus"`. */
8
+ const modalOf = (given) => given === "trap-focus" ? given : given !== void 0 && given !== false && given !== "false";
5
9
  /**
6
10
  * `<kui-popover>` around a `kui-part="trigger"` button and a `portal`, drawn at the end of the
7
11
  * page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,
8
12
  * `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`: the id of the element it is
9
- * placed against, when that is not the trigger) around the `popup`, which may hold a `title`,
10
- * a `description` and a `close` button. `open`, `default-open`; it tells `open-change`.
13
+ * placed against, when that is not the trigger) around the `popup`, which may hold an `arrow`,
14
+ * a `title`, a `description` and a `close` button; the portal may hold a `backdrop` too. The
15
+ * trigger takes `kui-open-on-hover`, with `kui-delay` and `kui-close-delay`. `open`,
16
+ * `default-open`, `modal` (there, or `"trap-focus"`); it tells `open-change`.
11
17
  */
12
18
  const tag = defineElement({
13
19
  tag: "kui-popover",
14
20
  props: {
15
21
  open: "boolean",
16
- "default-open": "boolean"
22
+ "default-open": "boolean",
23
+ modal: "string"
17
24
  },
18
- create: (props) => createPopover(props),
25
+ create: (props) => createPopover(computed(() => {
26
+ const own = props.get();
27
+ return {
28
+ ...own,
29
+ modal: modalOf(own.modal)
30
+ };
31
+ })),
19
32
  changes: { onOpenChange: {
20
33
  event: "open-change",
21
34
  prop: "open"
22
35
  } },
23
36
  parts: {
24
- trigger: (controller) => controller.trigger,
37
+ trigger(controller, element) {
38
+ const delay = number(element.getAttribute("kui-delay"));
39
+ const closeDelay = number(element.getAttribute("kui-close-delay"));
40
+ const hover = element.getAttribute("kui-open-on-hover");
41
+ controller.hovering.set({
42
+ ...hover === null ? {} : { openOnHover: hover !== "false" },
43
+ ...delay === void 0 ? {} : { delay },
44
+ ...closeDelay === void 0 ? {} : { closeDelay }
45
+ });
46
+ return controller.trigger;
47
+ },
48
+ backdrop: (controller) => ({
49
+ mounted: controller.mounted,
50
+ part: controller.backdrop
51
+ }),
25
52
  positioner,
26
53
  popup: (controller) => controller.popup,
54
+ arrow: (controller) => controller.arrow,
27
55
  title: (controller) => controller.title,
28
56
  description: (controller) => controller.description,
29
57
  close: (controller) => controller.close
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","names":[],"sources":["../../../../packages/web/src/popover.ts"],"sourcesContent":["import { createPopover } from \"@kirana-ui/core/popover\"\nimport type { PopoverProps } from \"@kirana-ui/core/popover\"\n\nimport { positioner } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\n/**\n * `<kui-popover>` around a `kui-part=\"trigger\"` button and a `portal`, drawn at the end of the\n * page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,\n * `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`: the id of the element it is\n * placed against, when that is not the trigger) around the `popup`, which may hold a `title`,\n * a `description` and a `close` button. `open`, `default-open`; it tells `open-change`.\n */\nexport const tag = defineElement({\n tag: \"kui-popover\",\n props: { open: \"boolean\", \"default-open\": \"boolean\" },\n create: (props) => createPopover(props),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: {\n trigger: (controller) => controller.trigger,\n positioner,\n popup: (controller) => controller.popup,\n title: (controller) => controller.title,\n description: (controller) => controller.description,\n close: (controller) => controller.close,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-popover\": ElementOf<\n As<typeof tag, PopoverProps>,\n { \"open-change\": [\"onOpenChange\", \"open\"] }\n >\n }\n}\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,MAAM,cAAc;CAC/B,KAAK;CACL,OAAO;EAAE,MAAM;EAAW,gBAAgB;CAAU;CACpD,SAAS,UAAU,cAAc,KAAK;CACtC,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO;EACL,UAAU,eAAe,WAAW;EACpC;EACA,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,cAAc,eAAe,WAAW;EACxC,QAAQ,eAAe,WAAW;CACpC;AACF,CAAC"}
1
+ {"version":3,"file":"popover.js","names":[],"sources":["../../../../packages/web/src/popover.ts"],"sourcesContent":["import { computed } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type { Popover, PopoverProps } from \"@kirana-ui/core/popover\"\n\nimport { positioner } from \"./around.ts\"\nimport type { Placed } from \"./around.ts\"\nimport { defineElement } from \"./runtime.ts\"\nimport type { As, ElementOf } from \"./runtime.ts\"\n\nconst number = (text: string | null) => (text === null ? undefined : Number(text))\n\n/** `modal` as its attribute writes it: there or not, `\"false\"`, or `\"trap-focus\"`. */\nconst modalOf = (given: unknown): PopoverProps[\"modal\"] =>\n given === \"trap-focus\" ? given : given !== undefined && given !== false && given !== \"false\"\n\n/**\n * `<kui-popover>` around a `kui-part=\"trigger\"` button and a `portal`, drawn at the end of the\n * page while it is open, with a `positioner` (`kui-side`, `kui-align`, `kui-side-offset`,\n * `kui-align-offset`, `kui-collision-padding`, and `kui-anchor`: the id of the element it is\n * placed against, when that is not the trigger) around the `popup`, which may hold an `arrow`,\n * a `title`, a `description` and a `close` button; the portal may hold a `backdrop` too. The\n * trigger takes `kui-open-on-hover`, with `kui-delay` and `kui-close-delay`. `open`,\n * `default-open`, `modal` (there, or `\"trap-focus\"`); it tells `open-change`.\n */\nexport const tag = defineElement<PopoverProps, Popover>({\n tag: \"kui-popover\",\n props: { open: \"boolean\", \"default-open\": \"boolean\", modal: \"string\" },\n create: (props) =>\n createPopover(\n computed(() => {\n const own = props.get()\n return { ...own, modal: modalOf(own.modal) }\n })\n ),\n changes: { onOpenChange: { event: \"open-change\", prop: \"open\" } },\n parts: {\n trigger(controller, element) {\n const delay = number(element.getAttribute(\"kui-delay\"))\n const closeDelay = number(element.getAttribute(\"kui-close-delay\"))\n const hover = element.getAttribute(\"kui-open-on-hover\")\n controller.hovering.set({\n ...(hover === null ? {} : { openOnHover: hover !== \"false\" }),\n ...(delay === undefined ? {} : { delay }),\n ...(closeDelay === undefined ? {} : { closeDelay }),\n })\n return controller.trigger\n },\n backdrop: (controller) => ({ mounted: controller.mounted, part: controller.backdrop }),\n positioner,\n popup: (controller) => controller.popup,\n arrow: (controller) => controller.arrow,\n title: (controller) => controller.title,\n description: (controller) => controller.description,\n close: (controller) => controller.close,\n },\n})\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kui-popover\": ElementOf<\n As<typeof tag, PopoverProps>,\n { \"open-change\": [\"onOpenChange\", \"open\"] }\n > &\n Placed\n }\n}\n"],"mappings":";;;;;AASA,MAAM,UAAU,SAAyB,SAAS,OAAO,KAAA,IAAY,OAAO,IAAI;;AAGhF,MAAM,WAAW,UACf,UAAU,eAAe,QAAQ,UAAU,KAAA,KAAa,UAAU,SAAS,UAAU;;;;;;;;;;AAWvF,MAAa,MAAM,cAAqC;CACtD,KAAK;CACL,OAAO;EAAE,MAAM;EAAW,gBAAgB;EAAW,OAAO;CAAS;CACrE,SAAS,UACP,cACE,eAAe;EACb,MAAM,MAAM,MAAM,IAAI;EACtB,OAAO;GAAE,GAAG;GAAK,OAAO,QAAQ,IAAI,KAAK;EAAE;CAC7C,CAAC,CACH;CACF,SAAS,EAAE,cAAc;EAAE,OAAO;EAAe,MAAM;CAAO,EAAE;CAChE,OAAO;EACL,QAAQ,YAAY,SAAS;GAC3B,MAAM,QAAQ,OAAO,QAAQ,aAAa,WAAW,CAAC;GACtD,MAAM,aAAa,OAAO,QAAQ,aAAa,iBAAiB,CAAC;GACjE,MAAM,QAAQ,QAAQ,aAAa,mBAAmB;GACtD,WAAW,SAAS,IAAI;IACtB,GAAI,UAAU,OAAO,CAAC,IAAI,EAAE,aAAa,UAAU,QAAQ;IAC3D,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM;IACvC,GAAI,eAAe,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW;GACnD,CAAC;GACD,OAAO,WAAW;EACpB;EACA,WAAW,gBAAgB;GAAE,SAAS,WAAW;GAAS,MAAM,WAAW;EAAS;EACpF;EACA,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,QAAQ,eAAe,WAAW;EAClC,cAAc,eAAe,WAAW;EACxC,QAAQ,eAAe,WAAW;CACpC;AACF,CAAC"}
@@ -3,7 +3,8 @@ import { RadioGroupProps } from "@kirana-ui/core/radio-group";
3
3
  /**
4
4
  * `<kui-radio-group>` around `kui-part="root"` and an `item` button for each `value`, with an
5
5
  * `indicator` inside that is in the page while its item is the chosen one. An item draws the
6
- * hidden native radio a form and a label reach. `value`, `default-value`, `disabled`,
6
+ * hidden native radio a form and a label reach; an item's `kui-id` is that radio's id, which a
7
+ * `<label for>` names. `value`, `default-value`, `disabled`,
7
8
  * `read-only`, `required`, `name`, `form`; it tells `value-change`.
8
9
  */
9
10
  export declare const tag: Tag<RadioGroupProps<string>, import("@kirana-ui/core/radio-group").RadioGroup<string>>;