UNPKG

@enact/sandstone

Version:

Large-screen/TV support library for Enact, containing a variety of UI components.

164 lines (161 loc) 6.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = exports.ActionGuideDecorator = exports.ActionGuideBase = exports.ActionGuide = void 0; var _kind = _interopRequireDefault(require("@enact/core/kind")); var _Pure = _interopRequireDefault(require("@enact/ui/internal/Pure")); var _propTypes = _interopRequireDefault(require("prop-types")); var _compose = _interopRequireDefault(require("ramda/src/compose")); var _$L = _interopRequireDefault(require("../internal/$L")); var _Button = _interopRequireDefault(require("../Button")); var _Marquee = require("../Marquee"); var _Skinnable = _interopRequireDefault(require("../Skinnable")); var _ActionGuideModule = _interopRequireDefault(require("./ActionGuide.module.css")); var _jsxRuntime = require("react/jsx-runtime"); var _excluded = ["buttonAriaLabel", "children", "css", "disabled", "icon", "onClick"]; /** * Sandstone styled action guide component and behaviors. * * @example * <ActionGuide icon="arrowlargedown">Hello</ActionGuide> * * @module sandstone/ActionGuide * @exports ActionGuide * @exports ActionGuideBase * @exports ActionGuideDecorator */ /** * An Action Guide component. * * This component is most often not used directly but may be composed within another component as it * is within {@link sandstone/ActionGuide.ActionGuide|ActionGuide}. * * @class ActionGuideBase * @memberof sandstone/ActionGuide * @ui * @public */ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 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 _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).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 _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); } 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 || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } var ActionGuideBase = exports.ActionGuideBase = (0, _kind["default"])({ name: 'ActionGuide', propTypes: /** @lends sandstone/ActionGuide.ActionGuideBase.prototype */{ /** * The "aria-label" for the button. * * @type {String} * @public */ buttonAriaLabel: _propTypes["default"].string, /** * The contents for the action guide. * * @type {String} * @public */ children: _propTypes["default"].string, /** * Customizes the component by mapping the supplied collection of CSS class names to the * corresponding internal elements and states of this component. * * The following classes are supported: * * * `actionGuide` - The root component class * * @type {Object} * @public */ css: _propTypes["default"].object, /** * Disables the button. * * @type {Boolean} * @public */ disabled: _propTypes["default"].bool, /** * The icon displayed within the action guide. * * @type {String} * @default 'arrowsmalldown' * @public */ icon: _propTypes["default"].string, /** * Called when Button is clicked. * * @type {Function} * @param {Object} event * @public */ onClick: _propTypes["default"].func }, defaultProps: { icon: 'arrowsmalldown' }, styles: { css: _ActionGuideModule["default"], className: 'actionGuide', publicClassNames: ['actionGuide'] }, render: function render(_ref) { var buttonAriaLabel = _ref.buttonAriaLabel, children = _ref.children, css = _ref.css, disabled = _ref.disabled, icon = _ref.icon, onClick = _ref.onClick, rest = _objectWithoutProperties(_ref, _excluded); return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", _objectSpread(_objectSpread({}, rest), {}, { children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button["default"], { "aria-label": buttonAriaLabel ? buttonAriaLabel : (0, _$L["default"])('More'), className: css.icon, disabled: disabled, icon: icon, minWidth: false, onClick: onClick, size: "small" }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Marquee.Marquee, { className: css.label, marqueeOn: "render", alignment: "center", children: children })] })); } }); /** * Applies Sandstone specific behaviors to {@link sandstone/ActionGuide.ActionGuideBase|ActionGuide}. * * @hoc * @memberof sandstone/ActionGuide * @mixes sandstone/Skinnable.Skinnable * @public */ var ActionGuideDecorator = exports.ActionGuideDecorator = (0, _compose["default"])(_Pure["default"], _Skinnable["default"]); /** * An Action Guide component, ready to use in Sandstone applications. * * `ActionGuide` may be used to display text and icon to describe an action. * * Usage: * ``` * <ActionGuide icon="arrowlargedown">Hello</ActionGuide> * ``` * * @class ActionGuide * @memberof sandstone/ActionGuide * @extends sandstone/ActionGuide.ActionGuideBase * @mixes sandstone/ActionGuide.ActionGuideDecorator * @ui * @public */ var ActionGuide = exports.ActionGuide = ActionGuideDecorator(ActionGuideBase); var _default = exports["default"] = ActionGuide;