@inkra/react 0.1.0 → 0.2.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 (160) hide show
  1. package/README.md +104 -1
  2. package/dist/PencilIcon.js +14 -16
  3. package/dist/PencilLine.js +18 -12
  4. package/dist/PencilText.js +192 -59
  5. package/dist/alert-dialog/index.d.ts +64 -0
  6. package/dist/alert-dialog/index.js +109 -0
  7. package/dist/audio-player/index.d.ts +60 -0
  8. package/dist/audio-player/index.js +101 -0
  9. package/dist/carousel/index.d.ts +51 -0
  10. package/dist/carousel/index.js +290 -0
  11. package/dist/choice-grid/index.d.ts +38 -0
  12. package/dist/choice-grid/index.js +85 -0
  13. package/dist/color-picker/color.d.ts +15 -0
  14. package/dist/color-picker/color.js +55 -0
  15. package/dist/color-picker/index.d.ts +31 -0
  16. package/dist/color-picker/index.js +69 -0
  17. package/dist/command/index.d.ts +23 -0
  18. package/dist/command/index.js +39 -0
  19. package/dist/context-menu/index.d.ts +76 -0
  20. package/dist/context-menu/index.js +240 -0
  21. package/dist/data-table/index.d.ts +47 -0
  22. package/dist/data-table/index.js +91 -0
  23. package/dist/date-picker/index.d.ts +50 -0
  24. package/dist/date-picker/index.js +180 -0
  25. package/dist/display/ProgressRing.d.ts +6 -0
  26. package/dist/display/ProgressRing.js +146 -0
  27. package/dist/display/index.d.ts +27 -0
  28. package/dist/display/index.js +18 -2
  29. package/dist/dockable-panel/index.d.ts +41 -0
  30. package/dist/dockable-panel/index.js +253 -0
  31. package/dist/dockable-panel/model.d.ts +21 -0
  32. package/dist/dockable-panel/model.js +61 -0
  33. package/dist/drawer/index.d.ts +63 -0
  34. package/dist/drawer/index.js +86 -0
  35. package/dist/editable/index.d.ts +53 -0
  36. package/dist/editable/index.js +162 -0
  37. package/dist/empty/index.d.ts +21 -0
  38. package/dist/empty/index.js +23 -0
  39. package/dist/flip/index.d.ts +49 -0
  40. package/dist/flip/index.js +138 -0
  41. package/dist/form/EditablePencilText.js +157 -146
  42. package/dist/form/Textarea.d.ts +12 -0
  43. package/dist/form/Textarea.js +83 -4
  44. package/dist/form/index.d.ts +1 -1
  45. package/dist/heatmap/index.d.ts +59 -0
  46. package/dist/heatmap/index.js +248 -0
  47. package/dist/hotkey/index.d.ts +37 -0
  48. package/dist/hotkey/index.js +130 -0
  49. package/dist/hotkey/model.d.ts +27 -0
  50. package/dist/hotkey/model.js +97 -0
  51. package/dist/hover-card/index.d.ts +33 -0
  52. package/dist/hover-card/index.js +141 -0
  53. package/dist/image-cropper/index.d.ts +82 -0
  54. package/dist/image-cropper/index.js +261 -0
  55. package/dist/image-cropper/model.d.ts +42 -0
  56. package/dist/image-cropper/model.js +94 -0
  57. package/dist/image-viewer/index.d.ts +79 -0
  58. package/dist/image-viewer/index.js +220 -0
  59. package/dist/image-viewer/model.d.ts +9 -0
  60. package/dist/image-viewer/model.js +18 -0
  61. package/dist/index.d.ts +47 -0
  62. package/dist/index.js +47 -0
  63. package/dist/internal/cache.d.ts +1 -1
  64. package/dist/internal/cache.js +1 -1
  65. package/dist/internal/renderTokens.d.ts +10 -0
  66. package/dist/internal/renderTokens.js +13 -0
  67. package/dist/internal/surfaceRenderer.d.ts +14 -6
  68. package/dist/internal/surfaceRenderer.js +15 -12
  69. package/dist/internal/textRenderer.d.ts +1 -0
  70. package/dist/internal/textRenderer.js +33 -7
  71. package/dist/internal/usePencilSurface.js +16 -8
  72. package/dist/internal/useSelectionDrawing.js +15 -11
  73. package/dist/journey-map/MapScale.js +3 -1
  74. package/dist/journey-map/index.js +3 -1
  75. package/dist/keypad/index.d.ts +23 -0
  76. package/dist/keypad/index.js +63 -0
  77. package/dist/keypad/model.d.ts +20 -0
  78. package/dist/keypad/model.js +33 -0
  79. package/dist/layout/index.d.ts +63 -0
  80. package/dist/layout/index.js +62 -0
  81. package/dist/log/index.d.ts +45 -0
  82. package/dist/log/index.js +159 -0
  83. package/dist/log/model.d.ts +16 -0
  84. package/dist/log/model.js +13 -0
  85. package/dist/node-graph/index.d.ts +123 -0
  86. package/dist/node-graph/index.js +304 -0
  87. package/dist/number-ticker/index.d.ts +29 -0
  88. package/dist/number-ticker/index.js +132 -0
  89. package/dist/number-ticker/model.d.ts +8 -0
  90. package/dist/number-ticker/model.js +34 -0
  91. package/dist/overflow-list/index.d.ts +39 -0
  92. package/dist/overflow-list/index.js +230 -0
  93. package/dist/overflow-list/layout.d.ts +19 -0
  94. package/dist/overflow-list/layout.js +44 -0
  95. package/dist/pagination/index.d.ts +23 -0
  96. package/dist/pagination/index.js +41 -0
  97. package/dist/pagination/model.d.ts +4 -0
  98. package/dist/pagination/model.js +42 -0
  99. package/dist/pan-zoom/index.d.ts +71 -0
  100. package/dist/pan-zoom/index.js +175 -0
  101. package/dist/radar/index.d.ts +54 -0
  102. package/dist/radar/index.js +220 -0
  103. package/dist/range-slider/index.d.ts +16 -0
  104. package/dist/range-slider/index.js +22 -0
  105. package/dist/rating/index.d.ts +28 -0
  106. package/dist/rating/index.js +127 -0
  107. package/dist/resizable/index.d.ts +32 -0
  108. package/dist/resizable/index.js +50 -0
  109. package/dist/scroll-area/index.d.ts +36 -0
  110. package/dist/scroll-area/index.js +44 -0
  111. package/dist/segmented-progress/SegmentedProgress.d.ts +17 -0
  112. package/dist/segmented-progress/SegmentedProgress.js +42 -0
  113. package/dist/slider/index.js +1 -1
  114. package/dist/slot/index.d.ts +24 -0
  115. package/dist/slot/index.js +29 -0
  116. package/dist/sortable/index.d.ts +50 -0
  117. package/dist/sortable/index.js +278 -0
  118. package/dist/sortable/model.d.ts +30 -0
  119. package/dist/sortable/model.js +64 -0
  120. package/dist/sparkline/index.d.ts +19 -0
  121. package/dist/sparkline/index.js +240 -0
  122. package/dist/sparkline/model.d.ts +16 -0
  123. package/dist/sparkline/model.js +28 -0
  124. package/dist/steps/index.d.ts +16 -0
  125. package/dist/steps/index.js +37 -0
  126. package/dist/styles.css +4850 -287
  127. package/dist/tag-input/index.d.ts +69 -0
  128. package/dist/tag-input/index.js +325 -0
  129. package/dist/tag-input/model.d.ts +14 -0
  130. package/dist/tag-input/model.js +38 -0
  131. package/dist/time-picker/index.d.ts +15 -0
  132. package/dist/time-picker/index.js +168 -0
  133. package/dist/timeline/index.d.ts +14 -0
  134. package/dist/timeline/index.js +16 -0
  135. package/dist/toast/index.d.ts +27 -0
  136. package/dist/toast/index.js +36 -0
  137. package/dist/toggle-group/index.d.ts +17 -0
  138. package/dist/toggle-group/index.js +26 -0
  139. package/dist/tokens.css +10 -9
  140. package/dist/transfer/index.d.ts +64 -0
  141. package/dist/transfer/index.js +174 -0
  142. package/dist/transfer/model.d.ts +12 -0
  143. package/dist/transfer/model.js +33 -0
  144. package/dist/tree/index.d.ts +39 -0
  145. package/dist/tree/index.js +36 -0
  146. package/dist/tree-select/index.d.ts +59 -0
  147. package/dist/tree-select/index.js +142 -0
  148. package/dist/tree-select/model.d.ts +31 -0
  149. package/dist/tree-select/model.js +135 -0
  150. package/dist/typewriter/index.d.ts +21 -0
  151. package/dist/typewriter/index.js +101 -0
  152. package/dist/typewriter/model.d.ts +7 -0
  153. package/dist/typewriter/model.js +45 -0
  154. package/dist/upload/index.d.ts +59 -0
  155. package/dist/upload/index.js +230 -0
  156. package/dist/virtual-list/index.d.ts +44 -0
  157. package/dist/virtual-list/index.js +128 -0
  158. package/dist/virtual-list/model.d.ts +7 -0
  159. package/dist/virtual-list/model.js +27 -0
  160. package/package.json +22 -3
