@dcs-tech/ui-native 0.0.0-stage → 0.15.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 (187) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/README.md +178 -2
  3. package/dist/components/Button/Button.js +61 -0
  4. package/dist/components/Button/buttonStyle.js +100 -0
  5. package/dist/components/Button/index.js +1 -0
  6. package/dist/components/Checkbox/Checkbox.js +60 -0
  7. package/dist/components/Checkbox/checkboxStyle.js +44 -0
  8. package/dist/components/Checkbox/index.js +1 -0
  9. package/dist/components/DataTable/BulkRun.js +85 -0
  10. package/dist/components/DataTable/CardList.js +70 -0
  11. package/dist/components/DataTable/DataTable.js +53 -0
  12. package/dist/components/DataTable/DataTableScrollView.js +33 -0
  13. package/dist/components/DataTable/DragSelect.js +153 -0
  14. package/dist/components/DataTable/LayoutSwitcher.js +48 -0
  15. package/dist/components/DataTable/Pager.js +15 -0
  16. package/dist/components/DataTable/RowActions.js +28 -0
  17. package/dist/components/DataTable/RowDetail.js +80 -0
  18. package/dist/components/DataTable/RowMenuSheet.js +72 -0
  19. package/dist/components/DataTable/SortSheet.js +25 -0
  20. package/dist/components/DataTable/SplitList.js +30 -0
  21. package/dist/components/DataTable/StatusRow.js +48 -0
  22. package/dist/components/DataTable/SwipeRow.js +125 -0
  23. package/dist/components/DataTable/ToolButton.js +9 -0
  24. package/dist/components/DataTable/Toolbar.js +53 -0
  25. package/dist/components/DataTable/cells.js +21 -0
  26. package/dist/components/DataTable/dataTableStyle.js +218 -0
  27. package/dist/components/DataTable/filters/FilterConditionRow.js +48 -0
  28. package/dist/components/DataTable/filters/FilterGroupEditor.js +21 -0
  29. package/dist/components/DataTable/filters/FilterSheet.js +67 -0
  30. package/dist/components/DataTable/filters/SavedFilterBar.js +39 -0
  31. package/dist/components/DataTable/filters/filterStyle.js +82 -0
  32. package/dist/components/DataTable/index.js +3 -0
  33. package/dist/components/DataTable/persistence/adapters.js +78 -0
  34. package/dist/components/DataTable/persistence/useViewPrefs.js +76 -0
  35. package/dist/components/DataTable/rowParts.js +47 -0
  36. package/dist/components/DataTable/useTableState.js +328 -0
  37. package/dist/components/DatePicker/Calendar.js +28 -0
  38. package/dist/components/DatePicker/DatePicker.js +296 -0
  39. package/dist/components/DatePicker/PeriodGrid.js +17 -0
  40. package/dist/components/DatePicker/PeriodPicker.js +213 -0
  41. package/dist/components/DatePicker/TimeField.js +50 -0
  42. package/dist/components/DatePicker/datePickerStyle.js +157 -0
  43. package/dist/components/DatePicker/index.js +2 -0
  44. package/dist/components/Dialog/Dialog.js +104 -0
  45. package/dist/components/Dialog/DialogHost.js +71 -0
  46. package/dist/components/Dialog/dialogStyle.js +72 -0
  47. package/dist/components/Dialog/index.js +2 -0
  48. package/dist/components/FieldContext/FieldContext.js +50 -0
  49. package/dist/components/FieldContext/index.js +1 -0
  50. package/dist/components/FieldWrapper/FieldWrapper.js +23 -0
  51. package/dist/components/FieldWrapper/fieldWrapperStyle.js +64 -0
  52. package/dist/components/FieldWrapper/index.js +1 -0
  53. package/dist/components/Icon/Icon.js +124 -0
  54. package/dist/components/Icon/IconContext.js +12 -0
  55. package/dist/components/Icon/iconStyle.js +59 -0
  56. package/dist/components/Icon/icons.js +239 -0
  57. package/dist/components/Icon/index.js +4 -0
  58. package/dist/components/Icon/useIconDone.js +19 -0
  59. package/dist/components/Input/Input.js +71 -0
  60. package/dist/components/Input/index.js +1 -0
  61. package/dist/components/Input/inputStyle.js +47 -0
  62. package/dist/components/Press/Ripple.js +92 -0
  63. package/dist/components/Press/index.js +1 -0
  64. package/dist/components/Press/measure.js +3 -0
  65. package/dist/components/Radio/Radio.js +54 -0
  66. package/dist/components/Radio/index.js +1 -0
  67. package/dist/components/Radio/radioStyle.js +45 -0
  68. package/dist/components/Select/Select.js +83 -0
  69. package/dist/components/Select/SelectSheet.js +85 -0
  70. package/dist/components/Select/index.js +1 -0
  71. package/dist/components/Suggest/Suggest.js +101 -0
  72. package/dist/components/Suggest/index.js +1 -0
  73. package/dist/components/Switch/Switch.js +71 -0
  74. package/dist/components/Switch/index.js +1 -0
  75. package/dist/components/Switch/switchStyle.js +59 -0
  76. package/dist/components/Toast/ToastHost.js +76 -0
  77. package/dist/components/Toast/ToastItem.js +115 -0
  78. package/dist/components/Toast/ToastLayer.js +21 -0
  79. package/dist/components/Toast/index.js +2 -0
  80. package/dist/components/Toast/toast.types.js +1 -0
  81. package/dist/components/Toast/toastStyle.js +73 -0
  82. package/dist/components/Toggle/ToggleField.js +20 -0
  83. package/dist/components/Toggle/ToggleGroupFrame.js +10 -0
  84. package/dist/components/UIProvider/UIProvider.js +14 -0
  85. package/dist/components/UIProvider/context.js +57 -0
  86. package/dist/components/UIProvider/index.js +1 -0
  87. package/dist/components/styles/color.js +35 -0
  88. package/dist/components/styles/fieldControl.js +102 -0
  89. package/dist/components/styles/popupList.js +102 -0
  90. package/dist/components/styles/toggle.js +64 -0
  91. package/dist/components/styles/webValues.js +147 -0
  92. package/dist/index.js +15 -0
  93. package/dist/locales/hi.js +1 -0
  94. package/dist/locales/ta.js +1 -0
  95. package/dist/types/components/Button/Button.d.ts +31 -0
  96. package/dist/types/components/Button/buttonStyle.d.ts +46 -0
  97. package/dist/types/components/Button/index.d.ts +3 -0
  98. package/dist/types/components/Checkbox/Checkbox.d.ts +60 -0
  99. package/dist/types/components/Checkbox/checkboxStyle.d.ts +16 -0
  100. package/dist/types/components/Checkbox/index.d.ts +3 -0
  101. package/dist/types/components/DataTable/BulkRun.d.ts +11 -0
  102. package/dist/types/components/DataTable/CardList.d.ts +18 -0
  103. package/dist/types/components/DataTable/DataTable.d.ts +11 -0
  104. package/dist/types/components/DataTable/DataTableScrollView.d.ts +10 -0
  105. package/dist/types/components/DataTable/DragSelect.d.ts +12 -0
  106. package/dist/types/components/DataTable/LayoutSwitcher.d.ts +23 -0
  107. package/dist/types/components/DataTable/Pager.d.ts +5 -0
  108. package/dist/types/components/DataTable/RowActions.d.ts +13 -0
  109. package/dist/types/components/DataTable/RowDetail.d.ts +15 -0
  110. package/dist/types/components/DataTable/RowMenuSheet.d.ts +5 -0
  111. package/dist/types/components/DataTable/SortSheet.d.ts +8 -0
  112. package/dist/types/components/DataTable/SplitList.d.ts +9 -0
  113. package/dist/types/components/DataTable/StatusRow.d.ts +7 -0
  114. package/dist/types/components/DataTable/SwipeRow.d.ts +25 -0
  115. package/dist/types/components/DataTable/ToolButton.d.ts +13 -0
  116. package/dist/types/components/DataTable/Toolbar.d.ts +8 -0
  117. package/dist/types/components/DataTable/cells.d.ts +13 -0
  118. package/dist/types/components/DataTable/dataTableStyle.d.ts +139 -0
  119. package/dist/types/components/DataTable/filters/FilterConditionRow.d.ts +12 -0
  120. package/dist/types/components/DataTable/filters/FilterGroupEditor.d.ts +13 -0
  121. package/dist/types/components/DataTable/filters/FilterSheet.d.ts +5 -0
  122. package/dist/types/components/DataTable/filters/SavedFilterBar.d.ts +20 -0
  123. package/dist/types/components/DataTable/filters/filterStyle.d.ts +46 -0
  124. package/dist/types/components/DataTable/index.d.ts +5 -0
  125. package/dist/types/components/DataTable/persistence/adapters.d.ts +12 -0
  126. package/dist/types/components/DataTable/persistence/useViewPrefs.d.ts +20 -0
  127. package/dist/types/components/DataTable/rowParts.d.ts +32 -0
  128. package/dist/types/components/DataTable/useTableState.d.ts +103 -0
  129. package/dist/types/components/DatePicker/Calendar.d.ts +11 -0
  130. package/dist/types/components/DatePicker/DatePicker.d.ts +65 -0
  131. package/dist/types/components/DatePicker/PeriodGrid.d.ts +11 -0
  132. package/dist/types/components/DatePicker/PeriodPicker.d.ts +10 -0
  133. package/dist/types/components/DatePicker/TimeField.d.ts +15 -0
  134. package/dist/types/components/DatePicker/datePickerStyle.d.ts +75 -0
  135. package/dist/types/components/DatePicker/index.d.ts +4 -0
  136. package/dist/types/components/Dialog/Dialog.d.ts +35 -0
  137. package/dist/types/components/Dialog/DialogHost.d.ts +45 -0
  138. package/dist/types/components/Dialog/dialogStyle.d.ts +23 -0
  139. package/dist/types/components/Dialog/index.d.ts +4 -0
  140. package/dist/types/components/FieldContext/FieldContext.d.ts +43 -0
  141. package/dist/types/components/FieldContext/index.d.ts +3 -0
  142. package/dist/types/components/FieldWrapper/FieldWrapper.d.ts +23 -0
  143. package/dist/types/components/FieldWrapper/fieldWrapperStyle.d.ts +24 -0
  144. package/dist/types/components/FieldWrapper/index.d.ts +3 -0
  145. package/dist/types/components/Icon/Icon.d.ts +37 -0
  146. package/dist/types/components/Icon/IconContext.d.ts +12 -0
  147. package/dist/types/components/Icon/iconStyle.d.ts +10 -0
  148. package/dist/types/components/Icon/icons.d.ts +237 -0
  149. package/dist/types/components/Icon/index.d.ts +7 -0
  150. package/dist/types/components/Icon/useIconDone.d.ts +4 -0
  151. package/dist/types/components/Input/Input.d.ts +53 -0
  152. package/dist/types/components/Input/index.d.ts +3 -0
  153. package/dist/types/components/Input/inputStyle.d.ts +11 -0
  154. package/dist/types/components/Press/Ripple.d.ts +20 -0
  155. package/dist/types/components/Press/index.d.ts +2 -0
  156. package/dist/types/components/Press/measure.d.ts +8 -0
  157. package/dist/types/components/Radio/Radio.d.ts +58 -0
  158. package/dist/types/components/Radio/index.d.ts +3 -0
  159. package/dist/types/components/Radio/radioStyle.d.ts +17 -0
  160. package/dist/types/components/Select/Select.d.ts +49 -0
  161. package/dist/types/components/Select/SelectSheet.d.ts +34 -0
  162. package/dist/types/components/Select/index.d.ts +3 -0
  163. package/dist/types/components/Suggest/Suggest.d.ts +44 -0
  164. package/dist/types/components/Suggest/index.d.ts +3 -0
  165. package/dist/types/components/Switch/Switch.d.ts +42 -0
  166. package/dist/types/components/Switch/index.d.ts +3 -0
  167. package/dist/types/components/Switch/switchStyle.d.ts +29 -0
  168. package/dist/types/components/Toast/ToastHost.d.ts +12 -0
  169. package/dist/types/components/Toast/ToastItem.d.ts +17 -0
  170. package/dist/types/components/Toast/ToastLayer.d.ts +11 -0
  171. package/dist/types/components/Toast/index.d.ts +5 -0
  172. package/dist/types/components/Toast/toast.types.d.ts +37 -0
  173. package/dist/types/components/Toast/toastStyle.d.ts +22 -0
  174. package/dist/types/components/Toggle/ToggleField.d.ts +31 -0
  175. package/dist/types/components/Toggle/ToggleGroupFrame.d.ts +14 -0
  176. package/dist/types/components/UIProvider/UIProvider.d.ts +16 -0
  177. package/dist/types/components/UIProvider/context.d.ts +20 -0
  178. package/dist/types/components/UIProvider/index.d.ts +2 -0
  179. package/dist/types/components/styles/color.d.ts +2 -0
  180. package/dist/types/components/styles/fieldControl.d.ts +26 -0
  181. package/dist/types/components/styles/popupList.d.ts +48 -0
  182. package/dist/types/components/styles/toggle.d.ts +26 -0
  183. package/dist/types/components/styles/webValues.d.ts +157 -0
  184. package/dist/types/index.d.ts +15 -0
  185. package/dist/types/locales/hi.d.ts +1 -0
  186. package/dist/types/locales/ta.d.ts +1 -0
  187. package/package.json +85 -4
