@m3ui-vue/m3ui-vue 1.4.0 → 1.4.2
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/dist/API.md +295 -11
- package/dist/{MButton-DQMTIlaV.js → MButton-D7M324r9.js} +2 -2
- package/dist/{MButton-DQMTIlaV.js.map → MButton-D7M324r9.js.map} +1 -1
- package/dist/{MDialog-cdgapGfZ.js → MDialog-DuOnNF9s.js} +2 -2
- package/dist/{MDialog-cdgapGfZ.js.map → MDialog-DuOnNF9s.js.map} +1 -1
- package/dist/{MListItem-ZkSGIIrb.js → MListItem-Bb84X6ex.js} +144 -120
- package/dist/{MListItem-ZkSGIIrb.js.map → MListItem-Bb84X6ex.js.map} +1 -1
- package/dist/{MLoadingIndicator-U6_oGx8z.js → MLoadingIndicator-BUGRo2Tu.js} +2 -2
- package/dist/{MLoadingIndicator-U6_oGx8z.js.map → MLoadingIndicator-BUGRo2Tu.js.map} +1 -1
- package/dist/{MSeekBar-DTZVizZg.js → MSeekBar-BQUvUqb9.js} +2 -2
- package/dist/{MSeekBar-DTZVizZg.js.map → MSeekBar-BQUvUqb9.js.map} +1 -1
- package/dist/{MSlider-CqJkEYRZ.js → MSlider-SFdjE1Hy.js} +2 -2
- package/dist/{MSlider-CqJkEYRZ.js.map → MSlider-SFdjE1Hy.js.map} +1 -1
- package/dist/{MSpinner-Btgc-0nb.js → MSpinner-DKGNN64_.js} +2 -2
- package/dist/{MSpinner-Btgc-0nb.js.map → MSpinner-DKGNN64_.js.map} +1 -1
- package/dist/{MTextField-B6M0gJEO.js → MTextField-Utsef6Kk.js} +2 -2
- package/dist/{MTextField-B6M0gJEO.js.map → MTextField-Utsef6Kk.js.map} +1 -1
- package/dist/{MTooltip-Dspji4XG.js → MTooltip-BhTFQ9Z2.js} +4 -4
- package/dist/{MTooltip-Dspji4XG.js.map → MTooltip-BhTFQ9Z2.js.map} +1 -1
- package/dist/api.json +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MAvailabilityCalendar.vue.d.ts +1 -1
- package/dist/components/MCalendarHeatmap.vue.d.ts +120 -0
- package/dist/components/MCountdown.vue.d.ts +80 -0
- package/dist/components/MDatePicker.vue.d.ts +5 -0
- package/dist/components/MDatePickerModal.vue.d.ts +5 -0
- package/dist/components/MDateRangePicker.vue.d.ts +5 -0
- package/dist/components/MDateRangePickerModal.vue.d.ts +5 -0
- package/dist/components/MLightbox.vue.d.ts +1 -1
- package/dist/components/MListItem.vue.d.ts +10 -6
- package/dist/components/MMeterGroup.vue.d.ts +98 -0
- package/dist/components/MPhoneInput.vue.d.ts +72 -0
- package/dist/components/MSeekBar.vue.d.ts +1 -1
- package/dist/components/MTreeTable.vue.d.ts +1 -1
- package/dist/components/MTypewriter.vue.d.ts +57 -0
- package/dist/components/MVideoPlayer.vue.d.ts +1 -1
- package/dist/components/_MMonthYearButton.vue.d.ts +16 -0
- package/dist/components/_MYearGrid.vue.d.ts +19 -0
- package/dist/composables/_useCalendarMonth.d.ts +7 -0
- package/dist/composables/phoneNumber.d.ts +39 -0
- package/dist/composables/useLocale.d.ts +18 -0
- package/dist/data/phone-countries.d.ts +2 -0
- package/dist/draw.js +2 -2
- package/dist/flow.js +1 -1
- package/dist/gantt.js +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/locales/index.js +63 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +5133 -3366
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +5 -5
- package/dist/media.js +4 -4
- package/dist/pdf.js +4 -4
- package/dist/rich-text-editor.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/{useLocale-DLKJIRFi.js → useLocale-B8YKWg-H.js} +10 -1
- package/dist/useLocale-B8YKWg-H.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/MCalendarHeatmap.test.ts +79 -0
- package/src/__tests__/MCountdown.test.ts +75 -0
- package/src/__tests__/MListItemNestedControl.test.ts +88 -0
- package/src/__tests__/MMeterGroup.test.ts +43 -0
- package/src/__tests__/MPhoneInput.test.ts +97 -0
- package/src/__tests__/MTypewriter.test.ts +50 -0
- package/src/__tests__/calendarMonth.test.ts +104 -0
- package/src/__tests__/clearToNull.test.ts +30 -0
- package/src/__tests__/ssr.test.ts +4 -0
- package/src/components/MAutocomplete.vue +2 -2
- package/src/components/MCalendarHeatmap.vue +349 -0
- package/src/components/MCountdown.vue +200 -0
- package/src/components/MDatePicker.vue +74 -34
- package/src/components/MDatePickerModal.vue +79 -36
- package/src/components/MDateRangePicker.vue +73 -33
- package/src/components/MDateRangePickerModal.vue +75 -35
- package/src/components/MListItem.vue +54 -8
- package/src/components/MMeterGroup.vue +196 -0
- package/src/components/MPhoneInput.vue +480 -0
- package/src/components/MSelect.vue +2 -2
- package/src/components/MTypewriter.vue +195 -0
- package/src/components/_MMonthYearButton.vue +36 -0
- package/src/components/_MYearGrid.vue +106 -0
- package/src/composables/_useCalendarMonth.ts +32 -2
- package/src/composables/phoneNumber.ts +137 -0
- package/src/composables/useLocale.ts +27 -0
- package/src/data/phone-countries.ts +62 -0
- package/src/index.ts +10 -0
- package/src/locales/de.ts +9 -0
- package/src/locales/es.ts +9 -0
- package/src/locales/fr.ts +9 -0
- package/src/locales/ja.ts +9 -0
- package/src/locales/ko.ts +9 -0
- package/src/locales/pt.ts +9 -0
- package/src/locales/zh.ts +9 -0
- package/dist/useLocale-DLKJIRFi.js.map +0 -1
package/dist/API.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @m3ui-vue/m3ui-vue 1.4.
|
|
1
|
+
# @m3ui-vue/m3ui-vue 1.4.2 — API reference
|
|
2
2
|
|
|
3
3
|
Material Design 3 components for Vue 3 + Tailwind CSS v4. Generated from the source by
|
|
4
4
|
`scripts/generate-api.mjs`; full docs with live demos at https://m3ui.dev.
|
|
@@ -232,7 +232,7 @@ Props:
|
|
|
232
232
|
- `debounce?: number = 0` — Delay (ms) before filtering and firing @debounced. Selection is always instant
|
|
233
233
|
|
|
234
234
|
Events:
|
|
235
|
-
- `update:modelValue(unknown)` — Emitted on selection — powers v-model
|
|
235
|
+
- `update:modelValue(unknown)` — Emitted on selection — powers v-model (`null` when the clear button empties it)
|
|
236
236
|
- `debounced(string)` — Emitted debounce ms after the user stops typing the search query (only when debounce > 0)
|
|
237
237
|
|
|
238
238
|
### MAvailabilityCalendar
|
|
@@ -591,6 +591,57 @@ export interface CalendarEvent {
|
|
|
591
591
|
}
|
|
592
592
|
```
|
|
593
593
|
|
|
594
|
+
### MCalendarHeatmap
|
|
595
|
+
|
|
596
|
+
MCalendarHeatmap — activity per day as a grid of weeks (a column per week, a row per weekday), each day tinted by how much happened: commits, workouts, sales, habits. Month and weekday names come from `Intl` in the app's language. Hover or focus a day for its value; arrow keys move by day (up/down) and by week (left/right), and Enter/Space or a click select it (v-model). Scrolls sideways when it doesn't fit, starting at the latest week.
|
|
597
|
+
|
|
598
|
+
Props:
|
|
599
|
+
- `data: Record<string, number> | HeatmapDay[]` — Values per day: `{ '2026-11-20': 4 }` or `[{ date: '2026-11-20', value: 4 }]`. Missing days are 0
|
|
600
|
+
- `end?: string | Date` — Last day shown (YYYY-MM-DD or a Date); defaults to today
|
|
601
|
+
- `start?: string | Date` — First day shown; defaults to `weeks` weeks before `end`
|
|
602
|
+
- `weeks?: number = 53` — How many weeks to show when there's no `start`
|
|
603
|
+
- `weekStart?: 0 | 1 = 1` — First day of the week: 1 Monday (default, like the date pickers), 0 Sunday
|
|
604
|
+
- `levels?: number = 5` — Number of tints, the empty one included
|
|
605
|
+
- `max?: number` — The value that gets the darkest tint; defaults to the largest value shown
|
|
606
|
+
- `color?: string = "primary"` — An M3 color role (`primary`, `tertiary`, `success`...) or any CSS color
|
|
607
|
+
- `cellSize?: number = 12` — Side of a day's square, in px
|
|
608
|
+
- `gap?: number = 3` — Space between days, in px
|
|
609
|
+
- `monthLabels?: boolean = true` — Month names above the weeks
|
|
610
|
+
- `dayLabels?: boolean = true` — Weekday names (Mon, Wed, Fri) beside the rows
|
|
611
|
+
- `legend?: boolean = true` — The "Less ▢▢▢ More" scale below
|
|
612
|
+
- `tooltip?: boolean = true` — Show the day's value on hover and focus
|
|
613
|
+
- `formatTooltip?: ((cell: HeatmapCell) => string)` — The tooltip's text (and each day's accessible name); defaults to "value · date"
|
|
614
|
+
- `locale?: string` — BCP-47 language for month/weekday names and numbers; defaults to the app's locale
|
|
615
|
+
- `modelValue?: string | null = null` (v-model) — Selected day, YYYY-MM-DD (v-model); outlined
|
|
616
|
+
- `label?: string` — Accessible name of the grid
|
|
617
|
+
|
|
618
|
+
Events:
|
|
619
|
+
- `update:modelValue(string)` — Emitted with the date (YYYY-MM-DD) of the day picked — powers v-model
|
|
620
|
+
- `select(HeatmapCell)` — Emitted with the `HeatmapCell` of the day picked
|
|
621
|
+
|
|
622
|
+
Slots:
|
|
623
|
+
- `#tooltip { date: string; value: number; level: number; }` — Replaces the tooltip's text; receives the `HeatmapCell` (`date`, `value`, `level`)
|
|
624
|
+
|
|
625
|
+
```ts
|
|
626
|
+
/** One day of `data` when given as an array */
|
|
627
|
+
export interface HeatmapDay {
|
|
628
|
+
/** YYYY-MM-DD */
|
|
629
|
+
date: string
|
|
630
|
+
value: number
|
|
631
|
+
}
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
```ts
|
|
635
|
+
/** A cell, as the tooltip slot and the select event get it */
|
|
636
|
+
export interface HeatmapCell {
|
|
637
|
+
/** YYYY-MM-DD */
|
|
638
|
+
date: string
|
|
639
|
+
value: number
|
|
640
|
+
/** 0 (nothing) to levels - 1 (the most) */
|
|
641
|
+
level: number
|
|
642
|
+
}
|
|
643
|
+
```
|
|
644
|
+
|
|
594
645
|
### MCandlestickChart
|
|
595
646
|
|
|
596
647
|
A candlestick (OHLC) chart for prices: stocks, crypto, commodities, an exchange rate. Drawn in plain SVG with no chart library: candles, volume bars, moving averages, the last-price line and a crosshair with the candle's open / high / low / close. Drag (or swipe) to pan through history, Ctrl + wheel (or a trackpad / two-finger pinch) to zoom; the arrow keys move the crosshair. Appending candles keeps the chart pinned to the latest one while it's in view, so it can be fed live.
|
|
@@ -1020,6 +1071,48 @@ Events:
|
|
|
1020
1071
|
- `error(unknown)` — Emitted if the browser refuses the clipboard write
|
|
1021
1072
|
- `copied(string)` — Emitted with the copied value after a successful clipboard write
|
|
1022
1073
|
|
|
1074
|
+
### MCountdown
|
|
1075
|
+
|
|
1076
|
+
MCountdown — a countdown to a date: days, hours, minutes and seconds with rolling digits, in boxes or inline. Unit names come from `Intl` in the app's language. Units left out of `units` fold into the next larger one shown (no `days` → 50 hours). Ticks on the second boundary; every tick costs one timer, not one per digit.
|
|
1077
|
+
|
|
1078
|
+
Props:
|
|
1079
|
+
- `to: string | number | Date` — The moment it counts down to: a `Date`, a timestamp in ms, or a date string
|
|
1080
|
+
- `units?: CountdownUnit[] = ["days", "hours", "minutes", "seconds"]` — Units shown, largest first; leaving one out folds it into the next larger one
|
|
1081
|
+
- `variant?: "inline" | "boxes" = "boxes"` — `boxes`: each unit in its own container with its name below; `inline`: one line of text (3d 04h 12m)
|
|
1082
|
+
- `size?: "sm" | "md" | "lg" = "md"` — Digit size
|
|
1083
|
+
- `labels?: boolean = true` — Show unit names
|
|
1084
|
+
- `hideEmpty?: boolean = false` — Hide leading units while they're zero (no "0 days" a few hours before)
|
|
1085
|
+
- `animate?: boolean = true` — Roll the digits; false (or the system's reduced motion) swaps them
|
|
1086
|
+
- `locale?: string` — BCP-47 language for the unit names; defaults to the app's locale
|
|
1087
|
+
|
|
1088
|
+
Events:
|
|
1089
|
+
- `finished()` — Emitted once when the countdown reaches zero (not on mount if `to` is already past)
|
|
1090
|
+
- `tick(CountdownParts)` — Emitted every second with the `CountdownParts`
|
|
1091
|
+
|
|
1092
|
+
Slots:
|
|
1093
|
+
- `#finished` — Shown instead of the countdown once it reaches zero
|
|
1094
|
+
- `#default { days: number; hours: number; minutes: number; seconds: number; total: number; finished: boolean; }` — Replaces the whole rendering; receives `CountdownParts` (`days`, `hours`, `minutes`, `seconds`, `total`, `finished`)
|
|
1095
|
+
|
|
1096
|
+
Exposed (template ref):
|
|
1097
|
+
- `parts: CountdownParts`
|
|
1098
|
+
|
|
1099
|
+
```ts
|
|
1100
|
+
export type CountdownUnit = 'days' | 'hours' | 'minutes' | 'seconds'
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
```ts
|
|
1104
|
+
/** What the default slot receives: the time left, split into the units shown */
|
|
1105
|
+
export interface CountdownParts {
|
|
1106
|
+
days: number
|
|
1107
|
+
hours: number
|
|
1108
|
+
minutes: number
|
|
1109
|
+
seconds: number
|
|
1110
|
+
/** Milliseconds left (0 once finished) */
|
|
1111
|
+
total: number
|
|
1112
|
+
finished: boolean
|
|
1113
|
+
}
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1023
1116
|
### MCreditCardInput
|
|
1024
1117
|
|
|
1025
1118
|
Card payment fields: number, expiry, security code and optionally the cardholder's name, with a live card preview that turns over while the security code is typed. The number is grouped as its network prints it (4-6-5 for American Express), the network is detected from the first digits, and every field is checked (length, Luhn checksum, a future expiry, the code's length for that network). It only collects and checks what is typed: it doesn't tokenize or send anything. Hand the value to your payment provider's SDK.
|
|
@@ -1142,6 +1235,7 @@ Props:
|
|
|
1142
1235
|
- `placeholder?: string` — Placeholder shown when no date is selected — falls back to label, then the current locale's string
|
|
1143
1236
|
- `min?: string` — Minimum selectable date (YYYY-MM-DD)
|
|
1144
1237
|
- `max?: string` — Maximum selectable date (YYYY-MM-DD)
|
|
1238
|
+
- `yearRange?: [number, number]` — First and last year the year grid (opened from the month's title) offers, as `[from, to]`; the years min/max leave no day in are disabled. Default 1900–2100, as Compose's DatePickerDefaults.YearRange
|
|
1145
1239
|
- `disabled?: boolean` — Disables the picker
|
|
1146
1240
|
- `error?: boolean` — Error state
|
|
1147
1241
|
- `errorLabel?: string` — Error message shown when error is true
|
|
@@ -1165,6 +1259,7 @@ Props:
|
|
|
1165
1259
|
- `max?: string` — Maximum selectable date (YYYY-MM-DD)
|
|
1166
1260
|
- `locale?: string` — Locale for month/day names. Falls back to the app's configured locale (createM3UI({ locale })) — same pattern as MRelativeTime
|
|
1167
1261
|
- `title?: string` — Dialog title
|
|
1262
|
+
- `yearRange?: [number, number]` — First and last year the year grid (opened from the month's title) offers, as `[from, to]`; the years min/max leave no day in are disabled. Default 1900–2100, as Compose's DatePickerDefaults.YearRange
|
|
1168
1263
|
|
|
1169
1264
|
Events:
|
|
1170
1265
|
- `update:modelValue(string | null)` — Emitted when a date is confirmed — powers v-model
|
|
@@ -1180,6 +1275,7 @@ Props:
|
|
|
1180
1275
|
- `placeholder?: string` — Placeholder shown when no range is selected — falls back to label, then the current locale's string
|
|
1181
1276
|
- `min?: string` — Minimum date (YYYY-MM-DD)
|
|
1182
1277
|
- `max?: string` — Maximum date (YYYY-MM-DD)
|
|
1278
|
+
- `yearRange?: [number, number]` — First and last year the year grid (opened from the month's title) offers, as `[from, to]`; the years min/max leave no day in are disabled. Default 1900–2100, as Compose's DatePickerDefaults.YearRange
|
|
1183
1279
|
- `disabled?: boolean` — Disables the picker
|
|
1184
1280
|
- `error?: boolean` — Error state
|
|
1185
1281
|
- `errorLabel?: string` — Error message shown when error is true
|
|
@@ -1210,6 +1306,7 @@ Props:
|
|
|
1210
1306
|
- `show?: boolean = false` (v-model:show) — Controls dialog visibility (v-model:show)
|
|
1211
1307
|
- `min?: string` — Minimum selectable date (YYYY-MM-DD)
|
|
1212
1308
|
- `max?: string` — Maximum selectable date (YYYY-MM-DD)
|
|
1309
|
+
- `yearRange?: [number, number]` — First and last year the year grid (opened from the month's title) offers, as `[from, to]`; the years min/max leave no day in are disabled. Default 1900–2100, as Compose's DatePickerDefaults.YearRange
|
|
1213
1310
|
- `locale?: string` — Locale for month/day names. Falls back to the app's configured locale (createM3UI({ locale })) — same pattern as MRelativeTime
|
|
1214
1311
|
- `title?: string` — Dialog title
|
|
1215
1312
|
|
|
@@ -1624,7 +1721,7 @@ Props:
|
|
|
1624
1721
|
- `editable?: boolean = false` — Drag tables around; otherwise a click opens one
|
|
1625
1722
|
- `grid?: number = 10` — Grid step in plan units (0: no snapping)
|
|
1626
1723
|
- `showGrid?: boolean = true` — Draw the grid while editing
|
|
1627
|
-
- `tableSnap?: "
|
|
1724
|
+
- `tableSnap?: "cell" | "point" = "point"` — Where a table's middle snaps: `point` a grid point (default), `cell` the middle of a grid square, so tables sit in the squares between the points while walls, zones and decor snap to the points (a plan of cells)
|
|
1628
1725
|
- `subgrid?: number = 1` — Snapping steps per grid square for walls, zones and decor: 2 puts them on the points and halfway between them (tables keep to the grid). Drawn as smaller dots
|
|
1629
1726
|
- `chairs?: boolean = true` — Draw chairs from `seats`
|
|
1630
1727
|
- `measure?: FloorMeasure` — Real lengths: while editing, the picked wall's or zone's sides, the wall being drawn, and the picked table's or decor's size are labeled in your unit (the inspector's sizes too)
|
|
@@ -2503,6 +2600,7 @@ Props:
|
|
|
2503
2600
|
- `to?: string | object` — Vue Router destination — renders the item as a router-link
|
|
2504
2601
|
- `expandable?: boolean = false` — Show an expand/collapse chevron revealing the #children slot
|
|
2505
2602
|
- `expanded?: boolean` (v-model:expanded) — Control the expanded state (v-model:expanded) — otherwise managed internally
|
|
2603
|
+
- `indent?: string | number` — Indent of the expanded #children: px, or any CSS length. Narrow it on small screens
|
|
2506
2604
|
|
|
2507
2605
|
Events:
|
|
2508
2606
|
- `update:expanded(value: boolean)` — Fires when an expandable item is toggled open/closed
|
|
@@ -2513,8 +2611,8 @@ Slots:
|
|
|
2513
2611
|
- `#leading` — Custom leading element, replacing the icon/avatar/image/icon-container
|
|
2514
2612
|
- `#overline` — Custom overline content, replacing the overline prop
|
|
2515
2613
|
- `#default` — Custom content replacing the title/subtitle/description text block
|
|
2614
|
+
- `#trailing` — Custom trailing element, replacing the icon/text/switch/checkbox. On an expandable item it sits before the expand icon, and its controls (a switch, a button) don't open or close the item
|
|
2516
2615
|
- `#children` — Nested content revealed when expandable is set and the item is expanded
|
|
2517
|
-
- `#trailing` — Custom trailing element, replacing the icon/text/switch/checkbox
|
|
2518
2616
|
|
|
2519
2617
|
```ts
|
|
2520
2618
|
export type ListItemLeading = 'icon' | 'avatar' | 'checkbox' | 'radio' | 'image' | 'icon-container'
|
|
@@ -2931,6 +3029,46 @@ Slots:
|
|
|
2931
3029
|
- `#default` — Item label text.
|
|
2932
3030
|
- `#children` — Nested submenu items. In the parent MMenu's default 'flyout' mode, clicking or hovering (mouse only) the item opens a side panel — supports unlimited nesting depth. In 'push' mode, clicking the item instead swaps the whole menu panel to the submenu with a back header; hover does nothing.
|
|
2933
3031
|
|
|
3032
|
+
### MMeterGroup
|
|
3033
|
+
|
|
3034
|
+
MMeterGroup — several values sharing one bar, like a phone's storage screen: photos, apps, system and what's left of the total. Each part is a segment with its own color, separated by a gap (M3's linear progress track gap), growing in on mount and sliding when values change; the legend lists each part with its value and share, and hovering a part highlights it in both places. Values over `max` are scaled to fit.
|
|
3035
|
+
|
|
3036
|
+
Props:
|
|
3037
|
+
- `items: MeterItem[]`
|
|
3038
|
+
- `max?: number` — The whole bar; defaults to the sum of the values (no remaining part)
|
|
3039
|
+
- `label?: string` — Title above the bar
|
|
3040
|
+
- `unit?: string` — Unit appended to formatted values ("GB")
|
|
3041
|
+
- `numberFormat?: Intl.NumberFormatOptions` — Intl.NumberFormat options for values
|
|
3042
|
+
- `format?: ((value: number) => string)` — Formats a value; overrides `unit` and `numberFormat`
|
|
3043
|
+
- `size?: "sm" | "md" | "lg" = "md"` — Bar thickness
|
|
3044
|
+
- `legend?: boolean = true` — Legend below the bar
|
|
3045
|
+
- `percent?: boolean = false` — Show each part's share (%) in the legend
|
|
3046
|
+
- `showRemaining?: boolean = true` — With `max`, list what's left as a last legend entry (outlined dot)
|
|
3047
|
+
- `remainingLabel?: string` — The remaining entry's label; defaults to the locale's
|
|
3048
|
+
- `summary?: boolean = true` — Show "used of max" on the right of the header
|
|
3049
|
+
- `animate?: boolean = true` — Grow the segments in on mount (off with reduced motion)
|
|
3050
|
+
- `locale?: string` — BCP-47 language for numbers; defaults to the app's locale
|
|
3051
|
+
|
|
3052
|
+
Events:
|
|
3053
|
+
- `select(item: MeterItem, index: number)` — Emitted with the item (and its index) when a segment or legend entry is clicked
|
|
3054
|
+
|
|
3055
|
+
Slots:
|
|
3056
|
+
- `#label` — Replaces the header's text on the left (defaults to `label`)
|
|
3057
|
+
- `#summary { used: number; max: number | undefined; }` — Replaces the header's text on the right (defaults to "used of max")
|
|
3058
|
+
- `#legend-item { item: MeterItem; percent: number; formatted: string; color: string; }` — Replaces a legend entry; receives `item`, `percent`, `formatted` and `color`
|
|
3059
|
+
|
|
3060
|
+
```ts
|
|
3061
|
+
/** One part of the meter */
|
|
3062
|
+
export interface MeterItem {
|
|
3063
|
+
label: string
|
|
3064
|
+
value: number
|
|
3065
|
+
/** An M3 color role (`primary`, `tertiary`...) or any CSS color; defaults to the next of a set of roles */
|
|
3066
|
+
color?: string
|
|
3067
|
+
/** Material Symbol shown in the legend instead of the color dot */
|
|
3068
|
+
icon?: string
|
|
3069
|
+
}
|
|
3070
|
+
```
|
|
3071
|
+
|
|
2934
3072
|
### MMortgageCalculator
|
|
2935
3073
|
|
|
2936
3074
|
A mortgage / loan calculator for a property listing or a bank: price, down payment, rate and term in, the monthly payment, the principal vs interest split and the yearly amortization schedule out. Supports the french system (the same payment every month) and the german one (the same principal every month, falling payments). The math is also exported on its own as `amortize()`.
|
|
@@ -3408,7 +3546,7 @@ Props:
|
|
|
3408
3546
|
- `colors?: string[] = ["#FFE14D", "#7ED957", "#5EB8FF", "#FF7EB6", "#B388FF", "#1F1F1F"]` — Colors offered for annotations
|
|
3409
3547
|
- `inkWidths?: number[] = [1, 2, 4, 8]` — The pen's widths offered in the toolbar, in PDF points (the first one is the default)
|
|
3410
3548
|
- `author?: string` — Written into new annotations' `author`
|
|
3411
|
-
- `sidebar?: "
|
|
3549
|
+
- `sidebar?: "outline" | "thumbnails" | null = null` (v-model:sidebar) — The side panel: thumbnails, the outline, or closed (v-model)
|
|
3412
3550
|
- `toolbar?: boolean = true` — Shows the top bar
|
|
3413
3551
|
- `downloadable?: boolean = true` — Shows download and print
|
|
3414
3552
|
- `fileName?: string` — File name for downloads; default the URL's or the document's title
|
|
@@ -3425,7 +3563,7 @@ Events:
|
|
|
3425
3563
|
- `update:zoom(PdfZoom)`
|
|
3426
3564
|
- `update:rotation(number)`
|
|
3427
3565
|
- `update:annotations(PdfAnnotation[])`
|
|
3428
|
-
- `update:sidebar("
|
|
3566
|
+
- `update:sidebar("outline" | "thumbnails" | null)`
|
|
3429
3567
|
- `loaded(PDFDocumentProxy)` — The document loaded, with its pdf.js proxy
|
|
3430
3568
|
- `annotation-click(PdfAnnotation)` — An annotation was clicked with the select tool
|
|
3431
3569
|
|
|
@@ -3475,6 +3613,41 @@ export type PdfTool = 'select' | 'highlight' | 'note' | 'ink' | 'eraser'
|
|
|
3475
3613
|
export type PdfZoom = number | 'fit-width' | 'fit-page'
|
|
3476
3614
|
```
|
|
3477
3615
|
|
|
3616
|
+
### MPhoneInput
|
|
3617
|
+
|
|
3618
|
+
MPhoneInput — a phone number field with a country selector: flag, calling code and a searchable list of every country (names from `Intl` in the app's language). The number is formatted as it's typed with the country's mask (Argentina's mobiles with the 9 too) and bound as E.164 (`+541123456789`), ready for an API or an SMS provider. Pasting or typing a full international number (`+34...`, `0034...`) switches the country. Without a `country`, it starts on the region of the app's locale (es-AR → Argentina). Filled or outlined, like MTextField.
|
|
3619
|
+
|
|
3620
|
+
Props:
|
|
3621
|
+
- `modelValue?: string | null = null` (v-model) — The number in E.164 (`+541123456789`), or null (v-model)
|
|
3622
|
+
- `label: string` — Field label
|
|
3623
|
+
- `country?: string` (v-model:country) — ISO 3166-1 alpha-2 code of the country (v-model:country)
|
|
3624
|
+
- `defaultCountry?: string` — Country to start on when there's neither a number nor `country`; defaults to the locale's region, else US
|
|
3625
|
+
- `countries?: string[]` — Only these countries (ISO codes) in the list
|
|
3626
|
+
- `preferred?: string[]` — Countries pinned at the top of the list
|
|
3627
|
+
- `variant?: "filled" | "outlined" = "filled"` — Visual style
|
|
3628
|
+
- `error?: boolean` — Puts the field in error state
|
|
3629
|
+
- `errorLabel?: string` — Error message below the field (when `error`, or when `validate` finds the number incomplete)
|
|
3630
|
+
- `hint?: string` — Hint text below the field
|
|
3631
|
+
- `disabled?: boolean` — Disables the field
|
|
3632
|
+
- `required?: boolean` — Marks as required — adds a red asterisk after the label
|
|
3633
|
+
- `validate?: boolean = true` — After leaving the field, show an error when the number doesn't fit its country's length
|
|
3634
|
+
- `placeholder?: string` — Placeholder; defaults to an example in the country's format
|
|
3635
|
+
- `flags?: boolean = true` — Show flag emoji
|
|
3636
|
+
- `fieldBg?: string` — Overrides the auto-detected background behind the outlined label
|
|
3637
|
+
- `locale?: string` — BCP-47 language for country names; defaults to the app's locale
|
|
3638
|
+
|
|
3639
|
+
Events:
|
|
3640
|
+
- `update:modelValue(string | null)` — Emitted with the number in E.164, or null when empty — powers v-model
|
|
3641
|
+
- `update:country(string)` — Emitted with the ISO code when the country changes — powers v-model:country
|
|
3642
|
+
- `update:valid(boolean)` — Emitted when the number becomes (in)valid for its country — powers v-model:valid
|
|
3643
|
+
|
|
3644
|
+
Slots:
|
|
3645
|
+
- `#flag { iso2: string; }` — Replaces the flag emoji (on the button and in the list), e.g. with an image set that also shows on Windows, which has no flag emoji; receives `iso2`
|
|
3646
|
+
|
|
3647
|
+
Exposed (template ref):
|
|
3648
|
+
- `focus: (options?: FocusOptions | undefined) => void | undefined`
|
|
3649
|
+
- `valid: boolean` — Whether the number fits its country's length
|
|
3650
|
+
|
|
3478
3651
|
### MPinInput
|
|
3479
3652
|
|
|
3480
3653
|
One box per character for OTP/PIN/verification codes. Typing advances to the next box, backspace on an empty box goes back, and pasting a full code fills every box at once.
|
|
@@ -4319,7 +4492,7 @@ Props:
|
|
|
4319
4492
|
- `noResultsText?: string` — Text shown when options is empty — defaults to the current locale's string
|
|
4320
4493
|
|
|
4321
4494
|
Events:
|
|
4322
|
-
- `update:modelValue(unknown)` — Emitted with the selected option's value.
|
|
4495
|
+
- `update:modelValue(unknown)` — Emitted with the selected option's value (`null` when the clear button empties it).
|
|
4323
4496
|
|
|
4324
4497
|
```ts
|
|
4325
4498
|
export interface SelectOption {
|
|
@@ -4708,7 +4881,7 @@ Secondary text component with muted color by default — a thin wrapper around `
|
|
|
4708
4881
|
|
|
4709
4882
|
Props:
|
|
4710
4883
|
- `size?: "small" | "medium" | "large" = "large"` — Subtitle size (maps to body-large/medium/small)
|
|
4711
|
-
- `color?: "error" | "primary" | "secondary" | "tertiary" | "on-surface
|
|
4884
|
+
- `color?: "error" | "primary" | "secondary" | "tertiary" | "on-surface" | "on-surface-variant" | "inherit" = "on-surface-variant"` — Text color
|
|
4712
4885
|
- `align?: "right" | "left" | "center"` — Text alignment
|
|
4713
4886
|
- `truncate?: boolean` — Truncate text with ellipsis on overflow
|
|
4714
4887
|
|
|
@@ -4909,7 +5082,7 @@ Renders any of the 15 Material 3 typography variants, with an auto-selected sema
|
|
|
4909
5082
|
Props:
|
|
4910
5083
|
- `variant?: TextVariant = "body-medium"` — Typography variant from the Material 3 type scale
|
|
4911
5084
|
- `tag?: string` — HTML tag to render (auto-selected based on variant — h1/h2/h3 for display/headline, p for title/body, span for label)
|
|
4912
|
-
- `color?: "error" | "primary" | "secondary" | "tertiary" | "on-surface
|
|
5085
|
+
- `color?: "error" | "primary" | "secondary" | "tertiary" | "on-surface" | "on-surface-variant" | "inherit" = "inherit"` — Text color
|
|
4913
5086
|
- `align?: "right" | "left" | "center" = "left"` — Text alignment
|
|
4914
5087
|
- `truncate?: boolean` — Truncate text with ellipsis on overflow
|
|
4915
5088
|
- `lines?: 1 | 2 | 3 | 4 | 5 | 6` — Clamp text to a specific number of lines
|
|
@@ -5117,7 +5290,7 @@ Semantic heading component in three sizes — a thin wrapper around `MText` at m
|
|
|
5117
5290
|
|
|
5118
5291
|
Props:
|
|
5119
5292
|
- `size?: "small" | "medium" | "large" = "large"` — Title size (maps to headline-large/medium/small)
|
|
5120
|
-
- `color?: "error" | "primary" | "secondary" | "tertiary" | "on-surface
|
|
5293
|
+
- `color?: "error" | "primary" | "secondary" | "tertiary" | "on-surface" | "on-surface-variant" | "inherit" = "inherit"` — Text color
|
|
5121
5294
|
- `align?: "right" | "left" | "center"` — Text alignment
|
|
5122
5295
|
- `truncate?: boolean` — Truncate text with ellipsis on overflow
|
|
5123
5296
|
|
|
@@ -5365,6 +5538,33 @@ export interface TreeTableRow {
|
|
|
5365
5538
|
}
|
|
5366
5539
|
```
|
|
5367
5540
|
|
|
5541
|
+
### MTypewriter
|
|
5542
|
+
|
|
5543
|
+
MTypewriter — text that types itself out and, with several phrases, erases and types the next in a loop, behind a blinking caret. Only the end that differs is erased ("faster" → "prettier" keeps nothing, "build faster apps" → "build prettier apps" erases back to "build "). Works by grapheme, so emoji and accents count as one character. Starts when it scrolls into view; with reduced motion the phrases swap whole. Screen readers get every phrase once, not each keystroke.
|
|
5544
|
+
|
|
5545
|
+
Props:
|
|
5546
|
+
- `text: string | string[]` — A phrase, or phrases typed one after another
|
|
5547
|
+
- `typeSpeed?: number = 70` — Milliseconds per character typed
|
|
5548
|
+
- `deleteSpeed?: number = 35` — Milliseconds per character erased
|
|
5549
|
+
- `pause?: number = 1600` — Milliseconds a typed phrase stays before it's erased
|
|
5550
|
+
- `startDelay?: number = 300` — Milliseconds before the first character
|
|
5551
|
+
- `loop?: boolean = true` — Start over after the last phrase; off stops on it
|
|
5552
|
+
- `smartBackspace?: boolean = true` — Erase only the end that differs from the next phrase
|
|
5553
|
+
- `humanize?: boolean = true` — Vary each keystroke's delay a little, like a person typing
|
|
5554
|
+
- `cursor?: boolean = true` — Show the caret
|
|
5555
|
+
- `startOnVisible?: boolean = true` — Wait until it's on screen to start
|
|
5556
|
+
- `tag?: string = "span"` — Element rendered
|
|
5557
|
+
|
|
5558
|
+
Events:
|
|
5559
|
+
- `done()` — Emitted when the last phrase is typed and `loop` is off
|
|
5560
|
+
- `typed(index: number)` — Emitted with the phrase's index when a phrase is fully typed
|
|
5561
|
+
|
|
5562
|
+
Slots:
|
|
5563
|
+
- `#cursor` — Replaces the caret
|
|
5564
|
+
|
|
5565
|
+
Exposed (template ref):
|
|
5566
|
+
- `restart: () => void`
|
|
5567
|
+
|
|
5368
5568
|
### MVideoPlayer
|
|
5369
5569
|
|
|
5370
5570
|
Import from `@m3ui-vue/m3ui-vue/media`.
|
|
@@ -6716,6 +6916,46 @@ Whether an `MM/YY` expiry is well formed and not in the past (a card is valid th
|
|
|
6716
6916
|
isValidExpiry(expiry: string, now: Date = new Date()): boolean
|
|
6717
6917
|
```
|
|
6718
6918
|
|
|
6919
|
+
### formatPhone
|
|
6920
|
+
|
|
6921
|
+
A stored E.164 number for display: `+54 11 2345-6789`; the input back when it isn't one
|
|
6922
|
+
|
|
6923
|
+
```ts
|
|
6924
|
+
formatPhone(e164: string, prefer?: string): string
|
|
6925
|
+
```
|
|
6926
|
+
|
|
6927
|
+
### isValidPhone
|
|
6928
|
+
|
|
6929
|
+
Whether an E.164 number is a plausible full number for its country
|
|
6930
|
+
|
|
6931
|
+
```ts
|
|
6932
|
+
isValidPhone(e164: string, prefer?: string): boolean
|
|
6933
|
+
```
|
|
6934
|
+
|
|
6935
|
+
### parsePhone
|
|
6936
|
+
|
|
6937
|
+
Splits an international number (`+541123456789`, `00 54 11...`, `+54 9 11 2345-6789`) into its country and national digits. Where a calling code is shared (+1), `prefer` wins if it has it, else the first listed (US).
|
|
6938
|
+
|
|
6939
|
+
```ts
|
|
6940
|
+
parsePhone(value: string, prefer?: string): ParsedPhone | null
|
|
6941
|
+
```
|
|
6942
|
+
|
|
6943
|
+
### phoneCountries
|
|
6944
|
+
|
|
6945
|
+
Every country, in the data's order
|
|
6946
|
+
|
|
6947
|
+
```ts
|
|
6948
|
+
phoneCountries(): PhoneCountry[]
|
|
6949
|
+
```
|
|
6950
|
+
|
|
6951
|
+
### flagEmoji
|
|
6952
|
+
|
|
6953
|
+
The flag emoji of an ISO 3166-1 alpha-2 code (regional indicator letters)
|
|
6954
|
+
|
|
6955
|
+
```ts
|
|
6956
|
+
flagEmoji(iso2: string): string
|
|
6957
|
+
```
|
|
6958
|
+
|
|
6719
6959
|
### amortize
|
|
6720
6960
|
|
|
6721
6961
|
Builds the payment schedule of a loan. Amounts are rounded to cents per payment and the last payment absorbs the rounding, so the balance ends at exactly 0.
|
|
@@ -8284,6 +8524,24 @@ export interface M3Locale {
|
|
|
8284
8524
|
ok: string
|
|
8285
8525
|
dateToggleInput: string
|
|
8286
8526
|
dateToggleCalendar: string
|
|
8527
|
+
/** The date pickers' month/year button: opens the year grid */
|
|
8528
|
+
dateSwitchToYear: string
|
|
8529
|
+
/** The same button while the year grid is open: back to the days */
|
|
8530
|
+
dateSwitchToDay: string
|
|
8531
|
+
/** Calendar heatmap legend, low end */
|
|
8532
|
+
heatmapLess: string
|
|
8533
|
+
/** Calendar heatmap legend, high end */
|
|
8534
|
+
heatmapMore: string
|
|
8535
|
+
/** Meter group: what's left of max */
|
|
8536
|
+
meterRemaining: string
|
|
8537
|
+
/** Meter group header; {used} and {max} are replaced */
|
|
8538
|
+
meterUsedOf: string
|
|
8539
|
+
/** Phone input: the country selector */
|
|
8540
|
+
phoneCountry: string
|
|
8541
|
+
/** Phone input: the country search field */
|
|
8542
|
+
phoneSearchCountry: string
|
|
8543
|
+
/** Phone input: the number doesn't fit its country's length */
|
|
8544
|
+
phoneInvalid: string
|
|
8287
8545
|
dateInputLabel: string
|
|
8288
8546
|
selectTime: string
|
|
8289
8547
|
timeHourSelection: string
|
|
@@ -9252,6 +9510,32 @@ export type FloorTool = 'select' | 'wall' | 'area' | 'polygon'
|
|
|
9252
9510
|
export type FloorItemKind = 'table' | 'area' | 'wall' | 'decor'
|
|
9253
9511
|
```
|
|
9254
9512
|
|
|
9513
|
+
```ts
|
|
9514
|
+
/*
|
|
9515
|
+
* Phone numbers for MPhoneInput, also exported to show a stored number elsewhere. Not libphonenumber: masks for the
|
|
9516
|
+
* countries most used and E.164 rules (a calling code, then at most 15 digits in all) for the rest. A number is
|
|
9517
|
+
* "valid" when its length fits one of its country's masks, or any 4 to 14 national digits for a country without
|
|
9518
|
+
* masks.
|
|
9519
|
+
*/
|
|
9520
|
+
|
|
9521
|
+
export interface PhoneCountry {
|
|
9522
|
+
/** ISO 3166-1 alpha-2 */
|
|
9523
|
+
iso2: string
|
|
9524
|
+
/** Calling code, without the + */
|
|
9525
|
+
dial: string
|
|
9526
|
+
/** National number masks, `#` a digit */
|
|
9527
|
+
masks: readonly string[]
|
|
9528
|
+
}
|
|
9529
|
+
```
|
|
9530
|
+
|
|
9531
|
+
```ts
|
|
9532
|
+
export interface ParsedPhone {
|
|
9533
|
+
country: PhoneCountry
|
|
9534
|
+
/** National significant number: digits only, no trunk 0 */
|
|
9535
|
+
national: string
|
|
9536
|
+
}
|
|
9537
|
+
```
|
|
9538
|
+
|
|
9255
9539
|
```ts
|
|
9256
9540
|
/** Card networks recognized by `detectCardBrand()` and `MCreditCardInput`. */
|
|
9257
9541
|
export type CardBrand =
|
|
@@ -9343,7 +9627,7 @@ export interface EmojiCategory {
|
|
|
9343
9627
|
`M3Locale` keys (pass a partial object to `createM3UI({ locale })`; presets from `@m3ui-vue/m3ui-vue/locales`:
|
|
9344
9628
|
`esLocale`, `frLocale`, `ptLocale`, `deLocale`, `jaLocale`, `zhLocale`, `koLocale`):
|
|
9345
9629
|
|
|
9346
|
-
lang, search, noResults, close, cancel, confirm, loading, menu, previous, next, today, more, selectedCount, recordCount, expand, collapse, clear, columns, exportCsv, noGroup, finish, dropText, selectText, maxSizePrefix, remove, selectDate, ok, dateToggleInput, dateToggleCalendar, dateInputLabel, selectTime, timeHourSelection, timeMinuteSelection, timePeriodToggle, timeToggleKeyboard, timeToggleDial, timeToggleScroll, sheetExpand, sheetCollapse, sheetDismiss, seekBar, seekBarValue, seekBarShowRemaining, seekBarShowDuration, selectRange, pickStart, pickEnd, previousMonth, nextMonth, selectColor, colorHue, colorSaturation, colorBrightness, colorAlpha, colorEyedropper, colorOriginal, colorFormat, colorRecent, colorPresets, dayView, weekView, allDay, emojiSearch, emojiNoResults, emojiRecent, emojiSkinTone, emojiSkinTones, emojiCategorySmileys, emojiCategoryGestures, emojiCategoryPeople, emojiCategoryAnimals, emojiCategoryNature, emojiCategoryFood, emojiCategoryActivities, emojiCategoryTravel, emojiCategoryObjects, emojiCategorySymbols, emojiCategoryFlags, available, selected, noItems, moveAllRight, moveRight, moveLeft, moveAllLeft, searchCommand, navigateHint, selectHint, openHint, closeHint, loadingMore, noMoreItems, bold, italic, underline, strikethrough, highlight, bulletList, orderedList, blockquote, code, alignLeft, alignCenter, alignRight, undo, redo, link, image, paragraph, heading1, heading2, heading3, insertLink, insertImage, imageUrlLabel, insert, jsonValid, jsonInvalid, jsonFormat, jsonMinify, jsonElements, jsonFields, resultSuccessTitle, resultSuccessDesc, resultErrorTitle, resultErrorDesc, resultWarningTitle, resultWarningDesc, resultInfoTitle, resultInfoDesc, result404Title, result404Desc, result403Title, result403Desc, result500Title, result500Desc, chatTyping, chatRecordingAudio, reorderHandle, reorderGrabbed, reorderMoved, reorderDropped, reorderCancelled, selectAll, clearSearch, kanbanMoved, windowMinimize, windowMaximize, windowRestore, paginationRange, paginationPage, previousPage, nextPage, carousel, carouselItem, sparklineSummary, sliderRangeStart, sliderRangeEnd, mapTitle, mapMarker, mapZoomIn, mapZoomOut, mapResetBearing, mapFindMyLocation, mapLocationNotAvailable, mapEnterFullscreen, mapExitFullscreen, mapToggleAttribution, mapFeedback, mapCtrlScroll, mapCmdScroll, mapTwoFingers, mapLayers, mapSearchLayers, mapNoLayers, mapShowLayer, mapHideLayer, mapOpacity, mapDownload, mapNoBaseLayer, mapHoverInfo, mapNoValue, mapMeasureDistance, mapMeasureArea, mapClearMeasurements, mapDeleteMeasurement, mapTotal, mapSearchPlaces, timelineShowMore, timelineShowLess, mediaPlayer, mediaPlay, mediaPause, mediaReplay, mediaSeekBack, mediaSeekForward, mediaSeconds, mediaMute, mediaUnmute, mediaVolume, mediaFullscreen, mediaExitFullscreen, mediaPictureInPicture, mediaSettings, mediaSpeed, mediaSpeedNormal, mediaSubtitles, mediaSubtitlesOff, mediaQuality, mediaQualityAuto, mediaLive, mediaError, mediaRepeat, mediaRepeatOne, mediaShuffle, pdfViewer, pdfThumbnails, pdfOutline, pdfPage, pdfZoom, pdfZoomIn, pdfZoomOut, pdfFitWidth, pdfFitPage, pdfSearch, pdfSearchPrevious, pdfSearchNext, pdfMatchCount, pdfNoMatches, pdfMore, pdfRotate, pdfDownload, pdfPrint, pdfFullscreen, pdfExitFullscreen, pdfPassword, pdfPasswordLabel, pdfWrongPassword, pdfOpen, pdfError, pdfLoading, pdfAnnotate, pdfSelect, pdfHighlight, pdfNote, pdfDraw, pdfEraser, pdfInkWidth, pdfColor, pdfUndo, pdfCopy, pdfDelete, pdfNotePlaceholder, pdfAddComment, flowCanvas, flowNode, flowEdge, flowZoomIn, flowZoomOut, flowFitView, flowLock, flowUnlock, flowUndo, flowRedo, flowMinimap, flowMoved, flowConnected, flowDeleted, flowDeleteEdge, flowDelete, ganttChart, ganttTask, ganttStart, ganttEnd, ganttDuration, ganttProgress, ganttDays, ganttHours, ganttMilestone, ganttQuarter, ganttToday, ganttZoomIn, ganttZoomOut, ganttExpandAll, ganttCollapseAll, ganttExpand, ganttCollapse, ganttUndo, ganttRedo, ganttScaleHour, ganttScaleDay, ganttScaleWeek, ganttScaleMonth, ganttScaleQuarter, ganttScaleYear, ganttMoved, ganttProgressSet, ganttLinked, ganttUnlink, ganttDeleted, ganttDelete, ganttReordered, ganttSlack, ganttCritical, ganttBaseline, ganttEmpty, ganttResize, timelineResource, timelineConflict, timelineMoved, timelineEmpty, cropArea, cropRotateLeft, cropRotateRight, cropFlip, cropReset, cropFree, drawCanvas, drawTools, drawMore, drawSelect, drawPan, drawPen, drawBrush, drawMarker, drawHighlighter, drawEraser, drawStrokeEraser, drawLine, drawArrow, drawRect, drawEllipse, drawText, drawFill, drawColor, floorPlan, floorSeats, floorRotate, floorTools, floorMove, floorDrawWall, floorDrawZone, floorAddTable, floorAddDecor, floorDuplicate, floorDelete, floorUndo, floorRedo, floorLabel, floorSeatsField, floorShape, floorRound, floorSquare, floorLong, floorAngle, floorFlip, floorZoomIn, floorZoomOut, floorZoomFit, floorOverlaps, floorSeatN, floorDrawShape, floorShapeHint, floorColor, floorThickness, floorWidth, floorHeight, floorMerge, floorSplit, floorNothingPicked, floorTablesPicked, floorTableN, floorZone, floorWall, floorDeleteCorner, floorFinishWall, floorCancel, floorDecorDoor, floorDecorWindow, floorDecorPlant, floorDecorColumn, floorDecorRestroom, floorDecorKitchen, floorDecorRegister, floorDecorStairs, floorDecorLabel, drawCustomColor, drawSize, drawUndo, drawRedo, drawDelete, drawLayers, drawLayer, drawLayerName, drawAddLayer, drawDeleteLayer, drawShowLayer, drawHideLayer, drawLockLayer, drawUnlockLayer, drawLayerUp, drawLayerDown, compareBefore, compareAfter, compareSlider, cardNumber, cardExpiry, cardCvc, cardName, cardInvalidNumber, cardInvalidExpiry, cardInvalidCvc, keypadDelete, keypadClear, keypadChange, keypadRemaining, seatStage, seatAvailable, seatSelected, seatOccupied, seatLabel, receiptSubtotal, receiptTotal, receiptPaid, receiptChange, configRequired, configOptional, configChooseUpTo, configChooseAtLeast, configChooseExactly, configUnavailable, configQuantity, configIncrease, configDecrease, availNight, availNights, availMinNights, availCheckIn, availCheckOut, availSelectCheckIn, availSelectCheckOut, availUnavailable, chartOpen, chartHigh, chartLow, chartClose, chartVolume, bookPrice, bookSize, bookTotal, bookSpread, mortgagePrice, mortgageDown, mortgageRate, mortgageTerm, mortgageYears, mortgageLoan, mortgageMonthly, mortgageFirstPayment, mortgageLastPayment, mortgagePrincipal, mortgageInterest, mortgageTotal, mortgageSchedule, mortgageYear, mortgageBalance, bodyFront, bodyBack, bodyRight, bodyLeft, bodyRear, bodyHead, bodyNeck, bodyChest, bodyAbdomen, bodyPelvis, bodyShoulder, bodyUpperArm, bodyForearm, bodyHand, bodyThigh, bodyKnee, bodyLeg, bodyFoot, bodyUpperBack, bodyLowerBack, bodyGlute, bodyCalf, odontoTooth, odontoUpper, odontoLower, odontoMesial, odontoDistal, odontoBuccal, odontoLingual, odontoOcclusal, odontoCaries, odontoFilling, odontoSealant, odontoCrown, odontoRootCanal, odontoImplant, odontoMissing, odontoExtraction, odontoEraser, vitalsNormal, vitalsHigh, vitalsLow, vitalsNoData, quizCheck, quizNext, quizFinish, quizCorrect, quizIncorrect, quizCorrectAnswer, quizQuestionOf, quizScore, quizPassed, quizFailed, quizRetry, quizTrue, quizFalse, quizSelectAll, quizOrderHint, quizMoveUp, quizMoveDown, quizTypeAnswer, quizTimeLeft, quizReview, certTitle, certPresentedTo, certDate, certId
|
|
9630
|
+
lang, search, noResults, close, cancel, confirm, loading, menu, previous, next, today, more, selectedCount, recordCount, expand, collapse, clear, columns, exportCsv, noGroup, finish, dropText, selectText, maxSizePrefix, remove, selectDate, ok, dateToggleInput, dateToggleCalendar, dateSwitchToYear, dateSwitchToDay, heatmapLess, heatmapMore, meterRemaining, meterUsedOf, phoneCountry, phoneSearchCountry, phoneInvalid, dateInputLabel, selectTime, timeHourSelection, timeMinuteSelection, timePeriodToggle, timeToggleKeyboard, timeToggleDial, timeToggleScroll, sheetExpand, sheetCollapse, sheetDismiss, seekBar, seekBarValue, seekBarShowRemaining, seekBarShowDuration, selectRange, pickStart, pickEnd, previousMonth, nextMonth, selectColor, colorHue, colorSaturation, colorBrightness, colorAlpha, colorEyedropper, colorOriginal, colorFormat, colorRecent, colorPresets, dayView, weekView, allDay, emojiSearch, emojiNoResults, emojiRecent, emojiSkinTone, emojiSkinTones, emojiCategorySmileys, emojiCategoryGestures, emojiCategoryPeople, emojiCategoryAnimals, emojiCategoryNature, emojiCategoryFood, emojiCategoryActivities, emojiCategoryTravel, emojiCategoryObjects, emojiCategorySymbols, emojiCategoryFlags, available, selected, noItems, moveAllRight, moveRight, moveLeft, moveAllLeft, searchCommand, navigateHint, selectHint, openHint, closeHint, loadingMore, noMoreItems, bold, italic, underline, strikethrough, highlight, bulletList, orderedList, blockquote, code, alignLeft, alignCenter, alignRight, undo, redo, link, image, paragraph, heading1, heading2, heading3, insertLink, insertImage, imageUrlLabel, insert, jsonValid, jsonInvalid, jsonFormat, jsonMinify, jsonElements, jsonFields, resultSuccessTitle, resultSuccessDesc, resultErrorTitle, resultErrorDesc, resultWarningTitle, resultWarningDesc, resultInfoTitle, resultInfoDesc, result404Title, result404Desc, result403Title, result403Desc, result500Title, result500Desc, chatTyping, chatRecordingAudio, reorderHandle, reorderGrabbed, reorderMoved, reorderDropped, reorderCancelled, selectAll, clearSearch, kanbanMoved, windowMinimize, windowMaximize, windowRestore, paginationRange, paginationPage, previousPage, nextPage, carousel, carouselItem, sparklineSummary, sliderRangeStart, sliderRangeEnd, mapTitle, mapMarker, mapZoomIn, mapZoomOut, mapResetBearing, mapFindMyLocation, mapLocationNotAvailable, mapEnterFullscreen, mapExitFullscreen, mapToggleAttribution, mapFeedback, mapCtrlScroll, mapCmdScroll, mapTwoFingers, mapLayers, mapSearchLayers, mapNoLayers, mapShowLayer, mapHideLayer, mapOpacity, mapDownload, mapNoBaseLayer, mapHoverInfo, mapNoValue, mapMeasureDistance, mapMeasureArea, mapClearMeasurements, mapDeleteMeasurement, mapTotal, mapSearchPlaces, timelineShowMore, timelineShowLess, mediaPlayer, mediaPlay, mediaPause, mediaReplay, mediaSeekBack, mediaSeekForward, mediaSeconds, mediaMute, mediaUnmute, mediaVolume, mediaFullscreen, mediaExitFullscreen, mediaPictureInPicture, mediaSettings, mediaSpeed, mediaSpeedNormal, mediaSubtitles, mediaSubtitlesOff, mediaQuality, mediaQualityAuto, mediaLive, mediaError, mediaRepeat, mediaRepeatOne, mediaShuffle, pdfViewer, pdfThumbnails, pdfOutline, pdfPage, pdfZoom, pdfZoomIn, pdfZoomOut, pdfFitWidth, pdfFitPage, pdfSearch, pdfSearchPrevious, pdfSearchNext, pdfMatchCount, pdfNoMatches, pdfMore, pdfRotate, pdfDownload, pdfPrint, pdfFullscreen, pdfExitFullscreen, pdfPassword, pdfPasswordLabel, pdfWrongPassword, pdfOpen, pdfError, pdfLoading, pdfAnnotate, pdfSelect, pdfHighlight, pdfNote, pdfDraw, pdfEraser, pdfInkWidth, pdfColor, pdfUndo, pdfCopy, pdfDelete, pdfNotePlaceholder, pdfAddComment, flowCanvas, flowNode, flowEdge, flowZoomIn, flowZoomOut, flowFitView, flowLock, flowUnlock, flowUndo, flowRedo, flowMinimap, flowMoved, flowConnected, flowDeleted, flowDeleteEdge, flowDelete, ganttChart, ganttTask, ganttStart, ganttEnd, ganttDuration, ganttProgress, ganttDays, ganttHours, ganttMilestone, ganttQuarter, ganttToday, ganttZoomIn, ganttZoomOut, ganttExpandAll, ganttCollapseAll, ganttExpand, ganttCollapse, ganttUndo, ganttRedo, ganttScaleHour, ganttScaleDay, ganttScaleWeek, ganttScaleMonth, ganttScaleQuarter, ganttScaleYear, ganttMoved, ganttProgressSet, ganttLinked, ganttUnlink, ganttDeleted, ganttDelete, ganttReordered, ganttSlack, ganttCritical, ganttBaseline, ganttEmpty, ganttResize, timelineResource, timelineConflict, timelineMoved, timelineEmpty, cropArea, cropRotateLeft, cropRotateRight, cropFlip, cropReset, cropFree, drawCanvas, drawTools, drawMore, drawSelect, drawPan, drawPen, drawBrush, drawMarker, drawHighlighter, drawEraser, drawStrokeEraser, drawLine, drawArrow, drawRect, drawEllipse, drawText, drawFill, drawColor, floorPlan, floorSeats, floorRotate, floorTools, floorMove, floorDrawWall, floorDrawZone, floorAddTable, floorAddDecor, floorDuplicate, floorDelete, floorUndo, floorRedo, floorLabel, floorSeatsField, floorShape, floorRound, floorSquare, floorLong, floorAngle, floorFlip, floorZoomIn, floorZoomOut, floorZoomFit, floorOverlaps, floorSeatN, floorDrawShape, floorShapeHint, floorColor, floorThickness, floorWidth, floorHeight, floorMerge, floorSplit, floorNothingPicked, floorTablesPicked, floorTableN, floorZone, floorWall, floorDeleteCorner, floorFinishWall, floorCancel, floorDecorDoor, floorDecorWindow, floorDecorPlant, floorDecorColumn, floorDecorRestroom, floorDecorKitchen, floorDecorRegister, floorDecorStairs, floorDecorLabel, drawCustomColor, drawSize, drawUndo, drawRedo, drawDelete, drawLayers, drawLayer, drawLayerName, drawAddLayer, drawDeleteLayer, drawShowLayer, drawHideLayer, drawLockLayer, drawUnlockLayer, drawLayerUp, drawLayerDown, compareBefore, compareAfter, compareSlider, cardNumber, cardExpiry, cardCvc, cardName, cardInvalidNumber, cardInvalidExpiry, cardInvalidCvc, keypadDelete, keypadClear, keypadChange, keypadRemaining, seatStage, seatAvailable, seatSelected, seatOccupied, seatLabel, receiptSubtotal, receiptTotal, receiptPaid, receiptChange, configRequired, configOptional, configChooseUpTo, configChooseAtLeast, configChooseExactly, configUnavailable, configQuantity, configIncrease, configDecrease, availNight, availNights, availMinNights, availCheckIn, availCheckOut, availSelectCheckIn, availSelectCheckOut, availUnavailable, chartOpen, chartHigh, chartLow, chartClose, chartVolume, bookPrice, bookSize, bookTotal, bookSpread, mortgagePrice, mortgageDown, mortgageRate, mortgageTerm, mortgageYears, mortgageLoan, mortgageMonthly, mortgageFirstPayment, mortgageLastPayment, mortgagePrincipal, mortgageInterest, mortgageTotal, mortgageSchedule, mortgageYear, mortgageBalance, bodyFront, bodyBack, bodyRight, bodyLeft, bodyRear, bodyHead, bodyNeck, bodyChest, bodyAbdomen, bodyPelvis, bodyShoulder, bodyUpperArm, bodyForearm, bodyHand, bodyThigh, bodyKnee, bodyLeg, bodyFoot, bodyUpperBack, bodyLowerBack, bodyGlute, bodyCalf, odontoTooth, odontoUpper, odontoLower, odontoMesial, odontoDistal, odontoBuccal, odontoLingual, odontoOcclusal, odontoCaries, odontoFilling, odontoSealant, odontoCrown, odontoRootCanal, odontoImplant, odontoMissing, odontoExtraction, odontoEraser, vitalsNormal, vitalsHigh, vitalsLow, vitalsNoData, quizCheck, quizNext, quizFinish, quizCorrect, quizIncorrect, quizCorrectAnswer, quizQuestionOf, quizScore, quizPassed, quizFailed, quizRetry, quizTrue, quizFalse, quizSelectAll, quizOrderHint, quizMoveUp, quizMoveDown, quizTypeAnswer, quizTimeLeft, quizReview, certTitle, certPresentedTo, certDate, certId
|
|
9347
9631
|
|
|
9348
9632
|
## Theme tokens
|
|
9349
9633
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { p as e } from "./MIconButton-DoNotQ9v.js";
|
|
2
2
|
import { t } from "./MIcon-Bxh9j135.js";
|
|
3
|
-
import { t as n } from "./MSpinner-
|
|
3
|
+
import { t as n } from "./MSpinner-DKGNN64_.js";
|
|
4
4
|
import { Fragment as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, defineComponent as c, normalizeClass as l, normalizeStyle as u, openBlock as d, renderSlot as f, resolveDynamicComponent as p, unref as m, withCtx as h, withDirectives as g } from "vue";
|
|
5
5
|
//#region src/components/MButton.vue?vue&type=script&setup=true&lang.ts
|
|
6
6
|
var _ = "relative inline-flex items-center justify-center font-medium whitespace-nowrap overflow-hidden transition-[box-shadow,background-color,color] duration-150 select-none cursor-pointer disabled:cursor-not-allowed disabled:shadow-none disabled:text-on-surface/38 before:content-[''] before:pointer-events-none before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:duration-150 enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]", v = /* @__PURE__ */ c({
|
|
@@ -169,4 +169,4 @@ var _ = "relative inline-flex items-center justify-center font-medium whitespace
|
|
|
169
169
|
//#endregion
|
|
170
170
|
export { v as t };
|
|
171
171
|
|
|
172
|
-
//# sourceMappingURL=MButton-
|
|
172
|
+
//# sourceMappingURL=MButton-D7M324r9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MButton-DQMTIlaV.js","names":[],"sources":["../src/components/MButton.vue","../src/components/MButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * The standard M3 button — five variants, five expressive size tiers, and either color.\n *\n * @slot default The button's label.\n */\nimport { computed } from 'vue'\nimport MSpinner from './MSpinner.vue'\nimport MIcon from './MIcon.vue'\nimport { vRipple } from '../directives/vRipple'\n\nconst NAMED_COLORS = ['primary', 'error'] as const\ntype NamedColor = (typeof NAMED_COLORS)[number]\n\nconst props = withDefaults(\n defineProps<{\n /** Visual style of the button */\n variant?: 'filled' | 'tonal' | 'outlined' | 'text' | 'elevated'\n /**\n * Named semantic color ('primary' | 'error') OR any CSS color string\n * ('red', '#e91e63', 'oklch(0.6 0.2 0)', …).\n * When a CSS color is passed, --color-primary is overridden for this button.\n */\n color?: string\n /** HTML button type */\n type?: 'button' | 'submit' | 'reset'\n /** Disables interaction */\n disabled?: boolean\n /** Shows a spinner and disables the button */\n loading?: boolean\n /** Material Symbol icon name shown next to the label */\n icon?: string\n /** Draw the icon filled (Material Symbols' FILL axis), e.g. a starred star or a play icon */\n iconFilled?: boolean\n /** Which side of the label the icon renders on */\n // Which side of the label `icon` renders on. Real M3 buttons support both via\n // `ButtonDefaults.contentPaddingFor(hasStartIcon/hasEndIcon)` — padding ends up identical\n // either way at every tier, so this only changes render order, not spacing.\n iconPos?: 'leading' | 'trailing'\n /**\n * M3's 5-tier expressive button sizing (xs: 32px, sm: 40px, md: 56px, lg: 96px, xl: 136px) — lg/xl are\n * meant for hero-style prominent buttons, not everyday UI\n */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /**\n * Button shape — rounded (pill, always) or squared (corner radius scales with size: 12px xs/sm, 16px md,\n * 28px lg/xl)\n */\n shape?: 'rounded' | 'squared'\n /** Vue Router destination — renders as RouterLink instead of button */\n to?: string | Record<string, any>\n /** Any CSS color for the press ripple; defaults to the button's content color */\n rippleColor?: string\n /**\n * Label and icon color, over what the variant and `color` give: an M3 role (`on-surface` for a neutral text\n * button, `on-primary-container`…) or any CSS color (`#000` on a white filled button). Disabled buttons keep\n * their own\n */\n contentColor?: string\n }>(),\n {\n variant: 'filled',\n color: 'primary',\n type: 'button',\n disabled: false,\n loading: false,\n iconPos: 'leading',\n size: 'sm',\n shape: 'rounded',\n },\n)\n\nconst tag = computed(() => props.to ? 'RouterLink' : 'button')\n\nconst isCustomColor = computed(\n () => !!props.color && !(NAMED_COLORS as readonly string[]).includes(props.color),\n)\n\nconst customStyle = computed(() => {\n if (!isCustomColor.value) return undefined\n return {\n '--color-primary': props.color,\n '--color-on-primary': '#ffffff',\n '--color-primary-container': props.color + '33',\n '--color-on-primary-container': props.color,\n }\n})\n\nconst isError = computed(() => props.color === 'error')\n\n// Color-role names (`on-surface`, `secondary-container`…) read the theme's token; anything else is a CSS color\nconst ROLE = /^(on-)?(primary|secondary|tertiary|error|surface|surface-variant|inverse-surface|inverse-primary)(-container|-variant)?$/\nconst style = computed(() => {\n const c = props.contentColor\n if (!c || props.disabled || props.loading) return customStyle.value\n return { ...customStyle.value, color: ROLE.test(c) ? `var(--color-${c})` : c }\n})\n\nconst base =\n 'relative inline-flex items-center justify-center font-medium ' +\n 'whitespace-nowrap overflow-hidden transition-[box-shadow,background-color,color] duration-150 select-none cursor-pointer ' +\n 'disabled:cursor-not-allowed disabled:shadow-none disabled:text-on-surface/38 ' +\n \"before:content-[''] before:pointer-events-none before:absolute before:inset-0 \" +\n 'before:bg-current before:opacity-0 before:transition-opacity before:duration-150 ' +\n 'enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]'\n\n// M3 disabled tokens: container at 10% on-surface opacity (DisabledContainerOpacity, same\n// across Filled/Tonal/Elevated), content/label always at 38% on-surface (handled in `base`\n// above, applies to every variant including text/elevated which have no container). The\n// outlined border uses the SAME color role as its enabled border (OutlineVariant, not\n// on-surface) just dimmed to that 10% too — see `variantClasses`' outlined case below for\n// why the enabled color is also outline-variant, not outline.\nconst disabledContainerClasses = computed(() => {\n switch (props.variant) {\n case 'filled':\n case 'tonal':\n case 'elevated':\n return 'disabled:bg-on-surface/10'\n case 'outlined':\n return isError.value ? 'disabled:border-error/10' : 'disabled:border-outline-variant/10'\n default:\n return ''\n }\n})\n\n/*\n * M3's newer 5-tier \"expressive\" button sizing (Button{XSmall,Small,Medium,Large,\n * XLarge}Tokens.kt + Button.kt's size-variant overloads — @ExperimentalMaterial3ExpressiveApi\n * in Compose, but this `size` prop is deliberately implementing exactly that system, same\n * as MFabMenu/MLoadingIndicator already do for other Expressive-only components). Content\n * padding is IDENTICAL whether or not an icon is present at every tier in the default\n * (non \"precision pointer\") mode — e.g. `IconMediumLeadingPadding = MediumLeadingPadding`\n * verbatim in the real source — so there's deliberately no separate icon-vs-no-icon padding\n * split here, unlike the old version of this file which had one (and got the values wrong\n * in both directions). `gap` between icon and label also varies by tier (IconLabelSpace),\n * not a flat value for every size.\n */\nconst sizeMap = {\n xs: { h: 'h-8', text: 'text-label-large', icon: 20, spinner: 16, gap: 'gap-1', px: 'px-3', pxText: 'px-2', squareRadius: 'rounded-md' },\n sm: { h: 'h-10', text: 'text-label-large', icon: 20, spinner: 16, gap: 'gap-2', px: 'px-4', pxText: 'px-3', squareRadius: 'rounded-md' },\n md: { h: 'h-14', text: 'text-title-medium', icon: 24, spinner: 18, gap: 'gap-2', px: 'px-6', pxText: 'px-3', squareRadius: 'rounded-lg' },\n lg: { h: 'h-24', text: 'text-headline-small', icon: 32, spinner: 26, gap: 'gap-3', px: 'px-12', pxText: 'px-4', squareRadius: 'rounded-xl' },\n xl: { h: 'h-[136px]', text: 'text-headline-large', icon: 40, spinner: 34, gap: 'gap-4', px: 'px-16', pxText: 'px-4', squareRadius: 'rounded-xl' },\n}\n\nconst s = computed(() => sizeMap[props.size] ?? sizeMap.sm)\nconst sizeClasses = computed(() => `${s.value.h} ${s.value.text} ${s.value.gap}`)\nconst iconSize = computed(() => s.value.icon)\nconst spinnerSize = computed(() => s.value.spinner)\n\nconst px = computed(() => props.variant === 'text' ? s.value.pxText : s.value.px)\n\n// Squared shape radius scales with size, matching each tier's own ContainerShapeSquare\n// token (ButtonXSmallTokens/ButtonSmallTokens use CornerMedium=12px, ButtonMediumTokens\n// CornerLarge=16px, ButtonLargeTokens/ButtonXLargeTokens CornerExtraLarge=28px) — the\n// pill (ContainerShapeRound) is CornerFull at every tier, so that half doesn't vary.\nconst shapeClass = computed(() => props.shape === 'squared' ? s.value.squareRadius : 'rounded-full')\n\nconst variantClasses = computed(() => {\n const err = isError.value\n switch (props.variant) {\n case 'filled':\n return err\n ? 'bg-error text-on-error enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n : 'bg-primary text-on-primary enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n case 'tonal':\n return err\n ? 'bg-error-container text-on-error-container enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n : 'bg-secondary-container text-on-secondary-container enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n case 'elevated':\n return err\n ? 'bg-surface-container-low text-error shadow-elevation-1 enabled:hover:shadow-elevation-2'\n : 'bg-surface-container-low text-primary shadow-elevation-1 enabled:hover:shadow-elevation-2'\n case 'outlined':\n // OutlinedButtonTokens.OutlineColor = ColorSchemeKeyTokens.OutlineVariant, not Outline\n return err\n ? 'border border-error text-error'\n : 'border border-outline-variant text-primary'\n case 'text':\n return err\n ? 'text-error'\n : 'text-primary'\n default:\n return ''\n }\n})\n</script>\n\n<template>\n <component\n :is=\"tag\"\n :to=\"to || undefined\"\n :type=\"to ? undefined : type\"\n :disabled=\"disabled || loading\"\n :class=\"[base, shapeClass, sizeClasses, px, variantClasses, disabledContainerClasses]\"\n :style=\"style\"\n v-ripple=\"{ disabled: disabled || loading, color: rippleColor }\"\n >\n <template v-if=\"iconPos === 'leading'\">\n <MSpinner v-if=\"loading\" :size=\"spinnerSize\" />\n <MIcon v-else-if=\"icon\" :name=\"icon\" :size=\"iconSize\" :filled=\"iconFilled\" />\n </template>\n <slot />\n <template v-if=\"iconPos === 'trailing'\">\n <MSpinner v-if=\"loading\" :size=\"spinnerSize\" />\n <MIcon v-else-if=\"icon\" :name=\"icon\" :size=\"iconSize\" :filled=\"iconFilled\" />\n </template>\n </component>\n</template>\n","<script setup lang=\"ts\">\n/**\n * The standard M3 button — five variants, five expressive size tiers, and either color.\n *\n * @slot default The button's label.\n */\nimport { computed } from 'vue'\nimport MSpinner from './MSpinner.vue'\nimport MIcon from './MIcon.vue'\nimport { vRipple } from '../directives/vRipple'\n\nconst NAMED_COLORS = ['primary', 'error'] as const\ntype NamedColor = (typeof NAMED_COLORS)[number]\n\nconst props = withDefaults(\n defineProps<{\n /** Visual style of the button */\n variant?: 'filled' | 'tonal' | 'outlined' | 'text' | 'elevated'\n /**\n * Named semantic color ('primary' | 'error') OR any CSS color string\n * ('red', '#e91e63', 'oklch(0.6 0.2 0)', …).\n * When a CSS color is passed, --color-primary is overridden for this button.\n */\n color?: string\n /** HTML button type */\n type?: 'button' | 'submit' | 'reset'\n /** Disables interaction */\n disabled?: boolean\n /** Shows a spinner and disables the button */\n loading?: boolean\n /** Material Symbol icon name shown next to the label */\n icon?: string\n /** Draw the icon filled (Material Symbols' FILL axis), e.g. a starred star or a play icon */\n iconFilled?: boolean\n /** Which side of the label the icon renders on */\n // Which side of the label `icon` renders on. Real M3 buttons support both via\n // `ButtonDefaults.contentPaddingFor(hasStartIcon/hasEndIcon)` — padding ends up identical\n // either way at every tier, so this only changes render order, not spacing.\n iconPos?: 'leading' | 'trailing'\n /**\n * M3's 5-tier expressive button sizing (xs: 32px, sm: 40px, md: 56px, lg: 96px, xl: 136px) — lg/xl are\n * meant for hero-style prominent buttons, not everyday UI\n */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /**\n * Button shape — rounded (pill, always) or squared (corner radius scales with size: 12px xs/sm, 16px md,\n * 28px lg/xl)\n */\n shape?: 'rounded' | 'squared'\n /** Vue Router destination — renders as RouterLink instead of button */\n to?: string | Record<string, any>\n /** Any CSS color for the press ripple; defaults to the button's content color */\n rippleColor?: string\n /**\n * Label and icon color, over what the variant and `color` give: an M3 role (`on-surface` for a neutral text\n * button, `on-primary-container`…) or any CSS color (`#000` on a white filled button). Disabled buttons keep\n * their own\n */\n contentColor?: string\n }>(),\n {\n variant: 'filled',\n color: 'primary',\n type: 'button',\n disabled: false,\n loading: false,\n iconPos: 'leading',\n size: 'sm',\n shape: 'rounded',\n },\n)\n\nconst tag = computed(() => props.to ? 'RouterLink' : 'button')\n\nconst isCustomColor = computed(\n () => !!props.color && !(NAMED_COLORS as readonly string[]).includes(props.color),\n)\n\nconst customStyle = computed(() => {\n if (!isCustomColor.value) return undefined\n return {\n '--color-primary': props.color,\n '--color-on-primary': '#ffffff',\n '--color-primary-container': props.color + '33',\n '--color-on-primary-container': props.color,\n }\n})\n\nconst isError = computed(() => props.color === 'error')\n\n// Color-role names (`on-surface`, `secondary-container`…) read the theme's token; anything else is a CSS color\nconst ROLE = /^(on-)?(primary|secondary|tertiary|error|surface|surface-variant|inverse-surface|inverse-primary)(-container|-variant)?$/\nconst style = computed(() => {\n const c = props.contentColor\n if (!c || props.disabled || props.loading) return customStyle.value\n return { ...customStyle.value, color: ROLE.test(c) ? `var(--color-${c})` : c }\n})\n\nconst base =\n 'relative inline-flex items-center justify-center font-medium ' +\n 'whitespace-nowrap overflow-hidden transition-[box-shadow,background-color,color] duration-150 select-none cursor-pointer ' +\n 'disabled:cursor-not-allowed disabled:shadow-none disabled:text-on-surface/38 ' +\n \"before:content-[''] before:pointer-events-none before:absolute before:inset-0 \" +\n 'before:bg-current before:opacity-0 before:transition-opacity before:duration-150 ' +\n 'enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]'\n\n// M3 disabled tokens: container at 10% on-surface opacity (DisabledContainerOpacity, same\n// across Filled/Tonal/Elevated), content/label always at 38% on-surface (handled in `base`\n// above, applies to every variant including text/elevated which have no container). The\n// outlined border uses the SAME color role as its enabled border (OutlineVariant, not\n// on-surface) just dimmed to that 10% too — see `variantClasses`' outlined case below for\n// why the enabled color is also outline-variant, not outline.\nconst disabledContainerClasses = computed(() => {\n switch (props.variant) {\n case 'filled':\n case 'tonal':\n case 'elevated':\n return 'disabled:bg-on-surface/10'\n case 'outlined':\n return isError.value ? 'disabled:border-error/10' : 'disabled:border-outline-variant/10'\n default:\n return ''\n }\n})\n\n/*\n * M3's newer 5-tier \"expressive\" button sizing (Button{XSmall,Small,Medium,Large,\n * XLarge}Tokens.kt + Button.kt's size-variant overloads — @ExperimentalMaterial3ExpressiveApi\n * in Compose, but this `size` prop is deliberately implementing exactly that system, same\n * as MFabMenu/MLoadingIndicator already do for other Expressive-only components). Content\n * padding is IDENTICAL whether or not an icon is present at every tier in the default\n * (non \"precision pointer\") mode — e.g. `IconMediumLeadingPadding = MediumLeadingPadding`\n * verbatim in the real source — so there's deliberately no separate icon-vs-no-icon padding\n * split here, unlike the old version of this file which had one (and got the values wrong\n * in both directions). `gap` between icon and label also varies by tier (IconLabelSpace),\n * not a flat value for every size.\n */\nconst sizeMap = {\n xs: { h: 'h-8', text: 'text-label-large', icon: 20, spinner: 16, gap: 'gap-1', px: 'px-3', pxText: 'px-2', squareRadius: 'rounded-md' },\n sm: { h: 'h-10', text: 'text-label-large', icon: 20, spinner: 16, gap: 'gap-2', px: 'px-4', pxText: 'px-3', squareRadius: 'rounded-md' },\n md: { h: 'h-14', text: 'text-title-medium', icon: 24, spinner: 18, gap: 'gap-2', px: 'px-6', pxText: 'px-3', squareRadius: 'rounded-lg' },\n lg: { h: 'h-24', text: 'text-headline-small', icon: 32, spinner: 26, gap: 'gap-3', px: 'px-12', pxText: 'px-4', squareRadius: 'rounded-xl' },\n xl: { h: 'h-[136px]', text: 'text-headline-large', icon: 40, spinner: 34, gap: 'gap-4', px: 'px-16', pxText: 'px-4', squareRadius: 'rounded-xl' },\n}\n\nconst s = computed(() => sizeMap[props.size] ?? sizeMap.sm)\nconst sizeClasses = computed(() => `${s.value.h} ${s.value.text} ${s.value.gap}`)\nconst iconSize = computed(() => s.value.icon)\nconst spinnerSize = computed(() => s.value.spinner)\n\nconst px = computed(() => props.variant === 'text' ? s.value.pxText : s.value.px)\n\n// Squared shape radius scales with size, matching each tier's own ContainerShapeSquare\n// token (ButtonXSmallTokens/ButtonSmallTokens use CornerMedium=12px, ButtonMediumTokens\n// CornerLarge=16px, ButtonLargeTokens/ButtonXLargeTokens CornerExtraLarge=28px) — the\n// pill (ContainerShapeRound) is CornerFull at every tier, so that half doesn't vary.\nconst shapeClass = computed(() => props.shape === 'squared' ? s.value.squareRadius : 'rounded-full')\n\nconst variantClasses = computed(() => {\n const err = isError.value\n switch (props.variant) {\n case 'filled':\n return err\n ? 'bg-error text-on-error enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n : 'bg-primary text-on-primary enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n case 'tonal':\n return err\n ? 'bg-error-container text-on-error-container enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n : 'bg-secondary-container text-on-secondary-container enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n case 'elevated':\n return err\n ? 'bg-surface-container-low text-error shadow-elevation-1 enabled:hover:shadow-elevation-2'\n : 'bg-surface-container-low text-primary shadow-elevation-1 enabled:hover:shadow-elevation-2'\n case 'outlined':\n // OutlinedButtonTokens.OutlineColor = ColorSchemeKeyTokens.OutlineVariant, not Outline\n return err\n ? 'border border-error text-error'\n : 'border border-outline-variant text-primary'\n case 'text':\n return err\n ? 'text-error'\n : 'text-primary'\n default:\n return ''\n }\n})\n</script>\n\n<template>\n <component\n :is=\"tag\"\n :to=\"to || undefined\"\n :type=\"to ? undefined : type\"\n :disabled=\"disabled || loading\"\n :class=\"[base, shapeClass, sizeClasses, px, variantClasses, disabledContainerClasses]\"\n :style=\"style\"\n v-ripple=\"{ disabled: disabled || loading, color: rippleColor }\"\n >\n <template v-if=\"iconPos === 'leading'\">\n <MSpinner v-if=\"loading\" :size=\"spinnerSize\" />\n <MIcon v-else-if=\"icon\" :name=\"icon\" :size=\"iconSize\" :filled=\"iconFilled\" />\n </template>\n <slot />\n <template v-if=\"iconPos === 'trailing'\">\n <MSpinner v-if=\"loading\" :size=\"spinnerSize\" />\n <MIcon v-else-if=\"icon\" :name=\"icon\" :size=\"iconSize\" :filled=\"iconFilled\" />\n </template>\n </component>\n</template>\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"MButton-D7M324r9.js","names":[],"sources":["../src/components/MButton.vue","../src/components/MButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * The standard M3 button — five variants, five expressive size tiers, and either color.\n *\n * @slot default The button's label.\n */\nimport { computed } from 'vue'\nimport MSpinner from './MSpinner.vue'\nimport MIcon from './MIcon.vue'\nimport { vRipple } from '../directives/vRipple'\n\nconst NAMED_COLORS = ['primary', 'error'] as const\ntype NamedColor = (typeof NAMED_COLORS)[number]\n\nconst props = withDefaults(\n defineProps<{\n /** Visual style of the button */\n variant?: 'filled' | 'tonal' | 'outlined' | 'text' | 'elevated'\n /**\n * Named semantic color ('primary' | 'error') OR any CSS color string\n * ('red', '#e91e63', 'oklch(0.6 0.2 0)', …).\n * When a CSS color is passed, --color-primary is overridden for this button.\n */\n color?: string\n /** HTML button type */\n type?: 'button' | 'submit' | 'reset'\n /** Disables interaction */\n disabled?: boolean\n /** Shows a spinner and disables the button */\n loading?: boolean\n /** Material Symbol icon name shown next to the label */\n icon?: string\n /** Draw the icon filled (Material Symbols' FILL axis), e.g. a starred star or a play icon */\n iconFilled?: boolean\n /** Which side of the label the icon renders on */\n // Which side of the label `icon` renders on. Real M3 buttons support both via\n // `ButtonDefaults.contentPaddingFor(hasStartIcon/hasEndIcon)` — padding ends up identical\n // either way at every tier, so this only changes render order, not spacing.\n iconPos?: 'leading' | 'trailing'\n /**\n * M3's 5-tier expressive button sizing (xs: 32px, sm: 40px, md: 56px, lg: 96px, xl: 136px) — lg/xl are\n * meant for hero-style prominent buttons, not everyday UI\n */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /**\n * Button shape — rounded (pill, always) or squared (corner radius scales with size: 12px xs/sm, 16px md,\n * 28px lg/xl)\n */\n shape?: 'rounded' | 'squared'\n /** Vue Router destination — renders as RouterLink instead of button */\n to?: string | Record<string, any>\n /** Any CSS color for the press ripple; defaults to the button's content color */\n rippleColor?: string\n /**\n * Label and icon color, over what the variant and `color` give: an M3 role (`on-surface` for a neutral text\n * button, `on-primary-container`…) or any CSS color (`#000` on a white filled button). Disabled buttons keep\n * their own\n */\n contentColor?: string\n }>(),\n {\n variant: 'filled',\n color: 'primary',\n type: 'button',\n disabled: false,\n loading: false,\n iconPos: 'leading',\n size: 'sm',\n shape: 'rounded',\n },\n)\n\nconst tag = computed(() => props.to ? 'RouterLink' : 'button')\n\nconst isCustomColor = computed(\n () => !!props.color && !(NAMED_COLORS as readonly string[]).includes(props.color),\n)\n\nconst customStyle = computed(() => {\n if (!isCustomColor.value) return undefined\n return {\n '--color-primary': props.color,\n '--color-on-primary': '#ffffff',\n '--color-primary-container': props.color + '33',\n '--color-on-primary-container': props.color,\n }\n})\n\nconst isError = computed(() => props.color === 'error')\n\n// Color-role names (`on-surface`, `secondary-container`…) read the theme's token; anything else is a CSS color\nconst ROLE = /^(on-)?(primary|secondary|tertiary|error|surface|surface-variant|inverse-surface|inverse-primary)(-container|-variant)?$/\nconst style = computed(() => {\n const c = props.contentColor\n if (!c || props.disabled || props.loading) return customStyle.value\n return { ...customStyle.value, color: ROLE.test(c) ? `var(--color-${c})` : c }\n})\n\nconst base =\n 'relative inline-flex items-center justify-center font-medium ' +\n 'whitespace-nowrap overflow-hidden transition-[box-shadow,background-color,color] duration-150 select-none cursor-pointer ' +\n 'disabled:cursor-not-allowed disabled:shadow-none disabled:text-on-surface/38 ' +\n \"before:content-[''] before:pointer-events-none before:absolute before:inset-0 \" +\n 'before:bg-current before:opacity-0 before:transition-opacity before:duration-150 ' +\n 'enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]'\n\n// M3 disabled tokens: container at 10% on-surface opacity (DisabledContainerOpacity, same\n// across Filled/Tonal/Elevated), content/label always at 38% on-surface (handled in `base`\n// above, applies to every variant including text/elevated which have no container). The\n// outlined border uses the SAME color role as its enabled border (OutlineVariant, not\n// on-surface) just dimmed to that 10% too — see `variantClasses`' outlined case below for\n// why the enabled color is also outline-variant, not outline.\nconst disabledContainerClasses = computed(() => {\n switch (props.variant) {\n case 'filled':\n case 'tonal':\n case 'elevated':\n return 'disabled:bg-on-surface/10'\n case 'outlined':\n return isError.value ? 'disabled:border-error/10' : 'disabled:border-outline-variant/10'\n default:\n return ''\n }\n})\n\n/*\n * M3's newer 5-tier \"expressive\" button sizing (Button{XSmall,Small,Medium,Large,\n * XLarge}Tokens.kt + Button.kt's size-variant overloads — @ExperimentalMaterial3ExpressiveApi\n * in Compose, but this `size` prop is deliberately implementing exactly that system, same\n * as MFabMenu/MLoadingIndicator already do for other Expressive-only components). Content\n * padding is IDENTICAL whether or not an icon is present at every tier in the default\n * (non \"precision pointer\") mode — e.g. `IconMediumLeadingPadding = MediumLeadingPadding`\n * verbatim in the real source — so there's deliberately no separate icon-vs-no-icon padding\n * split here, unlike the old version of this file which had one (and got the values wrong\n * in both directions). `gap` between icon and label also varies by tier (IconLabelSpace),\n * not a flat value for every size.\n */\nconst sizeMap = {\n xs: { h: 'h-8', text: 'text-label-large', icon: 20, spinner: 16, gap: 'gap-1', px: 'px-3', pxText: 'px-2', squareRadius: 'rounded-md' },\n sm: { h: 'h-10', text: 'text-label-large', icon: 20, spinner: 16, gap: 'gap-2', px: 'px-4', pxText: 'px-3', squareRadius: 'rounded-md' },\n md: { h: 'h-14', text: 'text-title-medium', icon: 24, spinner: 18, gap: 'gap-2', px: 'px-6', pxText: 'px-3', squareRadius: 'rounded-lg' },\n lg: { h: 'h-24', text: 'text-headline-small', icon: 32, spinner: 26, gap: 'gap-3', px: 'px-12', pxText: 'px-4', squareRadius: 'rounded-xl' },\n xl: { h: 'h-[136px]', text: 'text-headline-large', icon: 40, spinner: 34, gap: 'gap-4', px: 'px-16', pxText: 'px-4', squareRadius: 'rounded-xl' },\n}\n\nconst s = computed(() => sizeMap[props.size] ?? sizeMap.sm)\nconst sizeClasses = computed(() => `${s.value.h} ${s.value.text} ${s.value.gap}`)\nconst iconSize = computed(() => s.value.icon)\nconst spinnerSize = computed(() => s.value.spinner)\n\nconst px = computed(() => props.variant === 'text' ? s.value.pxText : s.value.px)\n\n// Squared shape radius scales with size, matching each tier's own ContainerShapeSquare\n// token (ButtonXSmallTokens/ButtonSmallTokens use CornerMedium=12px, ButtonMediumTokens\n// CornerLarge=16px, ButtonLargeTokens/ButtonXLargeTokens CornerExtraLarge=28px) — the\n// pill (ContainerShapeRound) is CornerFull at every tier, so that half doesn't vary.\nconst shapeClass = computed(() => props.shape === 'squared' ? s.value.squareRadius : 'rounded-full')\n\nconst variantClasses = computed(() => {\n const err = isError.value\n switch (props.variant) {\n case 'filled':\n return err\n ? 'bg-error text-on-error enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n : 'bg-primary text-on-primary enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n case 'tonal':\n return err\n ? 'bg-error-container text-on-error-container enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n : 'bg-secondary-container text-on-secondary-container enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n case 'elevated':\n return err\n ? 'bg-surface-container-low text-error shadow-elevation-1 enabled:hover:shadow-elevation-2'\n : 'bg-surface-container-low text-primary shadow-elevation-1 enabled:hover:shadow-elevation-2'\n case 'outlined':\n // OutlinedButtonTokens.OutlineColor = ColorSchemeKeyTokens.OutlineVariant, not Outline\n return err\n ? 'border border-error text-error'\n : 'border border-outline-variant text-primary'\n case 'text':\n return err\n ? 'text-error'\n : 'text-primary'\n default:\n return ''\n }\n})\n</script>\n\n<template>\n <component\n :is=\"tag\"\n :to=\"to || undefined\"\n :type=\"to ? undefined : type\"\n :disabled=\"disabled || loading\"\n :class=\"[base, shapeClass, sizeClasses, px, variantClasses, disabledContainerClasses]\"\n :style=\"style\"\n v-ripple=\"{ disabled: disabled || loading, color: rippleColor }\"\n >\n <template v-if=\"iconPos === 'leading'\">\n <MSpinner v-if=\"loading\" :size=\"spinnerSize\" />\n <MIcon v-else-if=\"icon\" :name=\"icon\" :size=\"iconSize\" :filled=\"iconFilled\" />\n </template>\n <slot />\n <template v-if=\"iconPos === 'trailing'\">\n <MSpinner v-if=\"loading\" :size=\"spinnerSize\" />\n <MIcon v-else-if=\"icon\" :name=\"icon\" :size=\"iconSize\" :filled=\"iconFilled\" />\n </template>\n </component>\n</template>\n","<script setup lang=\"ts\">\n/**\n * The standard M3 button — five variants, five expressive size tiers, and either color.\n *\n * @slot default The button's label.\n */\nimport { computed } from 'vue'\nimport MSpinner from './MSpinner.vue'\nimport MIcon from './MIcon.vue'\nimport { vRipple } from '../directives/vRipple'\n\nconst NAMED_COLORS = ['primary', 'error'] as const\ntype NamedColor = (typeof NAMED_COLORS)[number]\n\nconst props = withDefaults(\n defineProps<{\n /** Visual style of the button */\n variant?: 'filled' | 'tonal' | 'outlined' | 'text' | 'elevated'\n /**\n * Named semantic color ('primary' | 'error') OR any CSS color string\n * ('red', '#e91e63', 'oklch(0.6 0.2 0)', …).\n * When a CSS color is passed, --color-primary is overridden for this button.\n */\n color?: string\n /** HTML button type */\n type?: 'button' | 'submit' | 'reset'\n /** Disables interaction */\n disabled?: boolean\n /** Shows a spinner and disables the button */\n loading?: boolean\n /** Material Symbol icon name shown next to the label */\n icon?: string\n /** Draw the icon filled (Material Symbols' FILL axis), e.g. a starred star or a play icon */\n iconFilled?: boolean\n /** Which side of the label the icon renders on */\n // Which side of the label `icon` renders on. Real M3 buttons support both via\n // `ButtonDefaults.contentPaddingFor(hasStartIcon/hasEndIcon)` — padding ends up identical\n // either way at every tier, so this only changes render order, not spacing.\n iconPos?: 'leading' | 'trailing'\n /**\n * M3's 5-tier expressive button sizing (xs: 32px, sm: 40px, md: 56px, lg: 96px, xl: 136px) — lg/xl are\n * meant for hero-style prominent buttons, not everyday UI\n */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /**\n * Button shape — rounded (pill, always) or squared (corner radius scales with size: 12px xs/sm, 16px md,\n * 28px lg/xl)\n */\n shape?: 'rounded' | 'squared'\n /** Vue Router destination — renders as RouterLink instead of button */\n to?: string | Record<string, any>\n /** Any CSS color for the press ripple; defaults to the button's content color */\n rippleColor?: string\n /**\n * Label and icon color, over what the variant and `color` give: an M3 role (`on-surface` for a neutral text\n * button, `on-primary-container`…) or any CSS color (`#000` on a white filled button). Disabled buttons keep\n * their own\n */\n contentColor?: string\n }>(),\n {\n variant: 'filled',\n color: 'primary',\n type: 'button',\n disabled: false,\n loading: false,\n iconPos: 'leading',\n size: 'sm',\n shape: 'rounded',\n },\n)\n\nconst tag = computed(() => props.to ? 'RouterLink' : 'button')\n\nconst isCustomColor = computed(\n () => !!props.color && !(NAMED_COLORS as readonly string[]).includes(props.color),\n)\n\nconst customStyle = computed(() => {\n if (!isCustomColor.value) return undefined\n return {\n '--color-primary': props.color,\n '--color-on-primary': '#ffffff',\n '--color-primary-container': props.color + '33',\n '--color-on-primary-container': props.color,\n }\n})\n\nconst isError = computed(() => props.color === 'error')\n\n// Color-role names (`on-surface`, `secondary-container`…) read the theme's token; anything else is a CSS color\nconst ROLE = /^(on-)?(primary|secondary|tertiary|error|surface|surface-variant|inverse-surface|inverse-primary)(-container|-variant)?$/\nconst style = computed(() => {\n const c = props.contentColor\n if (!c || props.disabled || props.loading) return customStyle.value\n return { ...customStyle.value, color: ROLE.test(c) ? `var(--color-${c})` : c }\n})\n\nconst base =\n 'relative inline-flex items-center justify-center font-medium ' +\n 'whitespace-nowrap overflow-hidden transition-[box-shadow,background-color,color] duration-150 select-none cursor-pointer ' +\n 'disabled:cursor-not-allowed disabled:shadow-none disabled:text-on-surface/38 ' +\n \"before:content-[''] before:pointer-events-none before:absolute before:inset-0 \" +\n 'before:bg-current before:opacity-0 before:transition-opacity before:duration-150 ' +\n 'enabled:hover:before:opacity-[0.08] enabled:active:before:opacity-[0.12]'\n\n// M3 disabled tokens: container at 10% on-surface opacity (DisabledContainerOpacity, same\n// across Filled/Tonal/Elevated), content/label always at 38% on-surface (handled in `base`\n// above, applies to every variant including text/elevated which have no container). The\n// outlined border uses the SAME color role as its enabled border (OutlineVariant, not\n// on-surface) just dimmed to that 10% too — see `variantClasses`' outlined case below for\n// why the enabled color is also outline-variant, not outline.\nconst disabledContainerClasses = computed(() => {\n switch (props.variant) {\n case 'filled':\n case 'tonal':\n case 'elevated':\n return 'disabled:bg-on-surface/10'\n case 'outlined':\n return isError.value ? 'disabled:border-error/10' : 'disabled:border-outline-variant/10'\n default:\n return ''\n }\n})\n\n/*\n * M3's newer 5-tier \"expressive\" button sizing (Button{XSmall,Small,Medium,Large,\n * XLarge}Tokens.kt + Button.kt's size-variant overloads — @ExperimentalMaterial3ExpressiveApi\n * in Compose, but this `size` prop is deliberately implementing exactly that system, same\n * as MFabMenu/MLoadingIndicator already do for other Expressive-only components). Content\n * padding is IDENTICAL whether or not an icon is present at every tier in the default\n * (non \"precision pointer\") mode — e.g. `IconMediumLeadingPadding = MediumLeadingPadding`\n * verbatim in the real source — so there's deliberately no separate icon-vs-no-icon padding\n * split here, unlike the old version of this file which had one (and got the values wrong\n * in both directions). `gap` between icon and label also varies by tier (IconLabelSpace),\n * not a flat value for every size.\n */\nconst sizeMap = {\n xs: { h: 'h-8', text: 'text-label-large', icon: 20, spinner: 16, gap: 'gap-1', px: 'px-3', pxText: 'px-2', squareRadius: 'rounded-md' },\n sm: { h: 'h-10', text: 'text-label-large', icon: 20, spinner: 16, gap: 'gap-2', px: 'px-4', pxText: 'px-3', squareRadius: 'rounded-md' },\n md: { h: 'h-14', text: 'text-title-medium', icon: 24, spinner: 18, gap: 'gap-2', px: 'px-6', pxText: 'px-3', squareRadius: 'rounded-lg' },\n lg: { h: 'h-24', text: 'text-headline-small', icon: 32, spinner: 26, gap: 'gap-3', px: 'px-12', pxText: 'px-4', squareRadius: 'rounded-xl' },\n xl: { h: 'h-[136px]', text: 'text-headline-large', icon: 40, spinner: 34, gap: 'gap-4', px: 'px-16', pxText: 'px-4', squareRadius: 'rounded-xl' },\n}\n\nconst s = computed(() => sizeMap[props.size] ?? sizeMap.sm)\nconst sizeClasses = computed(() => `${s.value.h} ${s.value.text} ${s.value.gap}`)\nconst iconSize = computed(() => s.value.icon)\nconst spinnerSize = computed(() => s.value.spinner)\n\nconst px = computed(() => props.variant === 'text' ? s.value.pxText : s.value.px)\n\n// Squared shape radius scales with size, matching each tier's own ContainerShapeSquare\n// token (ButtonXSmallTokens/ButtonSmallTokens use CornerMedium=12px, ButtonMediumTokens\n// CornerLarge=16px, ButtonLargeTokens/ButtonXLargeTokens CornerExtraLarge=28px) — the\n// pill (ContainerShapeRound) is CornerFull at every tier, so that half doesn't vary.\nconst shapeClass = computed(() => props.shape === 'squared' ? s.value.squareRadius : 'rounded-full')\n\nconst variantClasses = computed(() => {\n const err = isError.value\n switch (props.variant) {\n case 'filled':\n return err\n ? 'bg-error text-on-error enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n : 'bg-primary text-on-primary enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n case 'tonal':\n return err\n ? 'bg-error-container text-on-error-container enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n : 'bg-secondary-container text-on-secondary-container enabled:hover:shadow-elevation-1 enabled:active:shadow-none'\n case 'elevated':\n return err\n ? 'bg-surface-container-low text-error shadow-elevation-1 enabled:hover:shadow-elevation-2'\n : 'bg-surface-container-low text-primary shadow-elevation-1 enabled:hover:shadow-elevation-2'\n case 'outlined':\n // OutlinedButtonTokens.OutlineColor = ColorSchemeKeyTokens.OutlineVariant, not Outline\n return err\n ? 'border border-error text-error'\n : 'border border-outline-variant text-primary'\n case 'text':\n return err\n ? 'text-error'\n : 'text-primary'\n default:\n return ''\n }\n})\n</script>\n\n<template>\n <component\n :is=\"tag\"\n :to=\"to || undefined\"\n :type=\"to ? undefined : type\"\n :disabled=\"disabled || loading\"\n :class=\"[base, shapeClass, sizeClasses, px, variantClasses, disabledContainerClasses]\"\n :style=\"style\"\n v-ripple=\"{ disabled: disabled || loading, color: rippleColor }\"\n >\n <template v-if=\"iconPos === 'leading'\">\n <MSpinner v-if=\"loading\" :size=\"spinnerSize\" />\n <MIcon v-else-if=\"icon\" :name=\"icon\" :size=\"iconSize\" :filled=\"iconFilled\" />\n </template>\n <slot />\n <template v-if=\"iconPos === 'trailing'\">\n <MSpinner v-if=\"loading\" :size=\"spinnerSize\" />\n <MIcon v-else-if=\"icon\" :name=\"icon\" :size=\"iconSize\" :filled=\"iconFilled\" />\n </template>\n </component>\n</template>\n"],"mappings":"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"}
|