@vizejs/fresco 0.101.0 → 0.104.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import { $ as FormProps, A as TableColumn, At as Box, B as TimerProps, C as Menu, Ct as GridProps, D as TreeNode, Dt as VStack, E as Tree, Et as StackProps, F as Tooltip, G as AlertProps, H as BadgeProps, I as TooltipPosition, J as ProgressBarProps, K as AlertType, L as TooltipProps, M as List, N as ListItem, O as TreeProps, Ot as Divider, P as ListProps, Q as FormField, R as Timer, S as TabsProps, St as Grid, T as MenuProps, Tt as Stack, U as BadgeVariant, V as Badge, W as Alert, X as SpinnerProps, Y as Spinner, Z as Form, _ as Breadcrumb, _t as CodeProps, a as KeyHintProps, at as Checkbox, b as Tab, bt as Card, c as StatusBar, ct as SelectOption, d as Modal, dt as TextAreaProps, et as Confirm, f as ModalProps, ft as TextInput, g as StepperProps, gt as Code, h as Stepper, ht as LinkProps, i as KeyHint, it as RadioOption, j as TableProps, jt as BoxProps, k as Table, kt as DividerProps, l as StatusBarItem, lt as SelectProps, m as StepStatus, mt as Link, n as AvatarProps, nt as RadioGroup, o as Header, ot as CheckboxProps, p as Step, pt as TextInputProps, q as ProgressBar, r as KeyBinding, rt as RadioGroupProps, s as HeaderProps, st as Select, t as Avatar, tt as ConfirmProps, u as StatusBarProps, ut as TextArea, v as BreadcrumbItem, vt as Text, w as MenuItem, wt as HStack, x as Tabs, xt as CardProps, y as BreadcrumbProps, yt as TextProps, z as TimerMode } from "../index-COlY8bRB.mjs";
2
- export { Alert, AlertProps, AlertType, Avatar, AvatarProps, Badge, BadgeProps, BadgeVariant, Box, BoxProps, Breadcrumb, BreadcrumbItem, BreadcrumbProps, Card, CardProps, Checkbox, CheckboxProps, Code, CodeProps, Confirm, ConfirmProps, Divider, DividerProps, Form, FormField, FormProps, Grid, GridProps, HStack, Header, HeaderProps, KeyBinding, KeyHint, KeyHintProps, Link, LinkProps, List, ListItem, ListProps, Menu, MenuItem, MenuProps, Modal, ModalProps, ProgressBar, ProgressBarProps, RadioGroup, RadioGroupProps, RadioOption, Select, SelectOption, SelectProps, Spinner, SpinnerProps, Stack, StackProps, StatusBar, StatusBarItem, StatusBarProps, Step, StepStatus, Stepper, StepperProps, Tab, Table, TableColumn, TableProps, Tabs, TabsProps, Text, TextArea, TextAreaProps, TextInput, TextInputProps, TextProps, Timer, TimerMode, TimerProps, Tooltip, TooltipPosition, TooltipProps, Tree, TreeNode, TreeProps, VStack };
1
+ import { $ as FormProps, A as TableColumn, At as HStack, B as TimerProps, C as Menu, Ct as NewlineProps, D as TreeNode, Dt as CardProps, E as Tree, Et as Card, F as Tooltip, Ft as DividerProps, G as AlertProps, H as BadgeProps, I as TooltipPosition, It as Spacer, J as ProgressBarProps, K as AlertType, L as TooltipProps, Lt as Box, M as List, Mt as StackProps, N as ListItem, Nt as VStack, O as TreeProps, Ot as Grid, P as ListProps, Pt as Divider, Q as FormField, R as Timer, Rt as BoxProps, S as TabsProps, St as Newline, T as MenuProps, Tt as TextProps, U as BadgeVariant, V as Badge, W as Alert, X as SpinnerProps, Y as Spinner, Z as Form, _ as Breadcrumb, _t as CodeProps, a as KeyHintProps, at as Checkbox, b as Tab, bt as Static, c as StatusBar, ct as SelectOption, d as Modal, dt as TextAreaProps, et as Confirm, f as ModalProps, ft as TextInput, g as StepperProps, gt as Code, h as Stepper, ht as LinkProps, i as KeyHint, it as RadioOption, j as TableProps, jt as Stack, k as Table, kt as GridProps, l as StatusBarItem, lt as SelectProps, m as StepStatus, mt as Link, n as AvatarProps, nt as RadioGroup, o as Header, ot as CheckboxProps, p as Step, pt as TextInputProps, q as ProgressBar, r as KeyBinding, rt as RadioGroupProps, s as HeaderProps, st as Select, t as Avatar, tt as ConfirmProps, u as StatusBarProps, ut as TextArea, v as BreadcrumbItem, vt as Transform, w as MenuItem, wt as Text, x as Tabs, xt as StaticProps, y as BreadcrumbProps, yt as TransformProps, z as TimerMode } from "../index-BPZVmkyv.mjs";
2
+ export { Alert, AlertProps, AlertType, Avatar, AvatarProps, Badge, BadgeProps, BadgeVariant, Box, BoxProps, Breadcrumb, BreadcrumbItem, BreadcrumbProps, Card, CardProps, Checkbox, CheckboxProps, Code, CodeProps, Confirm, ConfirmProps, Divider, DividerProps, Form, FormField, FormProps, Grid, GridProps, HStack, Header, HeaderProps, KeyBinding, KeyHint, KeyHintProps, Link, LinkProps, List, ListItem, ListProps, Menu, MenuItem, MenuProps, Modal, ModalProps, Newline, NewlineProps, ProgressBar, ProgressBarProps, RadioGroup, RadioGroupProps, RadioOption, Select, SelectOption, SelectProps, Spacer, Spinner, SpinnerProps, Stack, StackProps, Static, StaticProps, StatusBar, StatusBarItem, StatusBarProps, Step, StepStatus, Stepper, StepperProps, Tab, Table, TableColumn, TableProps, Tabs, TabsProps, Text, TextArea, TextAreaProps, TextInput, TextInputProps, TextProps, Timer, TimerMode, TimerProps, Tooltip, TooltipPosition, TooltipProps, Transform, TransformProps, Tree, TreeNode, TreeProps, VStack };
@@ -1,2 +1,2 @@
1
- import { A as Grid, C as Select, D as Code, E as Link, F as Box, M as Stack, N as VStack, O as Text, P as Divider, S as Checkbox, T as TextInput, _ as ProgressBar, a as Modal, b as Confirm, c as Tabs, d as Table, f as List, g as Alert, h as Badge, i as StatusBar, j as HStack, k as Card, l as Menu, m as Timer, n as KeyHint, o as Stepper, p as Tooltip, r as Header, s as Breadcrumb, t as Avatar, u as Tree, v as Spinner, w as TextArea, x as RadioGroup, y as Form } from "../components-B5VXjX9s.mjs";
2
- export { Alert, Avatar, Badge, Box, Breadcrumb, Card, Checkbox, Code, Confirm, Divider, Form, Grid, HStack, Header, KeyHint, Link, List, Menu, Modal, ProgressBar, RadioGroup, Select, Spinner, Stack, StatusBar, Stepper, Table, Tabs, Text, TextArea, TextInput, Timer, Tooltip, Tree, VStack };
1
+ import { A as Newline, C as Select, D as Code, E as Link, F as Stack, I as VStack, L as Divider, M as Card, N as Grid, O as Transform, P as HStack, R as Spacer, S as Checkbox, T as TextInput, _ as ProgressBar, a as Modal, b as Confirm, c as Tabs, d as Table, f as List, g as Alert, h as Badge, i as StatusBar, j as Text, k as Static, l as Menu, m as Timer, n as KeyHint, o as Stepper, p as Tooltip, r as Header, s as Breadcrumb, t as Avatar, u as Tree, v as Spinner, w as TextArea, x as RadioGroup, y as Form, z as Box } from "../components-BFV7PBp6.mjs";
2
+ export { Alert, Avatar, Badge, Box, Breadcrumb, Card, Checkbox, Code, Confirm, Divider, Form, Grid, HStack, Header, KeyHint, Link, List, Menu, Modal, Newline, ProgressBar, RadioGroup, Select, Spacer, Spinner, Stack, Static, StatusBar, Stepper, Table, Tabs, Text, TextArea, TextInput, Timer, Tooltip, Transform, Tree, VStack };
@@ -1,25 +1,40 @@
1
- import { t as useInput } from "./useInput-CbggNZUF.mjs";
1
+ import { i as useIsScreenReaderEnabled, t as useInput } from "./useInput-DrlvpGkS.mjs";
2
2
  import { computed, defineComponent, h, onMounted, onUnmounted, ref, watch } from "@vue/runtime-core";