@@ -0,0 +1,124 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { forwardRef, useContext, useEffect, useId, useRef } from 'react';
3
+ import { Animated, Easing, View } from 'react-native';
4
+ import Svg, { Circle, Defs, Ellipse, G, Line, Mask, Path, Rect, Text as SvgText } from 'react-native-svg';
5
+ import { checkIcon, iconAccessibleName, iconBadgeGeometry, iconBadgeText, iconInset, iconStrokeWidth, ICON_BADGE_MAX, ICON_INSET_STROKE, ICON_MARK } from '@dcs-tech/core';
6
+ import { useTokens } from '../UIProvider/context';
7
+ import { IconSlotContext, useIconDefaults } from './IconContext';
8
+ import { iconBadgeColors, iconDuotoneColor, iconPixels, iconShapeColor, iconToneColor } from './iconStyle';
9
+ const BLEED = 6;
10
+ function shapeElement(shape, key, paint) {
11
+ const own = shape.color && !paint.mask ? iconShapeColor(paint.tokens, shape.color, paint.color) : undefined;
12
+ const props = {};
13
+ if (shape.fill)
14
+ props.fill = own ?? paint.color;
15
+ if (own)
16
+ props.stroke = own;
17
+ if (shape.solid || shape.type === 'text') {
18
+ props.fill = own ?? paint.color;
19
+ props.stroke = 'none';
20
+ }
21
+ if (paint.duo !== undefined && shape.duo) {
22
+ props.fill = paint.duo;
23
+ props.fillOpacity = paint.duoOpacity;
24
+ if (shape.duo === 'only')
25
+ props.stroke = 'none';
26
+ }
27
+ switch (shape.type) {
28
+ case 'path': return _jsx(Path, { ...props, d: shape.d }, key);
29
+ case 'circle': return _jsx(Circle, { ...props, cx: shape.cx, cy: shape.cy, r: shape.r }, key);
30
+ case 'ellipse': return _jsx(Ellipse, { ...props, cx: shape.cx, cy: shape.cy, rx: shape.rx, ry: shape.ry }, key);
31
+ case 'rect': return _jsx(Rect, { ...props, x: shape.x, y: shape.y, width: shape.width, height: shape.height, rx: shape.rx }, key);
32
+ case 'line': return _jsx(Line, { ...props, x1: shape.x1, y1: shape.y1, x2: shape.x2, y2: shape.y2 }, key);
33
+ case 'text':
34
+ return (_jsx(SvgText, { ...props, x: shape.x, y: shape.y, fontSize: shape.size, fontWeight: shape.weight, fontStyle: shape.italic ? 'italic' : undefined, ...(shape.width ? { textLength: shape.width, lengthAdjust: 'spacingAndGlyphs' } : {}), children: shape.text }, key));
35
+ }
36
+ }
37
+ function shapes(parts, keep, paint) {
38
+ return parts
39
+ .flatMap(p => p.shapes)
40
+ .filter(s => keep(s) && (paint.duo !== undefined || s.duo !== 'only'))
41
+ .map((s, i) => shapeElement(s, i, paint));
42
+ }
43
+ const all = () => true;
44
+ const notCutout = (s) => !s.cutout;
45
+ const isCutout = (s) => !!s.cutout;
46
+ const erase = (tokens) => ({ color: 'black', duoOpacity: 1, tokens, mask: true });
47
+ const ROUND = { strokeLinecap: 'round', strokeLinejoin: 'round' };
48
+ function drawing(parts, paint, stroke, maskId) {
49
+ if (!parts.some(p => p.shapes.some(isCutout)))
50
+ return shapes(parts, all, paint);
51
+ return (_jsxs(_Fragment, { children: [_jsx(Defs, { children: _jsxs(Mask, { id: maskId, maskUnits: "userSpaceOnUse", x: -4, y: -4, width: 32, height: 32, children: [_jsx(Rect, { x: -4, y: -4, width: 32, height: 32, fill: "white", stroke: "none" }), _jsx(G, { stroke: "black", fill: "none", strokeWidth: stroke, ...ROUND, children: shapes(parts, isCutout, erase(paint.tokens)) })] }) }), _jsx(G, { mask: `url(#${maskId})`, children: shapes(parts, notCutout, paint) })] }));
52
+ }
53
+ function withMark(body, mark, paint, stroke, maskId, dx, gridW) {
54
+ const k = 1 / ICON_MARK.scale;
55
+ const cutShapes = mark.parts.flatMap(p => p.shapes).filter(s => s.duo !== 'only' && !s.cutout);
56
+ const place = `translate(${ICON_MARK.x + dx} ${ICON_MARK.y}) scale(${ICON_MARK.scale})`;
57
+ return (_jsxs(_Fragment, { children: [_jsx(Defs, { children: _jsxs(Mask, { id: maskId, maskUnits: "userSpaceOnUse", x: -4, y: -4, width: gridW + 8, height: 32, children: [_jsx(Rect, { x: -4, y: -4, width: gridW + 8, height: 32, fill: "white", stroke: "none" }), _jsx(G, { transform: place, fill: "black", stroke: "black", strokeWidth: stroke * k + (ICON_MARK.ring * 2) / ICON_MARK.scale, ...ROUND, children: cutShapes.map((s, i) => shapeElement({ ...s, fill: true }, i, erase(paint.tokens))) })] }) }), _jsx(G, { mask: `url(#${maskId})`, children: body }), _jsx(G, { transform: place, stroke: paint.color, strokeWidth: stroke * k, children: shapes(mark.parts, all, paint) })] }));
58
+ }
59
+ function withBadge(body, text, colors, fontWeight, maskId, dx, gridW) {
60
+ const g = iconBadgeGeometry(text);
61
+ return (_jsxs(_Fragment, { children: [_jsx(Defs, { children: _jsxs(Mask, { id: maskId, maskUnits: "userSpaceOnUse", x: -6, y: -6, width: gridW + 12, height: 36, children: [_jsx(Rect, { x: -6, y: -6, width: gridW + 12, height: 36, fill: "white", stroke: "none" }), _jsx(Rect, { ...g.cut, x: g.cut.x + dx, fill: "black", stroke: "none" })] }) }), _jsx(G, { mask: `url(#${maskId})`, children: body }), _jsxs(G, { stroke: "none", transform: dx ? `translate(${dx} 0)` : undefined, children: [_jsx(Rect, { x: g.x, y: g.y, width: g.width, height: g.height, rx: g.rx, fill: colors.bg }), text !== '' && (_jsx(SvgText, { x: g.textX, y: g.textY, fontSize: g.fontSize, fontWeight: fontWeight, fill: colors.text, textAnchor: "middle", alignmentBaseline: "central", children: text }))] })] }));
62
+ }
63
+ function Spin({ ms, children }) {
64
+ const turn = useRef(new Animated.Value(0)).current;
65
+ useEffect(() => {
66
+ const loop = Animated.loop(Animated.timing(turn, { toValue: 1, duration: ms, easing: Easing.linear, useNativeDriver: true }));
67
+ loop.start();
68
+ return () => loop.stop();
69
+ }, [turn, ms]);
70
+ const rotate = turn.interpolate({ inputRange: [0, 1], outputRange: ['0deg', '360deg'] });
71
+ return _jsx(Animated.View, { style: { transform: [{ rotate }] }, children: children });
72
+ }
73
+ export const Icon = forwardRef(function Icon({ icon, size, tone, color, filled, weight, variant, duotoneTone, label, done, badge, badgeTone, badgeMax, badgeLabel, mark, markTone, style, testID }, ref) {
74
+ const t = useTokens();
75
+ const defaults = useIconDefaults();
76
+ const slot = useContext(IconSlotContext);
77
+ const id = useId().replace(/[^\w-]/g, '');
78
+ const px = iconPixels(t, size, defaults.size, slot.size);
79
+ const ink = color ?? (tone ? iconToneColor(t, tone) : slot.color ?? t.textPrimary);
80
+ const shown = done ? checkIcon : icon;
81
+ const showFilled = !done && !!(filled && icon.filled);
82
+ const list = showFilled ? icon.filled : shown.parts;
83
+ const duotone = (variant ?? defaults.variant) === 'duotone';
84
+ const duoTone = duotoneTone ?? defaults.duotoneTone;
85
+ const paint = {
86
+ color: ink,
87
+ duo: duotone ? (duoTone ? iconDuotoneColor(t, duoTone) : ink) : undefined,
88
+ duoOpacity: t.iconDuotoneOpacity,
89
+ tokens: t,
90
+ };
91
+ const inset = iconInset(icon);
92
+ const stroke = iconStrokeWidth(weight ?? defaults.weight, px) * (inset ? ICON_INSET_STROKE : 1);
93
+ const gridW = shown.width ?? icon.width ?? 24;
94
+ const dx = gridW - 24;
95
+ let body = drawing(list, paint, stroke, `dcs-icon-cut-${id}`);
96
+ const markIcon = mark && !done ? ('parts' in mark ? mark : mark.icon) : undefined;
97
+ if (markIcon) {
98
+ const markPaint = markTone ? { ...paint, color: iconToneColor(t, markTone) } : paint;
99
+ body = withMark(body, markIcon, markPaint, stroke, `dcs-icon-mark-${id}`, dx, gridW);
100
+ }
101
+ const badgeText = iconBadgeText(badge, badgeMax ?? defaults.badgeMax ?? ICON_BADGE_MAX);
102
+ if (badgeText !== null) {
103
+ body = withBadge(body, badgeText, iconBadgeColors(t, badgeTone ?? defaults.badgeTone ?? 'primary'), t.fontWeightBold, `dcs-icon-badge-${id}`, dx, gridW);
104
+ }
105
+ const name = iconAccessibleName(label, badgeText, badgeLabel);
106
+ const unit = px / (24 + inset * 2);
107
+ const edge = BLEED + inset;
108
+ let art = (_jsx(Svg, { width: (gridW + edge * 2) * unit, height: (24 + edge * 2) * unit, viewBox: `${-edge} ${-edge} ${gridW + edge * 2} ${24 + edge * 2}`, style: { position: 'absolute', left: -BLEED * unit, top: -BLEED * unit }, children: _jsx(G, { fill: "none", stroke: ink, strokeWidth: stroke, strokeLinecap: "round", strokeLinejoin: "round", children: body }) }));
109
+ if (shown.spinning)
110
+ art = _jsx(Spin, { ms: t.durationLong * 3, children: art });
111
+ return (_jsx(View, { ref: ref, testID: testID, style: [{ width: px * (gridW / 24), height: px }, style], ...(name
112
+ ? { accessible: true, role: 'img', 'aria-label': name }
113
+ : { accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' }), children: art }));
114
+ });
115
+ Icon.displayName = 'Icon';
116
+ export function createIcon(icon, displayName) {
117
+ const Component = forwardRef((props, ref) => _jsx(Icon, { ref: ref, icon: icon, ...props }));
118
+ Component.displayName = displayName;
119
+ return Object.assign(Component, { icon });
120
+ }
121
+ const definitionOf = (d) => ('parts' in d ? d : d.icon);
122
+ export const IconSwap = forwardRef(function IconSwap({ on, icon, onIcon, label, onLabel, ...rest }, ref) {
123
+ return _jsx(Icon, { ref: ref, ...rest, icon: definitionOf(on ? onIcon : icon), label: on ? onLabel ?? label : label });
124
+ });
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from 'react';
3
+ import { mergeIconDefaults } from '@dcs-tech/core';
4
+ const IconDefaultsContext = createContext({});
5
+ export const IconProvider = ({ children, animate, motion, size, weight, variant, duotoneTone, animateChanges, press, badgeTone, badgeMax, doneDuration }) => {
6
+ const parent = useContext(IconDefaultsContext);
7
+ const value = useMemo(() => mergeIconDefaults(parent, { animate, motion, size, weight, variant, duotoneTone, animateChanges, press, badgeTone, badgeMax, doneDuration }), [parent, animate, motion, size, weight, variant, duotoneTone, animateChanges, press, badgeTone, badgeMax, doneDuration]);
8
+ return _jsx(IconDefaultsContext.Provider, { value: value, children: children });
9
+ };
10
+ IconProvider.displayName = 'IconProvider';
11
+ export const useIconDefaults = () => useContext(IconDefaultsContext);
12
+ export const IconSlotContext = createContext({});
@@ -0,0 +1,59 @@
1
+ const SIZE_TOKEN = {
2
+ xs: 'iconSizeXs',
3
+ sm: 'iconSizeSm',
4
+ md: 'iconSizeMd',
5
+ lg: 'iconSizeLg',
6
+ xl: 'iconSizeXl',
7
+ action: 'iconSizeAction',
8
+ marker: 'iconSizeMarker',
9
+ chip: 'iconSizeChip',
10
+ status: 'iconSizeStatus',
11
+ };
12
+ export function iconPixels(t, own, provider, slot) {
13
+ const size = own ?? provider;
14
+ if (typeof size === 'number')
15
+ return size;
16
+ if (size === 'inherit')
17
+ return Math.round(t.fontSizeMd * t.iconTextRatio);
18
+ if (size !== undefined)
19
+ return t[SIZE_TOKEN[size]];
20
+ return slot ?? t.iconSlotDefault;
21
+ }
22
+ export function iconToneColor(t, tone) {
23
+ switch (tone) {
24
+ case 'primary': return t.accentPrimaryText;
25
+ case 'success': return t.successText;
26
+ case 'warning': return t.warningText;
27
+ case 'danger': return t.errorText;
28
+ case 'info': return t.infoText;
29
+ case 'muted': return t.textSecondary;
30
+ }
31
+ }
32
+ export function iconDuotoneColor(t, tone) {
33
+ switch (tone) {
34
+ case 'primary': return t.accentPrimary;
35
+ case 'success': return t.success;
36
+ case 'warning': return t.warning;
37
+ case 'danger': return t.error;
38
+ case 'info': return t.info;
39
+ case 'muted': return t.textSecondary;
40
+ }
41
+ }
42
+ export function iconBadgeColors(t, tone) {
43
+ switch (tone) {
44
+ case 'primary': return { bg: t.accentPrimary, text: t.onPrimary };
45
+ case 'success': return { bg: t.success, text: t.onSuccess };
46
+ case 'warning': return { bg: t.warning, text: t.onWarning };
47
+ case 'danger': return { bg: t.error, text: t.onError };
48
+ case 'info': return { bg: t.info, text: t.onInfo };
49
+ case 'muted': return { bg: t.badgeBg, text: t.badgeText };
50
+ }
51
+ }
52
+ export function iconShapeColor(t, color, fallback) {
53
+ const v = /^var\(--([a-z0-9-]+)\)$/i.exec(color.trim());
54
+ if (!v)
55
+ return color;
56
+ const key = v[1].replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
57
+ const value = t[key];
58
+ return typeof value === 'string' ? value : fallback;
59
+ }
@@ -0,0 +1,239 @@
1
+ import { chevronLeftIcon, chevronRightIcon, chevronUpIcon, chevronDownIcon, firstPageIcon, lastPageIcon, arrowLeftIcon, arrowUpIcon, arrowDownIcon, arrowToTopIcon, arrowToBottomIcon, openExternalIcon, expandAllIcon, collapseAllIcon, dragHandleIcon, moreVerticalIcon, moreHorizontalIcon, closeIcon, addIcon, deleteIcon, editIcon, copyIcon, copyRowIcon, saveIcon, shareIcon, printIcon, downloadIcon, exportIcon, resetIcon, searchIcon, checkIcon, playIcon, pauseIcon, bugIcon, settingsIcon, slidersIcon, filterIcon, filterOnlyIcon, filterAddIcon, filterExcludeIcon, filterRowIcon, sortIcon, columnsIcon, pivotIcon, openDetailIcon, groupByIcon, autoFitIcon, selectRowsIcon, viewsIcon, customizeIcon, layoutTableIcon, layoutCardsIcon, layoutSplitIcon, layoutListIcon, insightsIcon, boltIcon, clickIcon, pinIcon, pinOffIcon, starIcon, bookmarkIcon, bookmarkAddIcon, checkboxIcon, eyeIcon, eyeOffIcon, successIcon, warningIcon, errorIcon, spinnerIcon, fileIcon, fileTextIcon, fileSheetIcon, bracesIcon, codeIcon, globeIcon, databaseIcon, folderIcon, homeIcon, menuIcon, swapHorizontalIcon, uploadIcon, refreshIcon, alignLeftIcon, alignCenterIcon, alignRightIcon, lockIcon, unlockIcon, infoIcon, helpIcon, imageAddIcon, zoomInIcon, zoomOutIcon, rotateLeftIcon, rotateRightIcon, flipIcon, rulerIcon, handIcon, userIcon, usersIcon, calendarIcon, clockIcon, storeIcon, cardIcon, arrowRightIcon, arrowUpRightIcon, panelLeftIcon, panelRightIcon, undoIcon, redoIcon, repeatIcon, linkIcon, unlinkIcon, scissorsIcon, minusIcon, plusCircleIcon, minusCircleIcon, maximizeIcon, minimizeIcon, wrenchIcon, heartIcon, bookmarkCheckIcon, circleIcon, banIcon, cancelIcon, checkDoubleIcon, filePlusIcon, fileCheckIcon, fileUploadIcon, fileDownloadIcon, imageIcon, cropIcon, boldIcon, italicIcon, underlineIcon, strikethroughIcon, fontSizeIcon, textIcon, eraserIcon, hashIcon, listNumberedIcon, listCheckIcon, listPlusIcon, listMinusIcon, userAddIcon, userCheckIcon, userSearchIcon, userSettingsIcon, userShieldIcon, accountCircleIcon, idCardIcon, logoutIcon, keyIcon, shieldIcon, shieldCheckIcon, badgeCheckIcon, mailIcon, phoneIcon, phoneCallIcon, messageIcon, commentIcon, sendIcon, atSignIcon, bellIcon, inboxIcon, cartIcon, shoppingBagIcon, walletIcon, coinsIcon, banknoteIcon, receiptIcon, invoiceIcon, calculatorIcon, percentIcon, tagIcon, giftIcon, pointOfSaleIcon, bankIcon, rupeeIcon, upiIcon, upiTaglineIcon, upiMonoIcon, dollarIcon, truckIcon, packageIcon, boxesIcon, archiveIcon, warehouseIcon, buildingIcon, locationPinIcon, mapIcon, routeIcon, barcodeIcon, qrCodeIcon, scanIcon, monitorIcon, smartphoneIcon, tabletIcon, cloudIcon, cloudOffIcon, cloudUploadIcon, cloudDownloadIcon, wifiOffIcon, powerIcon, moonIcon, sunIcon, paletteIcon, pipetteIcon, aspectRatioIcon, gridSnapIcon, fileSettingsIcon, fileReturnIcon, listClockIcon, priceChangeIcon, quickReplyIcon, magicWandIcon, brushIcon, roadIcon, dashboardIcon, layersIcon, gridIcon, historyIcon, clockPlusIcon, briefcaseIcon, bookIcon, clipboardIcon, clipboardListIcon, clipboardCheckIcon, hierarchyIcon, branchIcon, shapesIcon, scaleIcon, lifeBuoyIcon, awardIcon, targetIcon, barChartIcon, sparklesIcon, handshakeIcon, } from '@dcs-tech/core';
2
+ import { createIcon } from './Icon';
3
+ export const IconChevronLeft = createIcon(chevronLeftIcon, 'IconChevronLeft');
4
+ export const IconChevronRight = createIcon(chevronRightIcon, 'IconChevronRight');
5
+ export const IconChevronUp = createIcon(chevronUpIcon, 'IconChevronUp');
6
+ export const IconChevronDown = createIcon(chevronDownIcon, 'IconChevronDown');
7
+ export const IconFirstPage = createIcon(firstPageIcon, 'IconFirstPage');
8
+ export const IconLastPage = createIcon(lastPageIcon, 'IconLastPage');
9
+ export const IconArrowLeft = createIcon(arrowLeftIcon, 'IconArrowLeft');
10
+ export const IconArrowUp = createIcon(arrowUpIcon, 'IconArrowUp');
11
+ export const IconArrowDown = createIcon(arrowDownIcon, 'IconArrowDown');
12
+ export const IconArrowToTop = createIcon(arrowToTopIcon, 'IconArrowToTop');
13
+ export const IconArrowToBottom = createIcon(arrowToBottomIcon, 'IconArrowToBottom');
14
+ export const IconOpenExternal = createIcon(openExternalIcon, 'IconOpenExternal');
15
+ export const IconExpandAll = createIcon(expandAllIcon, 'IconExpandAll');
16
+ export const IconCollapseAll = createIcon(collapseAllIcon, 'IconCollapseAll');
17
+ export const IconDragHandle = createIcon(dragHandleIcon, 'IconDragHandle');
18
+ export const IconMoreVertical = createIcon(moreVerticalIcon, 'IconMoreVertical');
19
+ export const IconMoreHorizontal = createIcon(moreHorizontalIcon, 'IconMoreHorizontal');
20
+ export const IconHome = createIcon(homeIcon, 'IconHome');
21
+ export const IconMenu = createIcon(menuIcon, 'IconMenu');
22
+ export const IconSwapHorizontal = createIcon(swapHorizontalIcon, 'IconSwapHorizontal');
23
+ export const IconArrowRight = createIcon(arrowRightIcon, 'IconArrowRight');
24
+ export const IconArrowUpRight = createIcon(arrowUpRightIcon, 'IconArrowUpRight');
25
+ export const IconPanelLeft = createIcon(panelLeftIcon, 'IconPanelLeft');
26
+ export const IconPanelRight = createIcon(panelRightIcon, 'IconPanelRight');
27
+ export const IconClose = createIcon(closeIcon, 'IconClose');
28
+ export const IconAdd = createIcon(addIcon, 'IconAdd');
29
+ export const IconDelete = createIcon(deleteIcon, 'IconDelete');
30
+ export const IconEdit = createIcon(editIcon, 'IconEdit');
31
+ export const IconCopy = createIcon(copyIcon, 'IconCopy');
32
+ export const IconCopyRow = createIcon(copyRowIcon, 'IconCopyRow');
33
+ export const IconSave = createIcon(saveIcon, 'IconSave');
34
+ export const IconShare = createIcon(shareIcon, 'IconShare');
35
+ export const IconPrint = createIcon(printIcon, 'IconPrint');
36
+ export const IconDownload = createIcon(downloadIcon, 'IconDownload');
37
+ export const IconExport = createIcon(exportIcon, 'IconExport');
38
+ export const IconReset = createIcon(resetIcon, 'IconReset');
39
+ export const IconSearch = createIcon(searchIcon, 'IconSearch');
40
+ export const IconCheck = createIcon(checkIcon, 'IconCheck');
41
+ export const IconPlay = createIcon(playIcon, 'IconPlay');
42
+ export const IconPause = createIcon(pauseIcon, 'IconPause');
43
+ export const IconBug = createIcon(bugIcon, 'IconBug');
44
+ export const IconSettings = createIcon(settingsIcon, 'IconSettings');
45
+ export const IconSliders = createIcon(slidersIcon, 'IconSliders');
46
+ export const IconUpload = createIcon(uploadIcon, 'IconUpload');
47
+ export const IconRefresh = createIcon(refreshIcon, 'IconRefresh');
48
+ export const IconAlignLeft = createIcon(alignLeftIcon, 'IconAlignLeft');
49
+ export const IconAlignCenter = createIcon(alignCenterIcon, 'IconAlignCenter');
50
+ export const IconAlignRight = createIcon(alignRightIcon, 'IconAlignRight');
51
+ export const IconUndo = createIcon(undoIcon, 'IconUndo');
52
+ export const IconRedo = createIcon(redoIcon, 'IconRedo');
53
+ export const IconRepeat = createIcon(repeatIcon, 'IconRepeat');
54
+ export const IconLink = createIcon(linkIcon, 'IconLink');
55
+ export const IconUnlink = createIcon(unlinkIcon, 'IconUnlink');
56
+ export const IconScissors = createIcon(scissorsIcon, 'IconScissors');
57
+ export const IconMinus = createIcon(minusIcon, 'IconMinus');
58
+ export const IconPlusCircle = createIcon(plusCircleIcon, 'IconPlusCircle');
59
+ export const IconMinusCircle = createIcon(minusCircleIcon, 'IconMinusCircle');
60
+ export const IconMaximize = createIcon(maximizeIcon, 'IconMaximize');
61
+ export const IconMinimize = createIcon(minimizeIcon, 'IconMinimize');
62
+ export const IconWrench = createIcon(wrenchIcon, 'IconWrench');
63
+ export const IconFilter = createIcon(filterIcon, 'IconFilter');
64
+ export const IconFilterOnly = createIcon(filterOnlyIcon, 'IconFilterOnly');
65
+ export const IconFilterAdd = createIcon(filterAddIcon, 'IconFilterAdd');
66
+ export const IconFilterExclude = createIcon(filterExcludeIcon, 'IconFilterExclude');
67
+ export const IconFilterRow = createIcon(filterRowIcon, 'IconFilterRow');
68
+ export const IconSort = createIcon(sortIcon, 'IconSort');
69
+ export const IconColumns = createIcon(columnsIcon, 'IconColumns');
70
+ export const IconPivot = createIcon(pivotIcon, 'IconPivot');
71
+ export const IconOpenDetail = createIcon(openDetailIcon, 'IconOpenDetail');
72
+ export const IconGroupBy = createIcon(groupByIcon, 'IconGroupBy');
73
+ export const IconAutoFit = createIcon(autoFitIcon, 'IconAutoFit');
74
+ export const IconSelectRows = createIcon(selectRowsIcon, 'IconSelectRows');
75
+ export const IconViews = createIcon(viewsIcon, 'IconViews');
76
+ export const IconCustomize = createIcon(customizeIcon, 'IconCustomize');
77
+ export const IconLayoutTable = createIcon(layoutTableIcon, 'IconLayoutTable');
78
+ export const IconLayoutCards = createIcon(layoutCardsIcon, 'IconLayoutCards');
79
+ export const IconLayoutSplit = createIcon(layoutSplitIcon, 'IconLayoutSplit');
80
+ export const IconLayoutList = createIcon(layoutListIcon, 'IconLayoutList');
81
+ export const IconInsights = createIcon(insightsIcon, 'IconInsights');
82
+ export const IconBolt = createIcon(boltIcon, 'IconBolt');
83
+ export const IconClick = createIcon(clickIcon, 'IconClick');
84
+ export const IconPin = createIcon(pinIcon, 'IconPin');
85
+ export const IconPinOff = createIcon(pinOffIcon, 'IconPinOff');
86
+ export const IconStar = createIcon(starIcon, 'IconStar');
87
+ export const IconBookmark = createIcon(bookmarkIcon, 'IconBookmark');
88
+ export const IconBookmarkAdd = createIcon(bookmarkAddIcon, 'IconBookmarkAdd');
89
+ export const IconCheckbox = createIcon(checkboxIcon, 'IconCheckbox');
90
+ export const IconEye = createIcon(eyeIcon, 'IconEye');
91
+ export const IconEyeOff = createIcon(eyeOffIcon, 'IconEyeOff');
92
+ export const IconLock = createIcon(lockIcon, 'IconLock');
93
+ export const IconUnlock = createIcon(unlockIcon, 'IconUnlock');
94
+ export const IconHeart = createIcon(heartIcon, 'IconHeart');
95
+ export const IconBookmarkCheck = createIcon(bookmarkCheckIcon, 'IconBookmarkCheck');
96
+ export const IconCircle = createIcon(circleIcon, 'IconCircle');
97
+ export const IconSuccess = createIcon(successIcon, 'IconSuccess');
98
+ export const IconWarning = createIcon(warningIcon, 'IconWarning');
99
+ export const IconError = createIcon(errorIcon, 'IconError');
100
+ export const IconSpinner = createIcon(spinnerIcon, 'IconSpinner');
101
+ export const IconInfo = createIcon(infoIcon, 'IconInfo');
102
+ export const IconHelp = createIcon(helpIcon, 'IconHelp');
103
+ export const IconBan = createIcon(banIcon, 'IconBan');
104
+ export const IconCancel = createIcon(cancelIcon, 'IconCancel');
105
+ export const IconCheckDouble = createIcon(checkDoubleIcon, 'IconCheckDouble');
106
+ export const IconFile = createIcon(fileIcon, 'IconFile');
107
+ export const IconFileText = createIcon(fileTextIcon, 'IconFileText');
108
+ export const IconFileSheet = createIcon(fileSheetIcon, 'IconFileSheet');
109
+ export const IconBraces = createIcon(bracesIcon, 'IconBraces');
110
+ export const IconCode = createIcon(codeIcon, 'IconCode');
111
+ export const IconGlobe = createIcon(globeIcon, 'IconGlobe');
112
+ export const IconDatabase = createIcon(databaseIcon, 'IconDatabase');
113
+ export const IconFolder = createIcon(folderIcon, 'IconFolder');
114
+ export const IconFilePlus = createIcon(filePlusIcon, 'IconFilePlus');
115
+ export const IconFileCheck = createIcon(fileCheckIcon, 'IconFileCheck');
116
+ export const IconFileUpload = createIcon(fileUploadIcon, 'IconFileUpload');
117
+ export const IconFileDownload = createIcon(fileDownloadIcon, 'IconFileDownload');
118
+ export const IconImageAdd = createIcon(imageAddIcon, 'IconImageAdd');
119
+ export const IconZoomIn = createIcon(zoomInIcon, 'IconZoomIn');
120
+ export const IconZoomOut = createIcon(zoomOutIcon, 'IconZoomOut');
121
+ export const IconRotateLeft = createIcon(rotateLeftIcon, 'IconRotateLeft');
122
+ export const IconRotateRight = createIcon(rotateRightIcon, 'IconRotateRight');
123
+ export const IconFlip = createIcon(flipIcon, 'IconFlip');
124
+ export const IconRuler = createIcon(rulerIcon, 'IconRuler');
125
+ export const IconHand = createIcon(handIcon, 'IconHand');
126
+ export const IconImage = createIcon(imageIcon, 'IconImage');
127
+ export const IconCrop = createIcon(cropIcon, 'IconCrop');
128
+ export const IconUser = createIcon(userIcon, 'IconUser');
129
+ export const IconUsers = createIcon(usersIcon, 'IconUsers');
130
+ export const IconCalendar = createIcon(calendarIcon, 'IconCalendar');
131
+ export const IconClock = createIcon(clockIcon, 'IconClock');
132
+ export const IconStore = createIcon(storeIcon, 'IconStore');
133
+ export const IconCard = createIcon(cardIcon, 'IconCard');
134
+ export const IconHistory = createIcon(historyIcon, 'IconHistory');
135
+ export const IconClockPlus = createIcon(clockPlusIcon, 'IconClockPlus');
136
+ export const IconBriefcase = createIcon(briefcaseIcon, 'IconBriefcase');
137
+ export const IconBook = createIcon(bookIcon, 'IconBook');
138
+ export const IconClipboard = createIcon(clipboardIcon, 'IconClipboard');
139
+ export const IconClipboardList = createIcon(clipboardListIcon, 'IconClipboardList');
140
+ export const IconClipboardCheck = createIcon(clipboardCheckIcon, 'IconClipboardCheck');
141
+ export const IconHierarchy = createIcon(hierarchyIcon, 'IconHierarchy');
142
+ export const IconBranch = createIcon(branchIcon, 'IconBranch');
143
+ export const IconShapes = createIcon(shapesIcon, 'IconShapes');
144
+ export const IconScale = createIcon(scaleIcon, 'IconScale');
145
+ export const IconLifeBuoy = createIcon(lifeBuoyIcon, 'IconLifeBuoy');
146
+ export const IconAward = createIcon(awardIcon, 'IconAward');
147
+ export const IconTarget = createIcon(targetIcon, 'IconTarget');
148
+ export const IconBarChart = createIcon(barChartIcon, 'IconBarChart');
149
+ export const IconSparkles = createIcon(sparklesIcon, 'IconSparkles');
150
+ export const IconHandshake = createIcon(handshakeIcon, 'IconHandshake');
151
+ export const IconBold = createIcon(boldIcon, 'IconBold');
152
+ export const IconItalic = createIcon(italicIcon, 'IconItalic');
153
+ export const IconUnderline = createIcon(underlineIcon, 'IconUnderline');
154
+ export const IconStrikethrough = createIcon(strikethroughIcon, 'IconStrikethrough');
155
+ export const IconFontSize = createIcon(fontSizeIcon, 'IconFontSize');
156
+ export const IconText = createIcon(textIcon, 'IconText');
157
+ export const IconEraser = createIcon(eraserIcon, 'IconEraser');
158
+ export const IconHash = createIcon(hashIcon, 'IconHash');
159
+ export const IconListNumbered = createIcon(listNumberedIcon, 'IconListNumbered');
160
+ export const IconListCheck = createIcon(listCheckIcon, 'IconListCheck');
161
+ export const IconListPlus = createIcon(listPlusIcon, 'IconListPlus');
162
+ export const IconListMinus = createIcon(listMinusIcon, 'IconListMinus');
163
+ export const IconUserAdd = createIcon(userAddIcon, 'IconUserAdd');
164
+ export const IconUserCheck = createIcon(userCheckIcon, 'IconUserCheck');
165
+ export const IconUserSearch = createIcon(userSearchIcon, 'IconUserSearch');
166
+ export const IconUserSettings = createIcon(userSettingsIcon, 'IconUserSettings');
167
+ export const IconUserShield = createIcon(userShieldIcon, 'IconUserShield');
168
+ export const IconAccountCircle = createIcon(accountCircleIcon, 'IconAccountCircle');
169
+ export const IconIdCard = createIcon(idCardIcon, 'IconIdCard');
170
+ export const IconLogout = createIcon(logoutIcon, 'IconLogout');
171
+ export const IconKey = createIcon(keyIcon, 'IconKey');
172
+ export const IconShield = createIcon(shieldIcon, 'IconShield');
173
+ export const IconShieldCheck = createIcon(shieldCheckIcon, 'IconShieldCheck');
174
+ export const IconBadgeCheck = createIcon(badgeCheckIcon, 'IconBadgeCheck');
175
+ export const IconMail = createIcon(mailIcon, 'IconMail');
176
+ export const IconPhone = createIcon(phoneIcon, 'IconPhone');
177
+ export const IconPhoneCall = createIcon(phoneCallIcon, 'IconPhoneCall');
178
+ export const IconMessage = createIcon(messageIcon, 'IconMessage');
179
+ export const IconComment = createIcon(commentIcon, 'IconComment');
180
+ export const IconSend = createIcon(sendIcon, 'IconSend');
181
+ export const IconAtSign = createIcon(atSignIcon, 'IconAtSign');
182
+ export const IconBell = createIcon(bellIcon, 'IconBell');
183
+ export const IconInbox = createIcon(inboxIcon, 'IconInbox');
184
+ export const IconCart = createIcon(cartIcon, 'IconCart');
185
+ export const IconShoppingBag = createIcon(shoppingBagIcon, 'IconShoppingBag');
186
+ export const IconWallet = createIcon(walletIcon, 'IconWallet');
187
+ export const IconCoins = createIcon(coinsIcon, 'IconCoins');
188
+ export const IconBanknote = createIcon(banknoteIcon, 'IconBanknote');
189
+ export const IconReceipt = createIcon(receiptIcon, 'IconReceipt');
190
+ export const IconInvoice = createIcon(invoiceIcon, 'IconInvoice');
191
+ export const IconCalculator = createIcon(calculatorIcon, 'IconCalculator');
192
+ export const IconPercent = createIcon(percentIcon, 'IconPercent');
193
+ export const IconTag = createIcon(tagIcon, 'IconTag');
194
+ export const IconGift = createIcon(giftIcon, 'IconGift');
195
+ export const IconPointOfSale = createIcon(pointOfSaleIcon, 'IconPointOfSale');
196
+ export const IconBank = createIcon(bankIcon, 'IconBank');
197
+ export const IconRupee = createIcon(rupeeIcon, 'IconRupee');
198
+ export const IconUpi = createIcon(upiIcon, 'IconUpi');
199
+ export const IconUpiTagline = createIcon(upiTaglineIcon, 'IconUpiTagline');
200
+ export const IconUpiMono = createIcon(upiMonoIcon, 'IconUpiMono');
201
+ export const IconDollar = createIcon(dollarIcon, 'IconDollar');
202
+ export const IconTruck = createIcon(truckIcon, 'IconTruck');
203
+ export const IconPackage = createIcon(packageIcon, 'IconPackage');
204
+ export const IconBoxes = createIcon(boxesIcon, 'IconBoxes');
205
+ export const IconArchive = createIcon(archiveIcon, 'IconArchive');
206
+ export const IconWarehouse = createIcon(warehouseIcon, 'IconWarehouse');
207
+ export const IconBuilding = createIcon(buildingIcon, 'IconBuilding');
208
+ export const IconLocationPin = createIcon(locationPinIcon, 'IconLocationPin');
209
+ export const IconMap = createIcon(mapIcon, 'IconMap');
210
+ export const IconRoute = createIcon(routeIcon, 'IconRoute');
211
+ export const IconBarcode = createIcon(barcodeIcon, 'IconBarcode');
212
+ export const IconQrCode = createIcon(qrCodeIcon, 'IconQrCode');
213
+ export const IconScan = createIcon(scanIcon, 'IconScan');
214
+ export const IconMonitor = createIcon(monitorIcon, 'IconMonitor');
215
+ export const IconSmartphone = createIcon(smartphoneIcon, 'IconSmartphone');
216
+ export const IconTablet = createIcon(tabletIcon, 'IconTablet');
217
+ export const IconCloud = createIcon(cloudIcon, 'IconCloud');
218
+ export const IconCloudOff = createIcon(cloudOffIcon, 'IconCloudOff');
219
+ export const IconCloudUpload = createIcon(cloudUploadIcon, 'IconCloudUpload');
220
+ export const IconCloudDownload = createIcon(cloudDownloadIcon, 'IconCloudDownload');
221
+ export const IconWifiOff = createIcon(wifiOffIcon, 'IconWifiOff');
222
+ export const IconPower = createIcon(powerIcon, 'IconPower');
223
+ export const IconMoon = createIcon(moonIcon, 'IconMoon');
224
+ export const IconSun = createIcon(sunIcon, 'IconSun');
225
+ export const IconPalette = createIcon(paletteIcon, 'IconPalette');
226
+ export const IconPipette = createIcon(pipetteIcon, 'IconPipette');
227
+ export const IconDashboard = createIcon(dashboardIcon, 'IconDashboard');
228
+ export const IconLayers = createIcon(layersIcon, 'IconLayers');
229
+ export const IconGrid = createIcon(gridIcon, 'IconGrid');
230
+ export const IconAspectRatio = createIcon(aspectRatioIcon, 'IconAspectRatio');
231
+ export const IconGridSnap = createIcon(gridSnapIcon, 'IconGridSnap');
232
+ export const IconFileSettings = createIcon(fileSettingsIcon, 'IconFileSettings');
233
+ export const IconFileReturn = createIcon(fileReturnIcon, 'IconFileReturn');
234
+ export const IconListClock = createIcon(listClockIcon, 'IconListClock');
235
+ export const IconPriceChange = createIcon(priceChangeIcon, 'IconPriceChange');
236
+ export const IconQuickReply = createIcon(quickReplyIcon, 'IconQuickReply');
237
+ export const IconMagicWand = createIcon(magicWandIcon, 'IconMagicWand');
238
+ export const IconBrush = createIcon(brushIcon, 'IconBrush');
239
+ export const IconRoad = createIcon(roadIcon, 'IconRoad');
@@ -0,0 +1,4 @@
1
+ export { Icon, IconSwap, createIcon } from './Icon';
2
+ export { IconProvider, useIconDefaults } from './IconContext';
3
+ export { useIconDone } from './useIconDone';
4
+ export * from './icons';
@@ -0,0 +1,19 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { AccessibilityInfo } from 'react-native';
3
+ import { resolveIconDoneDuration } from '@dcs-tech/core';
4
+ import { useIconDefaults } from './IconContext';
5
+ export function useIconDone(options = {}) {
6
+ const defaults = useIconDefaults();
7
+ const ms = resolveIconDoneDuration(options.duration, defaults);
8
+ const [done, setDone] = useState(false);
9
+ const timer = useRef(undefined);
10
+ useEffect(() => () => clearTimeout(timer.current), []);
11
+ const markDone = useCallback((message) => {
12
+ clearTimeout(timer.current);
13
+ setDone(true);
14
+ if (message)
15
+ AccessibilityInfo.announceForAccessibility(message);
16
+ timer.current = setTimeout(() => setDone(false), ms);
17
+ }, [ms]);
18
+ return [done, markDone];
19
+ }
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
3
+ import { Pressable, Text, TextInput, View } from 'react-native';
4
+ import { closeIcon, eyeIcon, eyeOffIcon } from '@dcs-tech/core';
5
+ import { useTokens, useUILabels } from '../UIProvider/context';
6
+ import { useFieldSurface } from '../FieldContext/FieldContext';
7
+ import { FieldWrapper } from '../FieldWrapper/FieldWrapper';
8
+ import { Icon } from '../Icon/Icon';
9
+ import { IconSlotContext } from '../Icon/IconContext';
10
+ import { fieldControlLook } from '../styles/fieldControl';
11
+ import { affixStyle, charCountStyle, clearButtonStyle, multilineTextStyle, passwordToggleStyle } from './inputStyle';
12
+ const asText = (node, style) => typeof node === 'string' || typeof node === 'number' ? _jsx(Text, { style: style, children: node }) : node;
13
+ function typeProps(type, showPassword) {
14
+ switch (type) {
15
+ case 'number': return { inputMode: 'decimal' };
16
+ case 'email': return { inputMode: 'email', autoCapitalize: 'none', autoCorrect: false };
17
+ case 'password': return { secureTextEntry: !showPassword, autoCapitalize: 'none', autoCorrect: false };
18
+ case 'tel': return { inputMode: 'tel' };
19
+ case 'url': return { inputMode: 'url', autoCapitalize: 'none', autoCorrect: false };
20
+ case 'search': return { inputMode: 'search', returnKeyType: 'search' };
21
+ case 'text': return {};
22
+ }
23
+ }
24
+ export const Input = forwardRef(function Input({ id, name, value, defaultValue, onChange, onChangeText, type = 'text', label, placeholder, hint, error, required = false, disabled: disabledProp, readOnly: readOnlyProp, autoFocus, maxLength, showCharCount = false, clearable = false, prefix, suffix, icon, multiline = false, rows, size: sizeProp, variant: variantProp, layout: layoutProp, width, style, inputMode, spellCheck, autoComplete = 'off', returnKeyType, onSubmitEditing, onFocus, onBlur, 'aria-label': ariaLabel, testID, }, ref) {
25
+ const t = useTokens();
26
+ const words = useUILabels();
27
+ const surface = useFieldSurface({ size: sizeProp, variant: variantProp, layout: layoutProp, disabled: disabledProp, readOnly: readOnlyProp });
28
+ const { size, variant, shownLayout: layout, disabled, readOnly } = surface;
29
+ const reactId = useId();
30
+ const fieldId = id ?? `dcs-input-${reactId.replace(/[^\w-]/g, '')}`;
31
+ const labelId = `${fieldId}-label`;
32
+ const inputRef = useRef(null);
33
+ const [focused, setFocused] = useState(false);
34
+ const [showPassword, setShowPassword] = useState(false);
35
+ const [own, setOwn] = useState(defaultValue === undefined ? '' : String(defaultValue));
36
+ const text = value === undefined ? own : String(value);
37
+ const hasError = error !== undefined && error !== null && error !== false && error !== '';
38
+ useImperativeHandle(ref, () => ({
39
+ focus(opts) {
40
+ const el = inputRef.current;
41
+ if (!el)
42
+ return;
43
+ el.focus();
44
+ const end = text.length;
45
+ if (opts?.select)
46
+ el.setSelection(0, end);
47
+ else if (opts?.caret)
48
+ el.setSelection(opts.caret === 'start' ? 0 : end, opts.caret === 'start' ? 0 : end);
49
+ },
50
+ blur() { inputRef.current?.blur(); },
51
+ get element() { return inputRef.current; },
52
+ }), [text]);
53
+ const change = useCallback((next) => {
54
+ if (value === undefined)
55
+ setOwn(next);
56
+ onChangeText?.(next);
57
+ onChange?.({ target: { name, value: next, type } });
58
+ }, [value, onChange, onChangeText, name, type]);
59
+ const look = useMemo(() => fieldControlLook(t, { size, variant, error: hasError, disabled, readOnly, focused }), [t, size, variant, hasError, disabled, readOnly, focused]);
60
+ const iconSlot = useMemo(() => ({ size: t.iconSlotField, color: focused ? t.accentPrimaryText : t.textSecondary }), [look.fontSize, t, focused]);
61
+ const editable = !disabled && !readOnly;
62
+ const showClear = clearable && text.length > 0 && editable;
63
+ const showEye = type === 'password' && !disabled;
64
+ const pre = prefix ? affixStyle(t, 'prefix') : undefined;
65
+ const post = suffix ? affixStyle(t, 'suffix') : undefined;
66
+ const describe = (node) => (typeof node === 'string' ? node : undefined);
67
+ const control = (_jsx(IconSlotContext.Provider, { value: iconSlot, children: _jsxs(Pressable, { accessible: false, onPress: () => { if (!disabled)
68
+ inputRef.current?.focus(); }, style: [look.box, multiline && { alignItems: 'flex-start' }], children: [icon?.start !== undefined && (_jsx(Pressable, { accessible: !!icon.onClick, disabled: !icon.onClick, onPress: () => icon.onClick?.('start'), children: icon.start })), pre && _jsx(View, { style: pre.box, children: asText(prefix, pre.text) }), _jsx(TextInput, { ref: inputRef, nativeID: fieldId, testID: testID, value: text, onChangeText: change, placeholder: placeholder, placeholderTextColor: look.placeholderColor, editable: editable, autoFocus: autoFocus, maxLength: maxLength, multiline: multiline, numberOfLines: multiline ? rows : undefined, autoComplete: autoComplete, spellCheck: spellCheck, returnKeyType: returnKeyType, onSubmitEditing: onSubmitEditing, onFocus: () => { setFocused(true); onFocus?.(); }, onBlur: () => { setFocused(false); onBlur?.(); }, ...typeProps(type, showPassword), ...(inputMode ? { inputMode } : {}), accessibilityLabel: ariaLabel ?? describe(label), "aria-labelledby": label ? labelId : undefined, accessibilityHint: describe(hasError ? error : hint), accessibilityState: { disabled }, style: [look.text, multiline && multilineTextStyle(t, look.fontSize, rows)] }), post && _jsx(View, { style: post.box, children: asText(suffix, post.text) }), (showClear || showEye || icon?.end !== undefined) && (_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: t.spacingXs, flexShrink: 0 }, children: [showClear && (_jsx(Pressable, { role: "button", "aria-label": words.input.clear, onPress: () => { change(''); inputRef.current?.focus(); }, hitSlop: t.spacingSm, style: ({ pressed }) => clearButtonStyle(t, pressed), children: _jsx(Icon, { icon: closeIcon, size: t.iconSlotInline, color: t.textSecondary }) })), showEye && (_jsx(Pressable, { role: "button", "aria-label": showPassword ? words.input.hidePassword : words.input.showPassword, onPress: () => setShowPassword(v => !v), hitSlop: t.spacingSm, style: ({ pressed }) => passwordToggleStyle(t, pressed), children: _jsx(Icon, { icon: showPassword ? eyeOffIcon : eyeIcon }) })), icon?.end !== undefined && (_jsx(Pressable, { accessible: !!icon.onClick, disabled: !icon.onClick, onPress: () => icon.onClick?.('end'), children: icon.end }))] }))] }) }));
69
+ return (_jsx(FieldWrapper, { label: label, labelId: labelId, hint: hint, error: error, required: required, size: size, layout: layout, disabled: disabled, width: width, focused: focused, extraMessages: showCharCount && maxLength ? _jsx(Text, { style: charCountStyle(t, hasError), children: `${text.length}/${maxLength}` }) : null, style: [layout === 'cell' ? undefined : { marginBottom: t.fieldBlockSpacing }, style], children: control }));
70
+ });
71
+ Input.displayName = 'Input';
@@ -0,0 +1 @@
1
+ export { Input } from './Input';
@@ -0,0 +1,47 @@
1
+ export const PASSWORD_TOGGLE_BOX = 24;
2
+ export function affixStyle(t, side) {
3
+ return {
4
+ box: {
5
+ flexDirection: 'row',
6
+ alignItems: 'center',
7
+ flexShrink: 0,
8
+ ...(side === 'prefix'
9
+ ? { paddingRight: t.spacingMd, borderRightWidth: 1, borderRightColor: t.borderColor }
10
+ : { paddingLeft: t.spacingMd, borderLeftWidth: 1, borderLeftColor: t.borderColor }),
11
+ },
12
+ text: { fontSize: t.fontSizeMd, fontWeight: String(t.fontWeightMedium), color: t.textSecondary },
13
+ };
14
+ }
15
+ export function clearButtonStyle(t, pressed) {
16
+ return {
17
+ width: t.iconSizeAction,
18
+ height: t.iconSizeAction,
19
+ borderRadius: t.borderRadiusFull,
20
+ alignItems: 'center',
21
+ justifyContent: 'center',
22
+ backgroundColor: pressed ? t.borderColor : t.bgTertiary,
23
+ };
24
+ }
25
+ export function passwordToggleStyle(t, pressed) {
26
+ return {
27
+ width: PASSWORD_TOGGLE_BOX,
28
+ height: PASSWORD_TOGGLE_BOX,
29
+ marginVertical: -PASSWORD_TOGGLE_BOX / 2,
30
+ borderRadius: t.borderRadiusSm / 2,
31
+ alignItems: 'center',
32
+ justifyContent: 'center',
33
+ backgroundColor: pressed ? t.bgTertiary : 'transparent',
34
+ };
35
+ }
36
+ export function charCountStyle(t, error) {
37
+ return {
38
+ fontSize: t.fontSizeXs,
39
+ lineHeight: Math.round(t.fontSizeXs * t.lineHeightNormal),
40
+ fontWeight: String(t.fontWeightMedium),
41
+ color: error ? t.errorText : t.textTertiary,
42
+ };
43
+ }
44
+ export function multilineTextStyle(t, fontSize, rows) {
45
+ const line = Math.round(fontSize * t.lineHeightNormal);
46
+ return { lineHeight: line, minHeight: line * Math.max(1, rows ?? 3), textAlignVertical: 'top' };
47
+ }