@@ -0,0 +1,16 @@
1
+ export type SparklineDatum = number | null | undefined;
2
+ export type SparklinePoint = {
3
+ index: number;
4
+ value: number | null;
5
+ };
6
+ export type SparklineScale = (value: number | {
7
+ valueOf(): number;
8
+ }) => number;
9
+ export declare function normalizeSparklineData(data: readonly SparklineDatum[]): SparklinePoint[];
10
+ export declare function sparklineDomain(points: readonly SparklinePoint[]): [number, number];
11
+ export declare function createSparklineGeometry(points: readonly SparklinePoint[], width: number, height: number, padding?: number): {
12
+ x: SparklineScale;
13
+ y: SparklineScale;
14
+ linePath: string;
15
+ areaPath: string;
16
+ };
@@ -0,0 +1,28 @@
1
+ import { scaleLinear } from 'd3-scale';
2
+ import { area, line } from 'd3-shape';
3
+ export function normalizeSparklineData(data) {
4
+ return data.map((value, index) => ({ index, value: typeof value === 'number' && Number.isFinite(value) ? value : null }));
5
+ }
6
+ export function sparklineDomain(points) {
7
+ const values = points.flatMap(point => point.value === null ? [] : [point.value]);
8
+ if (values.length === 0)
9
+ return [0, 1];
10
+ const min = Math.min(...values);
11
+ const max = Math.max(...values);
12
+ if (min === max) {
13
+ const pad = Math.abs(min) * 0.12 || 1;
14
+ return [min - pad, max + pad];
15
+ }
16
+ const pad = (max - min) * 0.08;
17
+ return [min - pad, max + pad];
18
+ }
19
+ export function createSparklineGeometry(points, width, height, padding = 4) {
20
+ const innerWidth = Math.max(1, width - padding * 2);
21
+ const innerHeight = Math.max(1, height - padding * 2);
22
+ const x = scaleLinear().domain([0, Math.max(1, points.length - 1)]).range([padding, padding + innerWidth]);
23
+ const y = scaleLinear().domain(sparklineDomain(points)).range([padding + innerHeight, padding]);
24
+ const defined = (point) => point.value !== null;
25
+ const linePath = line().defined(defined).x(point => x(point.index)).y(point => y(point.value));
26
+ const areaPath = area().defined(defined).x(point => x(point.index)).y0(padding + innerHeight).y1(point => y(point.value));
27
+ return { x, y, linePath: linePath(points) ?? '', areaPath: areaPath(points) ?? '' };
28
+ }
@@ -0,0 +1,16 @@
1
+ import { type OlHTMLAttributes, type ReactNode } from 'react';
2
+ export type StepStatus = 'upcoming' | 'current' | 'complete' | 'error';
3
+ export interface StepItem {
4
+ id: string;
5
+ title: ReactNode;
6
+ description?: ReactNode;
7
+ status?: StepStatus;
8
+ disabled?: boolean;
9
+ }
10
+ export interface StepsProps extends Omit<OlHTMLAttributes<HTMLOListElement>, 'children'> {
11
+ current?: number;
12
+ items: readonly StepItem[];
13
+ onStepChange?: (index: number, item: StepItem) => void;
14
+ orientation?: 'horizontal' | 'vertical';
15
+ }
16
+ export declare const Steps: import("react").ForwardRefExoticComponent<StepsProps & import("react").RefAttributes<HTMLOListElement>>;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import { PencilIcon } from '../PencilIcon.js';
4
+ import { PencilLine } from '../PencilLine.js';
5
+ import { PencilSurface } from '../PencilSurface.js';
6
+ import { PencilText } from '../PencilText.js';
7
+ const markerPaths = {
8
+ upcoming: [{ d: 'M16 6a10 10 0 1 0 0 20 10 10 0 0 0 0-20Z' }],
9
+ current: [{ d: 'M16 6a10 10 0 1 0 0 20 10 10 0 0 0 0-20Z' }, { d: 'M16 12a4 4 0 1 0 0 8 4 4 0 0 0 0-8Z', mode: 'wash' }],
10
+ complete: [{ d: 'M6 17l6 6L27 8' }],
11
+ error: [{ d: 'M16 6a10 10 0 1 0 0 20 10 10 0 0 0 0-20ZM16 10v8M16 22v1' }],
12
+ };
13
+ const copy = (value) => typeof value === 'string' ? _jsx(PencilText, { children: value }) : value;
14
+ function resolvedStatus(item, index, current) {
15
+ if (item.status)
16
+ return item.status;
17
+ if (index < current)
18
+ return 'complete';
19
+ if (index === current)
20
+ return 'current';
21
+ return 'upcoming';
22
+ }
23
+ export const Steps = forwardRef(function Steps({ 'aria-label': ariaLabel = 'Progress', className, current = 0, items, onStepChange, orientation = 'horizontal', ...props }, ref) {
24
+ return _jsx("ol", { ...props, ref: ref, "aria-label": ariaLabel, className: ['inkra-steps', className].filter(Boolean).join(' '), "data-orientation": orientation, children: items.map((item, index) => {
25
+ const status = resolvedStatus(item, index, current);
26
+ const interactive = onStepChange !== undefined;
27
+ const content = _jsxs(_Fragment, { children: [status === 'current' && _jsx(PencilSurface, { "aria-hidden": "true", className: "inkra-steps__selection", variant: "selection", seed: `step-${item.id}` }), _jsx("span", { className: "inkra-steps__marker", "aria-hidden": "true", children: _jsx(PencilIcon, { paths: markerPaths[status], size: 28, sourceSize: 32, active: status === 'current' }) }), _jsxs("span", { className: "inkra-steps__copy", children: [_jsx("span", { className: "inkra-steps__title", children: copy(item.title) }), item.description != null && _jsx("span", { className: "inkra-steps__description", children: copy(item.description) })] })] });
28
+ const shared = {
29
+ className: 'inkra-steps__control',
30
+ 'aria-current': status === 'current' ? 'step' : undefined,
31
+ 'aria-disabled': item.disabled || undefined,
32
+ };
33
+ return _jsxs("li", { className: "inkra-steps__item", "data-status": status, "data-disabled": item.disabled || undefined, children: [interactive
34
+ ? _jsx("button", { ...shared, type: "button", disabled: item.disabled, onClick: () => onStepChange(index, item), children: content })
35
+ : _jsx("div", { ...shared, children: content }), index < items.length - 1 && _jsx(PencilLine, { className: "inkra-steps__connector", orientation: orientation === 'horizontal' ? 'horizontal' : 'vertical', seed: `step-line-${item.id}` })] }, item.id);
36
+ }) });
37
+ });