3
3
  //#region src/components/Box.ts
4
4
  /**
5
5
  * Box Component - Container with flexbox layout
6
6
  */
7
+ const dimensionProp = [Number, String];
8
+ function normalizeBorderStyle(style) {
9
+ if (style === "round") return "rounded";
10
+ if (style === "bold") return "heavy";
11
+ return style;
12
+ }
7
13
  const Box = defineComponent({
8
14
  name: "Box",
9
15
  props: {
16
+ display: String,
17
+ position: String,
18
+ top: dimensionProp,
19
+ right: dimensionProp,
20
+ bottom: dimensionProp,
21
+ left: dimensionProp,
10
22
  flexDirection: String,
11
23
  flexWrap: String,
12
24
  justifyContent: String,
13
25
  alignItems: String,
14
26
  alignSelf: String,
27
+ alignContent: String,
15
28
  flexGrow: Number,
16
29
  flexShrink: Number,
17
- width: [Number, String],
18
- height: [Number, String],
19
- minWidth: [Number, String],
20
- minHeight: [Number, String],
21
- maxWidth: [Number, String],
22
- maxHeight: [Number, String],
30
+ flexBasis: dimensionProp,
31
+ width: dimensionProp,
32
+ height: dimensionProp,
33
+ minWidth: dimensionProp,
34
+ minHeight: dimensionProp,
35
+ maxWidth: dimensionProp,
36
+ maxHeight: dimensionProp,
37
+ aspectRatio: Number,
23
38
  padding: Number,
24
39
  paddingX: Number,
25
40
  paddingY: Number,
@@ -35,46 +50,120 @@ const Box = defineComponent({
35
50
  marginBottom: Number,
36
51
  marginLeft: Number,
37
52
  gap: Number,
53
+ columnGap: Number,
54
+ rowGap: Number,
55
+ overflow: String,
56
+ overflowX: String,
57
+ overflowY: String,
38
58
  border: String,
59
+ borderStyle: String,
60
+ borderTop: Boolean,
61
+ borderRight: Boolean,
62
+ borderBottom: Boolean,
63
+ borderLeft: Boolean,
64
+ borderColor: String,
65
+ borderTopColor: String,
66
+ borderRightColor: String,
67
+ borderBottomColor: String,
68
+ borderLeftColor: String,
69
+ borderDimColor: Boolean,
70
+ borderTopDimColor: Boolean,
71
+ borderRightDimColor: Boolean,
72
+ borderBottomDimColor: Boolean,
73
+ borderLeftDimColor: Boolean,
74
+ borderBackgroundColor: String,
75
+ borderTopBackgroundColor: String,
76
+ borderRightBackgroundColor: String,
77
+ borderBottomBackgroundColor: String,
78
+ borderLeftBackgroundColor: String,
39
79
  fg: String,
40
- bg: String
80
+ color: String,
81
+ bg: String,
82
+ backgroundColor: String,
83
+ "aria-label": String,
84
+ "aria-hidden": Boolean,
85
+ "aria-role": String,
86
+ "aria-state": Object
41
87
  },
42
88
  setup(props, { slots }) {
89
+ const isScreenReaderEnabled = useIsScreenReaderEnabled();
43
90
  return () => {
91
+ if (isScreenReaderEnabled && props["aria-hidden"]) return null;
44
92
  const style = {};
45
- if (props.flexDirection) style.flex_direction = props.flexDirection;
46
- if (props.flexWrap) style.flex_wrap = props.flexWrap;
47
- if (props.justifyContent) style.justify_content = props.justifyContent;
48
- if (props.alignItems) style.align_items = props.alignItems;
49
- if (props.flexGrow !== void 0) style.flex_grow = props.flexGrow;
50
- if (props.flexShrink !== void 0) style.flex_shrink = props.flexShrink;
93
+ if (props.display) style.display = props.display;
94
+ if (props.position) style.position = props.position;
95
+ if (props.top !== void 0) style.top = String(props.top);
96
+ if (props.right !== void 0) style.right = String(props.right);
97
+ if (props.bottom !== void 0) style.bottom = String(props.bottom);
98
+ if (props.left !== void 0) style.left = String(props.left);
99
+ if (props.flexDirection) style.flexDirection = props.flexDirection;
100
+ if (props.flexWrap) style.flexWrap = props.flexWrap;
101
+ if (props.justifyContent) style.justifyContent = props.justifyContent;
102
+ if (props.alignItems) style.alignItems = props.alignItems;
103
+ if (props.alignSelf) style.alignSelf = props.alignSelf;
104
+ if (props.alignContent) style.alignContent = props.alignContent;
105
+ if (props.flexGrow !== void 0) style.flexGrow = props.flexGrow;
106
+ if (props.flexShrink !== void 0) style.flexShrink = props.flexShrink;
107
+ if (props.flexBasis !== void 0) style.flexBasis = String(props.flexBasis);
51
108
  if (props.width !== void 0) style.width = String(props.width);
52
109
  if (props.height !== void 0) style.height = String(props.height);
53
- if (props.minWidth !== void 0) style.min_width = String(props.minWidth);
54
- if (props.minHeight !== void 0) style.min_height = String(props.minHeight);
55
- if (props.maxWidth !== void 0) style.max_width = String(props.maxWidth);
56
- if (props.maxHeight !== void 0) style.max_height = String(props.maxHeight);
110
+ if (props.minWidth !== void 0) style.minWidth = String(props.minWidth);
111
+ if (props.minHeight !== void 0) style.minHeight = String(props.minHeight);
112
+ if (props.maxWidth !== void 0) style.maxWidth = String(props.maxWidth);
113
+ if (props.maxHeight !== void 0) style.maxHeight = String(props.maxHeight);
114
+ if (props.aspectRatio !== void 0) style.aspectRatio = props.aspectRatio;
57
115
  if (props.padding !== void 0) style.padding = props.padding;
58
- if (props.paddingTop !== void 0 || props.paddingY !== void 0) style.padding_top = props.paddingTop ?? props.paddingY ?? props.padding;
59
- if (props.paddingRight !== void 0 || props.paddingX !== void 0) style.padding_right = props.paddingRight ?? props.paddingX ?? props.padding;
60
- if (props.paddingBottom !== void 0 || props.paddingY !== void 0) style.padding_bottom = props.paddingBottom ?? props.paddingY ?? props.padding;
61
- if (props.paddingLeft !== void 0 || props.paddingX !== void 0) style.padding_left = props.paddingLeft ?? props.paddingX ?? props.padding;
116
+ if (props.paddingTop !== void 0 || props.paddingY !== void 0) style.paddingTop = props.paddingTop ?? props.paddingY ?? props.padding;
117
+ if (props.paddingRight !== void 0 || props.paddingX !== void 0) style.paddingRight = props.paddingRight ?? props.paddingX ?? props.padding;
118
+ if (props.paddingBottom !== void 0 || props.paddingY !== void 0) style.paddingBottom = props.paddingBottom ?? props.paddingY ?? props.padding;
119
+ if (props.paddingLeft !== void 0 || props.paddingX !== void 0) style.paddingLeft = props.paddingLeft ?? props.paddingX ?? props.padding;
62
120
  if (props.margin !== void 0) style.margin = props.margin;
63
- if (props.marginTop !== void 0 || props.marginY !== void 0) style.margin_top = props.marginTop ?? props.marginY ?? props.margin;
64
- if (props.marginRight !== void 0 || props.marginX !== void 0) style.margin_right = props.marginRight ?? props.marginX ?? props.margin;
65
- if (props.marginBottom !== void 0 || props.marginY !== void 0) style.margin_bottom = props.marginBottom ?? props.marginY ?? props.margin;
66
- if (props.marginLeft !== void 0 || props.marginX !== void 0) style.margin_left = props.marginLeft ?? props.marginX ?? props.margin;
121
+ if (props.marginTop !== void 0 || props.marginY !== void 0) style.marginTop = props.marginTop ?? props.marginY ?? props.margin;
122
+ if (props.marginRight !== void 0 || props.marginX !== void 0) style.marginRight = props.marginRight ?? props.marginX ?? props.margin;
123
+ if (props.marginBottom !== void 0 || props.marginY !== void 0) style.marginBottom = props.marginBottom ?? props.marginY ?? props.margin;
124
+ if (props.marginLeft !== void 0 || props.marginX !== void 0) style.marginLeft = props.marginLeft ?? props.marginX ?? props.margin;
67
125
  if (props.gap !== void 0) style.gap = props.gap;
126
+ if (props.columnGap !== void 0) style.columnGap = props.columnGap;
127
+ if (props.rowGap !== void 0) style.rowGap = props.rowGap;
128
+ if (props.overflow) style.overflow = props.overflow;
129
+ if (props.overflowX) style.overflowX = props.overflowX;
130
+ if (props.overflowY) style.overflowY = props.overflowY;
131
+ const children = isScreenReaderEnabled && props["aria-label"] ? [h("text", { text: props["aria-label"] })] : slots.default?.();
68
132
  return h("box", {
69
133
  style,
70
- border: props.border,
71
- fg: props.fg,
72
- bg: props.bg
73
- }, slots.default?.());
134
+ border: normalizeBorderStyle(props.borderStyle ?? props.border),
135
+ borderColor: props.borderColor,
136
+ borderTopColor: props.borderTopColor,
137
+ borderRightColor: props.borderRightColor,
138
+ borderBottomColor: props.borderBottomColor,
139
+ borderLeftColor: props.borderLeftColor,
140
+ borderDimColor: props.borderDimColor,
141
+ borderBackgroundColor: props.borderBackgroundColor,
142
+ fg: props.fg ?? props.color,
143
+ bg: props.bg ?? props.backgroundColor,
144
+ "aria-label": props["aria-label"],
145
+ "aria-hidden": props["aria-hidden"],
146
+ "aria-role": props["aria-role"],
147
+ "aria-state": props["aria-state"]
148
+ }, children);
74
149
  };
75
150
  }
76
151
  });
