@bacon-pos/ui 0.5.1 → 0.7.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 (157) hide show
  1. package/lib/commonjs/components/Dropdown/Dropdown.js +282 -0
  2. package/lib/commonjs/components/Dropdown/Dropdown.js.map +1 -0
  3. package/lib/commonjs/components/Dropdown/Dropdown.stories.js +519 -0
  4. package/lib/commonjs/components/Dropdown/Dropdown.stories.js.map +1 -0
  5. package/lib/commonjs/components/Dropdown/Dropdown.test.js +113 -0
  6. package/lib/commonjs/components/Dropdown/Dropdown.test.js.map +1 -0
  7. package/lib/commonjs/components/Dropdown/index.js +19 -0
  8. package/lib/commonjs/components/Dropdown/index.js.map +1 -0
  9. package/lib/commonjs/components/Menu/Menu.js +214 -0
  10. package/lib/commonjs/components/Menu/Menu.js.map +1 -0
  11. package/lib/commonjs/components/Menu/Menu.test.js +71 -0
  12. package/lib/commonjs/components/Menu/Menu.test.js.map +1 -0
  13. package/lib/commonjs/components/Menu/MenuButton.js +73 -0
  14. package/lib/commonjs/components/Menu/MenuButton.js.map +1 -0
  15. package/lib/commonjs/components/Menu/MenuButton.stories.js +166 -0
  16. package/lib/commonjs/components/Menu/MenuButton.stories.js.map +1 -0
  17. package/lib/commonjs/components/Menu/SelectButton.js +143 -0
  18. package/lib/commonjs/components/Menu/SelectButton.js.map +1 -0
  19. package/lib/commonjs/components/Menu/SelectButton.stories.js +116 -0
  20. package/lib/commonjs/components/Menu/SelectButton.stories.js.map +1 -0
  21. package/lib/commonjs/components/Menu/SelectButton.test.js +80 -0
  22. package/lib/commonjs/components/Menu/SelectButton.test.js.map +1 -0
  23. package/lib/commonjs/components/Menu/UserMenu.js +73 -0
  24. package/lib/commonjs/components/Menu/UserMenu.js.map +1 -0
  25. package/lib/commonjs/components/Menu/UserMenu.stories.js +85 -0
  26. package/lib/commonjs/components/Menu/UserMenu.stories.js.map +1 -0
  27. package/lib/commonjs/components/Menu/UserMenu.test.js +52 -0
  28. package/lib/commonjs/components/Menu/UserMenu.test.js.map +1 -0
  29. package/lib/commonjs/components/Menu/index.js +34 -0
  30. package/lib/commonjs/components/Menu/index.js.map +1 -0
  31. package/lib/commonjs/components/Select/Select.js +246 -0
  32. package/lib/commonjs/components/Select/Select.js.map +1 -0
  33. package/lib/commonjs/components/Select/Select.stories.js +221 -0
  34. package/lib/commonjs/components/Select/Select.stories.js.map +1 -0
  35. package/lib/commonjs/components/Select/Select.test.js +165 -0
  36. package/lib/commonjs/components/Select/Select.test.js.map +1 -0
  37. package/lib/commonjs/components/Select/index.js +13 -0
  38. package/lib/commonjs/components/Select/index.js.map +1 -0
  39. package/lib/commonjs/components/UserChip/UserChip.js +121 -0
  40. package/lib/commonjs/components/UserChip/UserChip.js.map +1 -0
  41. package/lib/commonjs/components/UserChip/UserChip.stories.js +153 -0
  42. package/lib/commonjs/components/UserChip/UserChip.stories.js.map +1 -0
  43. package/lib/commonjs/components/UserChip/UserChip.test.js +59 -0
  44. package/lib/commonjs/components/UserChip/UserChip.test.js.map +1 -0
  45. package/lib/commonjs/components/UserChip/index.js +13 -0
  46. package/lib/commonjs/components/UserChip/index.js.map +1 -0
  47. package/lib/commonjs/components/index.js +57 -13
  48. package/lib/commonjs/components/index.js.map +1 -1
  49. package/lib/module/components/Dropdown/Dropdown.js +277 -0
  50. package/lib/module/components/Dropdown/Dropdown.js.map +1 -0
  51. package/lib/module/components/Dropdown/Dropdown.stories.js +515 -0
  52. package/lib/module/components/Dropdown/Dropdown.stories.js.map +1 -0
  53. package/lib/module/components/Dropdown/Dropdown.test.js +113 -0
  54. package/lib/module/components/Dropdown/Dropdown.test.js.map +1 -0
  55. package/lib/module/components/Dropdown/index.js +4 -0
  56. package/lib/module/components/Dropdown/index.js.map +1 -0
  57. package/lib/module/components/Menu/Menu.js +210 -0
  58. package/lib/module/components/Menu/Menu.js.map +1 -0
  59. package/lib/module/components/Menu/Menu.test.js +71 -0
  60. package/lib/module/components/Menu/Menu.test.js.map +1 -0
  61. package/lib/module/components/Menu/MenuButton.js +69 -0
  62. package/lib/module/components/Menu/MenuButton.js.map +1 -0
  63. package/lib/module/components/Menu/MenuButton.stories.js +162 -0
  64. package/lib/module/components/Menu/MenuButton.stories.js.map +1 -0
  65. package/lib/module/components/Menu/SelectButton.js +139 -0
  66. package/lib/module/components/Menu/SelectButton.js.map +1 -0
  67. package/lib/module/components/Menu/SelectButton.stories.js +112 -0
  68. package/lib/module/components/Menu/SelectButton.stories.js.map +1 -0
  69. package/lib/module/components/Menu/SelectButton.test.js +80 -0
  70. package/lib/module/components/Menu/SelectButton.test.js.map +1 -0
  71. package/lib/module/components/Menu/UserMenu.js +69 -0
  72. package/lib/module/components/Menu/UserMenu.js.map +1 -0
  73. package/lib/module/components/Menu/UserMenu.stories.js +81 -0
  74. package/lib/module/components/Menu/UserMenu.stories.js.map +1 -0
  75. package/lib/module/components/Menu/UserMenu.test.js +52 -0
  76. package/lib/module/components/Menu/UserMenu.test.js.map +1 -0
  77. package/lib/module/components/Menu/index.js +7 -0
  78. package/lib/module/components/Menu/index.js.map +1 -0
  79. package/lib/module/components/Select/Select.js +244 -0
  80. package/lib/module/components/Select/Select.js.map +1 -0
  81. package/lib/module/components/Select/Select.stories.js +217 -0
  82. package/lib/module/components/Select/Select.stories.js.map +1 -0
  83. package/lib/module/components/Select/Select.test.js +165 -0
  84. package/lib/module/components/Select/Select.test.js.map +1 -0
  85. package/lib/module/components/Select/index.js +4 -0
  86. package/lib/module/components/Select/index.js.map +1 -0
  87. package/lib/module/components/UserChip/UserChip.js +117 -0
  88. package/lib/module/components/UserChip/UserChip.js.map +1 -0
  89. package/lib/module/components/UserChip/UserChip.stories.js +149 -0
  90. package/lib/module/components/UserChip/UserChip.stories.js.map +1 -0
  91. package/lib/module/components/UserChip/UserChip.test.js +59 -0
  92. package/lib/module/components/UserChip/UserChip.test.js.map +1 -0
  93. package/lib/module/components/UserChip/index.js +4 -0
  94. package/lib/module/components/UserChip/index.js.map +1 -0
  95. package/lib/module/components/index.js +4 -0
  96. package/lib/module/components/index.js.map +1 -1
  97. package/lib/typescript/commonjs/components/Dropdown/Dropdown.d.ts +105 -0
  98. package/lib/typescript/commonjs/components/Dropdown/Dropdown.d.ts.map +1 -0
  99. package/lib/typescript/commonjs/components/Dropdown/index.d.ts +3 -0
  100. package/lib/typescript/commonjs/components/Dropdown/index.d.ts.map +1 -0
  101. package/lib/typescript/commonjs/components/Menu/Menu.d.ts +66 -0
  102. package/lib/typescript/commonjs/components/Menu/Menu.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/components/Menu/MenuButton.d.ts +46 -0
  104. package/lib/typescript/commonjs/components/Menu/MenuButton.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/components/Menu/SelectButton.d.ts +60 -0
  106. package/lib/typescript/commonjs/components/Menu/SelectButton.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/components/Menu/UserMenu.d.ts +46 -0
  108. package/lib/typescript/commonjs/components/Menu/UserMenu.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/components/Menu/index.d.ts +9 -0
  110. package/lib/typescript/commonjs/components/Menu/index.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/components/Select/Select.d.ts +73 -0
  112. package/lib/typescript/commonjs/components/Select/Select.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/components/Select/index.d.ts +3 -0
  114. package/lib/typescript/commonjs/components/Select/index.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/components/UserChip/UserChip.d.ts +33 -0
  116. package/lib/typescript/commonjs/components/UserChip/UserChip.d.ts.map +1 -0
  117. package/lib/typescript/commonjs/components/UserChip/index.d.ts +3 -0
  118. package/lib/typescript/commonjs/components/UserChip/index.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/components/index.d.ts +4 -0
  120. package/lib/typescript/commonjs/components/index.d.ts.map +1 -1
  121. package/lib/typescript/module/components/Dropdown/Dropdown.d.ts +105 -0
  122. package/lib/typescript/module/components/Dropdown/Dropdown.d.ts.map +1 -0
  123. package/lib/typescript/module/components/Dropdown/index.d.ts +3 -0
  124. package/lib/typescript/module/components/Dropdown/index.d.ts.map +1 -0
  125. package/lib/typescript/module/components/Menu/Menu.d.ts +66 -0
  126. package/lib/typescript/module/components/Menu/Menu.d.ts.map +1 -0
  127. package/lib/typescript/module/components/Menu/MenuButton.d.ts +46 -0
  128. package/lib/typescript/module/components/Menu/MenuButton.d.ts.map +1 -0
  129. package/lib/typescript/module/components/Menu/SelectButton.d.ts +60 -0
  130. package/lib/typescript/module/components/Menu/SelectButton.d.ts.map +1 -0
  131. package/lib/typescript/module/components/Menu/UserMenu.d.ts +46 -0
  132. package/lib/typescript/module/components/Menu/UserMenu.d.ts.map +1 -0
  133. package/lib/typescript/module/components/Menu/index.d.ts +9 -0
  134. package/lib/typescript/module/components/Menu/index.d.ts.map +1 -0
  135. package/lib/typescript/module/components/Select/Select.d.ts +73 -0
  136. package/lib/typescript/module/components/Select/Select.d.ts.map +1 -0
  137. package/lib/typescript/module/components/Select/index.d.ts +3 -0
  138. package/lib/typescript/module/components/Select/index.d.ts.map +1 -0
  139. package/lib/typescript/module/components/UserChip/UserChip.d.ts +33 -0
  140. package/lib/typescript/module/components/UserChip/UserChip.d.ts.map +1 -0
  141. package/lib/typescript/module/components/UserChip/index.d.ts +3 -0
  142. package/lib/typescript/module/components/UserChip/index.d.ts.map +1 -0
  143. package/lib/typescript/module/components/index.d.ts +4 -0
  144. package/lib/typescript/module/components/index.d.ts.map +1 -1
  145. package/package.json +1 -1
  146. package/src/components/Dropdown/Dropdown.tsx +319 -0
  147. package/src/components/Dropdown/index.ts +2 -0
  148. package/src/components/Menu/Menu.tsx +249 -0
  149. package/src/components/Menu/MenuButton.tsx +98 -0
  150. package/src/components/Menu/SelectButton.tsx +171 -0
  151. package/src/components/Menu/UserMenu.tsx +100 -0
  152. package/src/components/Menu/index.ts +14 -0
  153. package/src/components/Select/Select.tsx +323 -0
  154. package/src/components/Select/index.ts +2 -0
  155. package/src/components/UserChip/UserChip.tsx +138 -0
  156. package/src/components/UserChip/index.ts +2 -0
  157. package/src/components/index.ts +4 -0
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SelectButton = SelectButton;
7
+ var _react = require("react");
8
+ var _index = require("../../theme/index.js");
9
+ var _Button = require("../Button/Button.js");
10
+ var _Dropdown = require("../Dropdown/Dropdown.js");
11
+ var _Icon = require("../Icon/Icon.js");
12
+ var _Menu = require("./Menu.js");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ /** A selectable option. Its `icon` shows both in the row and on the trigger when chosen. */
15
+
16
+ /** Button foreground per variant — mirrors Button so the trigger icon matches the label. */
17
+ function triggerForeground(theme, variant) {
18
+ const {
19
+ action,
20
+ state
21
+ } = theme.colors;
22
+ switch (variant) {
23
+ case 'secondary':
24
+ return action.secondaryForeground;
25
+ case 'inverse':
26
+ return action.inverseForeground;
27
+ case 'destructive':
28
+ return state.destructiveSubtleForeground;
29
+ case 'success':
30
+ return state.successForeground;
31
+ case 'successSubtle':
32
+ return state.successSubtleForeground;
33
+ default:
34
+ return action.primaryForeground;
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Select-style button — a `Button` (label + leading icon) that opens an anchored
40
+ * `Dropdown` to change its value; the current option is marked with a check.
41
+ * A composed component built from `Button` + `Menu` + `Dropdown`. Controlled via
42
+ * `value` / `onChange`, or uncontrolled via `defaultValue`.
43
+ */
44
+ function SelectButton({
45
+ options,
46
+ value: valueProp,
47
+ defaultValue,
48
+ onChange,
49
+ placeholder = 'Select',
50
+ placeholderIcon,
51
+ showSelectedIcon = true,
52
+ chevron = false,
53
+ variant = 'secondary',
54
+ size = 'sm',
55
+ fullWidth = false,
56
+ disabled = false,
57
+ anchorOrigin = {
58
+ vertical: 'bottom',
59
+ horizontal: 'left'
60
+ },
61
+ menuOrigin = {
62
+ vertical: 'top',
63
+ horizontal: 'left'
64
+ },
65
+ offset = 8,
66
+ menuWidth,
67
+ showDividers,
68
+ closeOnSelect = true,
69
+ open,
70
+ onOpenChange
71
+ }) {
72
+ const theme = (0, _index.useTheme)();
73
+ const isControlled = valueProp !== undefined;
74
+ const [uncontrolled, setUncontrolled] = (0, _react.useState)(defaultValue);
75
+ const value = isControlled ? valueProp : uncontrolled;
76
+ const selected = options.find(o => o.key === value);
77
+ const label = selected?.label ?? placeholder;
78
+ const triggerIcon = selected?.icon ?? placeholderIcon;
79
+ const fg = triggerForeground(theme, variant);
80
+ const iconSize = size === 'sm' ? 20 : 24;
81
+ const setValue = key => {
82
+ if (!isControlled) setUncontrolled(key);
83
+ onChange?.(key);
84
+ };
85
+ const rows = options.map(o => ({
86
+ key: o.key,
87
+ label: o.label,
88
+ disabled: o.disabled,
89
+ leading: o.icon ? {
90
+ kind: 'icon',
91
+ name: o.icon
92
+ } : undefined,
93
+ trailing: o.key === value ? {
94
+ kind: 'icon',
95
+ name: 'check',
96
+ color: theme.colors.feedback.success
97
+ } : undefined
98
+ }));
99
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Menu.Menu, {
100
+ anchorOrigin: anchorOrigin,
101
+ menuOrigin: menuOrigin,
102
+ offset: offset,
103
+ open: open,
104
+ onOpenChange: onOpenChange,
105
+ triggerStyle: fullWidth ? {
106
+ alignSelf: 'stretch'
107
+ } : undefined,
108
+ renderTrigger: ({
109
+ toggle
110
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
111
+ label: label,
112
+ variant: variant,
113
+ size: size,
114
+ fullWidth: fullWidth,
115
+ disabled: disabled,
116
+ onPress: toggle,
117
+ leftIcon: showSelectedIcon && triggerIcon ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.Icon, {
118
+ name: triggerIcon,
119
+ size: iconSize,
120
+ color: fg
121
+ }) : undefined,
122
+ rightIcon: chevron ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.Icon, {
123
+ name: "chevron-down",
124
+ size: iconSize,
125
+ color: fg
126
+ }) : undefined
127
+ }),
128
+ children: ({
129
+ close,
130
+ maxHeight
131
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dropdown.Dropdown, {
132
+ options: rows,
133
+ width: menuWidth,
134
+ maxHeight: maxHeight,
135
+ showDividers: showDividers,
136
+ onSelect: key => {
137
+ setValue(key);
138
+ if (closeOnSelect) close();
139
+ }
140
+ })
141
+ });
142
+ }
143
+ //# sourceMappingURL=SelectButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_index","_Button","_Dropdown","_Icon","_Menu","_jsxRuntime","triggerForeground","theme","variant","action","state","colors","secondaryForeground","inverseForeground","destructiveSubtleForeground","successForeground","successSubtleForeground","primaryForeground","SelectButton","options","value","valueProp","defaultValue","onChange","placeholder","placeholderIcon","showSelectedIcon","chevron","size","fullWidth","disabled","anchorOrigin","vertical","horizontal","menuOrigin","offset","menuWidth","showDividers","closeOnSelect","open","onOpenChange","useTheme","isControlled","undefined","uncontrolled","setUncontrolled","useState","selected","find","o","key","label","triggerIcon","icon","fg","iconSize","setValue","rows","map","leading","kind","name","trailing","color","feedback","success","jsx","Menu","triggerStyle","alignSelf","renderTrigger","toggle","Button","onPress","leftIcon","Icon","rightIcon","children","close","maxHeight","Dropdown","width","onSelect"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Menu/SelectButton.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AAA+C,IAAAM,WAAA,GAAAN,OAAA;AAE/C;;AAmDA;AACA,SAASO,iBAAiBA,CAACC,KAAkC,EAAEC,OAAsB,EAAU;EAC7F,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGH,KAAK,CA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ports.WithChevron = exports.Placeholder = exports.OrderType = exports.FullWidth = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _SelectButton = require("./SelectButton.js");
10
+ var _Text = require("../Text/Text.js");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ const meta = {
13
+ title: 'Components/SelectButton',
14
+ component: _SelectButton.SelectButton
15
+ };
16
+ var _default = exports.default = meta;
17
+ const ORDER_TYPES = [{
18
+ key: 'dine-in',
19
+ label: 'Dine in',
20
+ icon: 'dish'
21
+ }, {
22
+ key: 'take-out',
23
+ label: 'Take out',
24
+ icon: 'shopping-bag'
25
+ }, {
26
+ key: 'delivery',
27
+ label: 'Delivery',
28
+ icon: 'truck-delivery'
29
+ }];
30
+
31
+ /** The order-type selector from the mockup: leading icon, green check on the current value. */
32
+ const OrderType = exports.OrderType = {
33
+ render: () => {
34
+ const [value, setValue] = (0, _react.useState)('dine-in');
35
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
36
+ style: {
37
+ padding: 24,
38
+ height: 340
39
+ },
40
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectButton.SelectButton, {
41
+ options: ORDER_TYPES,
42
+ value: value,
43
+ onChange: setValue,
44
+ menuWidth: 300
45
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Text.Text, {
46
+ variant: "caption",
47
+ color: "secondary",
48
+ style: {
49
+ marginTop: 12
50
+ },
51
+ children: ["value: ", value]
52
+ })]
53
+ });
54
+ }
55
+ };
56
+
57
+ /** With a trailing chevron on the trigger. */
58
+ const WithChevron = exports.WithChevron = {
59
+ render: () => {
60
+ const [value, setValue] = (0, _react.useState)('dine-in');
61
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
62
+ style: {
63
+ padding: 24,
64
+ height: 340
65
+ },
66
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectButton.SelectButton, {
67
+ options: ORDER_TYPES,
68
+ value: value,
69
+ onChange: setValue,
70
+ chevron: true,
71
+ menuWidth: 300
72
+ })
73
+ });
74
+ }
75
+ };
76
+
77
+ /** Uncontrolled with a placeholder (nothing selected initially). */
78
+ const Placeholder = exports.Placeholder = {
79
+ render: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
80
+ style: {
81
+ padding: 24,
82
+ height: 340
83
+ },
84
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectButton.SelectButton, {
85
+ options: ORDER_TYPES,
86
+ placeholder: "Order type",
87
+ placeholderIcon: "dish",
88
+ chevron: true,
89
+ menuWidth: 300,
90
+ onChange: () => {}
91
+ })
92
+ })
93
+ };
94
+
95
+ /** Full-width trigger (e.g. inside a form). */
96
+ const FullWidth = exports.FullWidth = {
97
+ render: () => {
98
+ const [value, setValue] = (0, _react.useState)('take-out');
99
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
100
+ style: {
101
+ padding: 24,
102
+ height: 340,
103
+ width: 360
104
+ },
105
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectButton.SelectButton, {
106
+ options: ORDER_TYPES,
107
+ value: value,
108
+ onChange: setValue,
109
+ fullWidth: true,
110
+ chevron: true,
111
+ menuWidth: 312
112
+ })
113
+ });
114
+ }
115
+ };
116
+ //# sourceMappingURL=SelectButton.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_SelectButton","_Text","_jsxRuntime","meta","title","component","SelectButton","_default","exports","default","ORDER_TYPES","key","label","icon","OrderType","render","value","setValue","useState","jsxs","View","style","padding","height","children","jsx","options","onChange","menuWidth","Text","variant","color","marginTop","WithChevron","chevron","Placeholder","placeholder","placeholderIcon","FullWidth","width","fullWidth"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Menu/SelectButton.stories.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,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AAQ,CAAC,GAAG,IAAAC,eAAQ,EAAC,UAAU,CAAC;IAC9C,oBACE,IAAAhB,WAAA,CAAAuB,GAAA,EAAC1B,YAAA,CAAAqB,IAAI;MAACC,KAAK,EAAE;QAAEC,OAAO,EAAE,EAAE;QAAEC,MAAM,EAAE,GAAG;QAAEgB,KAAK,EAAE;MAAI,CAAE;MAAAf,QAAA,eACpD,IAAAtB,WAAA,CAAAuB,GAAA,EAACzB,aAAA,CAAAM,YAAY;QACXoB,OAAO,EAAEhB,WAAY;QACrBM,KAAK,EAAEA,KAAM;QACbW,QAAQ,EAAEV,QAAS;QACnBuB,SAAS;QACTN,OAAO;QACPN,SAAS,EAAE;MAAI,CAChB;IAAC,CACE,CAAC;EAEX;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var _react = require("react");
4
+ var _reactNative = require("@testing-library/react-native");
5
+ var _index = require("../../theme/index.js");
6
+ var _SelectButton = require("./SelectButton.js");
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ function wrap(ui) {
9
+ return (0, _reactNative.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ThemeProvider, {
10
+ children: ui
11
+ }));
12
+ }
13
+ const OPTIONS = [{
14
+ key: 'dine-in',
15
+ label: 'Dine in',
16
+ icon: 'dish'
17
+ }, {
18
+ key: 'take-out',
19
+ label: 'Take out',
20
+ icon: 'shopping-bag'
21
+ }, {
22
+ key: 'delivery',
23
+ label: 'Delivery',
24
+ icon: 'truck-delivery'
25
+ }];
26
+ function Controlled() {
27
+ const [value, setValue] = (0, _react.useState)('dine-in');
28
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectButton.SelectButton, {
29
+ options: OPTIONS,
30
+ value: value,
31
+ onChange: setValue
32
+ });
33
+ }
34
+ describe('SelectButton', () => {
35
+ it('shows the placeholder when nothing is selected', () => {
36
+ wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectButton.SelectButton, {
37
+ options: OPTIONS,
38
+ placeholder: "Order type"
39
+ }));
40
+ expect(_reactNative.screen.getByText('Order type')).toBeTruthy();
41
+ });
42
+ it('shows the selected option label on the trigger', () => {
43
+ wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectButton.SelectButton, {
44
+ options: OPTIONS,
45
+ value: "take-out"
46
+ }));
47
+ expect(_reactNative.screen.getByText('Take out')).toBeTruthy();
48
+ });
49
+ it('opens the menu and lists the options', () => {
50
+ wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectButton.SelectButton, {
51
+ options: OPTIONS,
52
+ value: "dine-in"
53
+ }));
54
+ // The trigger shows "Dine in"; open the menu to reveal the rows.
55
+ _reactNative.fireEvent.press(_reactNative.screen.getByText('Dine in'));
56
+ expect(_reactNative.screen.getByText('Take out')).toBeTruthy();
57
+ expect(_reactNative.screen.getByText('Delivery')).toBeTruthy();
58
+ });
59
+ it('selecting a row calls onChange with its key and closes', () => {
60
+ const onChange = jest.fn();
61
+ wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectButton.SelectButton, {
62
+ options: OPTIONS,
63
+ value: "dine-in",
64
+ onChange: onChange
65
+ }));
66
+ _reactNative.fireEvent.press(_reactNative.screen.getByText('Dine in'));
67
+ _reactNative.fireEvent.press(_reactNative.screen.getByText('Delivery'));
68
+ expect(onChange).toHaveBeenCalledWith('delivery');
69
+ expect(_reactNative.screen.queryByText('Take out')).toBeNull();
70
+ });
71
+ it('uncontrolled: the trigger reflects the new selection', () => {
72
+ wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(Controlled, {}));
73
+ _reactNative.fireEvent.press(_reactNative.screen.getByText('Dine in'));
74
+ _reactNative.fireEvent.press(_reactNative.screen.getByText('Delivery'));
75
+ // Trigger now shows Delivery; menu closed.
76
+ expect(_reactNative.screen.getByText('Delivery')).toBeTruthy();
77
+ expect(_reactNative.screen.queryByText('Take out')).toBeNull();
78
+ });
79
+ });
80
+ //# sourceMappingURL=SelectButton.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_index","_SelectButton","_jsxRuntime","wrap","ui","render","jsx","ThemeProvider","children","OPTIONS","key","label","icon","Controlled","value","setValue","useState","SelectButton","options","onChange","describe","it","placeholder","expect","screen","getByText","toBeTruthy","fireEvent","press","jest","fn","toHaveBeenCalledWith","queryByText","toBeNull"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Menu/SelectButton.test.tsx"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAAuE,IAAAI,WAAA,GAAAJ,OAAA;AAEvE,SAASK,IAAIA,CAACC,EAAsB,EAAE;EACpC,OAAO,IAAAC,mBAAM,eAAC,IAAAH,WAAA,CAAAI,GAAA,EAACN,MAAA,CAAAO,aAAa;IAAAC,QAAA,EAAEJ;EAAE,CAAgB,CAAC,CAAC;AACpD;AAEA,MAAMK,OAA6B,GAAG,CACpC;EAAEC,GAAG,EAAE,SAAS;EAAEC,KAAK,EAAE,SAAS;EAAEC,IAAI,EAAE;AAAO,CAAC,EAClD;EAAEF,GAAG,EAAE,UAAU;EAAEC,KAAK,EAAE,UAAU;EAAEC,IAAI,EAAE;AAAe,CAAC,EAC5D;EAAEF,GAAG,EAAE,UAAU;EAAEC,KAAK,EAAE,UAAU;EAAEC,IAAI,EAAE;AAAiB,CAAC,CAC/D;AAED,SAASC,UAAUA,CAAA,EAAG;EACpB,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAAC,SAAS,CAAC;EAC7C,oBAAO,IAAAd,WAAA,CAAAI,GAAA,EAACL,aAAA,CAAAgB,YAAY;IAACC,OAAO,EAAET,OAAQ;IAACK,KAAK,EAAEA,KAAM;IAACK,QAAQ,EAAEJ;EAAS,CAAE,CAAC;AAC7E;AAEAK,QAAQ,CA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,EAAET,OAAQ;MAACK,KAAK,EAAC,SAAS;MAACK,QAAQ,EAAEA;IAAS,CAAE,CAAC,CAAC;IAC5EQ,sBAAS,CAACC,KAAK,CAACJ,mBAAM,CAACC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5CE,sBAAS,CAACC,KAAK,CAACJ,mBAAM,CAACC,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7CF,MAAM,CAACJ,QAAQ,CAAC,CAACY,oBAAoB,CAAC,UAAU,CAAC;IACjDR,MAAM,CAACC,mBAAM,CAACQ,WAAW,CAAC,UAAU,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACnD,CAAC,CAAC;EAEFZ,EAAE,CAAC,sDAAsD,EAAE,MAAM;IAC/DlB,IAAI,cAAC,IAAAD,WAAA,CAAAI,GAAA,EAACO,UAAU,IAAE,CAAC,CAAC;IACpBc,sBAAS,CAACC,KAAK,CAACJ,mBAAM,CAACC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5CE,sBAAS,CAACC,KAAK,CAACJ,mBAAM,CAACC,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7C;IACAF,MAAM,CAACC,mBAAM,CAACC,SAAS,CAAC,UAAU,CAAC,CAAC,CAACC,UAAU,CAAC,CAAC;IACjDH,MAAM,CAACC,mBAAM,CAACQ,WAAW,CAAC,UAAU,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACnD,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UserMenu = UserMenu;
7
+ var _Dropdown = require("../Dropdown/Dropdown.js");
8
+ var _UserChip = require("../UserChip/UserChip.js");
9
+ var _Menu = require("./Menu.js");
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ /**
12
+ * User menu — an avatar / `UserChip` that opens an anchored `Dropdown` (e.g. an
13
+ * account menu). A composed component built from `UserChip` + `Menu` +
14
+ * `Dropdown`. Pass a `name` to use the labelled pill as the trigger, or omit it
15
+ * for just the avatar. Dismisses on outside press / back button.
16
+ */
17
+ function UserMenu({
18
+ options,
19
+ onSelect,
20
+ source,
21
+ name,
22
+ initials,
23
+ size = 'md',
24
+ chipBackgroundColor,
25
+ chipColor,
26
+ anchorOrigin = {
27
+ vertical: 'bottom',
28
+ horizontal: 'left'
29
+ },
30
+ menuOrigin = {
31
+ vertical: 'top',
32
+ horizontal: 'left'
33
+ },
34
+ offset = 8,
35
+ menuWidth,
36
+ showDividers,
37
+ closeOnSelect = true,
38
+ open,
39
+ onOpenChange
40
+ }) {
41
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Menu.Menu, {
42
+ anchorOrigin: anchorOrigin,
43
+ menuOrigin: menuOrigin,
44
+ offset: offset,
45
+ open: open,
46
+ onOpenChange: onOpenChange,
47
+ renderTrigger: ({
48
+ toggle
49
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_UserChip.UserChip, {
50
+ source: source,
51
+ name: name,
52
+ initials: initials,
53
+ size: size,
54
+ backgroundColor: chipBackgroundColor,
55
+ color: chipColor,
56
+ onPress: toggle
57
+ }),
58
+ children: ({
59
+ close,
60
+ maxHeight
61
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dropdown.Dropdown, {
62
+ options: options,
63
+ width: menuWidth,
64
+ maxHeight: maxHeight,
65
+ showDividers: showDividers,
66
+ onSelect: key => {
67
+ onSelect?.(key);
68
+ if (closeOnSelect) close();
69
+ }
70
+ })
71
+ });
72
+ }
73
+ //# sourceMappingURL=UserMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_Dropdown","require","_UserChip","_Menu","_jsxRuntime","UserMenu","options","onSelect","source","name","initials","size","chipBackgroundColor","chipColor","anchorOrigin","vertical","horizontal","menuOrigin","offset","menuWidth","showDividers","closeOnSelect","open","onOpenChange","jsx","Menu","renderTrigger","toggle","UserChip","backgroundColor","color","onPress","children","close","maxHeight","Dropdown","width","key"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Menu/UserMenu.tsx"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAA+C,IAAAG,WAAA,GAAAH,OAAA;AAuC/C;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,QAAQA,CAAC;EACvBC,OAAO;EACPC,QAAQ;EACRC,MAAM;EACNC,IAAI;EACJC,QAAQ;EACRC,IAAI,GAAG,IAAI;EACXC,mBAAmB;EACnBC,SAAS;EACTC,YAAY,GAAG;IAAEC,QAAQ,EAAE,QAAQ;IAAEC,UAAU,EAAE;EAAO,CAAC;EACzDC,UAAU,GAAG;IAAEF,QAAQ,EAAE,KAAK;IAAEC,UAAU,EAAE;EAAO,CAAC;EACpDE,MAAM,GAAG,CAAC;EACVC,SAAS;EACTC,YAAY;EACZC,aAAa,GAAG,IAAI;EACpBC,IAAI;EACJC;AACa,CAAC,EAAE;EAChB,oBACE,IAAAnB,WAAA,CAAAoB,GAAA,EAACrB,KAAA,CAAAsB,IAAI;IACHX,YAAY,EAAEA,YAAa;IAC3BG,UAAU,EAAEA,UAAW;IACvBC,MAAM,EAAEA,MAAO;IACfI,IAAI,EAAEA,IAAK;IACXC,YAAY,EAAEA,YAAa;IAC3BG,aAAa,EAAEA,CAAC;MAAEC;IAAO,CAAC,kBACxB,IAAAvB,WAAA,CAAAoB,GAAA,EAACtB,SAAA,CAAA0B,QAAQ;MACPpB,MAAM,EAAEA,MAAO;MACfC,IAAI,EAAEA,IAAK;MACXC,QAAQ,EAAEA,QAAS;MACnBC,IAAI,EAAEA,IAAK;MACXkB,eAAe,EAAEjB,mBAAoB;MACrCkB,KAAK,EAAEjB,SAAU;MACjBkB,OAAO,EAAEJ;IAAO,CACjB,CACD;IAAAK,QAAA,EAEDA,CAAC;MAAEC,KAAK;MAAEC;IAAU,CAAC,kBACpB,IAAA9B,WAAA,CAAAoB,GAAA,EAACxB,SAAA,CAAAmC,QAAQ;MACP7B,OAAO,EAAEA,OAAQ;MACjB8B,KAAK,EAAEjB,SAAU;MACjBe,SAAS,EAAEA,SAAU;MACrBd,YAAY,EAAEA,YAAa;MAC3Bb,QAAQ,EAAG8B,GAAG,IAAK;QACjB9B,QAAQ,GAAG8B,GAAG,CAAC;QACf,IAAIhB,aAAa,EAAEY,KAAK,CAAC,CAAC;MAC5B;IAAE,CACH;EACF,CACG,CAAC;AAEX","ignoreList":[]}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.ChipTrigger = exports.AvatarTrigger = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _UserMenu = require("./UserMenu.js");
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ const meta = {
11
+ title: 'Components/UserMenu',
12
+ component: _UserMenu.UserMenu
13
+ };
14
+ var _default = exports.default = meta;
15
+ const PHOTO = {
16
+ uri: 'https://i.pravatar.cc/150?img=47'
17
+ };
18
+ const ACCOUNT = [{
19
+ key: 'profile',
20
+ label: 'Profile',
21
+ leading: {
22
+ kind: 'icon',
23
+ name: 'user'
24
+ }
25
+ }, {
26
+ key: 'settings',
27
+ label: 'Settings',
28
+ leading: {
29
+ kind: 'icon',
30
+ name: 'settings'
31
+ }
32
+ }, {
33
+ key: 'div',
34
+ type: 'divider'
35
+ }, {
36
+ key: 'logout',
37
+ label: 'Log out',
38
+ destructive: true
39
+ }];
40
+
41
+ /** Trigger = the UserChip pill (avatar + name). */
42
+ const ChipTrigger = exports.ChipTrigger = {
43
+ render: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
44
+ style: {
45
+ padding: 24,
46
+ height: 320
47
+ },
48
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_UserMenu.UserMenu, {
49
+ name: "Juana Gomez",
50
+ source: PHOTO,
51
+ size: "lg",
52
+ options: ACCOUNT,
53
+ menuWidth: 240,
54
+ onSelect: () => {}
55
+ })
56
+ })
57
+ };
58
+
59
+ /** Trigger = just the avatar (no name) — e.g. a header account button. */
60
+ const AvatarTrigger = exports.AvatarTrigger = {
61
+ render: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
62
+ style: {
63
+ padding: 24,
64
+ height: 320,
65
+ alignItems: 'flex-end'
66
+ },
67
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_UserMenu.UserMenu, {
68
+ source: PHOTO,
69
+ initials: "JG",
70
+ size: "md",
71
+ options: ACCOUNT,
72
+ menuWidth: 220,
73
+ anchorOrigin: {
74
+ vertical: 'bottom',
75
+ horizontal: 'right'
76
+ },
77
+ menuOrigin: {
78
+ vertical: 'top',
79
+ horizontal: 'right'
80
+ },
81
+ onSelect: () => {}
82
+ })
83
+ })
84
+ };
85
+ //# sourceMappingURL=UserMenu.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_UserMenu","_jsxRuntime","meta","title","component","UserMenu","_default","exports","default","PHOTO","uri","ACCOUNT","key","label","leading","kind","name","type","destructive","ChipTrigger","render","jsx","View","style","padding","height","children","source","size","options","menuWidth","onSelect","AvatarTrigger","alignItems","initials","anchorOrigin","vertical","horizontal","menuOrigin"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Menu/UserMenu.stories.tsx"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAAsC,IAAAE,WAAA,GAAAF,OAAA;AAGtC,MAAMG,IAAI,GAAG;EACXC,KAAK,EAAE,qBAAqB;EAC5BC,SAAS,EAAEC;AACb,CAAiC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEnBN,IAAI;AAGnB,MAAMO,KAAK,GAAG;EAAEC,GAAG,EAAE;AAAmC,CAAC;AAEzD,MAAMC,OAAwB,GAAG,CAC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AAA,EAACrB,SAAA,CAAAK,QAAQ;MACPsB,MAAM,EAAElB,KAAM;MACdyB,QAAQ,EAAC,IAAI;MACbN,IAAI,EAAC,IAAI;MACTC,OAAO,EAAElB,OAAQ;MACjBmB,SAAS,EAAE,GAAI;MACfK,YAAY,EAAE;QAAEC,QAAQ,EAAE,QAAQ;QAAEC,UAAU,EAAE;MAAQ,CAAE;MAC1DC,UAAU,EAAE;QAAEF,QAAQ,EAAE,KAAK;QAAEC,UAAU,EAAE;MAAQ,CAAE;MACrDN,QAAQ,EAAEA,CAAA,KAAM,CAAC;IAAE,CACpB;EAAC,CACE;AAEV,CAAC","ignoreList":[]}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ var _reactNative = require("@testing-library/react-native");
4
+ var _index = require("../../theme/index.js");
5
+ var _UserMenu = require("./UserMenu.js");
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ function wrap(ui) {
8
+ return (0, _reactNative.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ThemeProvider, {
9
+ children: ui
10
+ }));
11
+ }
12
+ const OPTIONS = [{
13
+ key: 'profile',
14
+ label: 'Profile'
15
+ }, {
16
+ key: 'logout',
17
+ label: 'Log out',
18
+ destructive: true
19
+ }];
20
+ describe('UserMenu', () => {
21
+ it('opens the menu when the chip trigger is pressed', () => {
22
+ wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_UserMenu.UserMenu, {
23
+ name: "Juana Gomez",
24
+ options: OPTIONS
25
+ }));
26
+ expect(_reactNative.screen.queryByText('Profile')).toBeNull();
27
+ _reactNative.fireEvent.press(_reactNative.screen.getByText('Juana Gomez'));
28
+ expect(_reactNative.screen.getByText('Profile')).toBeTruthy();
29
+ expect(_reactNative.screen.getByText('Log out')).toBeTruthy();
30
+ });
31
+ it('opens from an avatar-only trigger (no name)', () => {
32
+ wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_UserMenu.UserMenu, {
33
+ initials: "JG",
34
+ options: OPTIONS
35
+ }));
36
+ _reactNative.fireEvent.press(_reactNative.screen.getByText('JG'));
37
+ expect(_reactNative.screen.getByText('Profile')).toBeTruthy();
38
+ });
39
+ it('calls onSelect with the key and closes', () => {
40
+ const onSelect = jest.fn();
41
+ wrap(/*#__PURE__*/(0, _jsxRuntime.jsx)(_UserMenu.UserMenu, {
42
+ name: "Juana Gomez",
43
+ options: OPTIONS,
44
+ onSelect: onSelect
45
+ }));
46
+ _reactNative.fireEvent.press(_reactNative.screen.getByText('Juana Gomez'));
47
+ _reactNative.fireEvent.press(_reactNative.screen.getByText('Profile'));
48
+ expect(onSelect).toHaveBeenCalledWith('profile');
49
+ expect(_reactNative.screen.queryByText('Log out')).toBeNull();
50
+ });
51
+ });
52
+ //# sourceMappingURL=UserMenu.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_index","_UserMenu","_jsxRuntime","wrap","ui","render","jsx","ThemeProvider","children","OPTIONS","key","label","destructive","describe","it","UserMenu","name","options","expect","screen","queryByText","toBeNull","fireEvent","press","getByText","toBeTruthy","initials","onSelect","jest","fn","toHaveBeenCalledWith"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Menu/UserMenu.test.tsx"],"mappings":";;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAAsC,IAAAG,WAAA,GAAAH,OAAA;AAGtC,SAASI,IAAIA,CAACC,EAAsB,EAAE;EACpC,OAAO,IAAAC,mBAAM,eAAC,IAAAH,WAAA,CAAAI,GAAA,EAACN,MAAA,CAAAO,aAAa;IAAAC,QAAA,EAAEJ;EAAE,CAAgB,CAAC,CAAC;AACpD;AAEA,MAAMK,OAAwB,GAAG,CAC/B;EAAEC,GAAG,EAAE,SAAS;EAAEC,KAAK,EAAE;AAAU,CAAC,EACpC;EAAED,GAAG,EAAE,QAAQ;EAAEC,KAAK,EAAE,SAAS;EAAEC,WAAW,EAAE;A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AAS,CAACC,KAAK,CAACJ,mBAAM,CAACK,SAAS,CAAC,aAAa,CAAC,CAAC;IAChDF,sBAAS,CAACC,KAAK,CAACJ,mBAAM,CAACK,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5CN,MAAM,CAACS,QAAQ,CAAC,CAACG,oBAAoB,CAAC,SAAS,CAAC;IAChDZ,MAAM,CAACC,mBAAM,CAACC,WAAW,CAAC,SAAS,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAClD,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Menu", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Menu.Menu;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "MenuButton", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _MenuButton.MenuButton;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "SelectButton", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _SelectButton.SelectButton;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "UserMenu", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _UserMenu.UserMenu;
28
+ }
29
+ });
30
+ var _Menu = require("./Menu.js");
31
+ var _MenuButton = require("./MenuButton.js");
32
+ var _SelectButton = require("./SelectButton.js");
33
+ var _UserMenu = require("./UserMenu.js");
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_Menu","require","_MenuButton","_SelectButton","_UserMenu"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Menu/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAQA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA","ignoreList":[]}