@kirana-ui/vue 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +140 -0
- package/llms.txt +1779 -182
- package/package.json +48 -3
- package/skills/kirana-ui-primitives/SKILL.md +53 -12
- package/src/accordion.d.ts +4 -0
- package/src/accordion.js +6 -0
- package/src/accordion.js.map +1 -1
- package/src/alert-dialog.d.ts +2 -2
- package/src/autocomplete.d.ts +2 -2
- package/src/avatar.d.ts +31 -4
- package/src/avatar.js +40 -16
- package/src/avatar.js.map +1 -1
- package/src/button.d.ts +4 -1
- package/src/button.js +4 -1
- package/src/button.js.map +1 -1
- package/src/calendar.d.ts +22 -13
- package/src/calendar.js +83 -12
- package/src/calendar.js.map +1 -1
- package/src/carousel.d.ts +5 -2
- package/src/carousel.js +1 -4
- package/src/carousel.js.map +1 -1
- package/src/checkbox-group-context.d.ts +5 -0
- package/src/checkbox-group-context.js +6 -0
- package/src/checkbox-group-context.js.map +1 -0
- package/src/checkbox-group.d.ts +12 -0
- package/src/checkbox-group.js +44 -0
- package/src/checkbox-group.js.map +1 -0
- package/src/checkbox.d.ts +17 -0
- package/src/checkbox.js +9 -2
- package/src/checkbox.js.map +1 -1
- package/src/collapsible.d.ts +2 -0
- package/src/color-picker.d.ts +118 -0
- package/src/color-picker.js +174 -0
- package/src/color-picker.js.map +1 -0
- package/src/combobox.d.ts +105 -5
- package/src/combobox.js +83 -12
- package/src/combobox.js.map +1 -1
- package/src/command.d.ts +2 -2
- package/src/command.js +3 -1
- package/src/command.js.map +1 -1
- package/src/date-field.d.ts +1 -1
- package/src/date-field.js +2 -0
- package/src/date-field.js.map +1 -1
- package/src/date-picker.d.ts +39 -13
- package/src/date-picker.js +104 -51
- package/src/date-picker.js.map +1 -1
- package/src/dialog.d.ts +41 -8
- package/src/dialog.js +44 -8
- package/src/dialog.js.map +1 -1
- package/src/drawer.d.ts +2 -2
- package/src/editable.d.ts +87 -0
- package/src/editable.js +83 -0
- package/src/editable.js.map +1 -0
- package/src/element.js +5 -5
- package/src/element.js.map +1 -1
- package/src/file-upload.d.ts +76 -0
- package/src/file-upload.js +139 -0
- package/src/file-upload.js.map +1 -0
- package/src/hover-card.d.ts +3 -0
- package/src/index.d.ts +28 -7
- package/src/index.js +12 -1
- package/src/menu.d.ts +10 -0
- package/src/menu.js +17 -6
- package/src/menu.js.map +1 -1
- package/src/menubar.js +10 -1
- package/src/menubar.js.map +1 -1
- package/src/navigation-menu.d.ts +14 -3
- package/src/navigation-menu.js +20 -2
- package/src/navigation-menu.js.map +1 -1
- package/src/number-field.d.ts +33 -1
- package/src/number-field.js +98 -68
- package/src/number-field.js.map +1 -1
- package/src/otp.d.ts +25 -3
- package/src/otp.js +22 -3
- package/src/otp.js.map +1 -1
- package/src/password-input.d.ts +37 -0
- package/src/password-input.js +44 -0
- package/src/password-input.js.map +1 -0
- package/src/popover.d.ts +32 -4
- package/src/popover.js +37 -5
- package/src/popover.js.map +1 -1
- package/src/radio-group.d.ts +12 -0
- package/src/radio-group.js +6 -2
- package/src/radio-group.js.map +1 -1
- package/src/rating.d.ts +34 -0
- package/src/rating.js +81 -0
- package/src/rating.js.map +1 -0
- package/src/runtime.d.ts +2 -1
- package/src/runtime.js +5 -2
- package/src/runtime.js.map +1 -1
- package/src/scroll-area.d.ts +24 -1
- package/src/select.d.ts +39 -5
- package/src/select.js +30 -9
- package/src/select.js.map +1 -1
- package/src/slider.d.ts +35 -0
- package/src/slider.js +1 -0
- package/src/slider.js.map +1 -1
- package/src/steps.d.ts +74 -0
- package/src/steps.js +84 -0
- package/src/steps.js.map +1 -0
- package/src/switch.d.ts +12 -0
- package/src/tabs.d.ts +2 -0
- package/src/tabs.js +5 -0
- package/src/tabs.js.map +1 -1
- package/src/tags-input.d.ts +69 -0
- package/src/tags-input.js +145 -0
- package/src/tags-input.js.map +1 -0
- package/src/time-field.d.ts +41 -0
- package/src/time-field.js +85 -0
- package/src/time-field.js.map +1 -0
- package/src/toast.d.ts +12 -4
- package/src/toggle-group.js +6 -0
- package/src/toggle-group.js.map +1 -1
- package/src/toolbar-context.d.ts +1 -1
- package/src/toolbar.d.ts +4 -1
- package/src/toolbar.js +17 -2
- package/src/toolbar.js.map +1 -1
- package/src/tooltip.d.ts +5 -0
- package/src/tour.d.ts +75 -0
- package/src/tour.js +95 -0
- package/src/tour.js.map +1 -0
- package/src/tree.d.ts +69 -0
- package/src/tree.js +118 -0
- package/src/tree.js.map +1 -0
package/src/calendar.js
CHANGED
|
@@ -2,7 +2,7 @@ import { useDirectionAround } from "./direction-context.js";
|
|
|
2
2
|
import { written } from "./element.js";
|
|
3
3
|
import { context, controller, fromSignal, optional, partComponent } from "./runtime.js";
|
|
4
4
|
import { within } from "@kirana-ui/core";
|
|
5
|
-
import { Fragment, defineComponent, h, useId } from "vue";
|
|
5
|
+
import { Fragment, defineComponent, h, inject, provide, useId } from "vue";
|
|
6
6
|
import { createCalendar } from "@kirana-ui/core/calendar";
|
|
7
7
|
// src/calendar.ts
|
|
8
8
|
/**
|
|
@@ -11,14 +11,36 @@ import { createCalendar } from "@kirana-ui/core/calendar";
|
|
|
11
11
|
*/
|
|
12
12
|
const scope = context("Calendar");
|
|
13
13
|
const RootElement = partComponent("CalendarRootElement", "div", () => scope.use().root);
|
|
14
|
-
/**
|
|
14
|
+
/** The place of the month its parts are drawn in, inside `Calendar.Months`. */
|
|
15
|
+
const MONTH = Symbol("CalendarMonth");
|
|
16
|
+
/** The month a part is drawn in: the one `Calendar.Months` gave, or the first. */
|
|
17
|
+
const useMonth = () => scope.use().monthAt(inject(MONTH, 0));
|
|
18
|
+
/**
|
|
19
|
+
* `v-model:value`, `@value-change="(value, details) => …"`; `v-model:month` (the first day of
|
|
20
|
+
* the month shown), `@month-change="(month, details) => …"`.
|
|
21
|
+
*/
|
|
15
22
|
const Root = defineComponent({
|
|
16
23
|
name: "CalendarRoot",
|
|
17
24
|
inheritAttrs: false,
|
|
18
25
|
props: {
|
|
19
|
-
value: optional([
|
|
20
|
-
|
|
26
|
+
value: optional([
|
|
27
|
+
String,
|
|
28
|
+
Object,
|
|
29
|
+
Array
|
|
30
|
+
]),
|
|
31
|
+
defaultValue: [
|
|
32
|
+
String,
|
|
33
|
+
Object,
|
|
34
|
+
Array
|
|
35
|
+
],
|
|
21
36
|
mode: String,
|
|
37
|
+
required: Boolean,
|
|
38
|
+
minDays: Number,
|
|
39
|
+
maxDays: Number,
|
|
40
|
+
months: Number,
|
|
41
|
+
pagedNavigation: Boolean,
|
|
42
|
+
month: optional(String),
|
|
43
|
+
defaultMonth: String,
|
|
22
44
|
defaultFocusedValue: String,
|
|
23
45
|
locale: String,
|
|
24
46
|
calendarSystem: Object,
|
|
@@ -28,11 +50,14 @@ const Root = defineComponent({
|
|
|
28
50
|
disabled: Boolean,
|
|
29
51
|
readOnly: Boolean,
|
|
30
52
|
fixedWeeks: Boolean,
|
|
53
|
+
name: String,
|
|
54
|
+
form: String,
|
|
31
55
|
id: String
|
|
32
56
|
},
|
|
33
57
|
emits: [
|
|
34
58
|
"update:value",
|
|
35
59
|
"valueChange",
|
|
60
|
+
"update:month",
|
|
36
61
|
"monthChange"
|
|
37
62
|
],
|
|
38
63
|
setup(props, { attrs, slots, emit }) {
|
|
@@ -43,6 +68,13 @@ const Root = defineComponent({
|
|
|
43
68
|
value: props.value,
|
|
44
69
|
defaultValue: props.defaultValue,
|
|
45
70
|
mode: props.mode,
|
|
71
|
+
required: props.required,
|
|
72
|
+
minDays: props.minDays,
|
|
73
|
+
maxDays: props.maxDays,
|
|
74
|
+
months: props.months,
|
|
75
|
+
pagedNavigation: props.pagedNavigation,
|
|
76
|
+
month: props.month,
|
|
77
|
+
defaultMonth: props.defaultMonth,
|
|
46
78
|
defaultFocusedValue: props.defaultFocusedValue,
|
|
47
79
|
locale: props.locale,
|
|
48
80
|
calendarSystem: props.calendarSystem,
|
|
@@ -52,11 +84,16 @@ const Root = defineComponent({
|
|
|
52
84
|
disabled: props.disabled,
|
|
53
85
|
readOnly: props.readOnly,
|
|
54
86
|
fixedWeeks: props.fixedWeeks,
|
|
87
|
+
name: props.name,
|
|
88
|
+
form: props.form,
|
|
55
89
|
onValueChange(value, details) {
|
|
56
90
|
emit("valueChange", value, details);
|
|
57
91
|
if (!details.canceled) emit("update:value", value);
|
|
58
92
|
},
|
|
59
|
-
onMonthChange
|
|
93
|
+
onMonthChange(month, details) {
|
|
94
|
+
emit("monthChange", month, details);
|
|
95
|
+
if (!details.canceled) emit("update:month", month);
|
|
96
|
+
}
|
|
60
97
|
})));
|
|
61
98
|
return () => h(RootElement, attrs, slots);
|
|
62
99
|
}
|
|
@@ -66,8 +103,9 @@ const Heading = defineComponent({
|
|
|
66
103
|
name: "CalendarHeading",
|
|
67
104
|
inheritAttrs: false,
|
|
68
105
|
setup(_, { attrs, slots }) {
|
|
69
|
-
const
|
|
70
|
-
const
|
|
106
|
+
const month = useMonth();
|
|
107
|
+
const title = fromSignal(month.title);
|
|
108
|
+
const HeadingElement = partComponent("CalendarHeadingElement", "div", () => month.heading, written(() => title.value));
|
|
71
109
|
return () => h(HeadingElement, attrs, slots.default ?? (() => title.value));
|
|
72
110
|
}
|
|
73
111
|
});
|
|
@@ -79,11 +117,37 @@ const Weekdays = defineComponent({
|
|
|
79
117
|
return () => weekdays.value.map((weekday) => h(Fragment, { key: weekday.index }, slots.default?.({ weekday })));
|
|
80
118
|
}
|
|
81
119
|
});
|
|
120
|
+
/** Holds the parts of one month: they are that month's. */
|
|
121
|
+
const MonthScope = defineComponent({
|
|
122
|
+
name: "CalendarMonthScope",
|
|
123
|
+
props: { index: {
|
|
124
|
+
type: Number,
|
|
125
|
+
required: true
|
|
126
|
+
} },
|
|
127
|
+
setup(props, { slots }) {
|
|
128
|
+
provide(MONTH, props.index);
|
|
129
|
+
return () => slots.default?.();
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
/**
|
|
133
|
+
* Its slot once for each month shown (`months` on the root), side by side: `v-slot="{ month }"`.
|
|
134
|
+
* The parts inside each are that month's. Left out for one month.
|
|
135
|
+
*/
|
|
136
|
+
const Months = defineComponent({
|
|
137
|
+
name: "CalendarMonths",
|
|
138
|
+
setup(_, { slots }) {
|
|
139
|
+
const months = fromSignal(scope.use().months);
|
|
140
|
+
return () => months.value.map((month) => h(MonthScope, {
|
|
141
|
+
key: month.index,
|
|
142
|
+
index: month.index
|
|
143
|
+
}, () => slots.default?.({ month })));
|
|
144
|
+
}
|
|
145
|
+
});
|
|
82
146
|
/** Its slot once for each week of the month shown: `v-slot="{ week }"`. */
|
|
83
147
|
const Weeks = defineComponent({
|
|
84
148
|
name: "CalendarWeeks",
|
|
85
149
|
setup(_, { slots }) {
|
|
86
|
-
const weeks = fromSignal(
|
|
150
|
+
const weeks = fromSignal(useMonth().weeks);
|
|
87
151
|
return () => weeks.value.map((week) => h(Fragment, { key: week[0].date }, slots.default?.({ week })));
|
|
88
152
|
}
|
|
89
153
|
});
|
|
@@ -100,15 +164,19 @@ const HeadCell = defineComponent({
|
|
|
100
164
|
return () => h(Element, attrs, slots);
|
|
101
165
|
}
|
|
102
166
|
});
|
|
167
|
+
const CELL = Symbol("CalendarCell");
|
|
103
168
|
const dated = (name, tag, member) => defineComponent({
|
|
104
169
|
name,
|
|
105
170
|
inheritAttrs: false,
|
|
106
171
|
props: { date: {
|
|
107
172
|
type: String,
|
|
108
|
-
required:
|
|
173
|
+
required: member === "cell"
|
|
109
174
|
} },
|
|
110
175
|
setup(props, { attrs, slots }) {
|
|
111
|
-
const
|
|
176
|
+
const date = props.date ?? inject(CELL, void 0);
|
|
177
|
+
if (date === void 0) throw new Error(`<${name}> needs a date or a Calendar.Cell around it`);
|
|
178
|
+
if (member === "cell") provide(CELL, date);
|
|
179
|
+
const part = scope.use()[member](date, inject(MONTH, void 0));
|
|
112
180
|
const Element = partComponent(`${name}Element`, tag, () => part);
|
|
113
181
|
return () => h(Element, attrs, slots);
|
|
114
182
|
}
|
|
@@ -118,12 +186,15 @@ const Calendar = {
|
|
|
118
186
|
Heading,
|
|
119
187
|
Previous: partComponent("CalendarPrevious", "button", () => scope.use().previous),
|
|
120
188
|
Next: partComponent("CalendarNext", "button", () => scope.use().next),
|
|
121
|
-
|
|
189
|
+
Months,
|
|
190
|
+
Grid: partComponent("CalendarGrid", "table", () => useMonth().grid),
|
|
122
191
|
Weekdays,
|
|
123
192
|
HeadCell,
|
|
124
193
|
Weeks,
|
|
125
194
|
Cell: dated("CalendarCell", "td", "cell"),
|
|
126
|
-
Day: dated("CalendarDay", "button", "day")
|
|
195
|
+
Day: dated("CalendarDay", "button", "day"),
|
|
196
|
+
/** The hidden input the value is submitted by, when the root has a `name`. */
|
|
197
|
+
Input: partComponent("CalendarInput", "input", () => scope.use().input)
|
|
127
198
|
};
|
|
128
199
|
export { Calendar, scope as calendarScope };
|
|
129
200
|
|
package/src/calendar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","names":[],"sources":["../../../../packages/vue/src/calendar.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createCalendar } from \"@kirana-ui/core/calendar\"\nimport type {\n Calendar as Controller,\n CalendarDay,\n CalendarProps,\n CalendarValue,\n CalendarWeekday,\n} from \"@kirana-ui/core/calendar\"\nimport { Fragment, defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { written } from \"./element.ts\"\nimport { context, controller, fromSignal, optional, partComponent } from \"./runtime.ts\"\nimport type {\n Changes,\n PartComponent,\n PartComponentProps,\n PlainComponent,\n StatesOf,\n} from \"./runtime.ts\"\n\ntype State = StatesOf<\"calendar\">\n\n/**\n * The calendar its parts are inside. Exported for a component that is made of one (a date picker\n * provides its own to the calendar's parts).\n */\nconst scope = context<Controller>(\"Calendar\")\n/** For a component made of this one's parts: a date picker. */\nexport { scope as calendarScope }\n\nconst RootElement = partComponent(\"CalendarRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<CalendarProps, \"id\" | \"onValueChange\" | \"onMonthChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"value\", CalendarValue> & {\n /** The month shown has changed: its first day. */\n monthChange: (month: string) => void\n}\n\n/** `v-model:value`, `@value-change=\"(value, details) => …\"`, `@month-change=\"(month) => …\"`. */\nconst Root = defineComponent({\n name: \"CalendarRoot\",\n inheritAttrs: false,\n props: {\n value: optional([String, Object] as PropType<CalendarValue>),\n defaultValue: [String, Object] as PropType<CalendarValue>,\n mode: String as PropType<\"single\" | \"range\">,\n defaultFocusedValue: String,\n locale: String,\n calendarSystem: Object as PropType<CalendarProps[\"calendarSystem\"]>,\n min: String,\n max: String,\n isDateUnavailable: Function as PropType<(date: string) => boolean>,\n disabled: Boolean,\n readOnly: Boolean,\n fixedWeeks: Boolean,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\", \"monthChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createCalendar, { direction }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n mode: props.mode,\n defaultFocusedValue: props.defaultFocusedValue,\n locale: props.locale,\n calendarSystem: props.calendarSystem,\n min: props.min,\n max: props.max,\n isDateUnavailable: props.isDateUnavailable,\n disabled: props.disabled,\n readOnly: props.readOnly,\n fixedWeeks: props.fixedWeeks,\n onValueChange(value: CalendarValue, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onMonthChange: (month: string) => emit(\"monthChange\", month),\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nexport type HeadingProps = PartComponentProps\n\n/** Names the month shown, unless it is given something else to say. */\nconst Heading = defineComponent({\n name: \"CalendarHeading\",\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n const title = fromSignal(scope.use().title)\n // With `as-child` the caller's element holds the text, unless it writes its own.\n const HeadingElement = partComponent(\n \"CalendarHeadingElement\",\n \"div\",\n () => scope.use().heading,\n written(() => title.value)\n )\n return () => h(HeadingElement, attrs, slots.default ?? (() => title.value))\n },\n}) as unknown as PartComponent<\"div\", State[\"heading\"], HeadingProps>\n\nexport type WeekdaysProps = Record<never, never>\n\n/** Its slot once for each day of the week, in the locale's order: `v-slot=\"{ weekday }\"`. */\nconst Weekdays = defineComponent({\n name: \"CalendarWeekdays\",\n setup(_, { slots }) {\n const weekdays = fromSignal(scope.use().weekdays)\n return () =>\n weekdays.value.map((weekday) =>\n h(Fragment, { key: weekday.index }, slots.default?.({ weekday }))\n )\n },\n}) as unknown as PlainComponent<WeekdaysProps, {}, { weekday: CalendarWeekday }>\n\nexport type WeeksProps = Record<never, never>\n\n/** Its slot once for each week of the month shown: `v-slot=\"{ week }\"`. */\nconst Weeks = defineComponent({\n name: \"CalendarWeeks\",\n setup(_, { slots }) {\n const weeks = fromSignal(scope.use().weeks)\n return () =>\n weeks.value.map((week) => h(Fragment, { key: week[0]!.date }, slots.default?.({ week })))\n },\n}) as unknown as PlainComponent<WeeksProps, {}, { week: readonly CalendarDay[] }>\n\nexport interface HeadCellProps extends PartComponentProps {\n /** The day of the week it names, as `Calendar.Weekdays` gives it. */\n weekday: CalendarWeekday\n}\n\nconst HeadCell = defineComponent({\n name: \"CalendarHeadCell\",\n inheritAttrs: false,\n props: { weekday: { type: Object as PropType<CalendarWeekday>, required: true } },\n setup(props, { attrs, slots }) {\n const part = scope.use().headCell(props.weekday)\n const Element = partComponent(\"CalendarHeadCellElement\", \"th\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"th\", State[\"headCell\"], HeadCellProps>\n\nexport interface CellProps extends PartComponentProps {\n /** The day it is for, as a week of `Calendar.Weeks` gives it. */\n date: string\n}\nexport type DayProps = CellProps\nexport type PreviousProps = PartComponentProps\nexport type NextProps = PartComponentProps\nexport type GridProps = PartComponentProps\n\nconst dated = <Tag extends string, Member extends \"cell\" | \"day\">(\n name: string,\n tag: Tag,\n member: Member\n) =>\n defineComponent({\n name,\n inheritAttrs: false,\n props: { date: { type: String, required: true } },\n setup(props, { attrs, slots }) {\n const part = scope.use()[member](props.date)\n const Element = partComponent<string>(`${name}Element`, tag, () => part)\n return () => h(Element, attrs, slots)\n },\n }) as unknown as PartComponent<Tag, State[Member], CellProps>\n\nexport const Calendar = {\n Root,\n Heading,\n Previous: partComponent<\"button\", State[\"previous\"]>(\n \"CalendarPrevious\",\n \"button\",\n () => scope.use().previous\n ),\n Next: partComponent<\"button\", State[\"next\"]>(\"CalendarNext\", \"button\", () => scope.use().next),\n Grid: partComponent<\"table\", State[\"grid\"]>(\"CalendarGrid\", \"table\", () => scope.use().grid),\n Weekdays,\n HeadCell,\n Weeks,\n Cell: dated(\"CalendarCell\", \"td\", \"cell\"),\n Day: dated(\"CalendarDay\", \"button\", \"day\"),\n}\n"],"mappings":";;;;;;;;;;;AA8BA,MAAM,QAAQ,QAAoB,UAAU;AAI5C,MAAM,cAAc,cAAc,uBAAuB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AAYtF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,OAAO,SAAS,CAAC,QAAQ,MAAM,CAA4B;EAC3D,cAAc,CAAC,QAAQ,MAAM;EAC7B,MAAM;EACN,qBAAqB;EACrB,QAAQ;EACR,gBAAgB;EAChB,KAAK;EACL,KAAK;EACL,mBAAmB;EACnB,UAAU;EACV,UAAU;EACV,YAAY;EACZ,IAAI;CACN;CACA,OAAO;EAAC;EAAgB;EAAe;CAAa;CACpD,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;EACnC,MAAM,YAAY,MAAM;EACxB,MAAM,YAAY,mBAAmB;EACrC,MAAM,QACJ,WAAW,OAAO,gBAAgB,EAAE,UAAU,CAAC,UAA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AK,KAAK,EAAE,CAAE,KAAK,GAAG,MAAM,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;CAC5F;AACF,CAAC;AAOD,MAAM,WAAW,gBAAgB;CAC/B,MAAM;CACN,cAAc;CACd,OAAO,EAAE,SAAS;EAAE,MAAM;EAAqC,UAAU;CAAK,EAAE;CAChF,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,SAAS,MAAM,OAAO;EAC/C,MAAM,UAAU,cAAc,2BAA2B,YAAY,IAAI;EACzE,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC;AAWD,MAAM,SACJ,MACA,KACA,WAEA,gBAAgB;CACd;CACA,cAAc;CACd,OAAO,EAAE,MAAM;EAAE,MAAM;EAAQ,UAAU;CAAK,EAAE;CAChD,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI;EAC3C,MAAM,UAAU,cAAsB,GAAG,KAAK,UAAU,WAAW,IAAI;EACvE,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC;AAEH,MAAa,WAAW;CACtB;CACA;CACA,UAAU,cACR,oBACA,gBACM,MAAM,IAAI,CAAC,CAAC,QACpB;CACA,MAAM,cAAuC,gBAAgB,gBAAgB,MAAM,IAAI,CAAC,CAAC,IAAI;CAC7F,MAAM,cAAsC,gBAAgB,eAAe,MAAM,IAAI,CAAC,CAAC,IAAI;CAC3F;CACA;CACA;CACA,MAAM,MAAM,gBAAgB,MAAM,MAAM;CACxC,KAAK,MAAM,eAAe,UAAU,KAAK;AAC3C"}
|
|
1
|
+
{"version":3,"file":"calendar.js","names":[],"sources":["../../../../packages/vue/src/calendar.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createCalendar } from \"@kirana-ui/core/calendar\"\nimport type {\n Calendar as Controller,\n CalendarDay,\n CalendarMode,\n CalendarMonth,\n CalendarProps,\n CalendarValue,\n CalendarValueOf,\n CalendarWeekday,\n} from \"@kirana-ui/core/calendar\"\nimport { Fragment, defineComponent, h, inject, provide, useId } from \"vue\"\nimport type { InjectionKey, PropType, PublicProps } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { written } from \"./element.ts\"\nimport { context, controller, fromSignal, optional, partComponent } from \"./runtime.ts\"\nimport type {\n Changes,\n PartComponent,\n PartComponentProps,\n PartGiven,\n PartInstance,\n PlainComponent,\n StatesOf,\n} from \"./runtime.ts\"\n\ntype State = StatesOf<\"calendar\">\n\n/**\n * The calendar its parts are inside. Exported for a component that is made of one (a date picker\n * provides its own to the calendar's parts).\n */\nconst scope = context<Controller>(\"Calendar\")\n/** For a component made of this one's parts: a date picker. */\nexport { scope as calendarScope }\n\nconst RootElement = partComponent(\"CalendarRootElement\", \"div\", () => scope.use().root)\n\n/** The place of the month its parts are drawn in, inside `Calendar.Months`. */\nconst MONTH: InjectionKey<number> = Symbol(\"CalendarMonth\")\n/** The month a part is drawn in: the one `Calendar.Months` gave, or the first. */\nconst useMonth = () => scope.use().monthAt(inject(MONTH, 0))\n\n/** `value` and its events are typed by `mode`: a day, a range, or a list of days. */\nexport type RootProps<Mode extends CalendarMode = \"single\"> = Omit<\n CalendarProps<Mode>,\n \"id\" | \"onValueChange\" | \"onMonthChange\"\n> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits<Mode extends CalendarMode = \"single\"> = Changes<\n \"value\",\n CalendarValueOf<Mode>\n> &\n Changes<\"month\", string>\n\n/**\n * `v-model:value`, `@value-change=\"(value, details) => …\"`; `v-model:month` (the first day of\n * the month shown), `@month-change=\"(month, details) => …\"`.\n */\nconst Root = defineComponent({\n name: \"CalendarRoot\",\n inheritAttrs: false,\n props: {\n value: optional([String, Object, Array] as PropType<CalendarValue>),\n defaultValue: [String, Object, Array] as PropType<CalendarValue>,\n mode: String as PropType<CalendarMode>,\n required: Boolean,\n minDays: Number,\n maxDays: Number,\n months: Number,\n pagedNavigation: Boolean,\n month: optional(String),\n defaultMonth: String,\n defaultFocusedValue: String,\n locale: String,\n calendarSystem: Object as PropType<CalendarProps[\"calendarSystem\"]>,\n min: String,\n max: String,\n isDateUnavailable: Function as PropType<(date: string) => boolean>,\n disabled: Boolean,\n readOnly: Boolean,\n fixedWeeks: Boolean,\n name: String,\n form: String,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\", \"update:month\", \"monthChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createCalendar, { direction }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n mode: props.mode,\n required: props.required,\n minDays: props.minDays,\n maxDays: props.maxDays,\n months: props.months,\n pagedNavigation: props.pagedNavigation,\n month: props.month,\n defaultMonth: props.defaultMonth,\n defaultFocusedValue: props.defaultFocusedValue,\n locale: props.locale,\n calendarSystem: props.calendarSystem,\n min: props.min,\n max: props.max,\n isDateUnavailable: props.isDateUnavailable,\n disabled: props.disabled,\n readOnly: props.readOnly,\n fixedWeeks: props.fixedWeeks,\n name: props.name,\n form: props.form,\n onValueChange(value: CalendarValue, details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n onMonthChange(month: string, details: ChangeDetails) {\n emit(\"monthChange\", month, details)\n if (!details.canceled) emit(\"update:month\", month)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as new <Mode extends CalendarMode = \"single\", As extends string = \"div\">(\n props: PartGiven<As, RootProps<Mode>, RootEmits<Mode>> & PublicProps\n) => PartInstance<As, RootProps<Mode>, RootEmits<Mode>, { state: State[\"root\"] }>\n\nexport type HeadingProps = PartComponentProps\n\n/** Names the month shown, unless it is given something else to say. */\nconst Heading = defineComponent({\n name: \"CalendarHeading\",\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n const month = useMonth()\n const title = fromSignal(month.title)\n // With `as-child` the caller's element holds the text, unless it writes its own.\n const HeadingElement = partComponent(\n \"CalendarHeadingElement\",\n \"div\",\n () => month.heading,\n written(() => title.value)\n )\n return () => h(HeadingElement, attrs, slots.default ?? (() => title.value))\n },\n}) as unknown as PartComponent<\"div\", State[\"heading\"], HeadingProps>\n\nexport type WeekdaysProps = Record<never, never>\n\n/** Its slot once for each day of the week, in the locale's order: `v-slot=\"{ weekday }\"`. */\nconst Weekdays = defineComponent({\n name: \"CalendarWeekdays\",\n setup(_, { slots }) {\n const weekdays = fromSignal(scope.use().weekdays)\n return () =>\n weekdays.value.map((weekday) =>\n h(Fragment, { key: weekday.index }, slots.default?.({ weekday }))\n )\n },\n}) as unknown as PlainComponent<WeekdaysProps, {}, { weekday: CalendarWeekday }>\n\nexport type MonthsProps = Record<never, never>\n\n/** Holds the parts of one month: they are that month's. */\nconst MonthScope = defineComponent({\n name: \"CalendarMonthScope\",\n props: { index: { type: Number, required: true } },\n setup(props, { slots }) {\n // Keyed by its place: a scope is one month's for as long as it is drawn.\n provide(MONTH, props.index)\n return () => slots.default?.()\n },\n})\n\n/**\n * Its slot once for each month shown (`months` on the root), side by side: `v-slot=\"{ month }\"`.\n * The parts inside each are that month's. Left out for one month.\n */\nconst Months = defineComponent({\n name: \"CalendarMonths\",\n setup(_, { slots }) {\n const months = fromSignal(scope.use().months)\n return () =>\n months.value.map((month) =>\n h(MonthScope, { key: month.index, index: month.index }, () => slots.default?.({ month }))\n )\n },\n}) as unknown as PlainComponent<MonthsProps, {}, { month: CalendarMonth }>\n\nexport type WeeksProps = Record<never, never>\n\n/** Its slot once for each week of the month shown: `v-slot=\"{ week }\"`. */\nconst Weeks = defineComponent({\n name: \"CalendarWeeks\",\n setup(_, { slots }) {\n const weeks = fromSignal(useMonth().weeks)\n return () =>\n weeks.value.map((week) => h(Fragment, { key: week[0]!.date }, slots.default?.({ week })))\n },\n}) as unknown as PlainComponent<WeeksProps, {}, { week: readonly CalendarDay[] }>\n\nexport interface HeadCellProps extends PartComponentProps {\n /** The day of the week it names, as `Calendar.Weekdays` gives it. */\n weekday: CalendarWeekday\n}\n\nconst HeadCell = defineComponent({\n name: \"CalendarHeadCell\",\n inheritAttrs: false,\n props: { weekday: { type: Object as PropType<CalendarWeekday>, required: true } },\n setup(props, { attrs, slots }) {\n const part = scope.use().headCell(props.weekday)\n const Element = partComponent(\"CalendarHeadCellElement\", \"th\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"th\", State[\"headCell\"], HeadCellProps>\n\nexport interface CellProps extends PartComponentProps {\n /** The day it is for, as a week of `Calendar.Weeks` gives it. */\n date: string\n}\nexport interface DayProps extends PartComponentProps {\n /** The day it is the button of. Left out, the `Calendar.Cell`'s it is inside. */\n date?: string | undefined\n}\nexport type PreviousProps = PartComponentProps\nexport type NextProps = PartComponentProps\nexport type GridProps = PartComponentProps\nexport type InputProps = PartComponentProps\n\n// The day a cell holds, for the day button inside it.\nconst CELL: InjectionKey<string> = Symbol(\"CalendarCell\")\n\nconst dated = <Tag extends string, Member extends \"cell\" | \"day\", Props>(\n name: string,\n tag: Tag,\n member: Member\n) =>\n defineComponent({\n name,\n inheritAttrs: false,\n props: { date: { type: String, required: member === \"cell\" } },\n setup(props, { attrs, slots }) {\n const date = props.date ?? inject(CELL, undefined)\n if (date === undefined) throw new Error(`<${name}> needs a date or a Calendar.Cell around it`)\n if (member === \"cell\") provide(CELL, date)\n const part = scope.use()[member](date, inject(MONTH, undefined))\n const Element = partComponent<string>(`${name}Element`, tag, () => part)\n return () => h(Element, attrs, slots)\n },\n }) as unknown as PartComponent<Tag, State[Member], Props>\n\nexport const Calendar = {\n Root,\n Heading,\n Previous: partComponent<\"button\", State[\"previous\"]>(\n \"CalendarPrevious\",\n \"button\",\n () => scope.use().previous\n ),\n Next: partComponent<\"button\", State[\"next\"]>(\"CalendarNext\", \"button\", () => scope.use().next),\n Months,\n Grid: partComponent<\"table\", State[\"grid\"]>(\"CalendarGrid\", \"table\", () => useMonth().grid),\n Weekdays,\n HeadCell,\n Weeks,\n Cell: dated<\"td\", \"cell\", CellProps>(\"CalendarCell\", \"td\", \"cell\"),\n Day: dated<\"button\", \"day\", DayProps>(\"CalendarDay\", \"button\", \"day\"),\n /** The hidden input the value is submitted by, when the root has a `name`. */\n Input: partComponent<\"input\", State[\"input\"]>(\"CalendarInput\", \"input\", () => scope.use().input),\n}\n"],"mappings":";;;;;;;;;;;AAmCA,MAAM,QAAQ,QAAoB,UAAU;AAI5C,MAAM,cAAc,cAAc,uBAAuB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AAGtF,MAAM,QAA8B,OAAO,eAAe;;AAE1D,MAAM,iBAAiB,MAAM,IAAI,CAAC,CAAC,QAAQ,OAAO,OAAO,CAAC,CAAC;;;;;AAoB3D,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,OAAO,SAAS;GAAC;GAAQ;GAAQ;EAAK,CAA4B;EAClE,cAAc;GAAC;GAAQ;GAAQ;EAAK;EACpC,MAAM;EACN,UAAU;EACV,SAAS;EACT,SAAS;EACT,QAAQ;EACR,iBAAiB;EACjB,OAAO,SAAS,MAAM;EACtB,cAAc;EACd,qBAAqB;EACrB,QAAQ;EACR,gBAAgB;EAChB,KAAK;EACL,KAAK;EACL,mBAAmB;EACnB,UAAU;EACV,UAAU;EACV,YAAY;EACZ,MAAM;EACN,MAAM;EACN,IAAI;CACN;CACA,OAAO;EAAC;EAAgB;EAAe;EAAgB;CAAa;CACpE,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;EACnC,MAAM,YAAY,MAAM;EACxB,MAAM,YAAY,mBAAmB;EACrC,MAAM,QACJ,WAAW,OAAO,gBAAgB,EAAE,UAAU,CAAC,UAAU;GACvD,IAAI,MAAM,MAAM;GAChB,OAAO,MAAM;GACb,cAAc,MAAM;GACpB,MAAM,MAAM;GACZ,UAAU,MAAM;GAChB,S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MAAM,KAAA,CAAS;EACjD,IAAI,SAAS,KAAA,GAAW,MAAM,IAAI,MAAM,IAAI,KAAK,4CAA4C;EAC7F,IAAI,WAAW,QAAQ,QAAQ,MAAM,IAAI;EACzC,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,OAAO,OAAO,KAAA,CAAS,CAAC;EAC/D,MAAM,UAAU,cAAsB,GAAG,KAAK,UAAU,WAAW,IAAI;EACvE,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC;AAEH,MAAa,WAAW;CACtB;CACA;CACA,UAAU,cACR,oBACA,gBACM,MAAM,IAAI,CAAC,CAAC,QACpB;CACA,MAAM,cAAuC,gBAAgB,gBAAgB,MAAM,IAAI,CAAC,CAAC,IAAI;CAC7F;CACA,MAAM,cAAsC,gBAAgB,eAAe,SAAS,CAAC,CAAC,IAAI;CAC1F;CACA;CACA;CACA,MAAM,MAA+B,gBAAgB,MAAM,MAAM;CACjE,KAAK,MAAiC,eAAe,UAAU,KAAK;;CAEpE,OAAO,cAAuC,iBAAiB,eAAe,MAAM,IAAI,CAAC,CAAC,KAAK;AACjG"}
|
package/src/carousel.d.ts
CHANGED
|
@@ -8,8 +8,11 @@ export type ViewportProps = PartComponentProps;
|
|
|
8
8
|
export type PreviousProps = PartComponentProps;
|
|
9
9
|
export type NextProps = PartComponentProps;
|
|
10
10
|
export interface ItemProps extends PartComponentProps {
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Its place among the slides, from 0. Left out, its place in the page, once it is there:
|
|
13
|
+
* give it on a page a server draws, which cannot count them.
|
|
14
|
+
*/
|
|
15
|
+
index?: number | undefined;
|
|
13
16
|
}
|
|
14
17
|
export interface IndicatorProps extends PartComponentProps {
|
|
15
18
|
/** The slide it goes to, from 0. */
|
package/src/carousel.js
CHANGED
|
@@ -44,10 +44,7 @@ const Carousel = {
|
|
|
44
44
|
Item: defineComponent({
|
|
45
45
|
name: "CarouselItem",
|
|
46
46
|
inheritAttrs: false,
|
|
47
|
-
props: { index:
|
|
48
|
-
type: Number,
|
|
49
|
-
required: true
|
|
50
|
-
} },
|
|
47
|
+
props: { index: Number },
|
|
51
48
|
setup(props, { attrs, slots }) {
|
|
52
49
|
const part = scope.use().item(props.index);
|
|
53
50
|
const Element = partComponent("CarouselItemElement", "div", () => part);
|
package/src/carousel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.js","names":[],"sources":["../../../../packages/vue/src/carousel.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Orientation } from \"@kirana-ui/core\"\nimport { createCarousel } from \"@kirana-ui/core/carousel\"\nimport type { CarouselProps, Carousel as Controller } from \"@kirana-ui/core/carousel\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { context, controller, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"carousel\">\n\nconst scope = context<Controller>(\"Carousel\")\n\nconst RootElement = partComponent(\"CarouselRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<CarouselProps, \"id\" | \"onIndexChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"index\", number>\n\n/** `v-model:index`, and `@index-change=\"(index, details) => …\"`. */\nconst Root = defineComponent({\n name: \"CarouselRoot\",\n inheritAttrs: false,\n props: {\n index: optional(Number),\n defaultIndex: Number,\n orientation: String as PropType<Orientation>,\n loop: Boolean,\n id: String,\n },\n emits: [\"update:index\", \"indexChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createCarousel, { direction }), () => ({\n id: props.id ?? generated,\n index: props.index,\n defaultIndex: props.defaultIndex,\n orientation: props.orientation,\n loop: props.loop,\n onIndexChange: (index: number, details: ChangeDetails) => {\n emit(\"indexChange\", index, details)\n if (!details.canceled) emit(\"update:index\", index)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nexport type ViewportProps = PartComponentProps\nexport type PreviousProps = PartComponentProps\nexport type NextProps = PartComponentProps\nconst Viewport = partComponent<\"div\", State[\"viewport\"]>(\n \"CarouselViewport\",\n \"div\",\n () => scope.use().viewport\n)\nconst Previous = partComponent<\"button\", State[\"previous\"]>(\n \"CarouselPrevious\",\n \"button\",\n () => scope.use().previous\n)\nconst Next = partComponent<\"button\", State[\"next\"]>(\n \"CarouselNext\",\n \"button\",\n () => scope.use().next\n)\n\nexport interface ItemProps extends PartComponentProps {\n
|
|
1
|
+
{"version":3,"file":"carousel.js","names":[],"sources":["../../../../packages/vue/src/carousel.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails, Orientation } from \"@kirana-ui/core\"\nimport { createCarousel } from \"@kirana-ui/core/carousel\"\nimport type { CarouselProps, Carousel as Controller } from \"@kirana-ui/core/carousel\"\nimport { defineComponent, h, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { useDirectionAround } from \"./direction-context.ts\"\nimport { context, controller, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"carousel\">\n\nconst scope = context<Controller>(\"Carousel\")\n\nconst RootElement = partComponent(\"CarouselRootElement\", \"div\", () => scope.use().root)\n\nexport type RootProps = Omit<CarouselProps, \"id\" | \"onIndexChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"index\", number>\n\n/** `v-model:index`, and `@index-change=\"(index, details) => …\"`. */\nconst Root = defineComponent({\n name: \"CarouselRoot\",\n inheritAttrs: false,\n props: {\n index: optional(Number),\n defaultIndex: Number,\n orientation: String as PropType<Orientation>,\n loop: Boolean,\n id: String,\n },\n emits: [\"update:index\", \"indexChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const direction = useDirectionAround()\n scope.provide(\n controller(within(createCarousel, { direction }), () => ({\n id: props.id ?? generated,\n index: props.index,\n defaultIndex: props.defaultIndex,\n orientation: props.orientation,\n loop: props.loop,\n onIndexChange: (index: number, details: ChangeDetails) => {\n emit(\"indexChange\", index, details)\n if (!details.canceled) emit(\"update:index\", index)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"root\"], RootProps, RootEmits>\n\nexport type ViewportProps = PartComponentProps\nexport type PreviousProps = PartComponentProps\nexport type NextProps = PartComponentProps\nconst Viewport = partComponent<\"div\", State[\"viewport\"]>(\n \"CarouselViewport\",\n \"div\",\n () => scope.use().viewport\n)\nconst Previous = partComponent<\"button\", State[\"previous\"]>(\n \"CarouselPrevious\",\n \"button\",\n () => scope.use().previous\n)\nconst Next = partComponent<\"button\", State[\"next\"]>(\n \"CarouselNext\",\n \"button\",\n () => scope.use().next\n)\n\nexport interface ItemProps extends PartComponentProps {\n /**\n * Its place among the slides, from 0. Left out, its place in the page, once it is there:\n * give it on a page a server draws, which cannot count them.\n */\n index?: number | undefined\n}\n\nconst Item = defineComponent({\n name: \"CarouselItem\",\n inheritAttrs: false,\n props: { index: Number },\n setup(props, { attrs, slots }) {\n const part = scope.use().item(props.index)\n const Element = partComponent(\"CarouselItemElement\", \"div\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"div\", State[\"item\"], ItemProps>\n\nexport interface IndicatorProps extends PartComponentProps {\n /** The slide it goes to, from 0. */\n index: number\n}\n\nconst Indicator = defineComponent({\n name: \"CarouselIndicator\",\n inheritAttrs: false,\n props: { index: { type: Number, required: true } },\n setup(props, { attrs, slots }) {\n const part = scope.use().indicator(props.index)\n const Element = partComponent(\"CarouselIndicatorElement\", \"button\", () => part)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\"button\", State[\"indicator\"], IndicatorProps>\n\nexport const Carousel = { Root, Viewport, Item, Previous, Next, Indicator }\n"],"mappings":";;;;;;AAaA,MAAM,QAAQ,QAAoB,UAAU;AAE5C,MAAM,cAAc,cAAc,uBAAuB,aAAa,MAAM,IAAI,CAAC,CAAC,IAAI;;AAStF,MAAM,OAAO,gBAAgB;CAC3B,MAAM;CACN,cAAc;CACd,OAAO;EACL,OAAO,SAAS,MAAM;EACtB,cAAc;EACd,aAAa;EACb,MAAM;EACN,IAAI;CACN;CACA,OAAO,CAAC,gBAAgB,aAAa;CACrC,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;EACnC,MAAM,YAAY,MAAM;EACxB,MAAM,YAAY,mBAAmB;EACrC,MAAM,QACJ,WAAW,OAAO,gBAAgB,EAAE,UAAU,CAAC,UAAU;GACvD,IAAI,MAAM,MAAM;GAChB,OAAO,MAAM;GACb,cAAc,MAAM;GACpB,aAAa,MAAM;GACnB,MAAM,MAAM;GACZ,gBAAgB,OAAe,YAA2B;IACxD,KAAK,eAAe,OAAO,OAAO;IAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;GACnD;EACF,EAAE,CACJ;EACA,aAAa,EAAE,aAAa,OAAO,KAAK;CAC1C;AACF,CAAC;AAKD,MAAM,WAAW,cACf,oBACA,aACM,MAAM,IAAI,CAAC,CAAC,QACpB;AACA,MAAM,WAAW,cACf,oBACA,gBACM,MAAM,IAAI,CAAC,CAAC,QACpB;AACA,MAAM,OAAO,cACX,gBACA,gBACM,MAAM,IAAI,CAAC,CAAC,IACpB;AAqCA,MAAa,WAAW;CAAE;CAAM;CAAU,MA3B7B,gBAAgB;EAC3B,MAAM;EACN,cAAc;EACd,OAAO,EAAE,OAAO,OAAO;EACvB,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,KAAK,MAAM,KAAK;GACzC,MAAM,UAAU,cAAc,uBAAuB,aAAa,IAAI;GACtE,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAkB0C;CAAM;CAAU;CAAM,WAX9C,gBAAgB;EAChC,MAAM;EACN,cAAc;EACd,OAAO,EAAE,OAAO;GAAE,MAAM;GAAQ,UAAU;EAAK,EAAE;EACjD,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC,UAAU,MAAM,KAAK;GAC9C,MAAM,UAAU,cAAc,4BAA4B,gBAAgB,IAAI;GAC9E,aAAa,EAAE,SAAS,OAAO,KAAK;EACtC;CACF,CAEgE;AAAU"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InjectionKey } from "vue";
|
|
2
|
+
import { CheckboxGroup } from "@kirana-ui/core/checkbox-group";
|
|
3
|
+
/** The group a checkbox is one of the boxes of, if it is in one. */
|
|
4
|
+
export declare const CHECKBOX_GROUP: InjectionKey<CheckboxGroup | null>;
|
|
5
|
+
//# sourceMappingURL=checkbox-group-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox-group-context.js","names":[],"sources":["../../../../packages/vue/src/checkbox-group-context.ts"],"sourcesContent":["import type { CheckboxGroup } from \"@kirana-ui/core/checkbox-group\"\nimport type { InjectionKey } from \"vue\"\n\n/** The group a checkbox is one of the boxes of, if it is in one. */\nexport const CHECKBOX_GROUP: InjectionKey<CheckboxGroup | null> = Symbol(\"CheckboxGroup\")\n"],"mappings":";;AAIA,MAAa,iBAAqD,OAAO,eAAe"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Changes, PartComponent, PartComponentProps, StatesOf } from "./runtime.js";
|
|
2
|
+
import { CheckboxGroupProps as CheckboxGroupProps$1 } from "@kirana-ui/core/checkbox-group";
|
|
3
|
+
export type CheckboxGroupProps = Omit<CheckboxGroupProps$1, "id" | "onValueChange"> & {
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
} & PartComponentProps;
|
|
6
|
+
export type CheckboxGroupEmits = Changes<"value", string[]>;
|
|
7
|
+
/**
|
|
8
|
+
* `v-model:value` (a list). Each `Checkbox.Root` with a `value` inside it is checked while the
|
|
9
|
+
* list has its value; with `all-values`, a `Checkbox.Root` marked `parent` stands for them all.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CheckboxGroup: PartComponent<"div", StatesOf<"checkboxGroup">["root"], CheckboxGroupProps, CheckboxGroupEmits>;
|
|
12
|
+
//# sourceMappingURL=checkbox-group.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CHECKBOX_GROUP } from "./checkbox-group-context.js";
|
|
2
|
+
import { useFieldAround } from "./field-context.js";
|
|
3
|
+
import { controller, optional, partComponent } from "./runtime.js";
|
|
4
|
+
import { within } from "@kirana-ui/core";
|
|
5
|
+
import { defineComponent, h, provide, useId } from "vue";
|
|
6
|
+
import { createCheckboxGroup } from "@kirana-ui/core/checkbox-group";
|
|
7
|
+
// src/checkbox-group.ts
|
|
8
|
+
/**
|
|
9
|
+
* `v-model:value` (a list). Each `Checkbox.Root` with a `value` inside it is checked while the
|
|
10
|
+
* list has its value; with `all-values`, a `Checkbox.Root` marked `parent` stands for them all.
|
|
11
|
+
*/
|
|
12
|
+
const CheckboxGroup = defineComponent({
|
|
13
|
+
name: "CheckboxGroup",
|
|
14
|
+
inheritAttrs: false,
|
|
15
|
+
props: {
|
|
16
|
+
value: optional(Array),
|
|
17
|
+
defaultValue: Array,
|
|
18
|
+
allValues: Array,
|
|
19
|
+
disabled: Boolean,
|
|
20
|
+
id: String
|
|
21
|
+
},
|
|
22
|
+
emits: ["update:value", "valueChange"],
|
|
23
|
+
setup(props, { attrs, slots, emit }) {
|
|
24
|
+
const generated = useId();
|
|
25
|
+
const field = useFieldAround();
|
|
26
|
+
const made = controller(within(createCheckboxGroup, { field }), () => ({
|
|
27
|
+
id: props.id ?? generated,
|
|
28
|
+
value: props.value,
|
|
29
|
+
defaultValue: props.defaultValue,
|
|
30
|
+
allValues: props.allValues,
|
|
31
|
+
disabled: props.disabled,
|
|
32
|
+
onValueChange(value, details) {
|
|
33
|
+
emit("valueChange", value, details);
|
|
34
|
+
if (!details.canceled) emit("update:value", value);
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
provide(CHECKBOX_GROUP, made);
|
|
38
|
+
const Element = partComponent("CheckboxGroupElement", "div", () => made.root);
|
|
39
|
+
return () => h(Element, attrs, slots);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
export { CheckboxGroup };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=checkbox-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox-group.js","names":[],"sources":["../../../../packages/vue/src/checkbox-group.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createCheckboxGroup } from \"@kirana-ui/core/checkbox-group\"\nimport type { CheckboxGroupProps as CoreProps } from \"@kirana-ui/core/checkbox-group\"\nimport { defineComponent, h, provide, useId } from \"vue\"\nimport type { PropType } from \"vue\"\n\nimport { CHECKBOX_GROUP } from \"./checkbox-group-context.ts\"\nimport { useFieldAround } from \"./field-context.ts\"\nimport { controller, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\nexport type CheckboxGroupProps = Omit<CoreProps, \"id\" | \"onValueChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type CheckboxGroupEmits = Changes<\"value\", string[]>\n\n/**\n * `v-model:value` (a list). Each `Checkbox.Root` with a `value` inside it is checked while the\n * list has its value; with `all-values`, a `Checkbox.Root` marked `parent` stands for them all.\n */\nexport const CheckboxGroup = defineComponent({\n name: \"CheckboxGroup\",\n inheritAttrs: false,\n props: {\n value: optional(Array as PropType<readonly string[]>),\n defaultValue: Array as PropType<readonly string[]>,\n allValues: Array as PropType<readonly string[]>,\n disabled: Boolean,\n id: String,\n },\n emits: [\"update:value\", \"valueChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n const made = controller(within(createCheckboxGroup, { field }), () => ({\n id: props.id ?? generated,\n value: props.value,\n defaultValue: props.defaultValue,\n allValues: props.allValues,\n disabled: props.disabled,\n onValueChange(value: string[], details: ChangeDetails) {\n emit(\"valueChange\", value, details)\n if (!details.canceled) emit(\"update:value\", value)\n },\n }))\n provide(CHECKBOX_GROUP, made)\n const Element = partComponent(\"CheckboxGroupElement\", \"div\", () => made.root)\n return () => h(Element, attrs, slots)\n },\n}) as unknown as PartComponent<\n \"div\",\n StatesOf<\"checkboxGroup\">[\"root\"],\n CheckboxGroupProps,\n CheckboxGroupEmits\n>\n"],"mappings":";;;;;;;;;;;AAsBA,MAAa,gBAAgB,gBAAgB;CAC3C,MAAM;CACN,cAAc;CACd,OAAO;EACL,OAAO,SAAS,KAAoC;EACpD,cAAc;EACd,WAAW;EACX,UAAU;EACV,IAAI;CACN;CACA,OAAO,CAAC,gBAAgB,aAAa;CACrC,MAAM,OAAO,EAAE,OAAO,OAAO,QAAQ;EACnC,MAAM,YAAY,MAAM;EACxB,MAAM,QAAQ,eAAe;EAC7B,MAAM,OAAO,WAAW,OAAO,qBAAqB,EAAE,MAAM,CAAC,UAAU;GACrE,IAAI,MAAM,MAAM;GAChB,OAAO,MAAM;GACb,cAAc,MAAM;GACpB,WAAW,MAAM;GACjB,UAAU,MAAM;GAChB,cAAc,OAAiB,SAAwB;IACrD,KAAK,eAAe,OAAO,OAAO;IAClC,IAAI,CAAC,QAAQ,UAAU,KAAK,gBAAgB,KAAK;GACnD;EACF,EAAE;EACF,QAAQ,gBAAgB,IAAI;EAC5B,MAAM,UAAU,cAAc,wBAAwB,aAAa,KAAK,IAAI;EAC5E,aAAa,EAAE,SAAS,OAAO,KAAK;CACtC;AACF,CAAC"}
|
package/src/checkbox.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ export type RootProps = Omit<CheckboxProps, "id" | "onCheckedChange"> & {
|
|
|
4
4
|
id?: string | undefined;
|
|
5
5
|
} & PartComponentProps;
|
|
6
6
|
export type RootEmits = Changes<"checked", boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* A dash while mixed and a tick while checked, from the slot's state: `<Checkbox.Indicator
|
|
9
|
+
* v-slot="{ state }">{{ state.indeterminate ? "–" : "✓" }}</Checkbox.Indicator>`.
|
|
10
|
+
*/
|
|
7
11
|
export interface IndicatorProps extends PartComponentProps {
|
|
8
12
|
/** Keeps the mark in the page while the box is unchecked. */
|
|
9
13
|
keepMounted?: boolean | undefined;
|
|
@@ -15,7 +19,14 @@ export declare const Checkbox: {
|
|
|
15
19
|
readonly disabled?: true | undefined;
|
|
16
20
|
readonly readonly?: true | undefined;
|
|
17
21
|
readonly required?: true | undefined;
|
|
22
|
+
readonly touched?: true | undefined;
|
|
23
|
+
readonly dirty?: true | undefined;
|
|
24
|
+
readonly filled?: true | undefined;
|
|
25
|
+
readonly focused?: true | undefined;
|
|
26
|
+
readonly valid?: true | undefined;
|
|
27
|
+
readonly invalid?: true | undefined;
|
|
18
28
|
readonly indeterminate?: true | undefined;
|
|
29
|
+
readonly parent?: true | undefined;
|
|
19
30
|
}, RootProps, RootEmits>;
|
|
20
31
|
Indicator: PartComponent<"span", {
|
|
21
32
|
readonly checked?: true | undefined;
|
|
@@ -23,6 +34,12 @@ export declare const Checkbox: {
|
|
|
23
34
|
readonly disabled?: true | undefined;
|
|
24
35
|
readonly readonly?: true | undefined;
|
|
25
36
|
readonly required?: true | undefined;
|
|
37
|
+
readonly touched?: true | undefined;
|
|
38
|
+
readonly dirty?: true | undefined;
|
|
39
|
+
readonly filled?: true | undefined;
|
|
40
|
+
readonly focused?: true | undefined;
|
|
41
|
+
readonly valid?: true | undefined;
|
|
42
|
+
readonly invalid?: true | undefined;
|
|
26
43
|
readonly indeterminate?: true | undefined;
|
|
27
44
|
readonly startingStyle?: true | undefined;
|
|
28
45
|
readonly endingStyle?: true | undefined;
|
package/src/checkbox.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { CHECKBOX_GROUP } from "./checkbox-group-context.js";
|
|
1
2
|
import { useFieldAround } from "./field-context.js";
|
|
2
3
|
import { context, controller, fromSignal, optional, partComponent } from "./runtime.js";
|
|
3
4
|
import { within } from "@kirana-ui/core";
|
|
4
|
-
import { defineComponent, h, useId } from "vue";
|
|
5
|
+
import { defineComponent, h, inject, useId } from "vue";
|
|
5
6
|
import { createCheckbox } from "@kirana-ui/core/checkbox";
|
|
6
7
|
// src/checkbox.ts
|
|
7
8
|
const scope = context("Checkbox");
|
|
@@ -15,6 +16,7 @@ const Root = defineComponent({
|
|
|
15
16
|
checked: optional(Boolean),
|
|
16
17
|
defaultChecked: Boolean,
|
|
17
18
|
indeterminate: Boolean,
|
|
19
|
+
parent: Boolean,
|
|
18
20
|
disabled: Boolean,
|
|
19
21
|
readOnly: Boolean,
|
|
20
22
|
required: Boolean,
|
|
@@ -27,11 +29,16 @@ const Root = defineComponent({
|
|
|
27
29
|
setup(props, { attrs, slots, emit }) {
|
|
28
30
|
const generated = useId();
|
|
29
31
|
const field = useFieldAround();
|
|
30
|
-
|
|
32
|
+
const group = inject(CHECKBOX_GROUP, null) ?? void 0;
|
|
33
|
+
scope.provide(controller(within(createCheckbox, {
|
|
34
|
+
field,
|
|
35
|
+
group
|
|
36
|
+
}), () => ({
|
|
31
37
|
id: props.id ?? generated,
|
|
32
38
|
checked: props.checked,
|
|
33
39
|
defaultChecked: props.defaultChecked,
|
|
34
40
|
indeterminate: props.indeterminate,
|
|
41
|
+
parent: props.parent,
|
|
35
42
|
disabled: props.disabled,
|
|
36
43
|
readOnly: props.readOnly,
|
|
37
44
|
required: props.required,
|
package/src/checkbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","names":[],"sources":["../../../../packages/vue/src/checkbox.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createCheckbox } from \"@kirana-ui/core/checkbox\"\nimport type { CheckboxProps, Checkbox as Controller } from \"@kirana-ui/core/checkbox\"\nimport { defineComponent, h, useId } from \"vue\"\n\nimport { useFieldAround } from \"./field-context.ts\"\nimport { context, controller, fromSignal, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"checkbox\">\n\nconst scope = context<Controller>(\"Checkbox\")\n\nconst Input = partComponent(\"CheckboxInput\", \"input\", () => scope.use().input)\n// Its native input is the element's last child, whatever element the caller asked for.\nconst RootElement = partComponent(\n \"CheckboxRootElement\",\n \"span\",\n () => scope.use().root,\n (content) => [content, h(Input)]\n)\n\nexport type RootProps = Omit<CheckboxProps, \"id\" | \"onCheckedChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"checked\", boolean>\n\n/** `v-model:checked`, or `checked` with `@checked-change=\"(checked, details) => …\"`. */\nconst Root = defineComponent({\n name: \"CheckboxRoot\",\n inheritAttrs: false,\n props: {\n checked: optional(Boolean),\n defaultChecked: Boolean,\n indeterminate: Boolean,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n value: String,\n id: String,\n },\n emits: [\"update:checked\", \"checkedChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n scope.provide(\n controller(within(createCheckbox, { field }), () => ({\n id: props.id ?? generated,\n checked: props.checked,\n defaultChecked: props.defaultChecked,\n indeterminate: props.indeterminate,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n value: props.value,\n onCheckedChange(checked: boolean, details: ChangeDetails) {\n emit(\"checkedChange\", checked, details)\n if (!details.canceled) emit(\"update:checked\", checked)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"root\"], RootProps, RootEmits>\n\nconst IndicatorElement = partComponent(\n \"CheckboxIndicatorElement\",\n \"span\",\n () => scope.use().indicator\n)\n\nexport interface IndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while the box is unchecked. */\n keepMounted?: boolean | undefined\n}\n\n/** `keep-mounted` keeps the mark in the page while the box is unchecked. */\nconst Indicator = defineComponent({\n name: \"CheckboxIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const mounted = fromSignal(scope.use().indicatorMounted)\n return () => (mounted.value || props.keepMounted ? h(IndicatorElement, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"indicator\"], IndicatorProps>\n\nexport const Checkbox = { Root, Indicator }\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkbox.js","names":[],"sources":["../../../../packages/vue/src/checkbox.ts"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { ChangeDetails } from \"@kirana-ui/core\"\nimport { createCheckbox } from \"@kirana-ui/core/checkbox\"\nimport type { CheckboxProps, Checkbox as Controller } from \"@kirana-ui/core/checkbox\"\nimport { defineComponent, h, inject, useId } from \"vue\"\n\nimport { CHECKBOX_GROUP } from \"./checkbox-group-context.ts\"\nimport { useFieldAround } from \"./field-context.ts\"\nimport { context, controller, fromSignal, optional, partComponent } from \"./runtime.ts\"\nimport type { Changes, PartComponent, PartComponentProps, StatesOf } from \"./runtime.ts\"\n\ntype State = StatesOf<\"checkbox\">\n\nconst scope = context<Controller>(\"Checkbox\")\n\nconst Input = partComponent(\"CheckboxInput\", \"input\", () => scope.use().input)\n// Its native input is the element's last child, whatever element the caller asked for.\nconst RootElement = partComponent(\n \"CheckboxRootElement\",\n \"span\",\n () => scope.use().root,\n (content) => [content, h(Input)]\n)\n\nexport type RootProps = Omit<CheckboxProps, \"id\" | \"onCheckedChange\"> & {\n id?: string | undefined\n} & PartComponentProps\n\nexport type RootEmits = Changes<\"checked\", boolean>\n\n/** `v-model:checked`, or `checked` with `@checked-change=\"(checked, details) => …\"`. */\nconst Root = defineComponent({\n name: \"CheckboxRoot\",\n inheritAttrs: false,\n props: {\n checked: optional(Boolean),\n defaultChecked: Boolean,\n indeterminate: Boolean,\n parent: Boolean,\n disabled: Boolean,\n readOnly: Boolean,\n required: Boolean,\n name: String,\n form: String,\n value: String,\n id: String,\n },\n emits: [\"update:checked\", \"checkedChange\"],\n setup(props, { attrs, slots, emit }) {\n const generated = useId()\n const field = useFieldAround()\n const group = inject(CHECKBOX_GROUP, null) ?? undefined\n scope.provide(\n controller(within(createCheckbox, { field, group }), () => ({\n id: props.id ?? generated,\n checked: props.checked,\n defaultChecked: props.defaultChecked,\n indeterminate: props.indeterminate,\n parent: props.parent,\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n name: props.name,\n form: props.form,\n value: props.value,\n onCheckedChange(checked: boolean, details: ChangeDetails) {\n emit(\"checkedChange\", checked, details)\n if (!details.canceled) emit(\"update:checked\", checked)\n },\n }))\n )\n return () => h(RootElement, attrs, slots)\n },\n}) as unknown as PartComponent<\"span\", State[\"root\"], RootProps, RootEmits>\n\nconst IndicatorElement = partComponent(\n \"CheckboxIndicatorElement\",\n \"span\",\n () => scope.use().indicator\n)\n\n/**\n * A dash while mixed and a tick while checked, from the slot's state: `<Checkbox.Indicator\n * v-slot=\"{ state }\">{{ state.indeterminate ? \"–\" : \"✓\" }}</Checkbox.Indicator>`.\n */\nexport interface IndicatorProps extends PartComponentProps {\n /** Keeps the mark in the page while the box is unchecked. */\n keepMounted?: boolean | undefined\n}\n\n/** `keep-mounted` keeps the mark in the page while the box is unchecked. */\nconst Indicator = defineComponent({\n name: \"CheckboxIndicator\",\n inheritAttrs: false,\n props: { keepMounted: Boolean },\n setup(props, { attrs, slots }) {\n const mounted = fromSignal(scope.use().indicatorMounted)\n return () => (mounted.value || props.keepMounted ? h(IndicatorElement, attrs, slots) : null)\n },\n}) as unknown as PartComponent<\"span\", State[\"indicator\"], Ind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;EACN,cAAc;EACd,OAAO,EAAE,aAAa,QAAQ;EAC9B,MAAM,OAAO,EAAE,OAAO,SAAS;GAC7B,MAAM,UAAU,WAAW,MAAM,IAAI,CAAC,CAAC,gBAAgB;GACvD,aAAc,QAAQ,SAAS,MAAM,cAAc,EAAE,kBAAkB,OAAO,KAAK,IAAI;EACzF;CACF,CAEgC;AAAU"}
|
package/src/collapsible.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export declare const Collapsible: {
|
|
|
14
14
|
readonly open?: true | undefined;
|
|
15
15
|
readonly closed?: true | undefined;
|
|
16
16
|
readonly disabled?: true | undefined;
|
|
17
|
+
readonly startingStyle?: true | undefined;
|
|
18
|
+
readonly endingStyle?: true | undefined;
|
|
17
19
|
}, RootProps, RootEmits>;
|
|
18
20
|
Trigger: PartComponent<"button", {
|
|
19
21
|
readonly panelOpen?: true | undefined;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Changes, PartComponent, PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ChangeDetails, Orientation } from "@kirana-ui/core";
|
|
3
|
+
import { ColorFormat, ColorPickerInputChannel, ColorPickerProps, ColorPickerSliderChannel } from "@kirana-ui/core/color-picker";
|
|
4
|
+
export type RootProps = Omit<ColorPickerProps, "id" | "onValueChange" | "onValueCommitted" | "onFormatChange"> & {
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
export type RootEmits = Changes<"value", string> & Changes<"format", ColorFormat> & {
|
|
8
|
+
/** The pointer let go, a key moved a thumb, a typed channel was left: the value to save. */
|
|
9
|
+
valueCommitted: (value: string, details: ChangeDetails) => void;
|
|
10
|
+
};
|
|
11
|
+
export interface ChannelSliderProps extends PartComponentProps {
|
|
12
|
+
/** The channel it moves: the hue, or the alpha. */
|
|
13
|
+
channel: ColorPickerSliderChannel;
|
|
14
|
+
/** The way its track runs. Default `horizontal`. */
|
|
15
|
+
orientation?: Orientation | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface ChannelInputProps extends PartComponentProps {
|
|
18
|
+
/** The channel it is typed in, or `hex` for the whole colour. */
|
|
19
|
+
channel: ColorPickerInputChannel;
|
|
20
|
+
}
|
|
21
|
+
export interface SwatchTriggerProps extends PartComponentProps {
|
|
22
|
+
/** The preset's colour, in any format: pressed, the colour is this one. */
|
|
23
|
+
value: string;
|
|
24
|
+
}
|
|
25
|
+
export type AreaProps = PartComponentProps;
|
|
26
|
+
export type AreaThumbProps = PartComponentProps;
|
|
27
|
+
export type ChannelSliderTrackProps = PartComponentProps;
|
|
28
|
+
export type ChannelSliderThumbProps = PartComponentProps;
|
|
29
|
+
export type SwatchProps = PartComponentProps;
|
|
30
|
+
export type EyeDropperTriggerProps = PartComponentProps;
|
|
31
|
+
export type ValueTextProps = PartComponentProps;
|
|
32
|
+
export type FormatTriggerProps = PartComponentProps;
|
|
33
|
+
export declare const ColorPicker: {
|
|
34
|
+
Root: PartComponent<"div", {
|
|
35
|
+
readonly disabled?: true | undefined;
|
|
36
|
+
readonly readonly?: true | undefined;
|
|
37
|
+
readonly required?: true | undefined;
|
|
38
|
+
readonly dragging?: true | undefined;
|
|
39
|
+
readonly format?: "hex" | "hsl" | "rgb" | undefined;
|
|
40
|
+
}, RootProps, RootEmits>;
|
|
41
|
+
Area: PartComponent<"div", {
|
|
42
|
+
readonly disabled?: true | undefined;
|
|
43
|
+
readonly readonly?: true | undefined;
|
|
44
|
+
readonly required?: true | undefined;
|
|
45
|
+
readonly dragging?: true | undefined;
|
|
46
|
+
}, PartComponentProps, {}, unknown>;
|
|
47
|
+
AreaThumb: PartComponent<"div", {
|
|
48
|
+
readonly disabled?: true | undefined;
|
|
49
|
+
readonly readonly?: true | undefined;
|
|
50
|
+
readonly required?: true | undefined;
|
|
51
|
+
readonly dragging?: true | undefined;
|
|
52
|
+
}, PartComponentProps, {}, unknown>;
|
|
53
|
+
ChannelSlider: PartComponent<"div", {
|
|
54
|
+
readonly disabled?: true | undefined;
|
|
55
|
+
readonly readonly?: true | undefined;
|
|
56
|
+
readonly required?: true | undefined;
|
|
57
|
+
readonly dragging?: true | undefined;
|
|
58
|
+
readonly channel?: "alpha" | "hue" | undefined;
|
|
59
|
+
readonly orientation?: "horizontal" | "vertical" | undefined;
|
|
60
|
+
}, ChannelSliderProps>;
|
|
61
|
+
ChannelSliderTrack: PartComponent<"div", {
|
|
62
|
+
readonly disabled?: true | undefined;
|
|
63
|
+
readonly readonly?: true | undefined;
|
|
64
|
+
readonly required?: true | undefined;
|
|
65
|
+
readonly dragging?: true | undefined;
|
|
66
|
+
readonly channel?: "alpha" | "hue" | undefined;
|
|
67
|
+
readonly orientation?: "horizontal" | "vertical" | undefined;
|
|
68
|
+
}, PartComponentProps, {}, unknown>;
|
|
69
|
+
ChannelSliderThumb: PartComponent<"div", {
|
|
70
|
+
readonly disabled?: true | undefined;
|
|
71
|
+
readonly readonly?: true | undefined;
|
|
72
|
+
readonly required?: true | undefined;
|
|
73
|
+
readonly dragging?: true | undefined;
|
|
74
|
+
readonly channel?: "alpha" | "hue" | undefined;
|
|
75
|
+
readonly orientation?: "horizontal" | "vertical" | undefined;
|
|
76
|
+
}, PartComponentProps, {}, unknown>;
|
|
77
|
+
ChannelInput: PartComponent<"input", {
|
|
78
|
+
readonly disabled?: true | undefined;
|
|
79
|
+
readonly readonly?: true | undefined;
|
|
80
|
+
readonly required?: true | undefined;
|
|
81
|
+
readonly dragging?: true | undefined;
|
|
82
|
+
readonly channel?: "alpha" | "blue" | "green" | "hex" | "hue" | "lightness" | "red" | "saturation" | undefined;
|
|
83
|
+
}, ChannelInputProps>;
|
|
84
|
+
Swatch: PartComponent<"div", {
|
|
85
|
+
readonly disabled?: true | undefined;
|
|
86
|
+
readonly readonly?: true | undefined;
|
|
87
|
+
readonly required?: true | undefined;
|
|
88
|
+
readonly dragging?: true | undefined;
|
|
89
|
+
}, PartComponentProps, {}, unknown>;
|
|
90
|
+
SwatchTrigger: PartComponent<"button", {
|
|
91
|
+
readonly disabled?: true | undefined;
|
|
92
|
+
readonly readonly?: true | undefined;
|
|
93
|
+
readonly required?: true | undefined;
|
|
94
|
+
readonly dragging?: true | undefined;
|
|
95
|
+
readonly selected?: true | undefined;
|
|
96
|
+
}, SwatchTriggerProps>;
|
|
97
|
+
EyeDropperTrigger: PartComponent<"button", {
|
|
98
|
+
readonly disabled?: true | undefined;
|
|
99
|
+
readonly readonly?: true | undefined;
|
|
100
|
+
readonly required?: true | undefined;
|
|
101
|
+
readonly dragging?: true | undefined;
|
|
102
|
+
}, PartComponentProps, {}, unknown>;
|
|
103
|
+
ValueText: PartComponent<"span", {
|
|
104
|
+
readonly disabled?: true | undefined;
|
|
105
|
+
readonly readonly?: true | undefined;
|
|
106
|
+
readonly required?: true | undefined;
|
|
107
|
+
readonly dragging?: true | undefined;
|
|
108
|
+
readonly format?: "hex" | "hsl" | "rgb" | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
FormatTrigger: PartComponent<"button", {
|
|
111
|
+
readonly disabled?: true | undefined;
|
|
112
|
+
readonly readonly?: true | undefined;
|
|
113
|
+
readonly required?: true | undefined;
|
|
114
|
+
readonly dragging?: true | undefined;
|
|
115
|
+
readonly format?: "hex" | "hsl" | "rgb" | undefined;
|
|
116
|
+
}>;
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=color-picker.d.ts.map
|