@getcortexlabs/mavis-core 0.1.0-alpha.3 → 0.1.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +2 -2
  2. package/dist/accordion.d.ts +17 -0
  3. package/dist/accordion.d.ts.map +1 -0
  4. package/dist/accordion.js +42 -0
  5. package/dist/accordion.js.map +1 -0
  6. package/dist/alert.d.ts +21 -0
  7. package/dist/alert.d.ts.map +1 -0
  8. package/dist/alert.js +13 -0
  9. package/dist/alert.js.map +1 -0
  10. package/dist/avatar.d.ts +10 -0
  11. package/dist/avatar.d.ts.map +1 -0
  12. package/dist/avatar.js +11 -0
  13. package/dist/avatar.js.map +1 -0
  14. package/dist/badge.d.ts +7 -0
  15. package/dist/badge.d.ts.map +1 -0
  16. package/dist/badge.js +11 -0
  17. package/dist/badge.js.map +1 -0
  18. package/dist/chip.d.ts +9 -0
  19. package/dist/chip.d.ts.map +1 -0
  20. package/dist/chip.js +16 -0
  21. package/dist/chip.js.map +1 -0
  22. package/dist/choice.d.ts +15 -0
  23. package/dist/choice.d.ts.map +1 -0
  24. package/dist/choice.js +27 -0
  25. package/dist/choice.js.map +1 -0
  26. package/dist/dialog.d.ts +4 -0
  27. package/dist/dialog.d.ts.map +1 -0
  28. package/dist/dialog.js +20 -0
  29. package/dist/dialog.js.map +1 -0
  30. package/dist/empty-state.d.ts +2 -0
  31. package/dist/empty-state.d.ts.map +1 -0
  32. package/dist/empty-state.js +5 -0
  33. package/dist/empty-state.js.map +1 -0
  34. package/dist/experimental.d.ts +122 -0
  35. package/dist/experimental.d.ts.map +1 -0
  36. package/dist/experimental.js +372 -0
  37. package/dist/experimental.js.map +1 -0
  38. package/dist/index.d.ts +29 -4
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +16 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/input.d.ts +10 -0
  43. package/dist/input.d.ts.map +1 -1
  44. package/dist/input.js +12 -0
  45. package/dist/input.js.map +1 -1
  46. package/dist/list-item.d.ts +3 -0
  47. package/dist/list-item.d.ts.map +1 -0
  48. package/dist/list-item.js +7 -0
  49. package/dist/list-item.js.map +1 -0
  50. package/dist/motion.d.ts +33 -0
  51. package/dist/motion.d.ts.map +1 -0
  52. package/dist/motion.js +21 -0
  53. package/dist/motion.js.map +1 -0
  54. package/dist/progress.d.ts +19 -0
  55. package/dist/progress.d.ts.map +1 -0
  56. package/dist/progress.js +19 -0
  57. package/dist/progress.js.map +1 -0
  58. package/dist/segmented.d.ts +11 -0
  59. package/dist/segmented.d.ts.map +1 -0
  60. package/dist/segmented.js +30 -0
  61. package/dist/segmented.js.map +1 -0
  62. package/dist/sheet.d.ts +8 -1
  63. package/dist/sheet.d.ts.map +1 -1
  64. package/dist/sheet.js +4 -3
  65. package/dist/sheet.js.map +1 -1
  66. package/dist/tabs.d.ts +11 -0
  67. package/dist/tabs.d.ts.map +1 -0
  68. package/dist/tabs.js +28 -0
  69. package/dist/tabs.js.map +1 -0
  70. package/dist/theme/themes.d.ts.map +1 -1
  71. package/dist/theme/themes.js +84 -11
  72. package/dist/theme/themes.js.map +1 -1
  73. package/dist/theme/types.d.ts +52 -1
  74. package/dist/theme/types.d.ts.map +1 -1
  75. package/dist/theme/typography.d.ts +10 -0
  76. package/dist/theme/typography.d.ts.map +1 -0
  77. package/dist/theme/typography.js +90 -0
  78. package/dist/theme/typography.js.map +1 -0
  79. package/dist/toast.d.ts +43 -0
  80. package/dist/toast.d.ts.map +1 -0
  81. package/dist/toast.js +228 -0
  82. package/dist/toast.js.map +1 -0
  83. package/dist/vue/button-content.d.ts +10 -0
  84. package/dist/vue/button-content.d.ts.map +1 -0
  85. package/dist/vue/button-content.js +54 -0
  86. package/dist/vue/button-content.js.map +1 -0
  87. package/dist/vue/cached-activity.d.ts +3 -0
  88. package/dist/vue/cached-activity.d.ts.map +1 -0
  89. package/dist/vue/cached-activity.js +13 -0
  90. package/dist/vue/cached-activity.js.map +1 -0
  91. package/dist/vue/dialog.d.ts +21 -0
  92. package/dist/vue/dialog.d.ts.map +1 -0
  93. package/dist/vue/dialog.js +58 -0
  94. package/dist/vue/dialog.js.map +1 -0
  95. package/dist/vue/global-components.d.ts +95 -2
  96. package/dist/vue/global-components.d.ts.map +1 -1
  97. package/dist/vue/index.d.ts +17 -1
  98. package/dist/vue/index.d.ts.map +1 -1
  99. package/dist/vue/index.js +15 -1
  100. package/dist/vue/index.js.map +1 -1
  101. package/dist/vue/inline-content.d.ts +52 -0
  102. package/dist/vue/inline-content.d.ts.map +1 -0
  103. package/dist/vue/inline-content.js +64 -0
  104. package/dist/vue/inline-content.js.map +1 -0
  105. package/dist/vue/props.d.ts +1983 -497
  106. package/dist/vue/props.d.ts.map +1 -1
  107. package/dist/vue/props.js +245 -2
  108. package/dist/vue/props.js.map +1 -1
  109. package/dist/vue/theme-provider.d.ts +58 -0
  110. package/dist/vue/theme-provider.d.ts.map +1 -0
  111. package/dist/vue/theme-provider.js +69 -0
  112. package/dist/vue/theme-provider.js.map +1 -0
  113. package/dist/vue/theme.d.ts +962 -12
  114. package/dist/vue/theme.d.ts.map +1 -1
  115. package/dist/vue/theme.js +17 -7
  116. package/dist/vue/theme.js.map +1 -1
  117. package/dist/vue/toast.d.ts +29 -0
  118. package/dist/vue/toast.d.ts.map +1 -0
  119. package/dist/vue/toast.js +79 -0
  120. package/dist/vue/toast.js.map +1 -0
  121. package/package.json +5 -1
  122. package/src/accordion.ts +66 -0
  123. package/src/alert.ts +16 -0
  124. package/src/avatar.ts +11 -0
  125. package/src/badge.ts +11 -0
  126. package/src/chip.ts +20 -0
  127. package/src/choice.ts +41 -0
  128. package/src/dialog.ts +20 -0
  129. package/src/empty-state.ts +4 -0
  130. package/src/experimental.ts +501 -0
  131. package/src/index.ts +47 -3
  132. package/src/input.ts +22 -0
  133. package/src/list-item.ts +5 -0
  134. package/src/motion.ts +22 -0
  135. package/src/progress.ts +22 -0
  136. package/src/segmented.ts +39 -0
  137. package/src/sheet.ts +6 -3
  138. package/src/tabs.ts +35 -0
  139. package/src/theme/themes.ts +88 -11
  140. package/src/theme/types.ts +42 -1
  141. package/src/theme/typography.ts +84 -0
  142. package/src/toast.ts +249 -0
  143. package/src/vue/button-content.ts +60 -0
  144. package/src/vue/cached-activity.ts +13 -0
  145. package/src/vue/dialog.ts +63 -0
  146. package/src/vue/global-components.ts +77 -2
  147. package/src/vue/index.ts +33 -0
  148. package/src/vue/inline-content.ts +71 -0
  149. package/src/vue/props.ts +263 -4
  150. package/src/vue/theme-provider.ts +74 -0
  151. package/src/vue/theme.ts +17 -6
  152. package/src/vue/toast.ts +99 -0