77
152
  //#endregion
153
+ //#region src/components/Spacer.ts
154
+ /**
155
+ * Spacer Component - flexible empty space along the parent main axis.
156
+ */
157
+ const Spacer = defineComponent({
158
+ name: "Spacer",
159
+ setup() {
160
+ return () => h("box", { style: {
161
+ flexGrow: 1,
162
+ flexShrink: 1
163
+ } });
164
+ }
165
+ });
166
+ //#endregion
78
167
  //#region src/components/Divider.ts
79
168
  /**
80
169
  * Divider Component - Horizontal or vertical divider line
@@ -317,6 +406,51 @@ const Card = defineComponent({
317
406
  }
318
407
  });
319
408
  //#endregion
409
+ //#region src/utils/text.ts
410
+ /**
411
+ * Unicode-aware text helpers shared by input and text components.
412
+ */
413
+ const segmenter = typeof Intl !== "undefined" && "Segmenter" in Intl ? new Intl.Segmenter(void 0, { granularity: "grapheme" }) : null;
414
+ function graphemes(value) {
415
+ if (!value) return [];
416
+ if (segmenter) return Array.from(segmenter.segment(value), (segment) => segment.segment);
417
+ return Array.from(value);
418
+ }
419
+ function graphemeLength(value) {
420
+ return graphemes(value).length;
421
+ }
422
+ function sliceGraphemes(value, start, end) {
423
+ return graphemes(value).slice(start, end).join("");
424
+ }
425
+ function insertAtGrapheme(value, index, text) {
426
+ return `${sliceGraphemes(value, 0, index)}${text}${sliceGraphemes(value, index)}`;
427
+ }
428
+ function deleteGraphemeBefore(value, index) {
429
+ if (index <= 0) return value;
430
+ return `${sliceGraphemes(value, 0, index - 1)}${sliceGraphemes(value, index)}`;
431
+ }
432
+ function deleteGraphemeAt(value, index) {
433
+ const length = graphemeLength(value);
434
+ if (index < 0 || index >= length) return value;
435
+ return `${sliceGraphemes(value, 0, index)}${sliceGraphemes(value, index + 1)}`;
436
+ }
437
+ function stringifyChildren(children) {
438
+ if (children == null || typeof children === "boolean") return "";
439
+ if (typeof children === "string" || typeof children === "number") return String(children);
440
+ if (Array.isArray(children)) return children.map((child) => stringifyChildren(child)).join("");
441
+ if (typeof children === "object") {
442
+ const vnode = children;
443
+ if ((typeof vnode.type === "string" ? vnode.type : vnode.type?.name) === "Newline") {
444
+ const count = typeof vnode.props?.count === "number" ? vnode.props.count : 1;
445
+ return "\n".repeat(Math.max(0, count));
446
+ }
447
+ if (typeof vnode.props?.text === "string" || typeof vnode.props?.text === "number") return String(vnode.props.text);
448
+ if (typeof vnode.props?.content === "string" || typeof vnode.props?.content === "number") return String(vnode.props.content);
449
+ return stringifyChildren(vnode.children);
450
+ }
451
+ return "";
452
+ }
453
+ //#endregion
320
454
  //#region src/components/Text.ts
