@xaui/native 0.0.41 → 0.1.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.
@@ -589,6 +589,94 @@ var getTimeMaxLength = (granularity, hourCycle) => {
589
589
  var getDateTimeMaxLength = (separator, granularity, hourCycle) => {
590
590
  return getDateMaxLength(separator) + 1 + getTimeMaxLength(granularity, hourCycle);
591
591
  };
592
+ var pad = (n) => String(n).padStart(2, "0");
593
+ var dateInputValueToDate = (value, dateOrder, separator) => {
594
+ const parts = value.split(separator);
595
+ if (parts.length !== 3) return null;
596
+ let year, month, day;
597
+ if (dateOrder === "YMD") {
598
+ year = parseInt(parts[0], 10);
599
+ month = parseInt(parts[1], 10);
600
+ day = parseInt(parts[2], 10);
601
+ } else if (dateOrder === "MDY") {
602
+ month = parseInt(parts[0], 10);
603
+ day = parseInt(parts[1], 10);
604
+ year = parseInt(parts[2], 10);
605
+ } else {
606
+ day = parseInt(parts[0], 10);
607
+ month = parseInt(parts[1], 10);
608
+ year = parseInt(parts[2], 10);
609
+ }
610
+ if (isNaN(year) || isNaN(month) || isNaN(day)) return null;
611
+ const date = new Date(year, month - 1, day);
612
+ if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day)
613
+ return null;
614
+ return date;
615
+ };
616
+ var dateToDateInputValue = (date, dateOrder, separator) => {
617
+ const d = typeof date === "string" ? new Date(date) : date;
618
+ if (isNaN(d.getTime())) return "";
619
+ const year = String(d.getFullYear());
620
+ const month = pad(d.getMonth() + 1);
621
+ const day = pad(d.getDate());
622
+ if (dateOrder === "YMD") return [year, month, day].join(separator);
623
+ if (dateOrder === "MDY") return [month, day, year].join(separator);
624
+ return [day, month, year].join(separator);
625
+ };
626
+ var timeInputValueToDate = (value, options = {}) => {
627
+ const { hourCycle = 24 } = options;
628
+ const isPM = /pm$/i.test(value);
629
+ const isAM = /am$/i.test(value);
630
+ const cleaned = value.replace(/\s*(am|pm)$/i, "").trim();
631
+ const segments = cleaned.split(":");
632
+ let hours = parseInt(segments[0], 10);
633
+ const minutes = parseInt(_nullishCoalesce(segments[1], () => ( "0")), 10);
634
+ const seconds = parseInt(_nullishCoalesce(segments[2], () => ( "0")), 10);
635
+ if (isNaN(hours) || isNaN(minutes) || isNaN(seconds)) return null;
636
+ if (hourCycle === 12) {
637
+ if (isPM && hours !== 12) hours += 12;
638
+ if (isAM && hours === 12) hours = 0;
639
+ }
640
+ const date = /* @__PURE__ */ new Date();
641
+ date.setHours(hours, minutes, seconds, 0);
642
+ return date;
643
+ };
644
+ var dateToTimeInputValue = (date, options = {}) => {
645
+ const { granularity = "minute", hourCycle = 24 } = options;
646
+ const d = typeof date === "string" ? new Date(date) : date;
647
+ if (isNaN(d.getTime())) return "";
648
+ let hours = d.getHours();
649
+ const minutes = pad(d.getMinutes());
650
+ const seconds = pad(d.getSeconds());
651
+ if (hourCycle === 12) {
652
+ const period = hours >= 12 ? "PM" : "AM";
653
+ hours = hours % 12 || 12;
654
+ const base2 = `${pad(hours)}:${minutes}`;
655
+ return granularity === "second" ? `${base2}:${seconds} ${period}` : `${base2} ${period}`;
656
+ }
657
+ const base = `${pad(hours)}:${minutes}`;
658
+ return granularity === "second" ? `${base}:${seconds}` : base;
659
+ };
660
+ var dateTimeInputValueToDate = (value, dateOrder, options = {}) => {
661
+ const { separator = "-", hourCycle = 24 } = options;
662
+ const spaceIndex = value.indexOf(" ");
663
+ if (spaceIndex === -1) return null;
664
+ const date = dateInputValueToDate(value.slice(0, spaceIndex), dateOrder, separator);
665
+ if (!date) return null;
666
+ const timePart = value.slice(spaceIndex + 1);
667
+ const timed = timeInputValueToDate(timePart, { hourCycle });
668
+ if (!timed) return null;
669
+ date.setHours(timed.getHours(), timed.getMinutes(), timed.getSeconds(), 0);
670
+ return date;
671
+ };
672
+ var dateToDateTimeInputValue = (date, dateOrder, options = {}) => {
673
+ const { separator = "-", granularity = "minute", hourCycle = 24 } = options;
674
+ const d = typeof date === "string" ? new Date(date) : date;
675
+ if (isNaN(d.getTime())) return "";
676
+ const datePart = dateToDateInputValue(d, dateOrder, separator);
677
+ const timePart = dateToTimeInputValue(d, { granularity, hourCycle });
678
+ return `${datePart} ${timePart}`;
679
+ };
592
680
 