@@ -0,0 +1,63 @@
1
+ import { nextTick, ref, watch } from '@vue/runtime-core'
2
+ import type { DialogCloseReason } from '../dialog.js'
3
+
4
+ type State = Readonly<{ open: boolean; loading: boolean; dismissible: boolean }>
5
+ type Events = {
6
+ (event: 'update:open', value: boolean): void
7
+ (event: 'close', reason: DialogCloseReason): void
8
+ (event: 'confirm'): void
9
+ }
10
+
11
+ /** @internal Controlled decisions share the same event semantics in both renderers. */
12
+ export function useDialogState(props: State, emit: Events) {
13
+ const presented = ref(props.open)
14
+ const visible = ref(props.open)
15
+ let requested: DialogCloseReason | undefined
16
+ let confirming = false
17
+ let generation = 0
18
+ watch(
19
+ () => props.open,
20
+ (open) => {
21
+ generation++
22
+ confirming = false
23
+ visible.value = open
24
+ if (open) presented.value = true
25
+ else if (presented.value && !requested) emit('close', 'program')
26
+ requested = undefined
27
+ },
28
+ { flush: 'sync' },
29
+ )
30
+ function request(reason: DialogCloseReason) {
31
+ const navigation = reason === 'navigation'
32
+ if (!props.open || requested || (!navigation && props.loading)) return
33
+ if (!navigation && reason !== 'cancel' && !props.dismissible) return
34
+ requested = reason
35
+ const current = generation
36
+ if (navigation) {
37
+ visible.value = false
38
+ presented.value = false
39
+ }
40
+ emit('update:open', false)
41
+ emit('close', reason)
42
+ // The parent can reject a request. Do not leave the still-open dialog inert afterward.
43
+ void nextTick(() => {
44
+ if (current === generation) requested = undefined
45
+ })
46
+ }
47
+ return {
48
+ presented,
49
+ visible,
50
+ request,
51
+ confirm() {
52
+ if (!props.open || props.loading || confirming || requested) return
53
+ confirming = true
54
+ emit('confirm')
55
+ void nextTick(() => {
56
+ confirming = false
57
+ })
58
+ },
59
+ left() {
60
+ if (!visible.value) presented.value = false
61
+ },
62
+ }
63
+ }
@@ -1,15 +1,24 @@
1
+ import type { AccordionPanelProps } from '../accordion.js'
2
+ import type { TabPanelProps } from '../tabs.js'
3
+ import type { ChoiceValue } from '../choice.js'
1
4
  import type { DefineComponent } from '@vue/runtime-core'
