@getcortexlabs/mavis-core 0.1.0-alpha.2 → 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 +30 -3
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +17 -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 +12 -0
  63. package/dist/sheet.d.ts.map +1 -0
  64. package/dist/sheet.js +15 -0
  65. package/dist/sheet.js.map +1 -0
  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 +102 -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 +2113 -533
  106. package/dist/vue/props.d.ts.map +1 -1
  107. package/dist/vue/props.js +272 -3
  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 +48 -2
  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 +20 -0
  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 +84 -2
  147. package/src/vue/index.ts +35 -0
  148. package/src/vue/inline-content.ts +71 -0
  149. package/src/vue/props.ts +290 -5
  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,28 +1,110 @@
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'
7
+ import type { SheetCloseReason } from '../sheet.js'
8
+ import type { InputHandle } from '../input.js'
3
9
 
4
10
  type Action = { onClick?: () => void }
5
11
  type Model = { 'onUpdate:modelValue'?: (value: number) => void }
6
12
  type InputEvents = {
13
+ onAction?: () => void
7
14
  'onUpdate:modelValue'?: (value: string) => void
8
15
  onFocus?: () => void
9
16
  onBlur?: () => void
10
17
  onSubmit?: (value: string) => void
11
18
  }
12
19
 
20
+ /** Additional input attributes supplied by a renderer, without DOM dependencies in core. */
21
+ export interface InputPlatformAttributes {}
22
+ type SheetEvents = {
23
+ 'onUpdate:open'?: (value: boolean) => void
24
+ onClose?: (reason: SheetCloseReason) => void
25
+ onOpened?: () => void
26
+ }
27
+
13
28
  /** Template props come from the same declarations used by both renderers. */
14
29
  declare module '@vue/runtime-core' {
15
30
  export interface GlobalComponents {
31
+ MThemeProvider: typeof import('./theme-provider.js').MThemeProvider
32
+ MSpan: typeof import('./inline-content.js').MSpan
16
33
  MScreen: DefineComponent<ComponentProps['MScreen']>
17
34
  MRow: DefineComponent<ComponentProps['MRow']>
18
35
  MColumn: DefineComponent<ComponentProps['MColumn']>
19
36
  MBox: DefineComponent<ComponentProps['MBox']>
20
37
  MCard: DefineComponent<ComponentProps['MCard'] & Action>
21
38
  MText: DefineComponent<ComponentProps['MText']>
22
- MButton: DefineComponent<ComponentProps['MButton'] & Action>
39
+ MButton: DefineComponent<ComponentProps['MButton'] & Action> & {
40
+ new (): {
41
+ $slots: { default?: () => unknown; leading?: () => unknown; trailing?: () => unknown }
42
+ }
43
+ }
23
44
  MSlider: DefineComponent<ComponentProps['MSlider'] & Model>
24
- 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
+ >
25
106
  MIcon: DefineComponent<ComponentProps['MIcon']>
26
107
  MReveal: DefineComponent<ComponentProps['MReveal']>
108
+ MSheet: DefineComponent<ComponentProps['MSheet'] & SheetEvents>
27
109
  }
28
110
  }
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,13 +20,47 @@ 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,
25
34
  revealProps,
35
+ sheetProps,
36
+ sheetEmits,
26
37
  componentProps,
27
38
  viewAttrs,
28
39
  actionEmits,
29
40
  sliderEmits,
30
41
  } from './props.js'
31
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,7 +1,17 @@
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'
14
+ import { sheetCloseReasons, type SheetCloseReason } from '../sheet.js'
5
15
 