321
455
  /**
322
456
  * Text Component - Text display
@@ -325,30 +459,38 @@ const Text = defineComponent({
325
459
  name: "Text",
326
460
  props: {
327
461
  content: String,
328
- wrap: Boolean,
462
+ wrap: [Boolean, String],
329
463
  fg: String,
464
+ color: String,
330
465
  bg: String,
466
+ backgroundColor: String,
331
467
  bold: Boolean,
332
468
  dim: Boolean,
469
+ dimColor: Boolean,
333
470
  italic: Boolean,
334
471
  underline: Boolean,
335
- strikethrough: Boolean
472
+ strikethrough: Boolean,
473
+ inverse: Boolean,
474
+ "aria-label": String,
475
+ "aria-hidden": Boolean
336
476
  },
337
477
  setup(props, { slots }) {
478
+ const isScreenReaderEnabled = useIsScreenReaderEnabled();
338
479
  return () => {
480
+ if (isScreenReaderEnabled && props["aria-hidden"]) return null;
339
481
  return h("text", {
340
- text: props.content ?? slots.default?.()?.map((vnode) => {
341
- if (typeof vnode.children === "string") return vnode.children;
342
- return "";
343
- }).join("") ?? "",
482
+ text: isScreenReaderEnabled && props["aria-label"] ? props["aria-label"] : props.content ?? stringifyChildren(slots.default?.()),
344
483
  wrap: props.wrap,
345
- fg: props.fg,
346
- bg: props.bg,
484
+ fg: props.fg ?? props.color,
485
+ bg: props.bg ?? props.backgroundColor,
347
486
  bold: props.bold,
348
- dim: props.dim,
487
+ dim: props.dim || props.dimColor,
349
488
  italic: props.italic,
350
489
  underline: props.underline,
351
- strikethrough: props.strikethrough
490
+ strikethrough: props.strikethrough,
491
+ inverse: props.inverse,
492
+ "aria-label": props["aria-label"],
493
+ "aria-hidden": props["aria-hidden"]
352
494
  });
353
495
  };
354
496
  }
@@ -404,6 +546,84 @@ defineComponent({
404
546
  }
405
547
  });
406
548
  //#endregion
549
+ //#region src/components/Newline.ts
550
+ /**
551
+ * Newline Component - inserts one or more newline characters inside Text.
552
+ */
553
+ const Newline = defineComponent({
554
+ name: "Newline",
555
+ props: { count: {
556
+ type: Number,
557
+ default: 1
558
+ } },
559
+ setup(props) {
560
+ return () => h("text", { text: "\n".repeat(Math.max(0, props.count)) });
561
+ }
562
+ });
563
+ //#endregion
564
+ //#region src/components/Static.ts
565
+ /**
566
+ * Static Component - renders stable items above the live area.
567
+ *
568
+ * The app renderer treats this component specially: newly added items are
569
+ * promoted into a persistent output region above the live frame.
570
+ */
571
+ const Static = defineComponent({
572
+ name: "Static",
573
+ props: {
574
+ items: {
575
+ type: Array,
576
+ default: () => []
577
+ },
578
+ style: Object
579
+ },
580
+ setup(props, { slots }) {
581
+ return () => {
582
+ const renderItem = slots.default;
583
+ return h("box", {
584
+ internal_static: true,
585
+ style: {
586
+ position: "absolute",
587
+ flexDirection: "column",
588
+ ...props.style
589
+ }
590
+ }, props.items.map((item, index) => h("box", {
591
+ key: index,
592
+ internal_static_item: true,
593
+ style: { flexDirection: "column" }
594
+ }, renderItem?.({
595
+ item,
596
+ index
597
+ }) ?? [])));
598
+ };
599
+ }
600
+ });
601
+ //#endregion
602
+ //#region src/components/Transform.ts
603
+ /**
604
+ * Transform Component - transforms stringified child output before rendering.
605
+ */
606
+ const Transform = defineComponent({
607
+ name: "Transform",
608
+ props: {
609
+ accessibilityLabel: String,
610
+ transform: {
611
+ type: Function,
612
+ required: true
613
+ }
614
+ },
615
+ setup(props, { slots }) {
616
+ const isScreenReaderEnabled = useIsScreenReaderEnabled();
617
+ return () => {
618
+ const text = stringifyChildren(slots.default?.());
619
+ return h("text", {
620
+ text: isScreenReaderEnabled && props.accessibilityLabel ? props.accessibilityLabel : text.split("\n").map((line, index) => props.transform(line, index)).join("\n"),
621
+ "aria-label": props.accessibilityLabel
622
+ });
623
+ };
624
+ }
625
+ });
626
+ //#endregion
407
627
  //#region src/components/Code.ts
