oneslash-design-system 2.29.0 → 2.30.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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/cases/agent-permissions/levels.jsx +3 -1
  3. package/dist/cases/agent-permissions/per-tool.jsx +5 -3
  4. package/dist/cases/agent-permissions.md +10 -5
  5. package/dist/cases/bulk-actions/list.jsx +2 -5
  6. package/dist/cases/bulk-actions/paged-table.jsx +3 -6
  7. package/dist/cases/bulk-actions.md +8 -14
  8. package/dist/cases/product-demo/scripted.d.ts +1 -3
  9. package/dist/cases/product-demo/scripted.jsx +14 -10
  10. package/dist/cases/product-demo.md +15 -10
  11. package/dist/cases.json +10 -7
  12. package/dist/components/checkBox.d.ts +3 -2
  13. package/dist/components/checkBox.jsx +18 -7
  14. package/dist/components/diff.d.ts +4 -1
  15. package/dist/components/diff.jsx +8 -1
  16. package/dist/components/segmentedControl.d.ts +3 -1
  17. package/dist/components/segmentedControl.jsx +8 -6
  18. package/dist/components/slidingIndicator.d.ts +5 -2
  19. package/dist/components/slidingIndicator.jsx +9 -3
  20. package/dist/components/tableContainer.d.ts +1 -1
  21. package/dist/components/tableContainer.jsx +2 -2
  22. package/dist/components/timeStamp.d.ts +3 -1
  23. package/dist/components/timeStamp.jsx +4 -2
  24. package/dist/components/useReducedMotion.d.ts +6 -0
  25. package/dist/components/useReducedMotion.js +19 -0
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.js +1 -0
  28. package/dist/stories/Checkbox.stories.d.ts +1 -0
  29. package/dist/stories/Checkbox.stories.jsx +21 -1
  30. package/dist/stories/Diff.stories.d.ts +1 -0
  31. package/dist/stories/Diff.stories.jsx +5 -0
  32. package/dist/stories/SegmentedControl.stories.d.ts +1 -0
  33. package/dist/stories/SegmentedControl.stories.jsx +6 -0
  34. package/dist/stories/Table.stories.d.ts +1 -0
  35. package/dist/stories/Table.stories.jsx +25 -0
  36. package/dist/stories/TimeStamp.stories.d.ts +1 -0
  37. package/dist/stories/TimeStamp.stories.jsx +13 -0
  38. package/package.json +5 -1
  39. package/dist/stories/ProductDemo.probe.stories.d.ts +0 -6
  40. package/dist/stories/ProductDemo.probe.stories.jsx +0 -12
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import React from 'react';
3
3
  export default function TimeStamp(_a) {
4
- var createdAt = _a.createdAt, dateFormat = _a.dateFormat, _b = _a.textSize, textSize = _b === void 0 ? 'small' : _b, _c = _a.textColor, textColor = _c === void 0 ? 'secondary' : _c, _d = _a.data, data = _d === void 0 ? 'date-and-time' : _d;
4
+ var createdAt = _a.createdAt, dateFormat = _a.dateFormat, _b = _a.textSize, textSize = _b === void 0 ? 'small' : _b, _c = _a.textColor, textColor = _c === void 0 ? 'secondary' : _c, _d = _a.data, data = _d === void 0 ? 'date-and-time' : _d, _e = _a.hourCycle, hourCycle = _e === void 0 ? '24' : _e;
5
5
  // absolute timestamp
6
6
  var absoluteTimeStamp = function (createdAt) {
7
7
  var date = new Date(createdAt);
@@ -15,7 +15,9 @@ export default function TimeStamp(_a) {
15
15
  var daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
16
16
  var dayOfWeek = daysOfWeek[date.getDay()];
17
17
  var dateString = "".concat(month, "/").concat(day, "/").concat(year, " ").concat(dayOfWeek);
18
- var timeString = "".concat(formattedHours, ":").concat(formattedMinutes);
18
+ var timeString = hourCycle === '12'
19
+ ? "".concat(hours % 12 || 12, ":").concat(formattedMinutes, " ").concat(hours < 12 ? 'AM' : 'PM')
20
+ : "".concat(formattedHours, ":").concat(formattedMinutes);
19
21
  if (data === 'date') {
20
22
  return dateString;
21
23
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * True when the visitor asks for reduced motion, and it follows the setting as it changes.
3
+ * True on the server and while hydrating, so motion that starts by itself waits for the browser's answer.
4
+ * CSS motion already stops with `motion-reduce:`; use this for motion a script starts, such as a demo that plays on open.
5
+ */
6
+ export default function useReducedMotion(): boolean;
@@ -0,0 +1,19 @@
1
+ 'use client';
2
+ import { useSyncExternalStore } from 'react';
3
+ var QUERY = '(prefers-reduced-motion: reduce)';
4
+ var subscribe = function (onChange) {
5
+ var mq = window.matchMedia ? window.matchMedia(QUERY) : null;
6
+ mq === null || mq === void 0 ? void 0 : mq.addEventListener('change', onChange);
7
+ return function () { return mq === null || mq === void 0 ? void 0 : mq.removeEventListener('change', onChange); };
8
+ };
9
+ var fromBrowser = function () { return (window.matchMedia ? window.matchMedia(QUERY).matches : false); };
10
+ // A server cannot know, so it takes the safe side: nothing moves until the browser says it may
11
+ var onServer = function () { return true; };
12
+ /**
13
+ * True when the visitor asks for reduced motion, and it follows the setting as it changes.
14
+ * True on the server and while hydrating, so motion that starts by itself waits for the browser's answer.
15
+ * CSS motion already stops with `motion-reduce:`; use this for motion a script starts, such as a demo that plays on open.
16
+ */
17
+ export default function useReducedMotion() {
18
+ return useSyncExternalStore(subscribe, fromBrowser, onServer);
19
+ }
package/dist/index.d.ts CHANGED
@@ -53,3 +53,4 @@ export * from './components/tooltip';
53
53
  export * from './components/userImage';
54
54
  export { default as useDarkMode, resolveDarkMode } from './components/useDarkMode';
55
55
  export { default as useHotkey } from './components/useHotkey';
56
+ export { default as useReducedMotion } from './components/useReducedMotion';
package/dist/index.js CHANGED
@@ -53,3 +53,4 @@ export * from './components/tooltip';
53
53
  export * from './components/userImage';
54
54
  export { default as useDarkMode, resolveDarkMode } from './components/useDarkMode';
55
55
  export { default as useHotkey } from './components/useHotkey';
56
+ export { default as useReducedMotion } from './components/useReducedMotion';
@@ -10,3 +10,4 @@ export declare const DisabledChecked: Story;
10
10
  export declare const NoLabel: Story;
11
11
  export declare const Indeterminate: Story;
12
12
  export declare const StaysMixed: Story;
13
+ export declare const FollowsParent: Story;
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useLayoutEffect, useRef, useState } from "react";
2
2
  import Checkbox from "../components/checkBox";
3
3
  var meta = {
4
4
  title: "Components/Checkbox",
@@ -61,3 +61,23 @@ export var StaysMixed = {
61
61
  tags: ["!dev", "!autodocs", "test-only"],
62
62
  render: function () { return <StaysMixedExample />; },
63
63
  };
64
+ // For tests/interactions.spec.ts only: the parent owns `checked` and reads the box through a ref right after
65
+ // each render. 'Behind' counts the renders where the box still showed the old value.
66
+ function FollowsParentExample() {
67
+ var _a = useState(false), checked = _a[0], setChecked = _a[1];
68
+ var _b = useState(0), behind = _b[0], setBehind = _b[1];
69
+ var box = useRef(null);
70
+ useLayoutEffect(function () {
71
+ if (box.current && box.current.checked !== checked)
72
+ setBehind(function (n) { return n + 1; });
73
+ }, [checked]);
74
+ return (<div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
75
+ <Checkbox ref={box} label="Email me" secondLabel={"Behind ".concat(behind, " times")} checked={checked} onChange={setChecked}/>
76
+ <button type="button" onClick={function () { return setChecked(function (c) { return !c; }); }}>Flip</button>
77
+ <button type="button" onClick={function () { var _a; return (_a = box.current) === null || _a === void 0 ? void 0 : _a.focus(); }}>Focus the box</button>
78
+ </div>);
79
+ }
80
+ export var FollowsParent = {
81
+ tags: ["!dev", "!autodocs", "test-only"],
82
+ render: function () { return <FollowsParentExample />; },
83
+ };
@@ -7,3 +7,4 @@ export declare const Short: Story;
7
7
  export declare const LongLine: Story;
8
8
  export declare const Capped: Story;
9
9
  export declare const Empty: Story;
10
+ export declare const LineNumbers: Story;
@@ -7,6 +7,7 @@ var meta = {
7
7
  maxRows: { control: "number" },
8
8
  emptyText: { control: "text" },
9
9
  wrap: { control: "boolean" },
10
+ lineNumbers: { control: "boolean" },
10
11
  },
11
12
  decorators: [function (Story) { return <div style={{ width: 520, maxWidth: "100%" }}><Story /></div>; }],
12
13
  };
@@ -38,3 +39,7 @@ export var Capped = {
38
39
  export var Empty = {
39
40
  args: { id: "diff-empty", label: "limits.ts", lines: diffLines(before, before) },
40
41
  };
42
+ // The old and the new line number before each mark
43
+ export var LineNumbers = {
44
+ args: { id: "diff-line-numbers", label: "limits.ts", lines: diffLines(before, after), lineNumbers: true },
45
+ };
@@ -6,3 +6,4 @@ type Story = StoryObj<typeof SegmentedControl>;
6
6
  export declare const Default: Story;
7
7
  export declare const Small: Story;
8
8
  export declare const Fit: Story;
9
+ export declare const Disabled: Story;
@@ -6,6 +6,7 @@ var meta = {
6
6
  argTypes: {
7
7
  size: { control: "select", options: ["medium", "small", "tiny"] },
8
8
  "aria-label": { control: "text" },
9
+ disabled: { control: "boolean" },
9
10
  },
10
11
  decorators: [function (Story) { return <div style={{ width: 360 }}><Story /></div>; }],
11
12
  };
@@ -31,3 +32,8 @@ export var Fit = {
31
32
  render: function (args) { return <Wrapper {...args}/>; },
32
33
  args: { options: options, value: "week", "aria-label": "Range", size: "small", width: "fit" },
33
34
  };
35
+ // Shows its value and takes no press, e.g. a setting only an admin can change
36
+ export var Disabled = {
37
+ render: function (args) { return <Wrapper {...args}/>; },
38
+ args: { options: options, value: "month", "aria-label": "Range", size: "small", disabled: true },
39
+ };
@@ -7,3 +7,4 @@ export declare const Default: Story;
7
7
  export declare const FlexibleWidth: Story;
8
8
  export declare const CenteredContent: Story;
9
9
  export declare const Scrolls: Story;
10
+ export declare const ScrollsWithLinks: Story;
@@ -14,6 +14,7 @@ import TableHeaderCell from "../components/tableHeaderCell";
14
14
  import TableRow from "../components/tableRow";
15
15
  import TableCell from "../components/tableCell";
16
16
  import Button from "../components/button";
17
+ import Link from "../components/link";
17
18
  var meta = {
18
19
  title: "Components/Table",
19
20
  component: TableContainer,
@@ -130,3 +131,27 @@ export var Scrolls = {
130
131
  tags: ["phone"],
131
132
  render: function () { return <ScrollsDemo />; },
132
133
  };
134
+ // Shot at 375px (the "phone" tag): a Link that says it opens a new tab sits in the last column,
135
+ // and its hidden words scroll with the table, so the page still does not scroll sideways
136
+ export var ScrollsWithLinks = {
137
+ tags: ["phone"],
138
+ render: function () { return (<TableContainer aria-label="Sources" minWidth="640px">
139
+ <TableHeader>
140
+ <TableRow>
141
+ <TableHeaderCell>Claim</TableHeaderCell>
142
+ <TableHeaderCell>Value</TableHeaderCell>
143
+ <TableHeaderCell>Source</TableHeaderCell>
144
+ </TableRow>
145
+ </TableHeader>
146
+ {[
147
+ { claim: "Seats on the free plan", value: "5", label: "Pricing", href: "https://northwind.example/pricing" },
148
+ { claim: "Single sign-on", value: "Yes, on Team", label: "Security", href: "https://northwind.example/security" },
149
+ ].map(function (row) { return (<TableRow key={row.claim}>
150
+ <TableCell rowHeader>{row.claim}</TableCell>
151
+ <TableCell>{row.value}</TableCell>
152
+ <TableCell>
153
+ <Link href={row.href} size="body2" openInNewTab announceNewTab>{row.label}</Link>
154
+ </TableCell>
155
+ </TableRow>); })}
156
+ </TableContainer>); },
157
+ };
@@ -13,4 +13,5 @@ export declare const RelativeWeeks: Story;
13
13
  export declare const RelativeMonths: Story;
14
14
  export declare const PrimaryColor: Story;
15
15
  export declare const LargeSize: Story;
16
+ export declare const TwelveHour: Story;
16
17
  export declare const AllFormats: Story;
@@ -20,6 +20,10 @@ var meta = {
20
20
  control: "select",
21
21
  options: ["date-and-time", "date", "time"],
22
22
  },
23
+ hourCycle: {
24
+ control: "select",
25
+ options: ["24", "12"],
26
+ },
23
27
  },
24
28
  };
25
29
  export default meta;
@@ -118,6 +122,15 @@ export var LargeSize = {
118
122
  data: "date-and-time",
119
123
  },
120
124
  };
125
+ // 2:40 PM in place of 14:40, for an app whose readers use a 12-hour clock
126
+ export var TwelveHour = {
127
+ render: function () { return (<div style={{ display: "flex", flexDirection: "column", gap: "8px" }}>
128
+ <TimeStamp createdAt="2026-11-16T14:40:00" dateFormat="absolute" data="time" hourCycle="12"/>
129
+ <TimeStamp createdAt="2026-11-16T00:05:00" dateFormat="absolute" data="time" hourCycle="12"/>
130
+ <TimeStamp createdAt="2026-11-16T14:40:00" dateFormat="absolute" data="date-and-time" hourCycle="12"/>
131
+ <TimeStamp createdAt="2026-11-16T14:40:00" dateFormat="absolute" data="time"/>
132
+ </div>); },
133
+ };
121
134
  export var AllFormats = {
122
135
  render: function () { return (<div style={{ display: "flex", flexDirection: "column", gap: "8px" }}>
123
136
  <div>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oneslash-design-system",
3
3
  "description": "A design system for the Oneslash projects",
4
- "version": "2.29.0",
4
+ "version": "2.30.0",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "./dist/index.js",
@@ -15,6 +15,10 @@
15
15
  "types": "./dist/components/useHotkey.d.ts",
16
16
  "default": "./dist/components/useHotkey.js"
17
17
  },
18
+ "./components/useReducedMotion": {
19
+ "types": "./dist/components/useReducedMotion.d.ts",
20
+ "default": "./dist/components/useReducedMotion.js"
21
+ },
18
22
  "./components/formatNumber": {
19
23
  "types": "./dist/components/formatNumber.d.ts",
20
24
  "default": "./dist/components/formatNumber.js"
@@ -1,6 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import ProductDemoScripted from "../cases/product-demo/scripted";
3
- declare const meta: Meta<typeof ProductDemoScripted>;
4
- export default meta;
5
- type Story = StoryObj<typeof ProductDemoScripted>;
6
- export declare const ScriptedProbe: Story;
@@ -1,12 +0,0 @@
1
- import React from "react";
2
- import ProductDemoScripted from "../cases/product-demo/scripted";
3
- var meta = {
4
- title: "ProductDemo",
5
- component: ProductDemoScripted,
6
- };
7
- export default meta;
8
- // For tests/interactions.spec.ts only: plays on open as a real site does, unless the visitor asks for reduced motion
9
- export var ScriptedProbe = {
10
- tags: ["!dev", "!autodocs", "test-only"],
11
- render: function () { return <ProductDemoScripted autoPlay={!window.matchMedia("(prefers-reduced-motion: reduce)").matches}/>; },
12
- };