593
681
  // src/components/input/date-time-input.tsx
594
682
  var DateInput = _react.forwardRef.call(void 0,
@@ -1347,4 +1435,10 @@ NumberInput.displayName = "NumberInput";
1347
1435
 
1348
1436
 
1349
1437
 
1350
- exports.DateInput = DateInput; exports.DateTimeInput = DateTimeInput; exports.NumberInput = NumberInput; exports.OTPInput = OTPInput; exports.TextArea = TextArea; exports.TextInput = TextInput; exports.TimeInput = TimeInput; exports.getDateOrder = getDateOrder;
1438
+
1439
+
1440
+
1441
+
1442
+
1443
+
1444
+ exports.DateInput = DateInput; exports.DateTimeInput = DateTimeInput; exports.NumberInput = NumberInput; exports.OTPInput = OTPInput; exports.TextArea = TextArea; exports.TextInput = TextInput; exports.TimeInput = TimeInput; exports.dateInputValueToDate = dateInputValueToDate; exports.dateTimeInputValueToDate = dateTimeInputValueToDate; exports.dateToDateInputValue = dateToDateInputValue; exports.dateToDateTimeInputValue = dateToDateTimeInputValue; exports.dateToTimeInputValue = dateToTimeInputValue; exports.getDateOrder = getDateOrder; exports.timeInputValueToDate = timeInputValueToDate;
@@ -148,6 +148,15 @@ declare const TextArea: React.FC<TextAreaProps>;
148
148
  type DateSeparator = '-' | '/' | '.';
149
149
  type DateOrder = 'YMD' | 'DMY' | 'MDY';
150
150
  type TimeInputGranularity = 'minute' | 'second';
151
+ type TimeInputConvertOptions = {
152
+ granularity?: TimeInputGranularity;
153
+ hourCycle?: 12 | 24;
154
+ };
155
+ type DateTimeInputConvertOptions = {
156
+ separator?: DateSeparator;
157
+ granularity?: TimeInputGranularity;
158
+ hourCycle?: 12 | 24;
159
+ };
151
160
  type DateInputProps = TextInputProps & {
152
161
  /**
153
162
  * Separator character between date segments.
@@ -502,5 +511,11 @@ type NumberInputProps = {
502
511
  declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<TextInput$1>>;
503
512
 
504
513
  declare const getDateOrder: (locale: string) => DateOrder;
514
+ declare const dateInputValueToDate: (value: string, dateOrder: DateOrder, separator: DateSeparator) => Date | null;
515
+ declare const dateToDateInputValue: (date: Date | string, dateOrder: DateOrder, separator: DateSeparator) => string;
516
+ declare const timeInputValueToDate: (value: string, options?: TimeInputConvertOptions) => Date | null;
517
+ declare const dateToTimeInputValue: (date: Date | string, options?: TimeInputConvertOptions) => string;
518
+ declare const dateTimeInputValueToDate: (value: string, dateOrder: DateOrder, options?: DateTimeInputConvertOptions) => Date | null;
519
+ declare const dateToDateTimeInputValue: (date: Date | string, dateOrder: DateOrder, options?: DateTimeInputConvertOptions) => string;
505
520
 
506
- export { DateInput, type DateInputProps, type DateOrder, type DateSeparator, DateTimeInput, type DateTimeInputProps, NumberInput, type NumberInputCustomAppearance, type NumberInputProps, OTPInput, type OTPInputCustomAppearance, type OTPInputProps, TextArea, type TextAreaProps, TextInput, type TextInputCustomAppearance, type TextInputLabelPlacement, type TextInputProps, type TextInputSize, type TextInputVariant, TimeInput, type TimeInputGranularity, type TimeInputProps, getDateOrder };
521
+ export { DateInput, type DateInputProps, type DateOrder, type DateSeparator, DateTimeInput, type DateTimeInputConvertOptions, type DateTimeInputProps, NumberInput, type NumberInputCustomAppearance, type NumberInputProps, OTPInput, type OTPInputCustomAppearance, type OTPInputProps, TextArea, type TextAreaProps, TextInput, type TextInputCustomAppearance, type TextInputLabelPlacement, type TextInputProps, type TextInputSize, type TextInputVariant, TimeInput, type TimeInputConvertOptions, type TimeInputGranularity, type TimeInputProps, dateInputValueToDate, dateTimeInputValueToDate, dateToDateInputValue, dateToDateTimeInputValue, dateToTimeInputValue, getDateOrder, timeInputValueToDate };
@@ -148,6 +148,15 @@ declare const TextArea: React.FC<TextAreaProps>;
148
148
  type DateSeparator = '-' | '/' | '.';
149
149
  type DateOrder = 'YMD' | 'DMY' | 'MDY';
150
150
  type TimeInputGranularity = 'minute' | 'second';
151
+ type TimeInputConvertOptions = {
152
+ granularity?: TimeInputGranularity;
153
+ hourCycle?: 12 | 24;
154
+ };
155
+ type DateTimeInputConvertOptions = {
156
+ separator?: DateSeparator;
157
+ granularity?: TimeInputGranularity;
158
+ hourCycle?: 12 | 24;
159
+ };
151
160
  type DateInputProps = TextInputProps & {
152
161
  /**
153
162
  * Separator character between date segments.
@@ -502,5 +511,11 @@ type NumberInputProps = {
502
511
  declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<TextInput$1>>;
503
512
 
504
513
  declare const getDateOrder: (locale: string) => DateOrder;
514
+ declare const dateInputValueToDate: (value: string, dateOrder: DateOrder, separator: DateSeparator) => Date | null;
515
+ declare const dateToDateInputValue: (date: Date | string, dateOrder: DateOrder, separator: DateSeparator) => string;
516
+ declare const timeInputValueToDate: (value: string, options?: TimeInputConvertOptions) => Date | null;
517
+ declare const dateToTimeInputValue: (date: Date | string, options?: TimeInputConvertOptions) => string;
518
+ declare const dateTimeInputValueToDate: (value: string, dateOrder: DateOrder, options?: DateTimeInputConvertOptions) => Date | null;
519
+ declare const dateToDateTimeInputValue: (date: Date | string, dateOrder: DateOrder, options?: DateTimeInputConvertOptions) => string;
505
520
 
506
- export { DateInput, type DateInputProps, type DateOrder, type DateSeparator, DateTimeInput, type DateTimeInputProps, NumberInput, type NumberInputCustomAppearance, type NumberInputProps, OTPInput, type OTPInputCustomAppearance, type OTPInputProps, TextArea, type TextAreaProps, TextInput, type TextInputCustomAppearance, type TextInputLabelPlacement, type TextInputProps, type TextInputSize, type TextInputVariant, TimeInput, type TimeInputGranularity, type TimeInputProps, getDateOrder };
521
+ export { DateInput, type DateInputProps, type DateOrder, type DateSeparator, DateTimeInput, type DateTimeInputConvertOptions, type DateTimeInputProps, NumberInput, type NumberInputCustomAppearance, type NumberInputProps, OTPInput, type OTPInputCustomAppearance, type OTPInputProps, TextArea, type TextAreaProps, TextInput, type TextInputCustomAppearance, type TextInputLabelPlacement, type TextInputProps, type TextInputSize, type TextInputVariant, TimeInput, type TimeInputConvertOptions, type TimeInputGranularity, type TimeInputProps, dateInputValueToDate, dateTimeInputValueToDate, dateToDateInputValue, dateToDateTimeInputValue, dateToTimeInputValue, getDateOrder, timeInputValueToDate };
@@ -589,6 +589,94 @@ var getTimeMaxLength = (granularity, hourCycle) => {
589
589
  var getDateTimeMaxLength = (separator, granularity, hourCycle) => {
590
590
  return getDateMaxLength(separator) + 1 + getTimeMaxLength(granularity, hourCycle);
591
591
  };
592
+ var pad = (n) => String(n).padStart(2, "0");
593
+ var dateInputValueToDate = (value, dateOrder, separator) => {
594
+ const parts = value.split(separator);
595
+ if (parts.length !== 3) return null;
596
+ let year, month, day;
597
+ if (dateOrder === "YMD") {
598
+ year = parseInt(parts[0], 10);
599
+ month = parseInt(parts[1], 10);
600
+ day = parseInt(parts[2], 10);
601
+ } else if (dateOrder === "MDY") {
602
+ month = parseInt(parts[0], 10);
603
+ day = parseInt(parts[1], 10);
604
+ year = parseInt(parts[2], 10);
605
+ } else {
606
+ day = parseInt(parts[0], 10);
607
+ month = parseInt(parts[1], 10);
608
+ year = parseInt(parts[2], 10);
609
+ }
610
+ if (isNaN(year) || isNaN(month) || isNaN(day)) return null;
611
+ const date = new Date(year, month - 1, day);
612
+ if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day)
613
+ return null;
614
+ return date;
615
+ };
616
+ var dateToDateInputValue = (date, dateOrder, separator) => {
617
+ const d = typeof date === "string" ? new Date(date) : date;
618
+ if (isNaN(d.getTime())) return "";
619
+ const year = String(d.getFullYear());
620
+ const month = pad(d.getMonth() + 1);
621
+ const day = pad(d.getDate());
622
+ if (dateOrder === "YMD") return [year, month, day].join(separator);
623
+ if (dateOrder === "MDY") return [month, day, year].join(separator);
624
+ return [day, month, year].join(separator);
625
+ };
626
+ var timeInputValueToDate = (value, options = {}) => {
627
+ const { hourCycle = 24 } = options;
628
+ const isPM = /pm$/i.test(value);
629
+ const isAM = /am$/i.test(value);
630
+ const cleaned = value.replace(/\s*(am|pm)$/i, "").trim();
631
+ const segments = cleaned.split(":");
632
+ let hours = parseInt(segments[0], 10);
633
+ const minutes = parseInt(segments[1] ?? "0", 10);
634
+ const seconds = parseInt(segments[2] ?? "0", 10);
635
+ if (isNaN(hours) || isNaN(minutes) || isNaN(seconds)) return null;
636
+ if (hourCycle === 12) {
637
+ if (isPM && hours !== 12) hours += 12;
638
+ if (isAM && hours === 12) hours = 0;
639
+ }
640
+ const date = /* @__PURE__ */ new Date();
641
+ date.setHours(hours, minutes, seconds, 0);
642
+ return date;
643
+ };
644
+ var dateToTimeInputValue = (date, options = {}) => {
645
+ const { granularity = "minute", hourCycle = 24 } = options;
646
+ const d = typeof date === "string" ? new Date(date) : date;
647
+ if (isNaN(d.getTime())) return "";
648
+ let hours = d.getHours();
649
+ const minutes = pad(d.getMinutes());
650
+ const seconds = pad(d.getSeconds());
651
+ if (hourCycle === 12) {
652
+ const period = hours >= 12 ? "PM" : "AM";
653
+ hours = hours % 12 || 12;
654
+ const base2 = `${pad(hours)}:${minutes}`;
655
+ return granularity === "second" ? `${base2}:${seconds} ${period}` : `${base2} ${period}`;
656
+ }
657
+ const base = `${pad(hours)}:${minutes}`;
658
+ return granularity === "second" ? `${base}:${seconds}` : base;
659
+ };
660
+ var dateTimeInputValueToDate = (value, dateOrder, options = {}) => {
661
+ const { separator = "-", hourCycle = 24 } = options;
662
+ const spaceIndex = value.indexOf(" ");
663
+ if (spaceIndex === -1) return null;
664
+ const date = dateInputValueToDate(value.slice(0, spaceIndex), dateOrder, separator);
665
+ if (!date) return null;
666
+ const timePart = value.slice(spaceIndex + 1);
667
+ const timed = timeInputValueToDate(timePart, { hourCycle });
668
+ if (!timed) return null;
669
+ date.setHours(timed.getHours(), timed.getMinutes(), timed.getSeconds(), 0);
670
+ return date;
671
+ };
672
+ var dateToDateTimeInputValue = (date, dateOrder, options = {}) => {
673
+ const { separator = "-", granularity = "minute", hourCycle = 24 } = options;
674
+ const d = typeof date === "string" ? new Date(date) : date;
675
+ if (isNaN(d.getTime())) return "";
676
+ const datePart = dateToDateInputValue(d, dateOrder, separator);
677
+ const timePart = dateToTimeInputValue(d, { granularity, hourCycle });
678
+ return `${datePart} ${timePart}`;
679
+ };
592
680
 
593
681
  // src/components/input/date-time-input.tsx
594
682
  var DateInput = forwardRef2(
@@ -1346,5 +1434,11 @@ export {
1346
1434
  TextArea,
1347
1435
  TextInput,
1348
1436
  TimeInput,
1349
- getDateOrder
1437
+ dateInputValueToDate,
1438
+ dateTimeInputValueToDate,
1439
+ dateToDateInputValue,
1440
+ dateToDateTimeInputValue,
1441
+ dateToTimeInputValue,
1442
+ getDateOrder,
1443
+ timeInputValueToDate
1350
1444
  };
@@ -70,6 +70,26 @@ var styles = _reactnative.StyleSheet.create({
70
70
  fontWeight: "600",
71
71
  includeFontPadding: false
72
72
  },
73
+ inlineSnippet: {
74
+ flexDirection: "row",
75
+ alignItems: "center",
76
+ paddingHorizontal: 10,
77
+ paddingVertical: 8,
78
+ gap: 10
79
+ },
80
+ inlineCopyButton: {
81
+ flexShrink: 0,
82
+ flexDirection: "row",
83
+ alignItems: "center",
84
+ gap: 6,
85
+ borderWidth: 1,
86
+ paddingHorizontal: 10,
87
+ paddingVertical: 6
88
+ },
89
+ inlineContent: {
90
+ flex: 1,
91
+ justifyContent: "center"
92
+ },
73
93
  disabled: {
74
94
  opacity: 0.55
75
95
  }
@@ -119,7 +139,8 @@ var useCopyButtonPositionStyles = (position) => {
119
139
  return _react.useMemo.call(void 0,
120
140
  () => ({
121
141
  isTop: position.startsWith("top"),
122
- isLeft: position.endsWith("left")
142
+ isLeft: position.endsWith("left"),
143
+ isInline: position.startsWith("inline")
123
144
  }),
124
145
  [position]
125
146
  );
@@ -149,6 +170,7 @@ var Snippet = ({
149
170
  copyButtonPosition = "top-right",
150
171
  copyLabel = "Copy",
151
172
  copiedLabel = "Copied",
173
+ hideCopyLabel = false,
152
174
  copyResetDelay = 1500,
153
175
  fullWidth = true,
154
176
  isDisabled = false,
@@ -162,7 +184,7 @@ var Snippet = ({
162
184
  const resetTimerRef = _react2.default.useRef(null);
163
185
  const radiusStyles = _chunkRZJFCDFScjs.useBorderRadiusStyles.call(void 0, radius);
164
186
  const colors = useSnippetColors(themeColor, variant, isDisabled);
165
- const { isTop, isLeft } = useCopyButtonPositionStyles(copyButtonPosition);
187
+ const { isTop, isLeft, isInline } = useCopyButtonPositionStyles(copyButtonPosition);
166
188
  _react2.default.useEffect(() => {
167
189
  return () => {
168
190
  if (resetTimerRef.current) {
@@ -192,6 +214,39 @@ var Snippet = ({
192
214
  setIsCopied(false);
193
215
  }, copyResetDelay);
194
216
  }, [copyResetDelay, isDisabled, onCopy, value]);
217
+ const copyButtonColors = {
218
+ backgroundColor: colors.copyButtonBackground,
219
+ borderColor: colors.copyButtonBorder
220
+ };
221
+ const copyButton = /* @__PURE__ */ _react2.default.createElement(
222
+ _reactnative.Pressable,
223
+ {
224
+ onPress: handleCopy,
225
+ accessibilityRole: "button",
226
+ accessibilityLabel: isCopied ? copiedLabel : copyLabel,
227
+ disabled: isDisabled,
228
+ style: isInline ? [styles.inlineCopyButton, radiusStyles, copyButtonColors, _optionalChain([customAppearance, 'optionalAccess', _9 => _9.copyButton])] : [
229
+ styles.copyButton,
230
+ radiusStyles,
231
+ isTop ? styles.top : styles.bottom,
232
+ isLeft ? styles.left : styles.right,
233
+ copyButtonColors,
234
+ _optionalChain([customAppearance, 'optionalAccess', _10 => _10.copyButton])
235
+ ]
236
+ },
237
+ /* @__PURE__ */ _react2.default.createElement(_icons.CopyIcon, { size: 14, color: colors.copyButtonText }),
238
+ !hideCopyLabel && /* @__PURE__ */ _react2.default.createElement(
239
+ _reactnative.Text,
240
+ {
241
+ style: [
242
+ styles.copyButtonText,
243
+ { color: colors.copyButtonText },
244
+ _optionalChain([customAppearance, 'optionalAccess', _11 => _11.copyButtonText])
245
+ ]
246
+ },
247
+ isCopied ? copiedLabel : copyLabel
248
+ )
249
+ );
195
250
  return /* @__PURE__ */ _react2.default.createElement(
196
251
  _reactnative.View,
197
252
  {
@@ -199,7 +254,7 @@ var Snippet = ({
199
254
  styles.container,
200
255
  !fullWidth && styles.noFullWidth,
201
256
  isDisabled && styles.disabled,
202
- _optionalChain([customAppearance, 'optionalAccess', _9 => _9.container])
257
+ _optionalChain([customAppearance, 'optionalAccess', _12 => _12.container])
203
258
  ]
204
259
  },
205
260
  /* @__PURE__ */ _react2.default.createElement(
@@ -207,6 +262,7 @@ var Snippet = ({
207
262
  {
208
263
  style: [
209
264
  styles.snippet,
265
+ isInline && styles.inlineSnippet,
210
266
  radiusStyles,
211
267
  {
212
268
  backgroundColor: colors.containerBackground,
@@ -214,45 +270,15 @@ var Snippet = ({
214
270
  }
215
271
  ]
216
272
  },
217
- /* @__PURE__ */ _react2.default.createElement(
218
- _reactnative.Pressable,
219
- {
220
- onPress: handleCopy,
221
- accessibilityRole: "button",
222
- accessibilityLabel: isCopied ? copiedLabel : copyLabel,
223
- disabled: isDisabled,
224
- style: [
225
- styles.copyButton,
226
- radiusStyles,
227
- isTop ? styles.top : styles.bottom,
228
- isLeft ? styles.left : styles.right,
229
- {
230
- backgroundColor: colors.copyButtonBackground,
231
- borderColor: colors.copyButtonBorder
232
- },
233
- _optionalChain([customAppearance, 'optionalAccess', _10 => _10.copyButton])
234
- ]
235
- },
236
- /* @__PURE__ */ _react2.default.createElement(_icons.CopyIcon, { size: 14, color: colors.copyButtonText }),
237
- /* @__PURE__ */ _react2.default.createElement(
238
- _reactnative.Text,
239
- {
240
- style: [
241
- styles.copyButtonText,
242
- { color: colors.copyButtonText },
243
- _optionalChain([customAppearance, 'optionalAccess', _11 => _11.copyButtonText])
244
- ]
245
- },
246
- isCopied ? copiedLabel : copyLabel
247
- )
248
- ),
273
+ isInline && isLeft && copyButton,
274
+ !isInline && copyButton,
249
275
  /* @__PURE__ */ _react2.default.createElement(
250
276
  _reactnative.View,
251
277
  {
252
278
  style: [
253
- styles.content,
254
- isTop ? styles.topInset : styles.bottomInset,
255
- _optionalChain([customAppearance, 'optionalAccess', _12 => _12.content])
279
+ isInline ? styles.inlineContent : styles.content,
280
+ !isInline && (isTop ? styles.topInset : styles.bottomInset),
281
+ _optionalChain([customAppearance, 'optionalAccess', _13 => _13.content])
256
282
  ]
257
283
  },
258
284
  /* @__PURE__ */ _react2.default.createElement(
@@ -268,12 +294,13 @@ var Snippet = ({
268
294
  lineHeight: Math.round(fontSize * 1.45),
269
295
  fontWeight
270
296
  },
271
- _optionalChain([customAppearance, 'optionalAccess', _13 => _13.text])
297
+ _optionalChain([customAppearance, 'optionalAccess', _14 => _14.text])
272
298
  ]
273
299
  },
274
300
  value
275
301
  )
276
- )
302
+ ),
303
+ isInline && !isLeft && copyButton
277
304
  )
278
305
  );
279
306
  };
@@ -3,7 +3,7 @@ import { TextStyle, StyleProp, ViewStyle } from 'react-native';
3
3
  import { T as ThemeColor, R as Radius } from '../index-DyU3sW3_.cjs';
4
4
 
5
5
  type SnippetVariant = 'outlined' | 'flat' | 'light';
6
- type CopyButtonPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
6
+ type CopyButtonPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'inline-left' | 'inline-right';
7
7
  type SnippetCustomAppearance = {
8
8
  container?: StyleProp<ViewStyle>;
9
9
  content?: StyleProp<ViewStyle>;
@@ -41,6 +41,11 @@ type SnippetProps = {
41
41
  * @default 'Copy'
42
42
  */
43
43
  copyLabel?: string;
44
+ /**
45
+ * Hide the copy/copied text label, showing only the icon.
46
+ * @default false
47
+ */
48
+ hideCopyLabel?: boolean;
44
49
  /**
45
50
  * Label shown after a successful copy action.
46
51
  * @default 'Copied'
@@ -3,7 +3,7 @@ import { TextStyle, StyleProp, ViewStyle } from 'react-native';
3
3
  import { T as ThemeColor, R as Radius } from '../index-DyU3sW3_.js';
4
4
 
5
5
  type SnippetVariant = 'outlined' | 'flat' | 'light';
6
- type CopyButtonPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
6
+ type CopyButtonPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'inline-left' | 'inline-right';
7
7
  type SnippetCustomAppearance = {
8
8
  container?: StyleProp<ViewStyle>;
9
9
  content?: StyleProp<ViewStyle>;
@@ -41,6 +41,11 @@ type SnippetProps = {
41
41
  * @default 'Copy'
42
42
  */
43
43
  copyLabel?: string;
44
+ /**
45
+ * Hide the copy/copied text label, showing only the icon.
46
+ * @default false
47
+ */
48
+ hideCopyLabel?: boolean;
44
49
  /**
45
50
  * Label shown after a successful copy action.
46
51
  * @default 'Copied'
@@ -70,6 +70,26 @@ var styles = StyleSheet.create({
70
70
  fontWeight: "600",
71
71
  includeFontPadding: false
72
72
  },
73
+ inlineSnippet: {
74
+ flexDirection: "row",
75
+ alignItems: "center",
76
+ paddingHorizontal: 10,
77
+ paddingVertical: 8,
78
+ gap: 10
79
+ },
80
+ inlineCopyButton: {
81
+ flexShrink: 0,
82
+ flexDirection: "row",
83
+ alignItems: "center",
84
+ gap: 6,
85
+ borderWidth: 1,
86
+ paddingHorizontal: 10,
87
+ paddingVertical: 6
88
+ },
89
+ inlineContent: {
90
+ flex: 1,
91
+ justifyContent: "center"
92
+ },
73
93
  disabled: {
74
94
  opacity: 0.55
75
95
  }
@@ -119,7 +139,8 @@ var useCopyButtonPositionStyles = (position) => {
119
139
  return useMemo(
120
140
  () => ({
121
141
  isTop: position.startsWith("top"),
122
- isLeft: position.endsWith("left")
142
+ isLeft: position.endsWith("left"),
143
+ isInline: position.startsWith("inline")
123
144
  }),
124
145
  [position]
125
146
  );
@@ -149,6 +170,7 @@ var Snippet = ({
149
170
  copyButtonPosition = "top-right",
150
171
  copyLabel = "Copy",
151
172
  copiedLabel = "Copied",
173
+ hideCopyLabel = false,
152
174
  copyResetDelay = 1500,
153
175
  fullWidth = true,
154
176
  isDisabled = false,
@@ -162,7 +184,7 @@ var Snippet = ({
162
184
  const resetTimerRef = React.useRef(null);
163
185
  const radiusStyles = useBorderRadiusStyles(radius);
164
186
  const colors = useSnippetColors(themeColor, variant, isDisabled);
165
- const { isTop, isLeft } = useCopyButtonPositionStyles(copyButtonPosition);
187
+ const { isTop, isLeft, isInline } = useCopyButtonPositionStyles(copyButtonPosition);
166
188
  React.useEffect(() => {
167
189
  return () => {
168
190
  if (resetTimerRef.current) {
@@ -192,6 +214,39 @@ var Snippet = ({
192
214
  setIsCopied(false);
193
215
  }, copyResetDelay);
194
216
  }, [copyResetDelay, isDisabled, onCopy, value]);
217
+ const copyButtonColors = {
218
+ backgroundColor: colors.copyButtonBackground,
219
+ borderColor: colors.copyButtonBorder
220
+ };
221
+ const copyButton = /* @__PURE__ */ React.createElement(
222
+ Pressable,
223
+ {
224
+ onPress: handleCopy,
225
+ accessibilityRole: "button",
226
+ accessibilityLabel: isCopied ? copiedLabel : copyLabel,
227
+ disabled: isDisabled,
228
+ style: isInline ? [styles.inlineCopyButton, radiusStyles, copyButtonColors, customAppearance?.copyButton] : [
229
+ styles.copyButton,
230
+ radiusStyles,
231
+ isTop ? styles.top : styles.bottom,
232
+ isLeft ? styles.left : styles.right,
233
+ copyButtonColors,
234
+ customAppearance?.copyButton
235
+ ]
236
+ },
237
+ /* @__PURE__ */ React.createElement(CopyIcon, { size: 14, color: colors.copyButtonText }),
238
+ !hideCopyLabel && /* @__PURE__ */ React.createElement(
239
+ Text,
240
+ {
241
+ style: [
242
+ styles.copyButtonText,
243
+ { color: colors.copyButtonText },
244
+ customAppearance?.copyButtonText
245
+ ]
246
+ },
247
+ isCopied ? copiedLabel : copyLabel
248
+ )
249
+ );
195
250
  return /* @__PURE__ */ React.createElement(
196
251
  View,
197
252
  {
@@ -207,6 +262,7 @@ var Snippet = ({
207
262
  {
208
263
  style: [
209
264
  styles.snippet,
265
+ isInline && styles.inlineSnippet,
210
266
  radiusStyles,
211
267
  {
212
268
  backgroundColor: colors.containerBackground,
@@ -214,44 +270,14 @@ var Snippet = ({
214
270
  }
215
271
  ]
216
272
  },
217
- /* @__PURE__ */ React.createElement(
218
- Pressable,
219
- {
220
- onPress: handleCopy,
221
- accessibilityRole: "button",
222
- accessibilityLabel: isCopied ? copiedLabel : copyLabel,
223
- disabled: isDisabled,
224
- style: [
225
- styles.copyButton,
226
- radiusStyles,
227
- isTop ? styles.top : styles.bottom,
228
- isLeft ? styles.left : styles.right,
229
- {
230
- backgroundColor: colors.copyButtonBackground,
231
- borderColor: colors.copyButtonBorder
232
- },
233
- customAppearance?.copyButton
234
- ]
235
- },
236
- /* @__PURE__ */ React.createElement(CopyIcon, { size: 14, color: colors.copyButtonText }),
237
- /* @__PURE__ */ React.createElement(
238
- Text,
239
- {
240
- style: [
241
- styles.copyButtonText,
242
- { color: colors.copyButtonText },
243
- customAppearance?.copyButtonText
244
- ]
245
- },
246
- isCopied ? copiedLabel : copyLabel
247
- )
248
- ),
273
+ isInline && isLeft && copyButton,
274
+ !isInline && copyButton,
249
275
  /* @__PURE__ */ React.createElement(
250
276
  View,
251
277
  {
252
278
  style: [
253
- styles.content,
254
- isTop ? styles.topInset : styles.bottomInset,
279
+ isInline ? styles.inlineContent : styles.content,
280
+ !isInline && (isTop ? styles.topInset : styles.bottomInset),
255
281
  customAppearance?.content
256
282
  ]
257
283
  },
@@ -273,7 +299,8 @@ var Snippet = ({
273
299
  },
274
300
  value
275
301
  )
276
- )
302
+ ),
303
+ isInline && !isLeft && copyButton
277
304
  )
278
305
  );
279
306
  };
@@ -179,6 +179,7 @@ var Typography = ({
179
179
  variantStyles,
180
180
  resolvedAlign && { textAlign: resolvedAlign },
181
181
  textStyleOverrides,
182
+ inheritedStyle.spacing != null ? { marginRight: inheritedStyle.spacing } : void 0,
182
183
  style
183
184
  ]
184
185
  },
@@ -189,11 +190,11 @@ var Typography = ({
189
190
  // src/components/typography/text-span.tsx
190
191
 
191
192
 
192
- var alignToJustifyContent = {
193
- left: "flex-start",
193
+ var alignToTextAlign = {
194
+ left: "left",
194
195
  center: "center",
195
- right: "flex-end",
196
- justify: "space-between"
196
+ right: "right",
197
+ justify: "justify"
197
198
  };
198
199
  var TextSpan = ({
199
200
  children,
@@ -211,18 +212,15 @@ var TextSpan = ({
211
212
  fontWeight,
212
213
  fontStyle,
213
214
  textTransform,
214
- align
215
+ align,
216
+ spacing
215
217
  };
216
218
  return /* @__PURE__ */ _react2.default.createElement(TextSpanContext.Provider, { value: inheritedTextStyle }, /* @__PURE__ */ _react2.default.createElement(
217
- _reactnative.View,
219
+ _reactnative.Text,
218
220
  {
219
221
  style: [
220
222
  {
221
- flexDirection: "row",
222
- flexWrap: "wrap",
223
- alignItems: "center",
224
- ...align ? { justifyContent: alignToJustifyContent[align] } : {},
225
- ...typeof spacing === "number" ? { gap: spacing } : {},
223
+ ...align ? { textAlign: alignToTextAlign[align] } : {},
226
224
  ...backgroundColor ? { backgroundColor } : {}
227
225
  },
228
226
  style
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { StyleProp, TextStyle, ViewStyle } from 'react-native';
2
+ import { StyleProp, TextStyle } from 'react-native';
3
3
  import { T as ThemeColor } from '../index-BOw6tbkc.cjs';
4
4
 
5
5
  type TypographyAlign = 'center' | 'justify' | 'left' | 'right';
@@ -97,11 +97,11 @@ type TextSpanProps = {
97
97
  /**
98
98
  * Background color for the text span container.
99
99
  */
100
- backgroundColor?: ViewStyle['backgroundColor'];
100
+ backgroundColor?: TextStyle['backgroundColor'];
101
101
  /**
102
102
  * Custom styles for the text span container.
103
103
  */
104
- style?: StyleProp<ViewStyle>;
104
+ style?: StyleProp<TextStyle>;
105
105
  };
106
106
 
107
107
  declare const TextSpan: React.FC<TextSpanProps>;
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { StyleProp, TextStyle, ViewStyle } from 'react-native';
2
+ import { StyleProp, TextStyle } from 'react-native';
3
3
  import { T as ThemeColor } from '../index-BOw6tbkc.js';
4
4
 
5
5
  type TypographyAlign = 'center' | 'justify' | 'left' | 'right';
@@ -97,11 +97,11 @@ type TextSpanProps = {
97
97
  /**
98
98
  * Background color for the text span container.
99
99
  */
100
- backgroundColor?: ViewStyle['backgroundColor'];
100
+ backgroundColor?: TextStyle['backgroundColor'];
101
101
  /**
102
102
  * Custom styles for the text span container.
103
103
  */
104
- style?: StyleProp<ViewStyle>;
104
+ style?: StyleProp<TextStyle>;
105
105
  };
106
106
 
107
107
  declare const TextSpan: React.FC<TextSpanProps>;
@@ -179,6 +179,7 @@ var Typography = ({
179
179
  variantStyles,
180
180
  resolvedAlign && { textAlign: resolvedAlign },
181
181
  textStyleOverrides,
182
+ inheritedStyle.spacing != null ? { marginRight: inheritedStyle.spacing } : void 0,
182
183
  style
183
184
  ]
184
185
  },
@@ -188,12 +189,12 @@ var Typography = ({
188
189
 
189
190
  // src/components/typography/text-span.tsx
190
191
  import React2 from "react";
191
- import { View } from "react-native";
192
- var alignToJustifyContent = {
193
- left: "flex-start",
192
+ import { Text as Text2 } from "react-native";
193
+ var alignToTextAlign = {
194
+ left: "left",
194
195
  center: "center",
195
- right: "flex-end",
196
- justify: "space-between"
196
+ right: "right",
197
+ justify: "justify"
197
198
  };
198
199
  var TextSpan = ({
199
200
  children,
@@ -211,18 +212,15 @@ var TextSpan = ({
211
212
  fontWeight,
212
213
  fontStyle,
213
214
  textTransform,
214
- align
215
+ align,
216
+ spacing
215
217
  };
216
218
  return /* @__PURE__ */ React2.createElement(TextSpanContext.Provider, { value: inheritedTextStyle }, /* @__PURE__ */ React2.createElement(
217
- View,
219
+ Text2,
218
220
  {
219
221
  style: [
220
222
  {
221
- flexDirection: "row",
222
- flexWrap: "wrap",
223
- alignItems: "center",
224
- ...align ? { justifyContent: alignToJustifyContent[align] } : {},
225
- ...typeof spacing === "number" ? { gap: spacing } : {},
223
+ ...align ? { textAlign: alignToTextAlign[align] } : {},
226
224
  ...backgroundColor ? { backgroundColor } : {}
227
225
  },
228
226
  style
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaui/native",
3
- "version": "0.0.41",
3
+ "version": "0.1.0",
4
4
  "description": "Flutter-inspired React Native UI components with native animations powered by React Native Reanimated",
5
5
  "keywords": [
6
6
  "react-native",