6
16
  function choice<T extends string>(values: readonly T[], defaultValue: T) {
7
17
  return {
@@ -44,6 +54,102 @@ export const boxProps = {
44
54
  height: dimensionProp,
45
55
  backgroundColor: String,
46
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
+ }
47
153
  export type Align = 'start' | 'center' | 'end' | 'stretch'
48
154
  export type Justify = 'start' | 'center' | 'end' | 'between' | 'around'
49
155
 
@@ -62,17 +168,25 @@ function layoutProps(direction: 'row' | 'column') {
62
168
  export const rowProps = layoutProps('row')
63
169
  export const columnProps = layoutProps('column')
64
170
  export const cardProps = {
171
+ motionSurface: { type: Object as PropType<MotionSurface>, default: undefined },
65
172
  ...boxProps,
66
- padding: { ...spacingProp, default: 'lg' },
67
- radius: { ...radiusProp, default: 'lg' },
173
+ padding: spacingProp,
174
+ radius: radiusProp,
175
+ elevation: { type: String as PropType<Elevation>, default: undefined },
68
176
  gap: spacingProp,
69
177
  interactive: Boolean,
70
178
  disabled: Boolean,
71
179
  }
72
180
  export const buttonProps = {
181
+ motionSurface: { type: Object as PropType<MotionSurface>, default: undefined },
73
182
  ...viewProps,
74
183
  ...flexProps,
75
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 },
76
190
  variant: choice(['primary', 'secondary', 'ghost'] as const, 'primary'),
77
191
  size: choice(['sm', 'md', 'lg'] as const, 'md'),
78
192
  disabled: Boolean,
@@ -94,10 +208,19 @@ const tones: readonly (keyof Palette)[] = [
94
208
  'onAccent',
95
209
  'accentSoft',
96
210
  'border',
211
+ 'warning',
97
212
  'success',
98
213
  'danger',
99
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
+ }
100
222
  export const textProps = {
223
+ weight: weightProp,
101
224
  ...viewProps,
102
225
  ...flexProps,
103
226
  text: { type: String, default: undefined },
@@ -117,6 +240,110 @@ export const sliderProps = {
117
240
  disabled: Boolean,
118
241
  label: { type: String, required: true as const },
119
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
120
347
  export const inputProps = {
121
348
  id: viewProps.id,
122
349
  accessibilityHidden: viewProps.accessibilityHidden,
@@ -128,6 +355,17 @@ export const inputProps = {
128
355
  helperText: { type: String, default: '' },
129
356
  error: { type: String, default: '' },
130
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 },
131
369
  disabled: Boolean,
132
370
  readonly: Boolean,
133
371
  multiline: Boolean,
@@ -140,10 +378,12 @@ export const inputProps = {
140
378
  },
141
379
  autocorrect: { type: Boolean, default: undefined },
142
380
  returnKey: choice(['done', 'next', 'go', 'search', 'send'] as const, 'done'),
381
+ trailingAction: { type: Object as PropType<InputAction>, default: undefined },
143
382
  icon: { type: String as PropType<IconName>, default: undefined },
144
383
  trailingIcon: { type: String as PropType<IconName>, default: undefined },
145
384
  }
146
385
  export const inputEmits = {
386
+ action: () => true,
147
387
  'update:modelValue': (value: string) => typeof value === 'string',
148
388
  focus: () => true,
149
389
  blur: () => true,
@@ -161,8 +401,33 @@ export const iconProps = {
161
401
  /** Accessible name. Without it the icon is decorative and hidden from assistive technology. */
162
402
  label: { type: String, default: undefined },
163
403
  }
164
- export const screenProps = { ...viewProps, scroll: Boolean }
404
+ export const screenProps = {
405
+ motionScroll: { type: Object as PropType<MotionScrollSource>, default: undefined },
406
+ ...viewProps,
407
+ scroll: Boolean,
408
+ /** Puts the software keyboard away on a tap outside the editor and, with `scroll`, on a drag towards it. */
409
+ dismissKeyboard: { type: Boolean, default: true },
410
+ }
165
411
  export const revealProps = { ...columnProps, show: Boolean }
412
+ export const sheetProps = {
413
+ id: viewProps.id,
414
+ accessibilityLabel: viewProps.accessibilityLabel,
415
+ open: Boolean,
416
+ /** Rendered as the sheet heading and used as its accessible name. */
417
+ title: { type: String, default: undefined },
418
+ /** Allows the scrim, Escape, the back gesture, swiping down and the close button. */
419
+ dismissible: { type: Boolean, default: true },
420
+ fullscreen: Boolean,
421
+ closeLabel: { type: String, default: 'Close' },
422
+ padding: { ...spacingProp, default: 'lg' },
423
+ gap: spacingProp,
424
+ align: columnProps.align,
425
+ }
426
+ export const sheetEmits = {
427
+ 'update:open': (value: boolean) => typeof value === 'boolean',
428
+ close: (reason: SheetCloseReason) => sheetCloseReasons.includes(reason),
429
+ opened: () => true,
430
+ }
166
431
  export const actionEmits = { click: () => true }
167
432
  export const sliderEmits = { 'update:modelValue': (value: number) => Number.isFinite(value) }
168
433
 
@@ -176,10 +441,30 @@ export const componentProps = {
176
441
  MButton: buttonProps,
177
442
  MSlider: sliderProps,
178
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,
179
462
  MIcon: iconProps,
180
463
  MReveal: revealProps,
464
+ MSheet: sheetProps,
181
465
  }
182
466
  export type BoxProps = ExtractPropTypes<typeof boxProps>
183
467
  export type ComponentProps = {
184
- [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)
185
470
  }