UNPKG

strivui

Version:

**StrivUI** is a modern, utility-first UI component library designed for building fast, beautiful, and accessible interfaces in **React** using both **TypeScript** and **JavaScript**.

683 lines (674 loc) 23 kB
'use strict'; var jsxRuntime = require('react/jsx-runtime'); var react = require('react'); function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = true, o = false; try { if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = true, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n} var _excluded$3 = ["children", "className"], _excluded2$3 = ["className"], _excluded3$2 = ["children", "className"], _excluded4$2 = ["children", "className"], _excluded5$1 = ["children", "className"], _excluded6$1 = ["children", "className"], _excluded7$1 = ["children", "className"], _excluded8$1 = ["children", "className"], _excluded9$1 = ["children", "className"], _excluded0$1 = ["children", "className"], _excluded1$1 = ["children", "className"], _excluded10 = ["children", "className"], _excluded11 = ["children", "className"], _excluded12 = ["children", "className"], _excluded13 = ["children", "className"]; var Button = function Button(_ref) { var children = _ref.children, className = _ref.className, props = _objectWithoutProperties(_ref, _excluded$3); return jsxRuntime.jsx("button", _objectSpread2(_objectSpread2({ className: clsx('default_button', className) }, props), {}, { children: children })); }; var Input = function Input(_ref2) { var className = _ref2.className, props = _objectWithoutProperties(_ref2, _excluded2$3); return jsxRuntime.jsx("input", _objectSpread2({ className: clsx('default_input', className) }, props)); }; var Link = function Link(_ref3) { var children = _ref3.children, className = _ref3.className, props = _objectWithoutProperties(_ref3, _excluded3$2); return jsxRuntime.jsx("a", _objectSpread2(_objectSpread2({ className: clsx('default_link', className) }, props), {}, { children: children })); }; var TextArea = function TextArea(_ref4) { var children = _ref4.children, className = _ref4.className, props = _objectWithoutProperties(_ref4, _excluded4$2); return jsxRuntime.jsx("textarea", _objectSpread2(_objectSpread2({ className: clsx('default_textarea', className) }, props), {}, { children: children })); }; var Select = function Select(_ref5) { var children = _ref5.children, className = _ref5.className, props = _objectWithoutProperties(_ref5, _excluded5$1); return jsxRuntime.jsx("select", _objectSpread2(_objectSpread2({ className: clsx('default_select', className) }, props), {}, { children: children })); }; var View = function View(_ref6) { var children = _ref6.children, className = _ref6.className, props = _objectWithoutProperties(_ref6, _excluded6$1); return jsxRuntime.jsx("div", _objectSpread2(_objectSpread2({ className: clsx('default_view', className) }, props), {}, { children: children })); }; var Text = function Text(_ref7) { var children = _ref7.children, className = _ref7.className, props = _objectWithoutProperties(_ref7, _excluded7$1); return jsxRuntime.jsx("p", _objectSpread2(_objectSpread2({ className: clsx('default_text', className) }, props), {}, { children: children })); }; var Label = function Label(_ref8) { var children = _ref8.children, className = _ref8.className, props = _objectWithoutProperties(_ref8, _excluded8$1); return jsxRuntime.jsx("label", _objectSpread2(_objectSpread2({ className: clsx('default_label', className) }, props), {}, { children: children })); }; var Span = function Span(_ref9) { var children = _ref9.children, className = _ref9.className, props = _objectWithoutProperties(_ref9, _excluded9$1); return jsxRuntime.jsx("span", _objectSpread2(_objectSpread2({ className: clsx('default_span', className) }, props), {}, { children: children })); }; var H1 = function H1(_ref0) { var children = _ref0.children, className = _ref0.className, props = _objectWithoutProperties(_ref0, _excluded0$1); return jsxRuntime.jsx("h1", _objectSpread2(_objectSpread2({ className: clsx('default_h1', className) }, props), {}, { children: children })); }; var H2 = function H2(_ref1) { var children = _ref1.children, className = _ref1.className, props = _objectWithoutProperties(_ref1, _excluded1$1); return jsxRuntime.jsx("h2", _objectSpread2(_objectSpread2({ className: clsx('default_h2', className) }, props), {}, { children: children })); }; var H3 = function H3(_ref10) { var children = _ref10.children, className = _ref10.className, props = _objectWithoutProperties(_ref10, _excluded10); return jsxRuntime.jsx("h3", _objectSpread2(_objectSpread2({ className: clsx('default_h3', className) }, props), {}, { children: children })); }; var H4 = function H4(_ref11) { var children = _ref11.children, className = _ref11.className, props = _objectWithoutProperties(_ref11, _excluded11); return jsxRuntime.jsx("h4", _objectSpread2(_objectSpread2({ className: clsx('default_h4', className) }, props), {}, { children: children })); }; var H5 = function H5(_ref12) { var children = _ref12.children, className = _ref12.className, props = _objectWithoutProperties(_ref12, _excluded12); return jsxRuntime.jsx("h5", _objectSpread2(_objectSpread2({ className: clsx('default_h5', className) }, props), {}, { children: children })); }; var H6 = function H6(_ref13) { var children = _ref13.children, className = _ref13.className, props = _objectWithoutProperties(_ref13, _excluded13); return jsxRuntime.jsx("h6", _objectSpread2(_objectSpread2({ className: clsx('default_h6', className) }, props), {}, { children: children })); }; var _excluded$2 = ["children", "onPress", "style", "className"], _excluded2$2 = ["children", "horizontal", "style", "onScroll", "className"], _excluded3$1 = ["children", "onPress", "className"], _excluded4$1 = ["source", "resizeMode", "children", "style", "className"]; var Pressable = function Pressable(_ref) { var children = _ref.children, onPress = _ref.onPress, style = _ref.style, className = _ref.className, props = _objectWithoutProperties(_ref, _excluded$2); return jsxRuntime.jsx("div", _objectSpread2(_objectSpread2({ role: "button", tabIndex: 0, className: clsx("default_pressable", className), style: style, onClick: onPress }, props), {}, { children: children })); }; var ScrollView = function ScrollView(_ref2) { var children = _ref2.children, horizontal = _ref2.horizontal, style = _ref2.style, onScroll = _ref2.onScroll, className = _ref2.className, props = _objectWithoutProperties(_ref2, _excluded2$2); return jsxRuntime.jsx("div", _objectSpread2(_objectSpread2({ className: clsx("default_scrollview", className), style: _objectSpread2({ overflowX: horizontal ? "auto" : "hidden", overflowY: horizontal ? "hidden" : "auto" }, style), onScroll: onScroll }, props), {}, { children: children })); }; var Image = function Image(props) { return jsxRuntime.jsx("img", _objectSpread2({ className: "default_image" }, props)); }; // ActivityIndicator var ActivityIndicator = function ActivityIndicator() { return jsxRuntime.jsx("div", { className: "default_activity_indicator" }); }; var TouchableOpacity = function TouchableOpacity(_ref3) { var children = _ref3.children, onPress = _ref3.onPress, className = _ref3.className, props = _objectWithoutProperties(_ref3, _excluded3$1); var _useState = react.useState(false), _useState2 = _slicedToArray(_useState, 2), active = _useState2[0], setActive = _useState2[1]; return jsxRuntime.jsx("div", _objectSpread2(_objectSpread2({ role: "button", tabIndex: 0, className: clsx("default_touchable_opacity", active && "default_touchable_opacity_active ", className), onMouseDown: function onMouseDown() { return setActive(true); }, onMouseUp: function onMouseUp() { return setActive(false); }, onMouseLeave: function onMouseLeave() { return setActive(false); }, onClick: onPress }, props), {}, { children: children })); }; function FlatList(_ref4) { var data = _ref4.data, renderItem = _ref4.renderItem, keyExtractor = _ref4.keyExtractor; return jsxRuntime.jsx("div", { className: "default_flatlist", children: data.map(function (item, index) { return jsxRuntime.jsx("div", { children: renderItem(item, index) }, keyExtractor ? keyExtractor(item, index) : index); }) }); } var ImageBackground = function ImageBackground(_ref5) { var source = _ref5.source, _ref5$resizeMode = _ref5.resizeMode, resizeMode = _ref5$resizeMode === void 0 ? "cover" : _ref5$resizeMode, children = _ref5.children, style = _ref5.style, className = _ref5.className, props = _objectWithoutProperties(_ref5, _excluded4$1); var backgroundSizeMap = { cover: "cover", contain: "contain", stretch: "100% 100%", center: "auto" }; return jsxRuntime.jsx("div", _objectSpread2(_objectSpread2({ className: clsx("w-full h-full flex flex-col", className), style: _objectSpread2({ backgroundImage: "url(".concat(source, ")"), backgroundRepeat: "no-repeat", backgroundPosition: "center", backgroundSize: backgroundSizeMap[resizeMode] }, style) }, props), {}, { children: children })); }; var Modal = function Modal(_ref6) { var open = _ref6.open, onClose = _ref6.onClose, children = _ref6.children; if (!open) return null; return jsxRuntime.jsx("div", { className: "fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[1000]", onClick: onClose, children: jsxRuntime.jsx("div", { onClick: function onClick(e) { return e.stopPropagation(); }, children: children }) }); }; var Dialog = function Dialog(_ref7) { var open = _ref7.open, title = _ref7.title, description = _ref7.description, _ref7$confirmText = _ref7.confirmText, confirmText = _ref7$confirmText === void 0 ? "OK" : _ref7$confirmText, _ref7$cancelText = _ref7.cancelText, cancelText = _ref7$cancelText === void 0 ? "Cancel" : _ref7$cancelText, onConfirm = _ref7.onConfirm, onCancel = _ref7.onCancel; if (!open) return null; return jsxRuntime.jsx("div", { className: "fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[1000]", children: jsxRuntime.jsxs("div", { className: "bg-white p-6 rounded-md w-full max-w-sm shadow-lg", onClick: function onClick(e) { return e.stopPropagation(); }, children: [jsxRuntime.jsx("h3", { className: "text-lg font-semibold mb-2", children: title }), jsxRuntime.jsx("p", { className: "text-sm text-gray-600 mb-4", children: description }), jsxRuntime.jsxs("div", { className: "flex justify-end gap-3", children: [jsxRuntime.jsx("button", { className: "px-4 py-2 rounded text-gray-600 hover:bg-gray-100", onClick: onCancel, children: cancelText }), jsxRuntime.jsx("button", { className: "px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700", onClick: onConfirm, children: confirmText })] })] }) }); }; function SectionList(_ref9) { var sections = _ref9.sections, renderItem = _ref9.renderItem, renderSectionHeader = _ref9.renderSectionHeader; return jsxRuntime.jsx("div", { className: "space-y-4", children: sections.map(function (section, i) { return jsxRuntime.jsxs("div", { children: [renderSectionHeader ? renderSectionHeader(section.title, i) : jsxRuntime.jsx("h4", { className: "text-lg font-semibold mb-2", children: section.title }), jsxRuntime.jsx("div", { className: "space-y-2", children: section.data.map(function (item, j) { return jsxRuntime.jsx("div", { children: renderItem(item, j) }, j); }) })] }, i); }) }); } var Overlay = function Overlay(_ref0) { var visible = _ref0.visible, onClick = _ref0.onClick, children = _ref0.children; if (!visible) return null; return jsxRuntime.jsx("div", { onClick: onClick, className: "default_overlay", children: children }); }; var _excluded$1 = ["children", "className"], _excluded2$1 = ["children", "className"], _excluded3 = ["children", "className"], _excluded4 = ["children", "className"], _excluded5 = ["children", "className"], _excluded6 = ["children", "className"], _excluded7 = ["children", "className"], _excluded8 = ["children", "className"], _excluded9 = ["children", "className"], _excluded0 = ["children", "className"], _excluded1 = ["children", "className"]; var Table = function Table(_ref) { var children = _ref.children, _ref$className = _ref.className, className = _ref$className === void 0 ? "" : _ref$className, props = _objectWithoutProperties(_ref, _excluded$1); return jsxRuntime.jsx("table", _objectSpread2(_objectSpread2({ className: clsx("default_table", className) }, props), {}, { children: children })); }; var TableHead = function TableHead(_ref2) { var children = _ref2.children, _ref2$className = _ref2.className, className = _ref2$className === void 0 ? "" : _ref2$className, props = _objectWithoutProperties(_ref2, _excluded2$1); return jsxRuntime.jsx("thead", _objectSpread2(_objectSpread2({ className: clsx("default_table_head", className) }, props), {}, { children: children })); }; var TableBody = function TableBody(_ref3) { var children = _ref3.children, _ref3$className = _ref3.className, className = _ref3$className === void 0 ? "" : _ref3$className, props = _objectWithoutProperties(_ref3, _excluded3); return jsxRuntime.jsx("tbody", _objectSpread2(_objectSpread2({ className: clsx("default_table_body", className) }, props), {}, { children: children })); }; var TableRow = function TableRow(_ref4) { var children = _ref4.children, _ref4$className = _ref4.className, className = _ref4$className === void 0 ? "" : _ref4$className, props = _objectWithoutProperties(_ref4, _excluded4); return jsxRuntime.jsx("tr", _objectSpread2(_objectSpread2({ className: clsx("default_table_row", className) }, props), {}, { children: children })); }; var TableHeaderCell = function TableHeaderCell(_ref5) { var children = _ref5.children, _ref5$className = _ref5.className, className = _ref5$className === void 0 ? "" : _ref5$className, props = _objectWithoutProperties(_ref5, _excluded5); return jsxRuntime.jsx("th", _objectSpread2(_objectSpread2({ className: clsx("default_th", className) }, props), {}, { children: children })); }; var TableDataCell = function TableDataCell(_ref6) { var children = _ref6.children, _ref6$className = _ref6.className, className = _ref6$className === void 0 ? "" : _ref6$className, props = _objectWithoutProperties(_ref6, _excluded6); return jsxRuntime.jsx("td", _objectSpread2(_objectSpread2({ className: clsx("default_td", className) }, props), {}, { children: children })); }; var Header = function Header(_ref7) { var children = _ref7.children, _ref7$className = _ref7.className, className = _ref7$className === void 0 ? "" : _ref7$className, props = _objectWithoutProperties(_ref7, _excluded7); return jsxRuntime.jsx("header", _objectSpread2(_objectSpread2({ className: clsx("default_header", className) }, props), {}, { children: children })); }; var Navigation = function Navigation(_ref8) { var children = _ref8.children, _ref8$className = _ref8.className, className = _ref8$className === void 0 ? "" : _ref8$className, props = _objectWithoutProperties(_ref8, _excluded8); return jsxRuntime.jsx("nav", _objectSpread2(_objectSpread2({ className: clsx("default_nav", className) }, props), {}, { children: children })); }; var Section = function Section(_ref9) { var children = _ref9.children, _ref9$className = _ref9.className, className = _ref9$className === void 0 ? "" : _ref9$className, props = _objectWithoutProperties(_ref9, _excluded9); return jsxRuntime.jsx("section", _objectSpread2(_objectSpread2({ className: clsx("default_section", className) }, props), {}, { children: children })); }; var Main = function Main(_ref0) { var children = _ref0.children, _ref0$className = _ref0.className, className = _ref0$className === void 0 ? "" : _ref0$className, props = _objectWithoutProperties(_ref0, _excluded0); return jsxRuntime.jsx("main", _objectSpread2(_objectSpread2({ className: clsx("default_main", className) }, props), {}, { children: children })); }; var Footer = function Footer(_ref1) { var children = _ref1.children, _ref1$className = _ref1.className, className = _ref1$className === void 0 ? "" : _ref1$className, props = _objectWithoutProperties(_ref1, _excluded1); return jsxRuntime.jsx("footer", _objectSpread2(_objectSpread2({ className: clsx("default_footer", className) }, props), {}, { children: children })); }; var _excluded = ["children", "className"], _excluded2 = ["children", "className"]; var Container = function Container(_ref) { var children = _ref.children, _ref$className = _ref.className, className = _ref$className === void 0 ? "" : _ref$className, props = _objectWithoutProperties(_ref, _excluded); return jsxRuntime.jsx("div", _objectSpread2(_objectSpread2({ className: clsx("default_container", className) }, props), {}, { children: children })); }; var Card = function Card(_ref2) { var children = _ref2.children, _ref2$className = _ref2.className, className = _ref2$className === void 0 ? "" : _ref2$className, props = _objectWithoutProperties(_ref2, _excluded2); return jsxRuntime.jsx("div", _objectSpread2(_objectSpread2({ className: clsx("default_card", className) }, props), {}, { children: children })); }; exports.ActivityIndicator = ActivityIndicator; exports.Button = Button; exports.Card = Card; exports.Container = Container; exports.Dialog = Dialog; exports.FlatList = FlatList; exports.Footer = Footer; exports.H1 = H1; exports.H2 = H2; exports.H3 = H3; exports.H4 = H4; exports.H5 = H5; exports.H6 = H6; exports.Header = Header; exports.Image = Image; exports.ImageBackground = ImageBackground; exports.Input = Input; exports.Label = Label; exports.Link = Link; exports.Main = Main; exports.Modal = Modal; exports.Navigation = Navigation; exports.Overlay = Overlay; exports.Pressable = Pressable; exports.ScrollView = ScrollView; exports.Section = Section; exports.SectionList = SectionList; exports.Select = Select; exports.Span = Span; exports.Table = Table; exports.TableBody = TableBody; exports.TableDataCell = TableDataCell; exports.TableHead = TableHead; exports.TableHeaderCell = TableHeaderCell; exports.TableRow = TableRow; exports.Text = Text; exports.TextArea = TextArea; exports.TouchableOpacity = TouchableOpacity; exports.View = View; //# sourceMappingURL=index.js.map