@radui/ui 0.0.4 → 0.0.6

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.
@@ -1,19 +1,33 @@
1
1
  'use client';
2
2
  import React, { useState } from 'react';
3
3
 
4
- const RAD_UI_CLASS_PREFIX = 'rad-ui';
5
- const customClassSwitcher = function (customRootClass) {
6
- let componentName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
7
- // applies a custom root class the user provides, else applies the default rad-ui classes to the component
8
- // rad ui's classes are based on this logic
9
-
10
- // add dashes between capitalized words
11
- const componentClassName = componentName.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
12
- if (customRootClass) return customRootClass;
13
- if (componentName) return `${RAD_UI_CLASS_PREFIX}-${componentClassName}`;
14
- return '';
15
- };
16
-
4
+ function _iterableToArrayLimit(r, l) {
5
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
6
+ if (null != t) {
7
+ var e,
8
+ n,
9
+ i,
10
+ u,
11
+ a = [],
12
+ f = !0,
13
+ o = !1;
14
+ try {
15
+ if (i = (t = t.call(r)).next, 0 === l) {
16
+ if (Object(t) !== t) return;
17
+ f = !1;
18
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
19
+ } catch (r) {
20
+ o = !0, n = r;
21
+ } finally {
22
+ try {
23
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
24
+ } finally {
25
+ if (o) throw n;
26
+ }
27
+ }
28
+ return a;
29
+ }
30
+ }
17
31
  function _extends() {
18
32
  _extends = Object.assign ? Object.assign.bind() : function (target) {
19
33
  for (var i = 1; i < arguments.length; i++) {
@@ -28,49 +42,114 @@ function _extends() {
28
42
  };
29
43
  return _extends.apply(this, arguments);
30
44
  }
45
+ function _objectWithoutPropertiesLoose(source, excluded) {
46
+ if (source == null) return {};
47
+ var target = {};
48
+ var sourceKeys = Object.keys(source);
49
+ var key, i;
50
+ for (i = 0; i < sourceKeys.length; i++) {
51
+ key = sourceKeys[i];
52
+ if (excluded.indexOf(key) >= 0) continue;
53
+ target[key] = source[key];
54
+ }
55
+ return target;
56
+ }
57
+ function _objectWithoutProperties(source, excluded) {
58
+ if (source == null) return {};
59
+ var target = _objectWithoutPropertiesLoose(source, excluded);
60
+ var key, i;
61
+ if (Object.getOwnPropertySymbols) {
62
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
63
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
64
+ key = sourceSymbolKeys[i];
65
+ if (excluded.indexOf(key) >= 0) continue;
66
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
67
+ target[key] = source[key];
68
+ }
69
+ }
70
+ return target;
71
+ }
72
+ function _slicedToArray(arr, i) {
73
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
74
+ }
75
+ function _arrayWithHoles(arr) {
76
+ if (Array.isArray(arr)) return arr;
77
+ }
78
+ function _unsupportedIterableToArray(o, minLen) {
79
+ if (!o) return;
80
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
81
+ var n = Object.prototype.toString.call(o).slice(8, -1);
82
+ if (n === "Object" && o.constructor) n = o.constructor.name;
83
+ if (n === "Map" || n === "Set") return Array.from(o);
84
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
85
+ }
86
+ function _arrayLikeToArray(arr, len) {
87
+ if (len == null || len > arr.length) len = arr.length;
88
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
89
+ return arr2;
90
+ }
91
+ function _nonIterableRest() {
92
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
93
+ }
31
94
 
32
- const COMPONENT_NAME$3 = 'TabTrigger';
33
- const TabTrigger = _ref => {
34
- let {
35
- tab,
36
- setActiveTab,
37
- activeTab,
38
- className = '',
39
- customRootClass,
40
- ...props
41
- } = _ref;
42
- const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME$3);
43
- const isActive = activeTab === tab.value;
44
- const handleClick = tab => {
95
+ var RAD_UI_CLASS_PREFIX = 'rad-ui';
96
+ var customClassSwitcher = function customClassSwitcher(customRootClass) {
97
+ var componentName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
98
+ // applies a custom root class the user provides, else applies the default rad-ui classes to the component
99
+ // rad ui's classes are based on this logic
100
+
101
+ // add dashes between capitalized words
102
+ var componentClassName = componentName.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
103
+ if (customRootClass) return customRootClass;
104
+ if (componentName) return "".concat(RAD_UI_CLASS_PREFIX, "-").concat(componentClassName);
105
+ return '';
106
+ };
107
+
108
+ var _excluded$2 = ["tab", "setActiveTab", "activeTab", "className", "customRootClass"];
109
+ var COMPONENT_NAME$3 = 'TabTrigger';
110
+ var TabTrigger = function TabTrigger(_ref) {
111
+ var tab = _ref.tab,
112
+ setActiveTab = _ref.setActiveTab,
113
+ activeTab = _ref.activeTab,
114
+ _ref$className = _ref.className,
115
+ className = _ref$className === void 0 ? '' : _ref$className,
116
+ customRootClass = _ref.customRootClass,
117
+ props = _objectWithoutProperties(_ref, _excluded$2);
118
+ var rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME$3);
119
+ var isActive = activeTab === tab.value;
120
+ var handleClick = function handleClick(tab) {
45
121
  setActiveTab(tab.value);
46
122
  };
47
123
  return /*#__PURE__*/React.createElement("button", _extends({
48
124
  role: "tab",
49
- className: `${rootClass} ${isActive ? 'active' : ''} ${className}`
125
+ className: "".concat(rootClass, " ").concat(isActive ? 'active' : '', " ").concat(className)
50
126
  }, props, {
51
- onClick: () => handleClick(tab)
127
+ onClick: function onClick() {
128
+ return handleClick(tab);
129
+ }
52
130
  }), /*#__PURE__*/React.createElement("span", {
53
- className: `${rootClass}-inner`
131
+ className: "".concat(rootClass, "-inner")
54
132
  }, tab.label));
55
133
  };
56
134
  TabTrigger.displayName = 'TabTrigger';
57
135
 
58
- const COMPONENT_NAME$2 = 'TabList';
59
- const TabList = _ref => {
60
- let {
61
- tabs = [],
62
- className = '',
63
- setActiveTab,
64
- activeTab,
65
- customRootClass = ''
66
- } = _ref;
67
- const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME$2);
136
+ var COMPONENT_NAME$2 = 'TabList';
137
+ var TabList = function TabList(_ref) {
138
+ var _ref$tabs = _ref.tabs,
139
+ tabs = _ref$tabs === void 0 ? [] : _ref$tabs,
140
+ _ref$className = _ref.className,
141
+ className = _ref$className === void 0 ? '' : _ref$className,
142
+ setActiveTab = _ref.setActiveTab,
143
+ activeTab = _ref.activeTab,
144
+ _ref$customRootClass = _ref.customRootClass,
145
+ customRootClass = _ref$customRootClass === void 0 ? '' : _ref$customRootClass;
146
+ var rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME$2);
68
147
  return /*#__PURE__*/React.createElement("div", {
69
148
  role: "tablist",
70
149
  "aria-orientation": "horizontal",
71
150
  "aria-label": "todo",
72
- className: `${rootClass} ${className}`
73
- }, tabs.map((tab, index) => {
151
+ className: "".concat(rootClass, " ").concat(className)
152
+ }, tabs.map(function (tab, index) {
74
153
  return /*#__PURE__*/React.createElement(TabTrigger, {
75
154
  activeTab: activeTab,
76
155
  setActiveTab: setActiveTab,
@@ -82,18 +161,19 @@ const TabList = _ref => {
82
161
  };
83
162
  TabList.displayName = COMPONENT_NAME$2;
84
163
 
85
- const COMPONENT_NAME$1 = 'TabContent';
86
- const TabContent = _ref => {
87
- let {
88
- tabs = [],
89
- activeTab,
90
- className = '',
91
- customRootClass = ''
92
- } = _ref;
93
- const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME$1);
164
+ var COMPONENT_NAME$1 = 'TabContent';
165
+ var TabContent = function TabContent(_ref) {
166
+ var _ref$tabs = _ref.tabs,
167
+ tabs = _ref$tabs === void 0 ? [] : _ref$tabs,
168
+ activeTab = _ref.activeTab,
169
+ _ref$className = _ref.className,
170
+ className = _ref$className === void 0 ? '' : _ref$className,
171
+ _ref$customRootClass = _ref.customRootClass,
172
+ customRootClass = _ref$customRootClass === void 0 ? '' : _ref$customRootClass;
173
+ var rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME$1);
94
174
  return /*#__PURE__*/React.createElement("div", {
95
- className: `${rootClass} ${className}`
96
- }, tabs.map((tab, index) => {
175
+ className: "".concat(rootClass, " ").concat(className)
176
+ }, tabs.map(function (tab, index) {
97
177
  if (tab.value === activeTab) {
98
178
  return /*#__PURE__*/React.createElement("div", {
99
179
  key: index
@@ -104,32 +184,37 @@ const TabContent = _ref => {
104
184
  };
105
185
  TabContent.displayName = COMPONENT_NAME$1;
106
186
 
107
- const COMPONENT_NAME = 'TabRoot';
108
- const TabRoot = _ref => {
109
- let {
110
- children,
111
- customRootClass = '',
112
- className = '',
113
- color = undefined,
114
- ...props
115
- } = _ref;
116
- const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
187
+ var _excluded$1 = ["children", "customRootClass", "className", "color"];
188
+ var COMPONENT_NAME = 'TabRoot';
189
+ var TabRoot = function TabRoot(_ref) {
190
+ var children = _ref.children,
191
+ _ref$customRootClass = _ref.customRootClass,
192
+ customRootClass = _ref$customRootClass === void 0 ? '' : _ref$customRootClass,
193
+ _ref$className = _ref.className,
194
+ className = _ref$className === void 0 ? '' : _ref$className,
195
+ _ref$color = _ref.color,
196
+ color = _ref$color === void 0 ? undefined : _ref$color,
197
+ props = _objectWithoutProperties(_ref, _excluded$1);
198
+ var rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
117
199
  if (color) {
118
200
  props['data-accent-color'] = color;
119
201
  }
120
202
  return /*#__PURE__*/React.createElement("div", _extends({
121
- className: `${rootClass} ${className}`
203
+ className: "".concat(rootClass, " ").concat(className)
122
204
  }, props), children);
123
205
  };
124
206
  TabRoot.displayName = COMPONENT_NAME;
125
207
 
126
- const Tabs = _ref => {
127
- let {
128
- tabs = [],
129
- ...props
130
- } = _ref;
208
+ var _excluded = ["tabs"];
209
+ var Tabs = function Tabs(_ref) {
210
+ var _ref$tabs = _ref.tabs,
211
+ tabs = _ref$tabs === void 0 ? [] : _ref$tabs,
212
+ props = _objectWithoutProperties(_ref, _excluded);
131
213
  // This should be a value <`tabs.value`> that is passed in from the parent component
132
- const [activeTab, setActiveTab] = useState(tabs[0].value || '');
214
+ var _useState = useState(tabs[0].value || ''),
215
+ _useState2 = _slicedToArray(_useState, 2),
216
+ activeTab = _useState2[0],
217
+ setActiveTab = _useState2[1];
133
218
  return /*#__PURE__*/React.createElement(TabRoot, props, /*#__PURE__*/React.createElement(TabList, {
134
219
  activeTab: activeTab,
135
220
  setActiveTab: setActiveTab,
@@ -15,35 +15,64 @@ function _extends() {
15
15
  };
16
16
  return _extends.apply(this, arguments);
17
17
  }
18
+ function _objectWithoutPropertiesLoose(source, excluded) {
19
+ if (source == null) return {};
20
+ var target = {};
21
+ var sourceKeys = Object.keys(source);
22
+ var key, i;
23
+ for (i = 0; i < sourceKeys.length; i++) {
24
+ key = sourceKeys[i];
25
+ if (excluded.indexOf(key) >= 0) continue;
26
+ target[key] = source[key];
27
+ }
28
+ return target;
29
+ }
30
+ function _objectWithoutProperties(source, excluded) {
31
+ if (source == null) return {};
32
+ var target = _objectWithoutPropertiesLoose(source, excluded);
33
+ var key, i;
34
+ if (Object.getOwnPropertySymbols) {
35
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
36
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
37
+ key = sourceSymbolKeys[i];
38
+ if (excluded.indexOf(key) >= 0) continue;
39
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
40
+ target[key] = source[key];
41
+ }
42
+ }
43
+ return target;
44
+ }
18
45
 
19
- const RAD_UI_CLASS_PREFIX = 'rad-ui';
20
- const customClassSwitcher = function (customRootClass) {
21
- let componentName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
46
+ var RAD_UI_CLASS_PREFIX = 'rad-ui';
47
+ var customClassSwitcher = function customClassSwitcher(customRootClass) {
48
+ var componentName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
22
49
  // applies a custom root class the user provides, else applies the default rad-ui classes to the component
23
50
  // rad ui's classes are based on this logic
24
51
 
25
52
  // add dashes between capitalized words
26
- const componentClassName = componentName.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
53
+ var componentClassName = componentName.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
27
54
  if (customRootClass) return customRootClass;
28
- if (componentName) return `${RAD_UI_CLASS_PREFIX}-${componentClassName}`;
55
+ if (componentName) return "".concat(RAD_UI_CLASS_PREFIX, "-").concat(componentClassName);
29
56
  return '';
30
57
  };
31
58
 
59
+ var _excluded = ["children", "customRootClass", "className"];
60
+
32
61
  // Can be rendered as p, label, div, span, etc.
33
62
  // TODO: Add as prop support
34
63
  // TODO: Add a core reusable function to check and render an as prop
35
64
 
36
- const COMPONENT_NAME = 'Text';
37
- const Text = _ref => {
38
- let {
39
- children,
40
- customRootClass = '',
41
- className = '',
42
- ...props
43
- } = _ref;
44
- const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
65
+ var COMPONENT_NAME = 'Text';
66
+ var Text = function Text(_ref) {
67
+ var children = _ref.children,
68
+ _ref$customRootClass = _ref.customRootClass,
69
+ customRootClass = _ref$customRootClass === void 0 ? '' : _ref$customRootClass,
70
+ _ref$className = _ref.className,
71
+ className = _ref$className === void 0 ? '' : _ref$className,
72
+ props = _objectWithoutProperties(_ref, _excluded);
73
+ var rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
45
74
  return /*#__PURE__*/React.createElement("p", _extends({
46
- className: `${rootClass} ${className}`
75
+ className: "".concat(rootClass, " ").concat(className)
47
76
  }, props), children);
48
77
  };
49
78
  Text.displayName = COMPONENT_NAME;
@@ -1,7 +1,8 @@
1
1
  'use client';
2
2
  import React from 'react';
3
3
 
4
- const TextArea = _ref => {
4
+ var TextArea = function TextArea(_ref) {
5
+ _ref.children;
5
6
  return /*#__PURE__*/React.createElement("textarea", null);
6
7
  };
7
8