408
628
  /**
409
629
  * Code Component - Code block display
@@ -541,6 +761,10 @@ const TextInput = defineComponent({
541
761
  type: Boolean,
542
762
  default: false
543
763
  },
764
+ focused: {
765
+ type: Boolean,
766
+ default: void 0
767
+ },
544
768
  mask: {
545
769
  type: Boolean,
546
770
  default: false
@@ -556,79 +780,188 @@ const TextInput = defineComponent({
556
780
  emits: [
557
781
  "update:modelValue",
558
782
  "submit",
559
- "cancel"
783
+ "cancel",
784
+ "compositionstart",
785
+ "compositionupdate",
786
+ "compositionend"
560
787
  ],
561
788
  setup(props, { emit }) {
562
789
  const internalValue = ref(props.modelValue);
563
- const cursorPos = ref(props.modelValue.length);
790
+ const cursorPos = ref(graphemeLength(props.modelValue));
791
+ const isComposing = ref(false);
792
+ const compositionAnchor = ref(cursorPos.value);
793
+ const preedit = ref("");
794
+ const preeditCursor = ref(0);
795
+ const focused = computed(() => props.focused ?? props.focus);
564
796
  watch(() => props.modelValue, (newValue) => {
565
797
  internalValue.value = newValue;
566
- if (cursorPos.value > newValue.length) cursorPos.value = newValue.length;
798
+ const length = graphemeLength(newValue);
799
+ if (cursorPos.value > length) cursorPos.value = length;
567
800
  });
568
801
  const updateValue = (value) => {
569
802
  internalValue.value = value;
570
803
  emit("update:modelValue", value);
571
804
  };
572
805
  const insertText = (text) => {
573
- const before = internalValue.value.slice(0, cursorPos.value);
574
- const after = internalValue.value.slice(cursorPos.value);
575
- updateValue(before + text + after);
576
- cursorPos.value += text.length;
806
+ updateValue(insertAtGrapheme(internalValue.value, cursorPos.value, text));
807
+ cursorPos.value += graphemeLength(text);
577
808
  };
578
809
  const deleteBack = () => {
579
810
  if (cursorPos.value > 0) {
580
- updateValue(internalValue.value.slice(0, cursorPos.value - 1) + internalValue.value.slice(cursorPos.value));
811
+ updateValue(deleteGraphemeBefore(internalValue.value, cursorPos.value));
581
812
  cursorPos.value--;
582
813
  }
583
814
  };
584
815
  const deleteForward = () => {
585
- if (cursorPos.value < internalValue.value.length) updateValue(internalValue.value.slice(0, cursorPos.value) + internalValue.value.slice(cursorPos.value + 1));
816
+ if (cursorPos.value < graphemeLength(internalValue.value)) updateValue(deleteGraphemeAt(internalValue.value, cursorPos.value));
586
817
  };
587
818
  const moveLeft = () => {
588
819
  if (cursorPos.value > 0) cursorPos.value--;
589
820
  };
590
821
  const moveRight = () => {
591
- if (cursorPos.value < internalValue.value.length) cursorPos.value++;
822
+ if (cursorPos.value < graphemeLength(internalValue.value)) cursorPos.value++;
592
823
  };
593
824
  const moveToStart = () => {
594
825
  cursorPos.value = 0;
595
826
  };
596
827
  const moveToEnd = () => {
597
- cursorPos.value = internalValue.value.length;
828
+ cursorPos.value = graphemeLength(internalValue.value);
598
829
  };
830
+ const updatePreedit = (text, cursor = graphemeLength(text)) => {
831
+ if (!isComposing.value) {
832
+ isComposing.value = true;
833
+ compositionAnchor.value = cursorPos.value;
834
+ emit("compositionstart");
835
+ }
836
+ preedit.value = text;
837
+ preeditCursor.value = Math.max(0, Math.min(cursor, graphemeLength(text)));
838
+ emit("compositionupdate", preedit.value, preeditCursor.value);
839
+ };
840
+ const finishComposition = (text = preedit.value) => {
841
+ if (!isComposing.value) return;
842
+ cursorPos.value = compositionAnchor.value;
843
+ isComposing.value = false;
844
+ preedit.value = "";
845
+ preeditCursor.value = 0;
846
+ if (text) insertText(text);
847
+ emit("compositionend", text);
848
+ };
849
+ const cancelComposition = () => {
850
+ if (!isComposing.value) return false;
851
+ isComposing.value = false;
852
+ preedit.value = "";
853
+ preeditCursor.value = 0;
854
+ cursorPos.value = compositionAnchor.value;
855
+ emit("compositionend", "");
856
+ return true;
857
+ };
858
+ const deletePreeditBack = () => {
859
+ if (!isComposing.value || preeditCursor.value === 0) return false;
860
+ preedit.value = deleteGraphemeBefore(preedit.value, preeditCursor.value);
861
+ preeditCursor.value--;
862
+ emit("compositionupdate", preedit.value, preeditCursor.value);
863
+ return true;
864
+ };
865
+ const deletePreeditForward = () => {
866
+ if (!isComposing.value || preeditCursor.value >= graphemeLength(preedit.value)) return false;
867
+ preedit.value = deleteGraphemeAt(preedit.value, preeditCursor.value);
868
+ emit("compositionupdate", preedit.value, preeditCursor.value);
869
+ return true;
870
+ };
871
+ const movePreeditLeft = () => {
872
+ if (!isComposing.value || preeditCursor.value === 0) return false;
873
+ preeditCursor.value--;
874
+ emit("compositionupdate", preedit.value, preeditCursor.value);
875
+ return true;
876
+ };
877
+ const movePreeditRight = () => {
878
+ if (!isComposing.value || preeditCursor.value >= graphemeLength(preedit.value)) return false;
879
+ preeditCursor.value++;
880
+ emit("compositionupdate", preedit.value, preeditCursor.value);
881
+ return true;
882
+ };
883
+ const movePreeditToStart = () => {
884
+ if (!isComposing.value) return false;
885
+ preeditCursor.value = 0;
886
+ emit("compositionupdate", preedit.value, preeditCursor.value);
887
+ return true;
888
+ };
889
+ const movePreeditToEnd = () => {
890
+ if (!isComposing.value) return false;
891
+ preeditCursor.value = graphemeLength(preedit.value);
892
+ emit("compositionupdate", preedit.value, preeditCursor.value);
893
+ return true;
894
+ };
895
+ const displayValue = computed(() => {
896
+ if (!isComposing.value) return internalValue.value;
897
+ return [
898
+ sliceGraphemes(internalValue.value, 0, compositionAnchor.value),
899
+ preedit.value,
900
+ sliceGraphemes(internalValue.value, compositionAnchor.value)
901
+ ].join("");
902
+ });
903
+ const displayCursor = computed(() => {
904
+ if (!isComposing.value) return cursorPos.value;
905
+ return compositionAnchor.value + preeditCursor.value;
906
+ });
599
907
  useInput({
600
- isActive: computed(() => props.focus),
908
+ isActive: computed(() => focused.value),
601
909
  onChar: (char) => {
910
+ if (isComposing.value) return;
602
911
  insertText(char);
603
912
  },
604
913
  onArrow: (direction) => {
605
- if (direction === "left") moveLeft();
606
- if (direction === "right") moveRight();
914
+ if (direction === "left") {
915
+ if (!movePreeditLeft()) moveLeft();
916
+ }
917
+ if (direction === "right") {
918
+ if (!movePreeditRight()) moveRight();
919
+ }
607
920
  },
608
921
  onKey: (key, modifiers) => {
609
- if (key === "backspace") deleteBack();
610
- else if (key === "delete") deleteForward();
611
- else if (key === "home") moveToStart();
612
- else if (key === "end") moveToEnd();
613
- else if (key === "a" && modifiers.ctrl) moveToEnd();
922
+ if (key === "backspace") {
923
+ if (!deletePreeditBack()) deleteBack();
924
+ } else if (key === "delete") {
925
+ if (!deletePreeditForward()) deleteForward();
926
+ } else if (key === "home") {
927
+ if (!movePreeditToStart()) moveToStart();
928
+ } else if (key === "end") {
929
+ if (!movePreeditToEnd()) moveToEnd();
930
+ } else if (key === "a" && modifiers.ctrl) {
931
+ if (!movePreeditToEnd()) moveToEnd();
932
+ }
614
933
  },
615
934
  onSubmit: () => {
935
+ if (isComposing.value) {
936
+ finishComposition();
937
+ return;
938
+ }
616
939
  emit("submit", internalValue.value);
617
940
  },
618
941
  onEscape: () => {
942
+ if (cancelComposition()) return;
619
943
  emit("cancel");
620
- }
944
+ },
945
+ onCompositionStart: () => {
946
+ isComposing.value = true;
947
+ compositionAnchor.value = cursorPos.value;
948
+ preedit.value = "";
949
+ preeditCursor.value = 0;
950
+ emit("compositionstart");
951
+ },
952
+ onCompositionUpdate: updatePreedit,
953
+ onCompositionEnd: finishComposition
621
954
  });
622
955
  return () => {
623
956
  const style = {};
624
957
  if (props.width !== void 0) style.width = String(props.width);
625
958
  return h("input", {
626
- value: internalValue.value,
959
+ value: displayValue.value,
627
960
  placeholder: props.placeholder,
628
- focused: props.focus,
629
- cursor: cursorPos.value,
961
+ focused: focused.value,
962
+ cursor: displayCursor.value,
630
963
  mask: props.mask,
631
- "mask-char": props.maskChar,
964
+ maskChar: props.maskChar,
632
965
  style,
633
966
  fg: props.fg,
634
967
  bg: props.bg
@@ -2557,6 +2890,6 @@ const Avatar = defineComponent({
2557
2890
  }
2558
2891
  });
2559
2892
  //#endregion
2560
- export { Grid as A, Select as C, Code as D, Link as E, Box as F, Stack as M, VStack as N, Text as O, Divider as P, Checkbox as S, TextInput as T, ProgressBar as _, Modal as a, Confirm as b, Tabs as c, Table as d, List as f, Alert as g, Badge as h, StatusBar as i, HStack as j, Card as k, Menu as l, Timer as m, KeyHint as n, Stepper as o, Tooltip as p, Header as r, Breadcrumb as s, Avatar as t, Tree as u, Spinner as v, TextArea as w, RadioGroup as x, Form as y };
2893
+ export { Newline as A, Select as C, Code as D, Link as E, Stack as F, VStack as I, Divider as L, Card as M, Grid as N, Transform as O, HStack as P, Spacer as R, Checkbox as S, TextInput as T, ProgressBar as _, Modal as a, Confirm as b, Tabs as c, Table as d, List as f, Alert as g, Badge as h, StatusBar as i, Text as j, Static as k, Menu as l, Timer as m, KeyHint as n, Stepper as o, Tooltip as p, Header as r, Breadcrumb as s, Avatar as t, Tree as u, Spinner as v, TextArea as w, RadioGroup as x, Form as y, Box as z };
2561
2894
 
2562
- //# sourceMappingURL=components-B5VXjX9s.mjs.map
2895
+ //# sourceMappingURL=components-BFV7PBp6.mjs.map