2
5
  import type { ComponentProps } from './props.js'
6
+ import type { DialogCloseReason } from '../dialog.js'
3
7
  import type { SheetCloseReason } from '../sheet.js'
8
+ import type { InputHandle } from '../input.js'
4
9
 
5
10
  type Action = { onClick?: () => void }
6
11
  type Model = { 'onUpdate:modelValue'?: (value: number) => void }
7
12
  type InputEvents = {
13
+ onAction?: () => void
8
14
  'onUpdate:modelValue'?: (value: string) => void
9
15
  onFocus?: () => void
10
16
  onBlur?: () => void
11
17
  onSubmit?: (value: string) => void
12
18
  }
19
+
20
+ /** Additional input attributes supplied by a renderer, without DOM dependencies in core. */
21
+ export interface InputPlatformAttributes {}
13
22
  type SheetEvents = {
14
23
  'onUpdate:open'?: (value: boolean) => void
15
24
  onClose?: (reason: SheetCloseReason) => void
@@ -19,15 +28,81 @@ type SheetEvents = {
19
28
  /** Template props come from the same declarations used by both renderers. */
20
29
  declare module '@vue/runtime-core' {
21
30
  export interface GlobalComponents {
31
+ MThemeProvider: typeof import('./theme-provider.js').MThemeProvider
32
+ MSpan: typeof import('./inline-content.js').MSpan
22
33
  MScreen: DefineComponent<ComponentProps['MScreen']>
23
34
  MRow: DefineComponent<ComponentProps['MRow']>
24
35
  MColumn: DefineComponent<ComponentProps['MColumn']>
25
36
  MBox: DefineComponent<ComponentProps['MBox']>
26
37
  MCard: DefineComponent<ComponentProps['MCard'] & Action>
27
38
  MText: DefineComponent<ComponentProps['MText']>
28
- MButton: DefineComponent<ComponentProps['MButton'] & Action>
39
+ MButton: DefineComponent<ComponentProps['MButton'] & Action> & {
40
+ new (): {
41
+ $slots: { default?: () => unknown; leading?: () => unknown; trailing?: () => unknown }
42
+ }
43
+ }
29
44
  MSlider: DefineComponent<ComponentProps['MSlider'] & Model>
30
- MInput: DefineComponent<ComponentProps['MInput'] & InputEvents>
45
+ MSwitch: DefineComponent<
46
+ ComponentProps['MSwitch'] & { 'onUpdate:modelValue'?: (value: boolean) => void }
47
+ >
48
+ MCheckbox: DefineComponent<
49
+ ComponentProps['MCheckbox'] & {
50
+ 'onUpdate:modelValue'?: (value: boolean) => void
51
+ 'onUpdate:indeterminate'?: (value: boolean) => void
52
+ }
53
+ >
54
+ MRadioGroup: DefineComponent<
55
+ ComponentProps['MRadioGroup'] & { 'onUpdate:modelValue'?: (value: ChoiceValue) => void }
56
+ >
57
+ MInput: DefineComponent<
58
+ ComponentProps['MInput'] & InputEvents & InputPlatformAttributes,
59
+ InputHandle
60
+ >
61
+ MSelect: DefineComponent<
62
+ ComponentProps['MSelect'] & { 'onUpdate:modelValue'?: (value: ChoiceValue) => void }
63
+ >
64
+ MTabs: DefineComponent<
65
+ ComponentProps['MTabs'] & { 'onUpdate:modelValue'?: (value: ChoiceValue) => void }
66
+ > & {
67
+ new (): { $slots: { default?: (props: TabPanelProps) => unknown } }
68
+ }
69
+ MListItem: DefineComponent<ComponentProps['MListItem'] & Action> & {
70
+ new (): { $slots: { leading?: () => unknown; trailing?: () => unknown } }
71
+ }
72
+ MSeparator: DefineComponent<ComponentProps['MSeparator']>
73
+ MAvatar: DefineComponent<ComponentProps['MAvatar']>
74
+ MBadge: DefineComponent<ComponentProps['MBadge']>
75
+ MSkeleton: DefineComponent<ComponentProps['MSkeleton']>
76
+ MChip: DefineComponent<
77
+ ComponentProps['MChip'] & {
78
+ 'onUpdate:modelValue'?: (value: boolean) => void
79
+ onRemove?: () => void
80
+ }
81
+ >
82
+ MEmptyState: DefineComponent<ComponentProps['MEmptyState']> & {
83
+ new (): { $slots: { illustration?: () => unknown; actions?: () => unknown } }
84
+ }
85
+ MProgress: DefineComponent<ComponentProps['MProgress']>
86
+ MAccordion: DefineComponent<
87
+ ComponentProps['MAccordion'] & { 'onUpdate:modelValue'?: (value: ChoiceValue[]) => void }
88
+ > & {
89
+ new (): { $slots: { default?: (props: AccordionPanelProps) => unknown } }
90
+ }
91
+ MSegmentedControl: DefineComponent<
92
+ ComponentProps['MSegmentedControl'] & { 'onUpdate:modelValue'?: (value: ChoiceValue) => void }
93
+ >
94
+
95
+ MAlert: DefineComponent<ComponentProps['MAlert'] & { onClose?: () => void }> & {
96
+ new (): { $slots: { actions?: () => unknown } }
97
+ }
98
+ MToast: DefineComponent<ComponentProps['MToast']>
99
+ MDialog: DefineComponent<
100
+ ComponentProps['MDialog'] & {
101
+ 'onUpdate:open'?: (value: boolean) => void
102
+ onConfirm?: () => void
103
+ onClose?: (reason: DialogCloseReason) => void
104
+ }
105
+ >
31
106
  MIcon: DefineComponent<ComponentProps['MIcon']>
32
107
  MReveal: DefineComponent<ComponentProps['MReveal']>
33
108
  MSheet: DefineComponent<ComponentProps['MSheet'] & SheetEvents>
package/src/vue/index.ts CHANGED
@@ -9,6 +9,7 @@ export type {
9
9
  export { layoutDirection, useDefaultShrink } from './layout-context.js'
10
10
  export { textContent } from './text-content.js'
11
11
  export type {} from './global-components.js'
12
+ export type { InputPlatformAttributes } from './global-components.js'
12
13
  export {
13
14
  boxProps,
14
15
  spacingProp,
@@ -19,6 +20,14 @@ export {
19
20
  textProps,
20
21
  sliderProps,
21
22
  inputProps,
23
+ switchProps,
24
+ checkboxProps,
25
+ checkboxEmits,
26
+ radioGroupProps,
27
+ radioGroupEmits,
28
+ selectProps,
29
+ selectEmits,
30
+ switchEmits,
22
31
  inputEmits,
23
32
  iconProps,
24
33
  screenProps,
@@ -31,3 +40,27 @@ export {
31
40
  sliderEmits,
32
41
  } from './props.js'
33
42
  export type { BoxProps, ComponentProps, Align, Justify } from './props.js'
43
+
44
+ export { useToast, useToastHost, installAppToast, useAppToastHost } from './toast.js'
45
+ export { toastProps } from './props.js'
46
+
47
+ export { useDialogState } from './dialog.js'
48
+ export { dialogProps, dialogEmits } from './props.js'
49
+
50
+ export { tabsProps, tabsEmits } from './props.js'
51
+
52
+ export { listItemProps, separatorProps, avatarProps, badgeProps, skeletonProps } from './props.js'
53
+
54
+ export { progressProps, alertProps, alertEmits } from './props.js'
55
+
56
+ export { accordionProps, accordionEmits, segmentedProps, segmentedEmits } from './props.js'
57
+
58
+ export { chipProps, chipEmits, emptyStateProps } from './props.js'
59
+
60
+ export { MThemeProvider, themeProviderProps } from './theme-provider.js'
61
+ export { MSpan, inlineContent } from './inline-content.js'
62
+ export type { TextRun } from './inline-content.js'
63
+ export { spanProps } from './props.js'
64
+
65
+ export { useCachedActivity } from './cached-activity.js'
66
+ export { buttonContent, ButtonAdornment, useButtonAction } from './button-content.js'
@@ -0,0 +1,71 @@
1
+ import { Comment, Fragment, Text, defineComponent, type VNode } from '@vue/runtime-core'
2
+ import type { FontWeight, Palette } from '../theme/types.js'
3
+ import { validateWeight } from '../theme/typography.js'
4
+ import { spanProps } from './props.js'
5
+
6
+ export interface TextRun {
7
+ text: string
8
+ weight?: FontWeight
9
+ tone?: keyof Palette
10
+ strong?: boolean
11
+ italic?: boolean
12
+ }
13
+
14
+ /** A declarative text run, consumed by MText before native/DOM views are created. */
15
+ export const MSpan = defineComponent({
16
+ name: 'MSpan',
17
+ inheritAttrs: false,
18
+ props: spanProps,
19
+ setup(): () => null {
20
+ throw new TypeError('MSpan must be inside MText or another MSpan')
21
+ },
22
+ })
23
+
24
+ export function inlineContent(
25
+ nodes: VNode[] = [],
26
+ inherited: Omit<TextRun, 'text'> = {},
27
+ ): TextRun[] {
28
+ const runs: TextRun[] = []
29
+ for (const node of Array.isArray(nodes) ? nodes : [nodes]) {
30
+ if (typeof node === 'string' || typeof node === 'number') {
31
+ runs.push({ ...inherited, text: String(node) })
32
+ continue
33
+ }
34
+ if (!node || typeof node === 'boolean') continue
35
+ if (node.type === Comment) continue
36
+ if (node.type === Text) {
37
+ runs.push({ ...inherited, text: String(node.children ?? '') })
38
+ } else if (node.type === Fragment) {
39
+ runs.push(...inlineContent(node.children as VNode[], inherited))
40
+ } else if (node.type === MSpan) {
41
+ const props = node.props ?? {}
42
+ for (const key of Object.keys(props)) {
43
+ if (!['text', 'weight', 'tone', 'emphasis', 'key'].includes(key)) {
44
+ throw new TypeError(`MSpan does not accept ${key}; use text, weight, tone or emphasis`)
45
+ }
46
+ }
47
+ if (props.emphasis !== undefined && !['strong', 'em'].includes(props.emphasis))
48
+ throw new RangeError('Unknown text emphasis')
49
+ const next = { ...inherited }
50
+ if (props.emphasis === 'strong') {
51
+ next.strong = true
52
+ next.weight = 'bold'
53
+ }
54
+ if (props.emphasis === 'em') next.italic = true
55
+ if (props.weight !== undefined) next.weight = validateWeight(props.weight)
56
+ if (props.tone !== undefined) next.tone = props.tone
57
+ const children = node.children as { default?: () => VNode[] } | VNode[] | null
58
+ if (props.text !== undefined) runs.push({ ...next, text: String(props.text) })
59
+ else if (typeof node.children === 'string') runs.push({ ...next, text: node.children })
60
+ else
61
+ runs.push(
62
+ ...inlineContent(Array.isArray(children) ? children : children?.default?.(), next),
63
+ )
64
+ } else {
65
+ throw new TypeError(
66
+ 'MText accepts text and MSpan. Use a layout for views; links have a separate navigation contract.',
67
+ )
68
+ }
69
+ }
70
+ return runs
71
+ }
package/src/vue/props.ts CHANGED
@@ -1,5 +1,14 @@
1
+ import type { MotionSurface, MotionScrollSource } from '../experimental.js'
2
+ import type { AccordionItem } from '../accordion.js'
3
+ import type { SegmentedOption } from '../segmented.js'
4
+ import type { TabOption } from '../tabs.js'
5
+ import type { InputAction } from '../input.js'
6
+ import type { SheetName } from '../sheet.js'
7
+ import { dialogCloseReasons, type DialogCloseReason } from '../dialog.js'
1
8
  import type { ExtractPropTypes, ExtractPublicPropTypes, PropType } from '@vue/runtime-core'
2
- import type { Palette, Spacing, Radius } from '../theme/types.js'
9
+ import type { Palette, Spacing, Radius, FontWeight, Elevation } from '../theme/types.js'
10
+ import { isChoiceValue, type ChoiceValue, type ChoiceOption } from '../choice.js'
11
+ import type { ToastController } from '../toast.js'
3
12
  import type { Dimension } from '../layout.js'
4
13
  import { iconSizes, type IconName, type IconSize } from '../icon.js'
5
14
  import { sheetCloseReasons, type SheetCloseReason } from '../sheet.js'
@@ -45,6 +54,102 @@ export const boxProps = {
45
54
  height: dimensionProp,
46
55
  backgroundColor: String,
47
56
  }
57
+ export const listItemProps = {
58
+ ...viewProps,
59
+ ...flexProps,
60
+ width: dimensionProp,
61
+ title: { type: String, required: true as const },
62
+ description: { type: String, default: '' },
63
+ interactive: Boolean,
64
+ disabled: Boolean,
65
+ }
66
+ export const separatorProps = {
67
+ id: viewProps.id,
68
+ orientation: choice(['horizontal', 'vertical'] as const, 'horizontal'),
69
+ length: { type: Number, default: undefined },
70
+ spacing: { ...spacingProp, default: 'none' },
71
+ inset: { ...spacingProp, default: 'none' },
72
+ }
73
+ export const avatarProps = {
74
+ ...viewProps,
75
+ src: { type: String, default: '' },
76
+ name: { type: String, default: '' },
77
+ size: choice(['sm', 'md', 'lg', 'xl'] as const, 'md'),
78
+ shape: choice(['circle', 'square'] as const, 'circle'),
79
+ }
80
+ export const badgeProps = {
81
+ ...viewProps,
82
+ text: { type: [String, Number], required: true as const },
83
+ size: choice(['sm', 'md'] as const, 'md'),
84
+ tone: choice(
85
+ ['neutral', 'primary', 'accent', 'success', 'warning', 'danger'] as const,
86
+ 'neutral',
87
+ ),
88
+ }
89
+ export const chipProps = {
90
+ id: viewProps.id,
91
+ accessibilityHidden: viewProps.accessibilityHidden,
92
+ ...flexProps,
93
+ width: dimensionProp,
94
+ label: { type: String, required: true as const },
95
+ icon: { type: String as PropType<IconName>, default: undefined },
96
+ tone: choice(['primary', 'accent'] as const, 'primary'),
97
+ selectable: Boolean,
98
+ modelValue: Boolean,
99
+ removable: Boolean,
100
+ removeLabel: { type: String, default: undefined },
101
+ disabled: Boolean,
102
+ }
103
+ export const chipEmits = {
104
+ 'update:modelValue': (value: boolean) => typeof value === 'boolean',
105
+ remove: () => true,
106
+ }
107
+ export const emptyStateProps = {
108
+ id: viewProps.id,
109
+ accessibilityHidden: viewProps.accessibilityHidden,
110
+ ...flexProps,
111
+ width: dimensionProp,
112
+ title: { type: String, required: true as const },
113
+ description: { type: String, default: '' },
114
+ icon: { type: String as PropType<IconName>, default: 'inbox' },
115
+ tone: choice(['primary', 'accent'] as const, 'primary'),
116
+ compact: Boolean,
117
+ titleAs: choice(['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const, 'h2'),
118
+ }
119
+ export const progressProps = {
120
+ id: viewProps.id,
121
+ accessibilityHidden: viewProps.accessibilityHidden,
122
+ ...flexProps,
123
+ width: dimensionProp,
124
+ value: { type: Number, default: 0 },
125
+ max: { type: Number, default: 100 },
126
+ indeterminate: Boolean,
127
+ label: { type: String, required: true as const },
128
+ indeterminateLabel: { type: String, default: 'Loading' },
129
+ size: choice(['sm', 'md', 'lg'] as const, 'md'),
130
+ tone: choice(['primary', 'accent', 'success', 'warning', 'danger'] as const, 'primary'),
131
+ }
132
+ export const alertProps = {
133
+ id: viewProps.id,
134
+ accessibilityHidden: viewProps.accessibilityHidden,
135
+ ...flexProps,
136
+ width: dimensionProp,
137
+ title: { type: String, required: true as const },
138
+ description: { type: String, default: '' },
139
+ tone: choice(['info', 'success', 'warning', 'error'] as const, 'info'),
140
+ dismissible: Boolean,
141
+ closeLabel: { type: String, default: 'Dismiss message' },
142
+ announce: Boolean,
143
+ }
144
+ export const alertEmits = { close: () => true }
145
+ export const skeletonProps = {
146
+ id: viewProps.id,
147
+ ...flexProps,
148
+ width: dimensionProp,
149
+ height: { ...dimensionProp, default: 16 },
150
+ radius: { ...radiusProp, default: 'sm' },
151
+ animated: { type: Boolean, default: true },
152
+ }
48
153
  export type Align = 'start' | 'center' | 'end' | 'stretch'
49
154
  export type Justify = 'start' | 'center' | 'end' | 'between' | 'around'
50
155
 
@@ -63,17 +168,25 @@ function layoutProps(direction: 'row' | 'column') {
63
168
  export const rowProps = layoutProps('row')
64
169
  export const columnProps = layoutProps('column')
65
170
  export const cardProps = {
171
+ motionSurface: { type: Object as PropType<MotionSurface>, default: undefined },
66
172
  ...boxProps,
67
- padding: { ...spacingProp, default: 'lg' },
68
- radius: { ...radiusProp, default: 'lg' },
173
+ padding: spacingProp,
174
+ radius: radiusProp,
175
+ elevation: { type: String as PropType<Elevation>, default: undefined },
69
176
  gap: spacingProp,
70
177
  interactive: Boolean,
71
178
  disabled: Boolean,
72
179
  }
73
180
  export const buttonProps = {
181
+ motionSurface: { type: Object as PropType<MotionSurface>, default: undefined },
74
182
  ...viewProps,
75
183
  ...flexProps,
76
184
  text: { type: String, default: undefined },
185
+ // HTML form behavior; NativeScript buttons remain application actions.
186
+ type: choice(['button', 'submit', 'reset'] as const, 'button'),
187
+ name: { type: String, default: undefined },
188
+ value: { type: String, default: undefined },
189
+ form: { type: String, default: undefined },
77
190
  variant: choice(['primary', 'secondary', 'ghost'] as const, 'primary'),
78
191
  size: choice(['sm', 'md', 'lg'] as const, 'md'),
79
192
  disabled: Boolean,
@@ -95,10 +208,19 @@ const tones: readonly (keyof Palette)[] = [
95
208
  'onAccent',
96
209
  'accentSoft',
97
210
  'border',
211
+ 'warning',
98
212
  'success',
99
213
  'danger',
100
214
  ]
215
+ export const weightProp = { type: String as PropType<FontWeight>, default: undefined }
216
+ export const spanProps = {
217
+ text: { type: String, default: undefined },
218
+ weight: weightProp,
219
+ tone: { type: String as PropType<keyof Palette>, default: undefined },
220
+ emphasis: { type: String as PropType<'strong' | 'em'>, default: undefined },
221
+ }
101
222
  export const textProps = {
223
+ weight: weightProp,
102
224
  ...viewProps,
103
225
  ...flexProps,
104
226
  text: { type: String, default: undefined },
@@ -118,6 +240,110 @@ export const sliderProps = {
118
240
  disabled: Boolean,
119
241
  label: { type: String, required: true as const },
120
242
  }
243
+ const booleanControlProps = {
244
+ id: viewProps.id,
245
+ accessibilityHidden: viewProps.accessibilityHidden,
246
+ ...flexProps,
247
+ width: dimensionProp,
248
+ modelValue: Boolean,
249
+ label: { type: String, required: true as const },
250
+ helperText: { type: String, default: '' },
251
+ disabled: Boolean,
252
+ }
253
+ export const switchProps = booleanControlProps
254
+ export const switchEmits = { 'update:modelValue': (value: boolean) => typeof value === 'boolean' }
255
+ export const checkboxProps = {
256
+ ...booleanControlProps,
257
+ indeterminate: Boolean,
258
+ indeterminateLabel: { type: String, default: 'Partially selected' },
259
+ }
260
+ export const checkboxEmits = {
261
+ 'update:modelValue': (value: boolean) => typeof value === 'boolean',
262
+ 'update:indeterminate': (value: boolean) => typeof value === 'boolean',
263
+ }
264
+ export const radioGroupProps = {
265
+ id: viewProps.id,
266
+ accessibilityHidden: viewProps.accessibilityHidden,
267
+ ...flexProps,
268
+ width: dimensionProp,
269
+ modelValue: { type: [String, Number] as PropType<ChoiceValue | null>, default: null },
270
+ options: { type: Array as PropType<readonly ChoiceOption[]>, required: true as const },
271
+ label: { type: String, required: true as const },
272
+ helperText: { type: String, default: '' },
273
+ disabled: Boolean,
274
+ }
275
+ export const radioGroupEmits = { 'update:modelValue': (value: ChoiceValue) => isChoiceValue(value) }
276
+ export const tabsProps = {
277
+ keepAlive: Boolean,
278
+ id: viewProps.id,
279
+ accessibilityHidden: viewProps.accessibilityHidden,
280
+ ...flexProps,
281
+ width: dimensionProp,
282
+ modelValue: radioGroupProps.modelValue,
283
+ tabs: { type: Array as PropType<readonly TabOption[]>, required: true as const },
284
+ label: { type: String, required: true as const },
285
+ disabled: Boolean,
286
+ }
287
+ export const tabsEmits = radioGroupEmits
288
+ export const accordionProps = {
289
+ id: viewProps.id,
290
+ accessibilityHidden: viewProps.accessibilityHidden,
291
+ ...flexProps,
292
+ width: dimensionProp,
293
+ items: { type: Array as PropType<readonly AccordionItem[]>, required: true as const },
294
+ modelValue: { type: Array as PropType<readonly ChoiceValue[]>, default: () => [] },
295
+ multiple: Boolean,
296
+ disabled: Boolean,
297
+ label: { type: String, required: true as const },
298
+ expandedLabel: { type: String, default: 'Expanded' },
299
+ collapsedLabel: { type: String, default: 'Collapsed' },
300
+ }
301
+ export const accordionEmits = {
302
+ 'update:modelValue': (value: ChoiceValue[]) => Array.isArray(value) && value.every(isChoiceValue),
303
+ }
304
+ export const segmentedProps = {
305
+ id: viewProps.id,
306
+ accessibilityHidden: viewProps.accessibilityHidden,
307
+ ...flexProps,
308
+ width: dimensionProp,
309
+ options: { type: Array as PropType<readonly SegmentedOption[]>, required: true as const },
310
+ modelValue: radioGroupProps.modelValue,
311
+ label: { type: String, required: true as const },
312
+ disabled: Boolean,
313
+ }
314
+ export const segmentedEmits = radioGroupEmits
315
+
316
+ export const dialogProps = {
317
+ id: viewProps.id,
318
+ open: Boolean,
319
+ title: { type: String, required: true as const },
320
+ description: { type: String, default: '' },
321
+ confirmLabel: { type: String, default: 'Continue' },
322
+ cancelLabel: { type: String, default: 'Cancel' },
323
+ loadingLabel: { type: String, default: 'Working…' },
324
+ tone: choice(['default', 'danger'] as const, 'default'),
325
+ loading: Boolean,
326
+ dismissible: { type: Boolean, default: true },
327
+ }
328
+ export const dialogEmits = {
329
+ 'update:open': (value: boolean) => typeof value === 'boolean',
330
+ confirm: () => true,
331
+ close: (reason: DialogCloseReason) => dialogCloseReasons.includes(reason),
332
+ }
333
+
334
+ export const toastProps = {
335
+ controller: { type: Object as PropType<ToastController>, required: true as const },
336
+ closeLabel: { type: String, default: 'Dismiss notification' },
337
+ }
338
+
339
+ export const selectProps = {
340
+ ...radioGroupProps,
341
+ placeholder: { type: String, default: 'Select an option' },
342
+ error: { type: String, default: '' },
343
+ closeLabel: { type: String, default: 'Close' },
344
+ emptyText: { type: String, default: 'No options available' },
345
+ }
346
+ export const selectEmits = radioGroupEmits
121
347
  export const inputProps = {
122
348
  id: viewProps.id,
123
349
  accessibilityHidden: viewProps.accessibilityHidden,
@@ -129,6 +355,17 @@ export const inputProps = {
129
355
  helperText: { type: String, default: '' },
130
356
  error: { type: String, default: '' },
131
357
  type: choice(['text', 'email', 'password', 'tel', 'url', 'search'] as const, 'text'),
358
+ // Browser editor attributes. NativeScript has no HTML form owner.
359
+ name: { type: String, default: undefined },
360
+ autocomplete: { type: String, default: undefined },
361
+ required: Boolean,
362
+ inputmode: {
363
+ type: String as PropType<
364
+ 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url'
365
+ >,
366
+ default: undefined,
367
+ },
368
+ form: { type: String, default: undefined },
132
369
  disabled: Boolean,
133
370
  readonly: Boolean,
134
371
  multiline: Boolean,
@@ -141,10 +378,12 @@ export const inputProps = {
141
378
  },
142
379
  autocorrect: { type: Boolean, default: undefined },
143
380
  returnKey: choice(['done', 'next', 'go', 'search', 'send'] as const, 'done'),
381
+ trailingAction: { type: Object as PropType<InputAction>, default: undefined },
144
382
  icon: { type: String as PropType<IconName>, default: undefined },
145
383
  trailingIcon: { type: String as PropType<IconName>, default: undefined },
146
384
  }
147
385
  export const inputEmits = {
386
+ action: () => true,
148
387
  'update:modelValue': (value: string) => typeof value === 'string',
149
388
  focus: () => true,
150
389
  blur: () => true,
@@ -163,6 +402,7 @@ export const iconProps = {
163
402
  label: { type: String, default: undefined },
164
403
  }
165
404
  export const screenProps = {
405
+ motionScroll: { type: Object as PropType<MotionScrollSource>, default: undefined },
166
406
  ...viewProps,
167
407
  scroll: Boolean,
168
408
  /** Puts the software keyboard away on a tap outside the editor and, with `scroll`, on a drag towards it. */
@@ -201,11 +441,30 @@ export const componentProps = {
201
441
  MButton: buttonProps,
202
442
  MSlider: sliderProps,
203
443
  MInput: inputProps,
444
+ MSwitch: switchProps,
445
+ MCheckbox: checkboxProps,
446
+ MRadioGroup: radioGroupProps,
447
+ MSelect: selectProps,
448
+ MToast: toastProps,
449
+ MDialog: dialogProps,
450
+ MTabs: tabsProps,
451
+ MSkeleton: skeletonProps,
452
+ MProgress: progressProps,
453
+ MChip: chipProps,
454
+ MEmptyState: emptyStateProps,
455
+ MAccordion: accordionProps,
456
+ MSegmentedControl: segmentedProps,
457
+ MAlert: alertProps,
458
+ MListItem: listItemProps,
459
+ MSeparator: separatorProps,
460
+ MAvatar: avatarProps,
461
+ MBadge: badgeProps,
204
462
  MIcon: iconProps,
205
463
  MReveal: revealProps,
206
464
  MSheet: sheetProps,
207
465
  }
208
466
  export type BoxProps = ExtractPropTypes<typeof boxProps>
209
467
  export type ComponentProps = {
210
- [Name in keyof typeof componentProps]: ExtractPublicPropTypes<(typeof componentProps)[Name]>
468
+ [Name in keyof typeof componentProps]: ExtractPublicPropTypes<(typeof componentProps)[Name]> &
469
+ (Name extends 'MSheet' ? SheetName : unknown)
211
470
  }