@wallarm-org/design-system 0.88.1 → 0.89.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.
@@ -2,4 +2,12 @@ import type { FilterOperator } from '../../types';
2
2
  import type { ParserState } from './types';
3
3
  export declare const validateField: (s: ParserState, name: string) => void;
4
4
  export declare const validateOperator: (s: ParserState, op: string, fieldName: string) => FilterOperator;
5
+ /**
6
+ * Validate pasted values through the *same* rules as inline typing
7
+ * (`getInvalidValueIndices`): a custom `validate`, `getSuggestions` fields, and
8
+ * `strictValues: false` all mean "the value list is a hint, not an allowlist",
9
+ * and grouped value options are flattened to their committable leaves. Reusing
10
+ * that one path keeps paste and typing in agreement — a value accepted when
11
+ * typed must not be rejected when pasted (AS-1377).
12
+ */
5
13
  export declare const validateValues: (s: ParserState, fieldName: string, values: Array<string | number>) => void;
@@ -1,3 +1,4 @@
1
+ import { getInvalidValueIndices } from "../validation.js";
1
2
  import { FilterParseError } from "./error.js";
2
3
  import { OPERATORS } from "./tokenizer.js";
3
4
  const validateField = (s, name)=>{
@@ -9,17 +10,10 @@ const validateOperator = (s, op, fieldName)=>{
9
10
  if (field?.operators && !field.operators.includes(op)) throw FilterParseError(`Operator '${op}' is not allowed for field '${fieldName}'`);
10
11
  return op;
11
12
  };
12
- const getAllowedValues = (field)=>{
13
- if (field.values && field.values.length > 0) return new Set(field.values.map((v)=>String(v.value)));
14
- if (field.options && field.options.length > 0) return new Set(field.options);
15
- return null;
16
- };
17
13
  const validateValues = (s, fieldName, values)=>{
18
14
  const field = s.fields.find((f)=>f.name === fieldName);
19
15
  if (!field) return;
20
- const allowed = getAllowedValues(field);
21
- if (!allowed) return;
22
- const invalid = values.filter((v)=>!allowed.has(String(v)));
16
+ const invalid = getInvalidValueIndices(field, values).map((i)=>values[i]);
23
17
  if (invalid.length > 0) {
24
18
  const formatted = invalid.map((v)=>`"${v}"`).join(', ');
25
19
  throw FilterParseError(`Invalid value ${formatted} for field '${fieldName}'`);
@@ -1,12 +1,18 @@
1
1
  import type { FC, HTMLAttributes, Ref } from 'react';
2
2
  import type { TestableProps } from '../../utils/testId';
3
3
  type FormatDateTimeFormat = 'relative' | 'date' | 'datetime';
4
+ type FormatDateTimeLayout = 'stacked' | 'inline';
4
5
  interface FormatDateTimeBaseProps {
5
6
  /** ISO string, Date object, or Unix timestamp (ms) */
6
7
  value: string | Date | number | null | undefined;
7
8
  /** Display format. Default: 'relative' */
8
9
  format?: FormatDateTimeFormat;
9
- /** Show seconds in tooltip absolute time. Default: true */
10
+ /**
11
+ * Datetime layout. `stacked` puts date over time; `inline` puts them on one
12
+ * line. Only affects `format='datetime'`. Default: 'stacked'
13
+ */
14
+ layout?: FormatDateTimeLayout;
15
+ /** Show seconds in the relative-format tooltip. Default: true */
10
16
  showSeconds?: boolean;
11
17
  ref?: Ref<HTMLTimeElement>;
12
18
  }
@@ -8,7 +8,7 @@ const toDate = (value)=>{
8
8
  if (value instanceof Date) return value;
9
9
  return new Date(value);
10
10
  };
11
- const FormatDateTime = ({ value, format = 'relative', showSeconds = true, ref, ...props })=>{
11
+ const FormatDateTime = ({ value, format = 'relative', layout = 'stacked', showSeconds = true, ref, ...props })=>{
12
12
  if (null == value) return /*#__PURE__*/ jsxs(Tooltip, {
13
13
  children: [
14
14
  /*#__PURE__*/ jsx(TooltipTrigger, {
@@ -67,54 +67,34 @@ const FormatDateTime = ({ value, format = 'relative', showSeconds = true, ref, .
67
67
  })
68
68
  ]
69
69
  });
70
- if ('datetime' === format) return /*#__PURE__*/ jsxs(Tooltip, {
70
+ if ('datetime' === format) return /*#__PURE__*/ jsxs("time", {
71
+ ref: ref,
72
+ dateTime: isoString,
73
+ className: cn('inline-flex whitespace-nowrap', 'inline' === layout ? 'items-baseline gap-4' : 'flex-col'),
74
+ "data-slot": "format-date-time",
75
+ ...props,
71
76
  children: [
72
- /*#__PURE__*/ jsx(TooltipTrigger, {
73
- asChild: true,
74
- children: /*#__PURE__*/ jsxs("time", {
75
- ref: ref,
76
- dateTime: isoString,
77
- className: "inline-flex flex-col whitespace-nowrap",
78
- "data-slot": "format-date-time",
79
- ...props,
80
- children: [
81
- /*#__PURE__*/ jsx(Text, {
82
- size: "sm",
83
- children: formatAbsoluteDate(date)
84
- }),
85
- /*#__PURE__*/ jsx(Text, {
86
- size: "sm",
87
- color: "secondary",
88
- children: formatTimeOnly(date)
89
- })
90
- ]
91
- })
77
+ /*#__PURE__*/ jsx(Text, {
78
+ size: "sm",
79
+ children: formatAbsoluteDate(date)
92
80
  }),
93
- /*#__PURE__*/ jsx(TooltipContent, {
94
- children: tooltipText
81
+ /*#__PURE__*/ jsx(Text, {
82
+ size: "sm",
83
+ color: "secondary",
84
+ children: formatTimeOnly(date)
95
85
  })
96
86
  ]
97
87
  });
98
- return /*#__PURE__*/ jsxs(Tooltip, {
99
- children: [
100
- /*#__PURE__*/ jsx(TooltipTrigger, {
101
- asChild: true,
102
- children: /*#__PURE__*/ jsx("time", {
103
- ref: ref,
104
- dateTime: isoString,
105
- className: "inline-flex flex-col whitespace-nowrap",
106
- "data-slot": "format-date-time",
107
- ...props,
108
- children: /*#__PURE__*/ jsx(Text, {
109
- size: "sm",
110
- children: formatAbsoluteDate(date)
111
- })
112
- })
113
- }),
114
- /*#__PURE__*/ jsx(TooltipContent, {
115
- children: tooltipText
116
- })
117
- ]
88
+ return /*#__PURE__*/ jsx("time", {
89
+ ref: ref,
90
+ dateTime: isoString,
91
+ className: "inline-flex flex-col whitespace-nowrap",
92
+ "data-slot": "format-date-time",
93
+ ...props,
94
+ children: /*#__PURE__*/ jsx(Text, {
95
+ size: "sm",
96
+ children: formatAbsoluteDate(date)
97
+ })
118
98
  });
119
99
  };
120
100
  FormatDateTime.displayName = 'FormatDateTime';
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.88.0",
3
- "generatedAt": "2026-08-11T12:56:16.025Z",
2
+ "version": "0.88.2",
3
+ "generatedAt": "2026-08-12T09:08:55.589Z",
4
4
  "components": [
5
5
  {
6
6
  "name": "Accordion",
@@ -31450,11 +31450,18 @@
31450
31450
  "description": "Display format. Default: 'relative'",
31451
31451
  "defaultValue": "relative"
31452
31452
  },
31453
+ {
31454
+ "name": "layout",
31455
+ "type": "FormatDateTimeLayout | undefined",
31456
+ "required": false,
31457
+ "description": "Datetime layout. `stacked` puts date over time; `inline` puts them on one\nline. Only affects `format='datetime'`. Default: 'stacked'",
31458
+ "defaultValue": "stacked"
31459
+ },
31453
31460
  {
31454
31461
  "name": "showSeconds",
31455
31462
  "type": "boolean | undefined",
31456
31463
  "required": false,
31457
- "description": "Show seconds in tooltip absolute time. Default: true",
31464
+ "description": "Show seconds in the relative-format tooltip. Default: true",
31458
31465
  "defaultValue": "true"
31459
31466
  }
31460
31467
  ],
@@ -31473,6 +31480,10 @@
31473
31480
  "name": "DatetimeFormat",
31474
31481
  "code": "() => (\n <VStack gap={12} align='start'>\n <FormatDateTime value='2026-01-01T11:00:00' format='datetime' />\n <FormatDateTime value='2026-02-11T14:32:07' format='datetime' />\n <FormatDateTime value='2025-12-25T23:59:59' format='datetime' />\n </VStack>\n)"
31475
31482
  },
31483
+ {
31484
+ "name": "DatetimeLayout",
31485
+ "code": "() => (\n <HStack gap={64} align='start'>\n <VStack gap={12} align='start'>\n <Text size='sm' color='secondary'>\n Stacked (default)\n </Text>\n <FormatDateTime value='2026-01-01T11:00:00' format='datetime' layout='stacked' />\n <FormatDateTime value='2026-02-11T14:32:07' format='datetime' layout='stacked' />\n <FormatDateTime value='2025-12-25T23:59:59' format='datetime' layout='stacked' />\n </VStack>\n <VStack gap={12} align='start'>\n <Text size='sm' color='secondary'>\n Inline\n </Text>\n <FormatDateTime value='2026-01-01T11:00:00' format='datetime' layout='inline' />\n <FormatDateTime value='2026-02-11T14:32:07' format='datetime' layout='inline' />\n <FormatDateTime value='2025-12-25T23:59:59' format='datetime' layout='inline' />\n </VStack>\n </HStack>\n)"
31486
+ },
31476
31487
  {
31477
31488
  "name": "WithDescription",
31478
31489
  "code": "() => (\n <VStack gap={12} align='start'>\n <VStack gap={2}>\n <FormatDateTime value='2026-01-01T00:00:00' format='date' />\n <Text size='sm' color='secondary'>\n Created by admin\n </Text>\n </VStack>\n <VStack gap={2}>\n <FormatDateTime value='2026-02-11T14:32:07' format='date' />\n <Text size='sm' color='secondary'>\n Last modified\n </Text>\n </VStack>\n </VStack>\n)"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wallarm-org/design-system",
3
- "version": "0.88.1",
3
+ "version": "0.89.0",
4
4
  "description": "Core design system library with React components and Storybook documentation",
5
5
  "publishConfig": {
6
6
  "access": "public",