@getcortexlabs/mavis-web 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.
- package/README.md +4 -4
- package/dist/components/MAccordion.d.ts +109 -0
- package/dist/components/MAccordion.d.ts.map +1 -0
- package/dist/components/MAccordion.js +180 -0
- package/dist/components/MAccordion.js.map +1 -0
- package/dist/components/MAlert.d.ts +99 -0
- package/dist/components/MAlert.d.ts.map +1 -0
- package/dist/components/MAlert.js +88 -0
- package/dist/components/MAlert.js.map +1 -0
- package/dist/components/MAvatar.d.ts +74 -0
- package/dist/components/MAvatar.d.ts.map +1 -0
- package/dist/components/MAvatar.js +88 -0
- package/dist/components/MAvatar.js.map +1 -0
- package/dist/components/MBadge.d.ts +64 -0
- package/dist/components/MBadge.d.ts.map +1 -0
- package/dist/components/MBadge.js +35 -0
- package/dist/components/MBadge.js.map +1 -0
- package/dist/components/MButton.d.ts +59 -7
- package/dist/components/MButton.d.ts.map +1 -1
- package/dist/components/MButton.js +51 -18
- package/dist/components/MButton.js.map +1 -1
- package/dist/components/MCard.d.ts +23 -5
- package/dist/components/MCard.d.ts.map +1 -1
- package/dist/components/MCard.js +28 -6
- package/dist/components/MCard.js.map +1 -1
- package/dist/components/MCheckbox.d.ts +93 -0
- package/dist/components/MCheckbox.d.ts.map +1 -0
- package/dist/components/MCheckbox.js +108 -0
- package/dist/components/MCheckbox.js.map +1 -0
- package/dist/components/MChip.d.ts +107 -0
- package/dist/components/MChip.d.ts.map +1 -0
- package/dist/components/MChip.js +103 -0
- package/dist/components/MChip.js.map +1 -0
- package/dist/components/MDialog.d.ts +94 -0
- package/dist/components/MDialog.d.ts.map +1 -0
- package/dist/components/MDialog.js +214 -0
- package/dist/components/MDialog.js.map +1 -0
- package/dist/components/MEmptyState.d.ts +107 -0
- package/dist/components/MEmptyState.d.ts.map +1 -0
- package/dist/components/MEmptyState.js +79 -0
- package/dist/components/MEmptyState.js.map +1 -0
- package/dist/components/MIcon.d.ts +1 -1
- package/dist/components/MInput.d.ts +66 -8
- package/dist/components/MInput.d.ts.map +1 -1
- package/dist/components/MInput.js +96 -20
- package/dist/components/MInput.js.map +1 -1
- package/dist/components/MListItem.d.ts +92 -0
- package/dist/components/MListItem.d.ts.map +1 -0
- package/dist/components/MListItem.js +53 -0
- package/dist/components/MListItem.js.map +1 -0
- package/dist/components/MProgress.d.ts +112 -0
- package/dist/components/MProgress.d.ts.map +1 -0
- package/dist/components/MProgress.js +69 -0
- package/dist/components/MProgress.js.map +1 -0
- package/dist/components/MRadioGroup.d.ts +94 -0
- package/dist/components/MRadioGroup.d.ts.map +1 -0
- package/dist/components/MRadioGroup.js +167 -0
- package/dist/components/MRadioGroup.js.map +1 -0
- package/dist/components/MReveal.d.ts.map +1 -1
- package/dist/components/MReveal.js +28 -3
- package/dist/components/MReveal.js.map +1 -1
- package/dist/components/MScreen.d.ts +19 -1
- package/dist/components/MScreen.d.ts.map +1 -1
- package/dist/components/MScreen.js +30 -1
- package/dist/components/MScreen.js.map +1 -1
- package/dist/components/MSegmentedControl.d.ts +85 -0
- package/dist/components/MSegmentedControl.d.ts.map +1 -0
- package/dist/components/MSegmentedControl.js +128 -0
- package/dist/components/MSegmentedControl.js.map +1 -0
- package/dist/components/MSelect.d.ts +130 -0
- package/dist/components/MSelect.d.ts.map +1 -0
- package/dist/components/MSelect.js +308 -0
- package/dist/components/MSelect.js.map +1 -0
- package/dist/components/MSeparator.d.ts +54 -0
- package/dist/components/MSeparator.d.ts.map +1 -0
- package/dist/components/MSeparator.js +36 -0
- package/dist/components/MSeparator.js.map +1 -0
- package/dist/components/MSheet.d.ts +102 -0
- package/dist/components/MSheet.d.ts.map +1 -0
- package/dist/components/MSheet.js +265 -0
- package/dist/components/MSheet.js.map +1 -0
- package/dist/components/MSkeleton.d.ts +70 -0
- package/dist/components/MSkeleton.d.ts.map +1 -0
- package/dist/components/MSkeleton.js +43 -0
- package/dist/components/MSkeleton.js.map +1 -0
- package/dist/components/MSlider.d.ts +1 -1
- package/dist/components/MSlider.d.ts.map +1 -1
- package/dist/components/MSlider.js +2 -1
- package/dist/components/MSlider.js.map +1 -1
- package/dist/components/MSwitch.d.ts +79 -0
- package/dist/components/MSwitch.d.ts.map +1 -0
- package/dist/components/MSwitch.js +87 -0
- package/dist/components/MSwitch.js.map +1 -0
- package/dist/components/MTabs.d.ts +91 -0
- package/dist/components/MTabs.d.ts.map +1 -0
- package/dist/components/MTabs.js +228 -0
- package/dist/components/MTabs.js.map +1 -0
- package/dist/components/MText.d.ts +18 -9
- package/dist/components/MText.d.ts.map +1 -1
- package/dist/components/MText.js +26 -7
- package/dist/components/MText.js.map +1 -1
- package/dist/components/MToast.d.ts +24 -0
- package/dist/components/MToast.d.ts.map +1 -0
- package/dist/components/MToast.js +196 -0
- package/dist/components/MToast.js.map +1 -0
- package/dist/index.d.ts +27 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -4
- package/dist/index.js.map +1 -1
- package/dist/input-attrs.d.ts +15 -0
- package/dist/input-attrs.d.ts.map +1 -0
- package/dist/input-attrs.js +18 -0
- package/dist/input-attrs.js.map +1 -0
- package/dist/motion-surface.d.ts +8 -0
- package/dist/motion-surface.d.ts.map +1 -0
- package/dist/motion-surface.js +79 -0
- package/dist/motion-surface.js.map +1 -0
- package/dist/motion.d.ts +20 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +227 -0
- package/dist/motion.js.map +1 -0
- package/dist/screen-viewport.d.ts.map +1 -1
- package/dist/screen-viewport.js +3 -0
- package/dist/screen-viewport.js.map +1 -1
- package/dist/scroll-motion.d.ts +5 -0
- package/dist/scroll-motion.d.ts.map +1 -0
- package/dist/scroll-motion.js +69 -0
- package/dist/scroll-motion.js.map +1 -0
- package/dist/sheet-motion.d.ts +8 -0
- package/dist/sheet-motion.d.ts.map +1 -0
- package/dist/sheet-motion.js +148 -0
- package/dist/sheet-motion.js.map +1 -0
- package/dist/style.d.ts.map +1 -1
- package/dist/style.js +24 -9
- package/dist/style.js.map +1 -1
- package/package.json +4 -3
- package/src/components/MAccordion.ts +231 -0
- package/src/components/MAlert.ts +109 -0
- package/src/components/MAvatar.ts +97 -0
- package/src/components/MBadge.ts +40 -0
- package/src/components/MButton.ts +68 -15
- package/src/components/MCard.ts +43 -5
- package/src/components/MCheckbox.ts +127 -0
- package/src/components/MChip.ts +109 -0
- package/src/components/MDialog.ts +245 -0
- package/src/components/MEmptyState.ts +96 -0
- package/src/components/MInput.ts +166 -71
- package/src/components/MListItem.ts +66 -0
- package/src/components/MProgress.ts +82 -0
- package/src/components/MRadioGroup.ts +184 -0
- package/src/components/MReveal.ts +40 -3
- package/src/components/MScreen.ts +31 -1
- package/src/components/MSegmentedControl.ts +151 -0
- package/src/components/MSelect.ts +362 -0
- package/src/components/MSeparator.ts +40 -0
- package/src/components/MSheet.ts +317 -0
- package/src/components/MSkeleton.ts +52 -0
- package/src/components/MSlider.ts +7 -1
- package/src/components/MSwitch.ts +108 -0
- package/src/components/MTabs.ts +275 -0
- package/src/components/MText.ts +30 -7
- package/src/components/MToast.ts +241 -0
- package/src/index.ts +82 -4
- package/src/input-attrs.ts +41 -0
- package/src/motion-surface.ts +86 -0
- package/src/motion.ts +275 -0
- package/src/screen-viewport.ts +2 -0
- package/src/scroll-motion.ts +75 -0
- package/src/sheet-motion.ts +152 -0
- package/src/style.css +861 -39
- package/src/style.ts +20 -9
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export declare const MSwitch: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
width: {
|
|
3
|
+
type: import("vue").PropType<import("@getcortexlabs/mavis-core").Dimension>;
|
|
4
|
+
default: undefined;
|
|
5
|
+
};
|
|
6
|
+
modelValue: BooleanConstructor;
|
|
7
|
+
label: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
helperText: {
|
|
12
|
+
type: StringConstructor;
|
|
13
|
+
default: string;
|
|
14
|
+
};
|
|
15
|
+
disabled: BooleanConstructor;
|
|
16
|
+
grow: {
|
|
17
|
+
type: NumberConstructor;
|
|
18
|
+
default: number;
|
|
19
|
+
};
|
|
20
|
+
shrink: {
|
|
21
|
+
type: NumberConstructor;
|
|
22
|
+
default: undefined;
|
|
23
|
+
};
|
|
24
|
+
id: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: undefined;
|
|
27
|
+
};
|
|
28
|
+
accessibilityHidden: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
default: undefined;
|
|
31
|
+
};
|
|
32
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
35
|
+
'update:modelValue': (value: boolean) => boolean;
|
|
36
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
37
|
+
width: {
|
|
38
|
+
type: import("vue").PropType<import("@getcortexlabs/mavis-core").Dimension>;
|
|
39
|
+
default: undefined;
|
|
40
|
+
};
|
|
41
|
+
modelValue: BooleanConstructor;
|
|
42
|
+
label: {
|
|
43
|
+
type: StringConstructor;
|
|
44
|
+
required: true;
|
|
45
|
+
};
|
|
46
|
+
helperText: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
default: string;
|
|
49
|
+
};
|
|
50
|
+
disabled: BooleanConstructor;
|
|
51
|
+
grow: {
|
|
52
|
+
type: NumberConstructor;
|
|
53
|
+
default: number;
|
|
54
|
+
};
|
|
55
|
+
shrink: {
|
|
56
|
+
type: NumberConstructor;
|
|
57
|
+
default: undefined;
|
|
58
|
+
};
|
|
59
|
+
id: {
|
|
60
|
+
type: StringConstructor;
|
|
61
|
+
default: undefined;
|
|
62
|
+
};
|
|
63
|
+
accessibilityHidden: {
|
|
64
|
+
type: BooleanConstructor;
|
|
65
|
+
default: undefined;
|
|
66
|
+
};
|
|
67
|
+
}>> & Readonly<{
|
|
68
|
+
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
69
|
+
}>, {
|
|
70
|
+
width: import("@getcortexlabs/mavis-core").Dimension;
|
|
71
|
+
grow: number;
|
|
72
|
+
shrink: number;
|
|
73
|
+
id: string;
|
|
74
|
+
accessibilityHidden: boolean;
|
|
75
|
+
disabled: boolean;
|
|
76
|
+
modelValue: boolean;
|
|
77
|
+
helperText: string;
|
|
78
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
79
|
+
//# sourceMappingURL=MSwitch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MSwitch.d.ts","sourceRoot":"","sources":["../../src/components/MSwitch.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EA+FlB,CAAA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { fontFamily } from '@getcortexlabs/mavis-core';
|
|
2
|
+
import { defineComponent, h, mergeProps, useId } from 'vue';
|
|
3
|
+
import { useButtonAction, switchProps, switchEmits, useMavisTheme, useDefaultShrink, } from '@getcortexlabs/mavis-core/vue';
|
|
4
|
+
import { nonNegative, resolveDimension } from '@getcortexlabs/mavis-core';
|
|
5
|
+
import { length, webAttrs } from '../style.js';
|
|
6
|
+
export const MSwitch = defineComponent({
|
|
7
|
+
name: 'MSwitch',
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
props: switchProps,
|
|
10
|
+
emits: switchEmits,
|
|
11
|
+
setup(props, { attrs, emit }) {
|
|
12
|
+
useButtonAction();
|
|
13
|
+
const { theme } = useMavisTheme();
|
|
14
|
+
const shrink = useDefaultShrink();
|
|
15
|
+
const labelId = `m-switch-${useId()}`;
|
|
16
|
+
return () => {
|
|
17
|
+
const { colors, space, typography, radius } = theme.value;
|
|
18
|
+
return h('button', mergeProps({
|
|
19
|
+
class: 'm-switch',
|
|
20
|
+
style: {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
flexWrap: 'wrap',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
gap: `${space.md}px`,
|
|
25
|
+
boxSizing: 'border-box',
|
|
26
|
+
minWidth: 0,
|
|
27
|
+
minHeight: '48px',
|
|
28
|
+
padding: `${space.sm}px 0`,
|
|
29
|
+
border: 0,
|
|
30
|
+
borderRadius: `${radius.sm}px`,
|
|
31
|
+
margin: 0,
|
|
32
|
+
background: 'transparent',
|
|
33
|
+
color: colors.text,
|
|
34
|
+
textAlign: 'start',
|
|
35
|
+
fontFamily: fontFamily(theme.value.typography.body.fontFamily, 'web'),
|
|
36
|
+
fontSize: `${typography.body.fontSize}px`,
|
|
37
|
+
lineHeight: 1.5,
|
|
38
|
+
opacity: props.disabled ? 0.45 : 1,
|
|
39
|
+
flexGrow: nonNegative(props.grow, 'grow'),
|
|
40
|
+
flexShrink: nonNegative(props.shrink ?? shrink, 'shrink'),
|
|
41
|
+
width: length(resolveDimension(props.width)),
|
|
42
|
+
'--m-focus': colors.primary,
|
|
43
|
+
'--m-switch-track': props.modelValue ? colors.primary : colors.muted,
|
|
44
|
+
'--m-switch-thumb': props.modelValue ? colors.onPrimary : colors.surface,
|
|
45
|
+
},
|
|
46
|
+
}, webAttrs({ ...attrs, id: props.id, accessibilityHidden: props.accessibilityHidden }), {
|
|
47
|
+
type: 'button',
|
|
48
|
+
role: 'switch',
|
|
49
|
+
disabled: props.disabled,
|
|
50
|
+
'aria-checked': props.modelValue,
|
|
51
|
+
'aria-labelledby': labelId,
|
|
52
|
+
'aria-describedby': props.helperText ? `${labelId}-help` : undefined,
|
|
53
|
+
onClick: () => {
|
|
54
|
+
if (!props.disabled)
|
|
55
|
+
emit('update:modelValue', !props.modelValue);
|
|
56
|
+
},
|
|
57
|
+
}), [
|
|
58
|
+
h('span', {
|
|
59
|
+
style: {
|
|
60
|
+
flex: '1 1 min-content',
|
|
61
|
+
minWidth: 0,
|
|
62
|
+
overflowWrap: 'break-word',
|
|
63
|
+
maxWidth: '100%',
|
|
64
|
+
},
|
|
65
|
+
}, [
|
|
66
|
+
h('span', { id: labelId, style: { display: 'block', fontWeight: 600 } }, props.label),
|
|
67
|
+
props.helperText
|
|
68
|
+
? h('span', {
|
|
69
|
+
id: `${labelId}-help`,
|
|
70
|
+
style: {
|
|
71
|
+
display: 'block',
|
|
72
|
+
marginTop: `${space.xs}px`,
|
|
73
|
+
color: colors.muted,
|
|
74
|
+
fontSize: `${typography.caption.fontSize}px`,
|
|
75
|
+
fontWeight: 'normal',
|
|
76
|
+
},
|
|
77
|
+
}, props.helperText)
|
|
78
|
+
: null,
|
|
79
|
+
]),
|
|
80
|
+
h('span', { class: 'm-switch-track', 'aria-hidden': 'true' }, [
|
|
81
|
+
h('span', { class: 'm-switch-thumb' }),
|
|
82
|
+
]),
|
|
83
|
+
]);
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=MSwitch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MSwitch.js","sourceRoot":"","sources":["../../src/components/MSwitch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAC3D,OAAO,EACL,eAAe,EACf,WAAW,EACX,WAAW,EACX,aAAa,EACb,gBAAgB,GACjB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AACzE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE9C,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;IACrC,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BACF,EACD;oBACE,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC;oBACrF,KAAK,CAAC,UAAU;wBACd,CAAC,CAAC,CAAC,CACC,MAAM,EACN;4BACE,EAAE,EAAE,GAAG,OAAO,OAAO;4BACrB,KAAK,EAAE;gCACL,OAAO,EAAE,OAAO;gCAChB,SAAS,EAAE,GAAG,KAAK,CAAC,EAAE,IAAI;gCAC1B,KAAK,EAAE,MAAM,CAAC,KAAK;gCACnB,QAAQ,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,IAAI;gCAC5C,UAAU,EAAE,QAAQ;6BACrB;yBACF,EACD,KAAK,CAAC,UAAU,CACjB;wBACH,CAAC,CAAC,IAAI;iBACT,CACF;gBACD,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE;oBAC5D,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;iBACvC,CAAC;aACH,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type SlotsType } from 'vue';
|
|
2
|
+
import { type TabOption, type TabPanelProps } from '@getcortexlabs/mavis-core';
|
|
3
|
+
export declare const MTabs: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
width: {
|
|
5
|
+
type: import("vue").PropType<import("@getcortexlabs/mavis-core").Dimension>;
|
|
6
|
+
default: undefined;
|
|
7
|
+
};
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: import("vue").PropType<import("@getcortexlabs/mavis-core").ChoiceValue | null>;
|
|
10
|
+
default: null;
|
|
11
|
+
};
|
|
12
|
+
tabs: {
|
|
13
|
+
type: import("vue").PropType<readonly TabOption[]>;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
label: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
required: true;
|
|
19
|
+
};
|
|
20
|
+
disabled: BooleanConstructor;
|
|
21
|
+
grow: {
|
|
22
|
+
type: NumberConstructor;
|
|
23
|
+
default: number;
|
|
24
|
+
};
|
|
25
|
+
shrink: {
|
|
26
|
+
type: NumberConstructor;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
29
|
+
keepAlive: BooleanConstructor;
|
|
30
|
+
id: {
|
|
31
|
+
type: StringConstructor;
|
|
32
|
+
default: undefined;
|
|
33
|
+
};
|
|
34
|
+
accessibilityHidden: {
|
|
35
|
+
type: BooleanConstructor;
|
|
36
|
+
default: undefined;
|
|
37
|
+
};
|
|
38
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
41
|
+
'update:modelValue': (value: import("@getcortexlabs/mavis-core").ChoiceValue) => boolean;
|
|
42
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
43
|
+
width: {
|
|
44
|
+
type: import("vue").PropType<import("@getcortexlabs/mavis-core").Dimension>;
|
|
45
|
+
default: undefined;
|
|
46
|
+
};
|
|
47
|
+
modelValue: {
|
|
48
|
+
type: import("vue").PropType<import("@getcortexlabs/mavis-core").ChoiceValue | null>;
|
|
49
|
+
default: null;
|
|
50
|
+
};
|
|
51
|
+
tabs: {
|
|
52
|
+
type: import("vue").PropType<readonly TabOption[]>;
|
|
53
|
+
required: true;
|
|
54
|
+
};
|
|
55
|
+
label: {
|
|
56
|
+
type: StringConstructor;
|
|
57
|
+
required: true;
|
|
58
|
+
};
|
|
59
|
+
disabled: BooleanConstructor;
|
|
60
|
+
grow: {
|
|
61
|
+
type: NumberConstructor;
|
|
62
|
+
default: number;
|
|
63
|
+
};
|
|
64
|
+
shrink: {
|
|
65
|
+
type: NumberConstructor;
|
|
66
|
+
default: undefined;
|
|
67
|
+
};
|
|
68
|
+
keepAlive: BooleanConstructor;
|
|
69
|
+
id: {
|
|
70
|
+
type: StringConstructor;
|
|
71
|
+
default: undefined;
|
|
72
|
+
};
|
|
73
|
+
accessibilityHidden: {
|
|
74
|
+
type: BooleanConstructor;
|
|
75
|
+
default: undefined;
|
|
76
|
+
};
|
|
77
|
+
}>> & Readonly<{
|
|
78
|
+
"onUpdate:modelValue"?: ((value: import("@getcortexlabs/mavis-core").ChoiceValue) => any) | undefined;
|
|
79
|
+
}>, {
|
|
80
|
+
width: import("@getcortexlabs/mavis-core").Dimension;
|
|
81
|
+
grow: number;
|
|
82
|
+
shrink: number;
|
|
83
|
+
id: string;
|
|
84
|
+
accessibilityHidden: boolean;
|
|
85
|
+
disabled: boolean;
|
|
86
|
+
modelValue: import("@getcortexlabs/mavis-core").ChoiceValue | null;
|
|
87
|
+
keepAlive: boolean;
|
|
88
|
+
}, SlotsType<{
|
|
89
|
+
default: TabPanelProps;
|
|
90
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
91
|
+
//# sourceMappingURL=MTabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MTabs.d.ts","sourceRoot":"","sources":["../../src/components/MTabs.ts"],"names":[],"mappings":"AACA,OAAO,EAcL,KAAK,SAAS,EACf,MAAM,KAAK,CAAA;AACZ,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAA;AAYlC,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAKsB,aAAa;yEAyOnD,CAAA"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { fontFamily } from '@getcortexlabs/mavis-core';
|
|
2
|
+
import { computed, KeepAlive, defineComponent, h, mergeProps, nextTick, onBeforeUnmount, onActivated, onDeactivated, onMounted, ref, useId, watch, } from 'vue';
|
|
3
|
+
import { canChoose, choiceKey, tabFocusTarget, validateTabs, } from '@getcortexlabs/mavis-core';
|
|
4
|
+
import { useButtonAction, tabsProps, tabsEmits, useMavisTheme } from '@getcortexlabs/mavis-core/vue';
|
|
5
|
+
import { MColumn } from './layout.js';
|
|
6
|
+
const TabPanel = defineComponent({
|
|
7
|
+
name: 'MTabPanel',
|
|
8
|
+
setup(_props, { slots }) {
|
|
9
|
+
useButtonAction();
|
|
10
|
+
return () => h('div', {}, slots.default?.());
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
export const MTabs = defineComponent({
|
|
14
|
+
name: 'MTabs',
|
|
15
|
+
inheritAttrs: false,
|
|
16
|
+
props: tabsProps,
|
|
17
|
+
emits: tabsEmits,
|
|
18
|
+
slots: Object,
|
|
19
|
+
setup(props, { attrs, emit, slots }) {
|
|
20
|
+
const { theme } = useMavisTheme();
|
|
21
|
+
const generated = `m-tabs-${useId()}`;
|
|
22
|
+
const controls = new Map();
|
|
23
|
+
const track = ref(), scroller = ref();
|
|
24
|
+
const marker = ref();
|
|
25
|
+
const focusValue = ref(props.modelValue);
|
|
26
|
+
const selected = computed(() => {
|
|
27
|
+
validateTabs(props.tabs, props.modelValue, props.label);
|
|
28
|
+
return props.tabs.find((tab) => tab.value === props.modelValue);
|
|
29
|
+
});
|
|
30
|
+
let observer;
|
|
31
|
+
let frame;
|
|
32
|
+
let alive = false;
|
|
33
|
+
function reveal(button) {
|
|
34
|
+
if (!scroller.value)
|
|
35
|
+
return;
|
|
36
|
+
const bounds = button.getBoundingClientRect(), viewport = scroller.value.getBoundingClientRect();
|
|
37
|
+
const delta = bounds.left < viewport.left
|
|
38
|
+
? bounds.left - viewport.left
|
|
39
|
+
: bounds.right > viewport.right
|
|
40
|
+
? bounds.right - viewport.right
|
|
41
|
+
: 0;
|
|
42
|
+
if (delta)
|
|
43
|
+
scroller.value.scrollBy({ left: delta, behavior: 'instant' });
|
|
44
|
+
}
|
|
45
|
+
function measure(revealSelection = false) {
|
|
46
|
+
if (!alive)
|
|
47
|
+
return;
|
|
48
|
+
if (frame !== undefined)
|
|
49
|
+
cancelAnimationFrame(frame);
|
|
50
|
+
frame = requestAnimationFrame(() => {
|
|
51
|
+
frame = undefined;
|
|
52
|
+
const button = selected.value && controls.get(choiceKey(selected.value.value));
|
|
53
|
+
marker.value = button ? { left: button.offsetLeft, width: button.offsetWidth } : undefined;
|
|
54
|
+
if (button && revealSelection)
|
|
55
|
+
reveal(button);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function observe() {
|
|
59
|
+
observer?.disconnect();
|
|
60
|
+
if (!alive)
|
|
61
|
+
return;
|
|
62
|
+
if (track.value)
|
|
63
|
+
observer?.observe(track.value);
|
|
64
|
+
if (scroller.value)
|
|
65
|
+
observer?.observe(scroller.value);
|
|
66
|
+
for (const button of controls.values())
|
|
67
|
+
observer?.observe(button);
|
|
68
|
+
measure(true);
|
|
69
|
+
}
|
|
70
|
+
const start = () => {
|
|
71
|
+
if (alive)
|
|
72
|
+
return;
|
|
73
|
+
alive = true;
|
|
74
|
+
observer = new ResizeObserver(() => measure(true));
|
|
75
|
+
observe();
|
|
76
|
+
};
|
|
77
|
+
const stop = () => {
|
|
78
|
+
alive = false;
|
|
79
|
+
observer?.disconnect();
|
|
80
|
+
if (frame !== undefined)
|
|
81
|
+
cancelAnimationFrame(frame);
|
|
82
|
+
frame = undefined;
|
|
83
|
+
};
|
|
84
|
+
onMounted(start);
|
|
85
|
+
onActivated(start);
|
|
86
|
+
onDeactivated(stop);
|
|
87
|
+
watch(() => [props.modelValue, props.tabs, props.disabled], () => {
|
|
88
|
+
const focused = typeof document !== 'undefined' ? document.activeElement : null;
|
|
89
|
+
const ownedFocus = focused && track.value?.contains(focused);
|
|
90
|
+
focusValue.value = props.modelValue;
|
|
91
|
+
void nextTick(() => {
|
|
92
|
+
observe();
|
|
93
|
+
if (!alive || !ownedFocus || props.disabled)
|
|
94
|
+
return;
|
|
95
|
+
const stillAvailable = props.tabs.some((tab) => !tab.disabled && controls.get(choiceKey(tab.value)) === focused);
|
|
96
|
+
if (stillAvailable)
|
|
97
|
+
return;
|
|
98
|
+
const next = props.tabs.find((tab) => !tab.disabled && tab.value === props.modelValue) ??
|
|
99
|
+
props.tabs.find((tab) => !tab.disabled);
|
|
100
|
+
const button = next && controls.get(choiceKey(next.value));
|
|
101
|
+
button?.focus({ preventScroll: true });
|
|
102
|
+
if (button)
|
|
103
|
+
reveal(button);
|
|
104
|
+
});
|
|
105
|
+
}, { deep: true, flush: 'pre' });
|
|
106
|
+
onBeforeUnmount(() => {
|
|
107
|
+
alive = false;
|
|
108
|
+
observer?.disconnect();
|
|
109
|
+
if (frame !== undefined)
|
|
110
|
+
cancelAnimationFrame(frame);
|
|
111
|
+
controls.clear();
|
|
112
|
+
});
|
|
113
|
+
function request(tab) {
|
|
114
|
+
if (canChoose(tab, props.modelValue, props.disabled))
|
|
115
|
+
emit('update:modelValue', tab.value);
|
|
116
|
+
}
|
|
117
|
+
function keydown(event, tab) {
|
|
118
|
+
if (props.disabled || tab.disabled || event.altKey || event.ctrlKey || event.metaKey)
|
|
119
|
+
return;
|
|
120
|
+
const rtl = track.value && getComputedStyle(track.value).direction === 'rtl';
|
|
121
|
+
const next = tabFocusTarget(props.tabs, tab.value, event.key, rtl);
|
|
122
|
+
if (!next)
|
|
123
|
+
return;
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
focusValue.value = next.value;
|
|
126
|
+
const button = controls.get(choiceKey(next.value));
|
|
127
|
+
button?.focus({ preventScroll: true });
|
|
128
|
+
if (button)
|
|
129
|
+
reveal(button);
|
|
130
|
+
}
|
|
131
|
+
return () => {
|
|
132
|
+
const active = selected.value;
|
|
133
|
+
const { colors, typography } = theme.value;
|
|
134
|
+
const id = props.id ?? generated;
|
|
135
|
+
const tabId = (tab) => `${id}-${encodeURIComponent(choiceKey(tab.value))}`;
|
|
136
|
+
const focus = props.tabs.find((tab) => !tab.disabled && tab.value === focusValue.value) ??
|
|
137
|
+
props.tabs.find((tab) => !tab.disabled);
|
|
138
|
+
return h(MColumn, mergeProps(attrs, {
|
|
139
|
+
id,
|
|
140
|
+
width: props.width,
|
|
141
|
+
grow: props.grow,
|
|
142
|
+
shrink: props.shrink,
|
|
143
|
+
accessibilityHidden: props.accessibilityHidden,
|
|
144
|
+
gap: 'md',
|
|
145
|
+
}), {
|
|
146
|
+
default: () => [
|
|
147
|
+
h('div', { ref: scroller, class: 'm-tabs-scroll', style: { '--m-focus': colors.primary } }, [
|
|
148
|
+
h('div', {
|
|
149
|
+
ref: track,
|
|
150
|
+
class: 'm-tabs-track',
|
|
151
|
+
role: 'tablist',
|
|
152
|
+
'aria-label': props.label,
|
|
153
|
+
'aria-orientation': 'horizontal',
|
|
154
|
+
'aria-disabled': props.disabled || undefined,
|
|
155
|
+
style: {
|
|
156
|
+
borderBottomColor: colors.border,
|
|
157
|
+
fontFamily: fontFamily(theme.value.typography.body.fontFamily, 'web'),
|
|
158
|
+
fontSize: `${typography.body.fontSize}px`,
|
|
159
|
+
},
|
|
160
|
+
}, [
|
|
161
|
+
...props.tabs.map((tab) => h('button', {
|
|
162
|
+
key: choiceKey(tab.value),
|
|
163
|
+
id: tabId(tab),
|
|
164
|
+
class: 'm-tab',
|
|
165
|
+
type: 'button',
|
|
166
|
+
role: 'tab',
|
|
167
|
+
ref: (element) => {
|
|
168
|
+
if (element)
|
|
169
|
+
controls.set(choiceKey(tab.value), element);
|
|
170
|
+
else
|
|
171
|
+
controls.delete(choiceKey(tab.value));
|
|
172
|
+
},
|
|
173
|
+
disabled: props.disabled || tab.disabled,
|
|
174
|
+
tabindex: !props.disabled && focus?.value === tab.value ? 0 : -1,
|
|
175
|
+
'aria-selected': active?.value === tab.value,
|
|
176
|
+
'aria-controls': active?.value === tab.value ? `${id}-panel` : undefined,
|
|
177
|
+
style: {
|
|
178
|
+
color: active?.value === tab.value ? colors.primary : colors.muted,
|
|
179
|
+
'--m-tab-active': colors.primarySoft,
|
|
180
|
+
},
|
|
181
|
+
onFocus: () => {
|
|
182
|
+
focusValue.value = tab.value;
|
|
183
|
+
},
|
|
184
|
+
onClick: () => request(tab),
|
|
185
|
+
onKeydown: (event) => keydown(event, tab),
|
|
186
|
+
}, tab.label)),
|
|
187
|
+
h('span', {
|
|
188
|
+
class: 'm-tabs-indicator',
|
|
189
|
+
'aria-hidden': 'true',
|
|
190
|
+
style: {
|
|
191
|
+
backgroundColor: colors.primary,
|
|
192
|
+
opacity: marker.value ? 1 : 0,
|
|
193
|
+
width: `${marker.value?.width ?? 0}px`,
|
|
194
|
+
transform: `translateX(${marker.value?.left ?? 0}px)`,
|
|
195
|
+
},
|
|
196
|
+
}),
|
|
197
|
+
]),
|
|
198
|
+
]),
|
|
199
|
+
props.keepAlive
|
|
200
|
+
? props.tabs.map((tab) => h(KeepAlive, { key: choiceKey(tab.value), max: 1 }, {
|
|
201
|
+
default: () => active?.value === tab.value
|
|
202
|
+
? h(TabPanel, {
|
|
203
|
+
id: `${id}-panel`,
|
|
204
|
+
class: 'm-tab-panel',
|
|
205
|
+
role: 'tabpanel',
|
|
206
|
+
tabindex: 0,
|
|
207
|
+
'aria-labelledby': tabId(tab),
|
|
208
|
+
style: { '--m-focus': colors.primary },
|
|
209
|
+
}, { default: () => slots.default?.({ value: tab.value }) })
|
|
210
|
+
: null,
|
|
211
|
+
}))
|
|
212
|
+
: active
|
|
213
|
+
? h('div', {
|
|
214
|
+
key: choiceKey(active.value),
|
|
215
|
+
id: `${id}-panel`,
|
|
216
|
+
class: 'm-tab-panel',
|
|
217
|
+
role: 'tabpanel',
|
|
218
|
+
tabindex: 0,
|
|
219
|
+
'aria-labelledby': tabId(active),
|
|
220
|
+
style: { '--m-focus': colors.primary },
|
|
221
|
+
}, slots.default?.({ value: active.value }))
|
|
222
|
+
: null,
|
|
223
|
+
],
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
//# sourceMappingURL=MTabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MTabs.js","sourceRoot":"","sources":["../../src/components/MTabs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EACL,QAAQ,EACR,SAAS,EACT,eAAe,EACf,CAAC,EACD,UAAU,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACX,aAAa,EACb,SAAS,EACT,GAAG,EACH,KAAK,EACL,KAAK,GAEN,MAAM,KAAK,CAAA;AACZ,OAAO,EACL,SAAS,EACT,SAAS,EACT,cAAc,EACd,YAAY,GAGb,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AACpG,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,MAAM,QAAQ,GAAG,eAAe,CAAC;IAC/B,IAAI,EAAE,WAAW;IACjB,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE;QACrB,eAAe,EAAE,CAAA;QACjB,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IAC9C,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAC;IACnC,IAAI,EAAE,OAAO;IACb,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,MAA+C;IACtD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;QACjC,MAAM,EAAE,KAAK,EAAE,GAAG,aAA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Aa;gCACpB,IAAI,EAAE,UAAU;gCAChB,QAAQ,EAAE,CAAC;gCACX,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC;gCAChC,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE;6BACvC,EACD,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CACzC;4BACH,CAAC,CAAC,IAAI;iBACX;aACF,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -4,9 +4,9 @@ export declare const MText: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
4
4
|
default: undefined;
|
|
5
5
|
};
|
|
6
6
|
as: {
|
|
7
|
-
type: import("vue").PropType<"
|
|
8
|
-
default: "
|
|
9
|
-
validator: (value: "
|
|
7
|
+
type: import("vue").PropType<"h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span">;
|
|
8
|
+
default: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span";
|
|
9
|
+
validator: (value: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span") => boolean;
|
|
10
10
|
};
|
|
11
11
|
variant: {
|
|
12
12
|
type: import("vue").PropType<"display" | "title" | "heading" | "body" | "caption" | "overline">;
|
|
@@ -47,6 +47,10 @@ export declare const MText: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
47
47
|
type: BooleanConstructor;
|
|
48
48
|
default: undefined;
|
|
49
49
|
};
|
|
50
|
+
weight: {
|
|
51
|
+
type: import("vue").PropType<import("@getcortexlabs/mavis-core").FontWeight>;
|
|
52
|
+
default: undefined;
|
|
53
|
+
};
|
|
50
54
|
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
51
55
|
[key: string]: any;
|
|
52
56
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -55,9 +59,9 @@ export declare const MText: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
55
59
|
default: undefined;
|
|
56
60
|
};
|
|
57
61
|
as: {
|
|
58
|
-
type: import("vue").PropType<"
|
|
59
|
-
default: "
|
|
60
|
-
validator: (value: "
|
|
62
|
+
type: import("vue").PropType<"h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span">;
|
|
63
|
+
default: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span";
|
|
64
|
+
validator: (value: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span") => boolean;
|
|
61
65
|
};
|
|
62
66
|
variant: {
|
|
63
67
|
type: import("vue").PropType<"display" | "title" | "heading" | "body" | "caption" | "overline">;
|
|
@@ -98,7 +102,12 @@ export declare const MText: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
98
102
|
type: BooleanConstructor;
|
|
99
103
|
default: undefined;
|
|
100
104
|
};
|
|
105
|
+
weight: {
|
|
106
|
+
type: import("vue").PropType<import("@getcortexlabs/mavis-core").FontWeight>;
|
|
107
|
+
default: undefined;
|
|
108
|
+
};
|
|
101
109
|
}>> & Readonly<{}>, {
|
|
110
|
+
text: string;
|
|
102
111
|
grow: number;
|
|
103
112
|
shrink: number;
|
|
104
113
|
id: string;
|
|
@@ -106,9 +115,9 @@ export declare const MText: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
106
115
|
accessibilityHidden: boolean;
|
|
107
116
|
align: "center" | "left" | "right";
|
|
108
117
|
wrap: boolean;
|
|
109
|
-
|
|
110
|
-
as: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span";
|
|
111
|
-
variant: "body" | "caption" | "title" | "display" | "heading" | "overline";
|
|
118
|
+
weight: import("@getcortexlabs/mavis-core").FontWeight;
|
|
112
119
|
tone: keyof import("@getcortexlabs/mavis-core").Palette;
|
|
120
|
+
variant: "body" | "caption" | "title" | "display" | "heading" | "overline";
|
|
121
|
+
as: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span";
|
|
113
122
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
114
123
|
//# sourceMappingURL=MText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MText.d.ts","sourceRoot":"","sources":["../../src/components/MText.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,KAAK
|
|
1
|
+
{"version":3,"file":"MText.d.ts","sourceRoot":"","sources":["../../src/components/MText.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAyDhB,CAAA"}
|
package/dist/components/MText.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, h, mergeProps } from 'vue';
|
|
2
|
-
import { textProps, useMavisTheme,
|
|
3
|
-
import { nonNegative } from '@getcortexlabs/mavis-core';
|
|
2
|
+
import { textProps, useMavisTheme, inlineContent, useDefaultShrink, viewAttrs, } from '@getcortexlabs/mavis-core/vue';
|
|
3
|
+
import { fontFamily, nonNegative, validateWeight } from '@getcortexlabs/mavis-core';
|
|
4
4
|
import { webAttrs } from '../style.js';
|
|
5
5
|
export const MText = defineComponent({
|
|
6
6
|
name: 'MText',
|
|
@@ -11,13 +11,18 @@ export const MText = defineComponent({
|
|
|
11
11
|
const shrink = useDefaultShrink();
|
|
12
12
|
return () => {
|
|
13
13
|
const type = theme.value.typography[props.variant];
|
|
14
|
+
const runs = props.text !== undefined ? [{ text: props.text }] : inlineContent(slots.default?.());
|
|
14
15
|
return h(props.as, mergeProps({
|
|
16
|
+
class: 'm-text',
|
|
15
17
|
style: {
|
|
16
18
|
margin: 0,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
fontFamily: `var(--m-text-font-family, ${fontFamily(type.fontFamily, 'web')})`,
|
|
20
|
+
fontSize: `var(--m-text-font-size, ${type.fontSize}px)`,
|
|
21
|
+
fontWeight: props.weight
|
|
22
|
+
? validateWeight(props.weight)
|
|
23
|
+
: `var(--m-text-font-weight, ${type.fontWeight})`,
|
|
24
|
+
letterSpacing: `var(--m-text-letter-spacing, ${type.letterSpacing}em)`,
|
|
25
|
+
lineHeight: `var(--m-text-line-height, ${type.lineHeight})`,
|
|
21
26
|
color: theme.value.colors[props.tone],
|
|
22
27
|
textAlign: props.align,
|
|
23
28
|
whiteSpace: props.wrap ? 'normal' : 'nowrap',
|
|
@@ -26,7 +31,21 @@ export const MText = defineComponent({
|
|
|
26
31
|
flexShrink: nonNegative(props.shrink ?? shrink, 'shrink'),
|
|
27
32
|
minWidth: 0,
|
|
28
33
|
},
|
|
29
|
-
}, webAttrs({ ...attrs, ...viewAttrs(props) })),
|
|
34
|
+
}, webAttrs({ ...attrs, ...viewAttrs(props) })), runs.every((run) => !run.weight && !run.tone && !run.strong && !run.italic)
|
|
35
|
+
? runs.map((run) => run.text).join('')
|
|
36
|
+
: runs.map((run) => {
|
|
37
|
+
if (!run.weight && !run.tone && !run.strong && !run.italic)
|
|
38
|
+
return run.text;
|
|
39
|
+
if (run.tone && !(run.tone in theme.value.colors))
|
|
40
|
+
throw new RangeError(`Unknown text tone: ${run.tone}`);
|
|
41
|
+
const content = run.strong && run.italic ? h('em', {}, run.text) : run.text;
|
|
42
|
+
return h(run.strong ? 'strong' : run.italic ? 'em' : 'span', {
|
|
43
|
+
style: {
|
|
44
|
+
fontWeight: run.weight ?? 'inherit',
|
|
45
|
+
color: run.tone ? theme.value.colors[run.tone] : undefined,
|
|
46
|
+
},
|
|
47
|
+
}, content);
|
|
48
|
+
}));
|
|
30
49
|
};
|
|
31
50
|
},
|
|
32
51
|
});
|