diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..e9a2b0416a --- /dev/null +++ b/.gitignore @@ -0,0 +1,322 @@ +### Project files ### + +# Only used for release server authentication +/.npmrc + +# React Storybook +storybook/ +storybook-based-tests/ + +# Publishing and dist build +.tmp* + +# For build server. A copy of itself from master is pulled down in order to publish itself. +design-system-react + +# Allow custom pre-commit +scripts/pre-commit.sh + +# Visual diff images. These are the images that compare differences +# in the current and previous capture +__diff_output__ + +# Dev notes +dev-notes.txt + +# --- MACHINE GENERATED BELOW THIS LINE --- + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +### Code ### +# Visual Studio Code - https://code.visualstudio.com/ +.settings/ +.vscode/ +tsconfig.json +jsconfig.json + +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +/dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile +projectile-bookmarks.eld + +# directory configuration +.dir-locals.el + +# saveplace +places + +# url cache +url/cache/ + +# cedet +ede-projects.el + +# smex +smex-items + +# company-statistics +company-statistics-cache.el + +# anaconda-mode +anaconda-mode/ + +### macOS ### +*.DS_Store +.AppleDouble +.LSOverride + +# Removed due to Icon component not working on NPM. +# Icon must end with two \r +# Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### SublimeText ### +# cache files for sublime text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# workspace files are user-specific +*.sublime-workspace + +# project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using SublimeText +# *.sublime-project + +# sftp configuration file +sftp-config.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +### Vim ### +# swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] +# session +Session.vim +# temporary +.netrwhist +# auto-generated tag files +tags + +### WebStorm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Ruby plugin and RubyMine +/.rakeTasks + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### WebStorm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Intellij IDE +.idea/* +*.iml diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000000..5c48ca436c --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,24 @@ +Copyright (c) 2015-present, Salesforce.com, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Salesforce.com nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000..745d1126e0 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# Design System for React + +### Accessible, localization-friendly, presentational React components + +## Install + +``` +$ npm install @salesforce-ux/design-system @salesforce/design-system-react +``` + +## Getting Started + +Welcome to the project! :wave: This library is the [React](https://facebook.github.io/react/) implementation of the [Salesforce Lightning Design System](https://www.lightningdesignsystem.com/). This library has a peer dependency on `@salesforce-ux/design-system`, `react`, and `react-dom`. + +* [Getting Started](https://react.lightningdesignsystem.com/getting-started/) +* [Documentation and interactive examples](https://react.lightningdesignsystem.com) + +### Quick Setup (CommonJS) + +A CommonJS-compatible version has been included within the NPM package to allows usage without transpiling. Use the following named `import` syntax to access CommonJS components from `/lib/index.js`: + +``` +import { Button } from '@salesforce/design-system-react'; + + + +
+ +
+ +
+ Accordion details - A +
+ + +
  • +
    +
    +

    + +

    +
    + +
    +
    +
    + Accordion details - B +
    +
    +
  • +
  • +
    +
    +

    + +

    +
    + +
    +
    +
    + Accordion details - C +
    +
    +
  • + + +`; + +exports[`DOM snapshots SLDSAccordion Base Open 1`] = ` +
    + +
    +`; diff --git a/components/accordion/__docs__/site-stories.js b/components/accordion/__docs__/site-stories.js new file mode 100644 index 0000000000..dca1dc6844 --- /dev/null +++ b/components/accordion/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/accordion/__examples__/base.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/accordion/__docs__/storybook-stories.js b/components/accordion/__docs__/storybook-stories.js new file mode 100644 index 0000000000..c40a42b093 --- /dev/null +++ b/components/accordion/__docs__/storybook-stories.js @@ -0,0 +1,29 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _constants = require("../../../utilities/constants"); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +var _baseOpen = _interopRequireDefault(require("../__examples__/base-open")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.ACCORDION, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base', function () { + return _react.default.createElement(_base.default, { + action: _addonActions.action + }); +}).add('Base Open', function () { + return _react.default.createElement(_baseOpen.default, { + action: _addonActions.action + }); +}); \ No newline at end of file diff --git a/components/accordion/__examples__/base-open.js b/components/accordion/__examples__/base-open.js new file mode 100644 index 0000000000..aafcfbc2b0 --- /dev/null +++ b/components/accordion/__examples__/base-open.js @@ -0,0 +1,106 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _accordion = _interopRequireDefault(require("../../../../components/accordion")); + +var _panel = _interopRequireDefault(require("../../../../components/accordion/panel")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + expandedPanels: {}, + items: [{ + id: '1', + summary: 'Accordion Summary', + details: 'Accordion details - A' + }, { + id: '2', + summary: 'Accordion Summary', + details: 'Accordion details - B' + }] + }; + return _this; + } + + _createClass(Example, [{ + key: "togglePanel", + value: function togglePanel(event, data) { + this.setState(function (state) { + return _objectSpread({}, state, { + expandedPanels: _objectSpread({}, state.expandedPanels, _defineProperty({}, data.id, !state.expandedPanels[data.id])) + }); + }); + console.log('onClick', data); + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_accordion.default, { + id: "base-example-accordion" + }, this.state.items.map(function (item) { + return _react.default.createElement(_panel.default, { + expanded: true, + id: item.id, + key: item.id, + onTogglePanel: function onTogglePanel() { + return _this2.togglePanel(event, item); + }, + summary: item.summary + }, item.details); + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'AccordionExample'; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/accordion/__examples__/base.js b/components/accordion/__examples__/base.js new file mode 100644 index 0000000000..442a4f114e --- /dev/null +++ b/components/accordion/__examples__/base.js @@ -0,0 +1,171 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _accordion = _interopRequireDefault(require("../../../../components/accordion")); + +var _panel = _interopRequireDefault(require("../../../../components/accordion/panel")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + expandedPanels: {}, + items: [{ + id: '1', + summary: 'Accordion Summary', + details: 'Accordion details - A' + }, { + id: '2', + summary: 'Accordion Summary', + details: 'Accordion details - B' + }, { + id: '3', + summary: 'Accordion Summary', + details: 'Accordion details - C' + }] + }; + return _this; + } + + _createClass(Example, [{ + key: "menuDropdown", + value: function menuDropdown(selectedItem) { + var _this2 = this; + + return _react.default.createElement(_menuDropdown.default, { + align: "right", + id: "ButtonGroupExampleDropdown", + assistiveText: { + icon: 'More Options' + }, + buttonVariant: "icon", + buttonClassName: "slds-shrink-none", + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + onSelect: function onSelect(option) { + if (option.label === 'delete') { + _this2.setState(function (state) { + return _objectSpread({}, state, { + items: state.items.filter(function (item) { + return item.id !== selectedItem.id; + }) + }); + }); + } else if (console) { + console.log('onSelect', event, option); + } + }, + options: [{ + label: 'delete', + value: 'A0' + }, { + label: 'redo', + value: 'B0' + }, { + label: 'activate', + value: 'C0' + }], + iconSize: "x-small" + }); + } + }, { + key: "togglePanel", + value: function togglePanel(event, data) { + this.setState(function (state) { + return _objectSpread({}, state, { + expandedPanels: _objectSpread({}, state.expandedPanels, _defineProperty({}, data.id, !state.expandedPanels[data.id])) + }); + }); + + if (this.props.action) { + var dataAsArray = Object.keys(data).map(function (id) { + return data[id]; + }); + this.props.action('onClick').apply(void 0, [event].concat(_toConsumableArray(dataAsArray))); + } else if (console) { + console.log('[onSelect] (event, data)', event, data); + } + } + }, { + key: "render", + value: function render() { + var _this3 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_accordion.default, { + id: "base-example-accordion" + }, this.state.items.map(function (item, i) { + return _react.default.createElement(_panel.default, { + expanded: !!_this3.state.expandedPanels[item.id], + id: item.id, + panelContentActions: _this3.menuDropdown(item), + key: item.id, + onTogglePanel: function onTogglePanel(event) { + return _this3.togglePanel(event, item); + }, + summary: item.summary + }, item.details); + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'AccordionExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/accordion/docs.json b/components/accordion/docs.json new file mode 100644 index 0000000000..6874bdb224 --- /dev/null +++ b/components/accordion/docs.json @@ -0,0 +1,16 @@ +{ + "component": "accordion", + "status": "prod", + "display-name": "Accordions", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/accordion", + "dependencies": [ + { + "component": "panel" + } + ], + "url-slug": "accordions" +} \ No newline at end of file diff --git a/components/accordion/index.js b/components/accordion/index.js new file mode 100644 index 0000000000..0f052f9c1a --- /dev/null +++ b/components/accordion/index.js @@ -0,0 +1,102 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireWildcard(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * CSS class names to be added to the accordion component. _Tested with snapshot testing._ + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * HTML id for accordion component. _Tested with snapshot testing._ + */ + id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), + + /** + * The panel content for the Accordion component. Accordion panels should be added as . Event handler for the accordion panels should be added to ``. Optional `panelContentActions` component may be passed as prop. _Tested with Mocha framework and snapshot testing._ + * + * Example: + * ``` + * + * + * + * + * + * ``` + */ + children: _propTypes.default.node.isRequired +}; +/** + * An accordion allows a user to toggle the display of sections of content. + * The accordion component wraps accordion panels that can be selected and expanded. It accepts children to define the content displayed within. + */ + +var Accordion = +/*#__PURE__*/ +function (_Component) { + _inherits(Accordion, _Component); + + function Accordion() { + _classCallCheck(this, Accordion); + + return _possibleConstructorReturn(this, _getPrototypeOf(Accordion).apply(this, arguments)); + } + + _createClass(Accordion, [{ + key: "componentWillMount", + value: function componentWillMount() { + this.generatedId = _shortid.default.generate(); + } + }, { + key: "render", + value: function render() { + return _react.default.createElement("ul", { + name: this.props.id || this.generatedId, + className: (0, _classnames.default)('slds-accordion', this.props.className) + }, this.props.children); + } + }]); + + return Accordion; +}(_react.Component); + +Accordion.displayName = _constants.ACCORDION; +Accordion.propTypes = propTypes; +var _default = Accordion; +exports.default = _default; \ No newline at end of file diff --git a/components/accordion/panel.js b/components/accordion/panel.js new file mode 100644 index 0000000000..de34052bc9 --- /dev/null +++ b/components/accordion/panel.js @@ -0,0 +1,106 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _button = _interopRequireDefault(require("../button")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// Implements the [Accordion design +// pattern](https://www.lightningdesignsystem.com/components/accordion/) in +// React. Based on SLDS v2.3.2 +var propTypes = { + /** + * The panel content for the Accordion component. Accordion panels should be added as . Event handler for the accordion panels should be added to ``. Optional `panelContentActions` component may be passed as prop. _Tested with Mocha framework and snapshot testing._ + */ + children: _propTypes.default.node, + + /** + * Indicates whether item is expanded or not, which should be handled by `onTogglePanel`. _Tested with Mocha framework and snapshot testing._ + */ + expanded: _propTypes.default.bool.isRequired, + + /** + * Id of the item belonging to this panel. _Tested with snapshot testing._ + */ + id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired, + + /** + * Component that can be passed as prop to ``. As an example, a menu dropdown could be used here to handle additional actions for each accordion panel. _Tested with Mocha framework._ + */ + panelContentActions: _propTypes.default.node, + + /** + * Callback that will run whenever a panel is toggled. Function should handle state to toggle `expanded` prop. _Tested with Mocha framework._ + */ + onTogglePanel: _propTypes.default.func.isRequired, + + /** + * Summary in the span element in the header of this panel. The summary is truncated and so the title element should contain the full text so that it is accessible on hover. _Tested with snapshot testing._ + */ + summary: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired, + + /** + * HTML title attribute. _Tested with snapshot testing._ + */ + title: _propTypes.default.string +}; +/** + * The panel content for the Accordion component. + */ + +var AccordionPanel = function AccordionPanel(_ref) { + var children = _ref.children, + expanded = _ref.expanded, + id = _ref.id, + panelContentActions = _ref.panelContentActions, + summary = _ref.summary, + title = _ref.title, + onTogglePanel = _ref.onTogglePanel; + return _react.default.createElement("li", { + className: "slds-accordion__list-item" + }, _react.default.createElement("section", { + className: (0, _classnames.default)('slds-accordion__section', { + 'slds-is-open': expanded + }) + }, _react.default.createElement("div", { + className: "slds-accordion__summary" + }, _react.default.createElement("h3", { + className: "slds-text-heading_small slds-accordion__summary-heading slds-has-flexi-truncate" + }, _react.default.createElement(_button.default, { + "aria-controls": "".concat(id, "-accordion-panel"), + "aria-expanded": expanded, + className: "slds-button_reset slds-accordion__summary-action", + iconCategory: "utility", + iconClassName: "slds-accordion__summary-action-icon slds-button__icon slds-button__icon_left", + iconName: "switch", + onClick: onTogglePanel, + variant: "base" + }, _react.default.createElement("span", { + className: "slds-truncate", + title: title || summary + }, summary))), panelContentActions), _react.default.createElement("div", { + "aria-hidden": !expanded, + className: "slds-accordion__content", + id: "".concat(id, "-accordion-panel") + }, children))); +}; + +var _default = AccordionPanel; +exports.default = _default; +AccordionPanel.propTypes = propTypes; +AccordionPanel.displayName = _constants.ACCORDION_PANEL; \ No newline at end of file diff --git a/components/alert/__docs__/__snapshots__/storybook-stories.storyshot b/components/alert/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..cb1cdae900 --- /dev/null +++ b/components/alert/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,355 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSAlert Close alert 1`] = ` +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAlert Custom Class Names 1`] = ` +
    +
    +
    + + info + + + + + +

    + Logged in as John Smith (johnsmith@acme.com). + + + Log out + +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAlert Custom Styles 1`] = ` +
    +
    +
    + + info + + + + + +

    + Logged in as John Smith (johnsmith@acme.com). + + + Log out + +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAlert Dismissable 1`] = ` +
    +
    +
    + + info + + + + + +

    + Logged in as John Smith (johnsmith@acme.com). + + + Log out + +

    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAlert Error 1`] = ` +
    +
    +
    + + error + + + + + +

    + Your browser is currently not supported. Your Salesforce may be degraded. + + + More Information + +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAlert Info 1`] = ` +
    +
    +
    + + info + + + + + +

    + Logged in as John Smith (johnsmith@acme.com). + + + Log out + +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAlert Offline 1`] = ` +
    +
    +
    + + offline + + + + + +

    + You are in offline mode. + + + More information + +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAlert Warning 1`] = ` +
    +
    +
    + + warning + + + + + +

    + Your browser is outdated. Your Salesforce experience may be degraded. + + + More Information + +

    +
    +
    +
    +`; diff --git a/components/alert/__docs__/site-stories.js b/components/alert/__docs__/site-stories.js new file mode 100644 index 0000000000..d88bb18da4 --- /dev/null +++ b/components/alert/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/alert/__examples__/info.jsx'), require('raw-loader!@salesforce/design-system-react/components/alert/__examples__/warning.jsx'), require('raw-loader!@salesforce/design-system-react/components/alert/__examples__/offline.jsx'), require('raw-loader!@salesforce/design-system-react/components/alert/__examples__/error.jsx'), require('raw-loader!@salesforce/design-system-react/components/alert/__examples__/dismissable.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/alert/__docs__/storybook-stories.js b/components/alert/__docs__/storybook-stories.js new file mode 100644 index 0000000000..61fdd1b9b7 --- /dev/null +++ b/components/alert/__docs__/storybook-stories.js @@ -0,0 +1,48 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _info = _interopRequireDefault(require("../__examples__/info")); + +var _warning = _interopRequireDefault(require("../__examples__/warning")); + +var _error = _interopRequireDefault(require("../__examples__/error")); + +var _offline = _interopRequireDefault(require("../__examples__/offline")); + +var _dismissable = _interopRequireDefault(require("../__examples__/dismissable")); + +var _closeAlert = _interopRequireDefault(require("../__examples__/close-alert")); + +var _customClassName = _interopRequireDefault(require("../__examples__/custom-class-name")); + +var _customStyle = _interopRequireDefault(require("../__examples__/custom-style")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* eslint-disable react/display-name */ +(0, _react2.storiesOf)(_constants.ALERT, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium slds-p-top_xx-large" + }, getStory()); +}).add('Info', function () { + return _react.default.createElement(_info.default, null); +}).add('Warning', function () { + return _react.default.createElement(_warning.default, null); +}).add('Error', function () { + return _react.default.createElement(_error.default, null); +}).add('Offline', function () { + return _react.default.createElement(_offline.default, null); +}).add('Dismissable', function () { + return _react.default.createElement(_dismissable.default, null); +}).add('Close alert', function () { + return _react.default.createElement(_closeAlert.default, null); +}).add('Custom Class Names', function () { + return _react.default.createElement(_customClassName.default, null); +}).add('Custom Styles', function () { + return _react.default.createElement(_customStyle.default, null); +}); \ No newline at end of file diff --git a/components/alert/__examples__/close-alert.js b/components/alert/__examples__/close-alert.js new file mode 100644 index 0000000000..39c2563469 --- /dev/null +++ b/components/alert/__examples__/close-alert.js @@ -0,0 +1,101 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _alert = _interopRequireDefault(require("../../../../components/alert")); + +var _container = _interopRequireDefault(require("../../../../components/alert/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + isOpen: false + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement(_button.default, { + label: "Toggle alert", + onClick: function onClick() { + _this2.setState(function (prevState) { + return { + isOpen: !prevState.isOpen + }; + }); + } + }), _react.default.createElement(_container.default, null, this.state.isOpen ? _react.default.createElement(_alert.default, { + dismissible: true, + icon: _react.default.createElement(_icon.default, { + category: "utility", + name: "user" + }), + labels: { + heading: 'Logged in as John Smith (johnsmith@acme.com).', + headingLink: 'Log out' + }, + onClickHeadingLink: function onClickHeadingLink() { + console.log('Link clicked.'); + }, + onRequestClose: function onRequestClose() { + _this2.setState({ + isOpen: false + }); + } + }) : null))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'AlertExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/alert/__examples__/custom-class-name.js b/components/alert/__examples__/custom-class-name.js new file mode 100644 index 0000000000..085e80275d --- /dev/null +++ b/components/alert/__examples__/custom-class-name.js @@ -0,0 +1,79 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _alert = _interopRequireDefault(require("../../../../components/alert")); + +var _container = _interopRequireDefault(require("../../../../components/alert/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, { + className: "this-is-the-container" + }, _react.default.createElement(_alert.default, { + className: "this-is-the-alert", + icon: _react.default.createElement(_icon.default, { + category: "utility", + name: "user" + }), + labels: { + heading: 'Logged in as John Smith (johnsmith@acme.com).', + headingLink: 'Log out' + }, + onClickHeadingLink: function onClickHeadingLink() { + console.log('Link clicked.'); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'AlertExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/alert/__examples__/custom-style.js b/components/alert/__examples__/custom-style.js new file mode 100644 index 0000000000..ca614fca90 --- /dev/null +++ b/components/alert/__examples__/custom-style.js @@ -0,0 +1,81 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _alert = _interopRequireDefault(require("../../../../components/alert")); + +var _container = _interopRequireDefault(require("../../../../components/alert/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, { + className: "this-is-the-container" + }, _react.default.createElement(_alert.default, { + style: { + backgroundColor: 'rgb(18, 49, 35)' + }, + icon: _react.default.createElement(_icon.default, { + category: "utility", + name: "user" + }), + labels: { + heading: 'Logged in as John Smith (johnsmith@acme.com).', + headingLink: 'Log out' + }, + onClickHeadingLink: function onClickHeadingLink() { + console.log('Link clicked.'); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'AlertExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/alert/__examples__/dismissable.js b/components/alert/__examples__/dismissable.js new file mode 100644 index 0000000000..c76fbf68de --- /dev/null +++ b/components/alert/__examples__/dismissable.js @@ -0,0 +1,92 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _alert = _interopRequireDefault(require("../../../../components/alert")); + +var _container = _interopRequireDefault(require("../../../../components/alert/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + isOpen: true + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, this.state.isOpen ? _react.default.createElement(_container.default, null, _react.default.createElement(_alert.default, { + dismissible: true, + icon: _react.default.createElement(_icon.default, { + category: "utility", + name: "user" + }), + labels: { + heading: 'Logged in as John Smith (johnsmith@acme.com).', + headingLink: 'Log out' + }, + onClickHeadingLink: function onClickHeadingLink() { + console.log('Link clicked.'); + }, + onRequestClose: function onRequestClose() { + _this2.setState({ + isOpen: false + }); + } + })) : null); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'AlertExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/alert/__examples__/error.js b/components/alert/__examples__/error.js new file mode 100644 index 0000000000..deb60827ad --- /dev/null +++ b/components/alert/__examples__/error.js @@ -0,0 +1,77 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _alert = _interopRequireDefault(require("../../../../components/alert")); + +var _container = _interopRequireDefault(require("../../../../components/alert/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, null, _react.default.createElement(_alert.default, { + icon: _react.default.createElement(_icon.default, { + category: "utility", + name: "error" + }), + labels: { + heading: 'Your browser is currently not supported. Your Salesforce may be degraded.', + headingLink: 'More Information' + }, + onClickHeadingLink: function onClickHeadingLink() { + console.log('Link clicked.'); + }, + variant: "error" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'AlertExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/alert/__examples__/info.js b/components/alert/__examples__/info.js new file mode 100644 index 0000000000..4131169083 --- /dev/null +++ b/components/alert/__examples__/info.js @@ -0,0 +1,76 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _alert = _interopRequireDefault(require("../../../../components/alert")); + +var _container = _interopRequireDefault(require("../../../../components/alert/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, null, _react.default.createElement(_alert.default, { + icon: _react.default.createElement(_icon.default, { + category: "utility", + name: "user" + }), + labels: { + heading: 'Logged in as John Smith (johnsmith@acme.com).', + headingLink: 'Log out' + }, + onClickHeadingLink: function onClickHeadingLink() { + console.log('Link clicked.'); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'AlertExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/alert/__examples__/offline.js b/components/alert/__examples__/offline.js new file mode 100644 index 0000000000..307de7b5ce --- /dev/null +++ b/components/alert/__examples__/offline.js @@ -0,0 +1,73 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _alert = _interopRequireDefault(require("../../../../components/alert")); + +var _container = _interopRequireDefault(require("../../../../components/alert/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, null, _react.default.createElement(_alert.default, { + labels: { + heading: 'You are in offline mode.', + headingLink: 'More information' + }, + onClickHeadingLink: function onClickHeadingLink() { + console.log('Link clicked.'); + }, + variant: "offline" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'AlertExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/alert/__examples__/warning.js b/components/alert/__examples__/warning.js new file mode 100644 index 0000000000..dd19136164 --- /dev/null +++ b/components/alert/__examples__/warning.js @@ -0,0 +1,73 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _alert = _interopRequireDefault(require("../../../../components/alert")); + +var _container = _interopRequireDefault(require("../../../../components/alert/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, null, _react.default.createElement(_alert.default, { + labels: { + heading: 'Your browser is outdated. Your Salesforce experience may be degraded.', + headingLink: 'More Information' + }, + onClickHeadingLink: function onClickHeadingLink() { + console.log('Link clicked.'); + }, + variant: "warning" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'AlertExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/alert/check-props.js b/components/alert/check-props.js new file mode 100644 index 0000000000..15119f4bb4 --- /dev/null +++ b/components/alert/check-props.js @@ -0,0 +1,38 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + /* eslint-disable max-len */ + + (0, _sunsetProperty.default)(COMPONENT, props.iconCategory, 'iconCategory', "Use `Icon` instead. ".concat(createDocUrl('icon'))); + (0, _sunsetProperty.default)(COMPONENT, props.iconName, 'iconName', "Use `Icon` instead. ".concat(createDocUrl('icon'))); + (0, _sunsetProperty.default)(COMPONENT, props.content, 'content', "Use `labels.heading` and `labels.headingLink` instead.".concat(createDocUrl('labels'))); + (0, _sunsetProperty.default)(COMPONENT, props.duration, 'duration', "Only Toasts can auto-hide. ".concat(createDocUrl())); + (0, _sunsetProperty.default)(COMPONENT, props.isOpen, 'isOpen', "Use a conditional outside of alert. ".concat(createDocUrl())); + (0, _sunsetProperty.default)(COMPONENT, props.isOpen, 'onDismiss', "Use `onRequestClose` instead. ".concat(createDocUrl('onRequestClose'))); + (0, _sunsetProperty.default)(COMPONENT, props.texture, 'texture', createDocUrl()); + (0, _sunsetProperty.default)(COMPONENT, props.theme, 'theme', "Use `variant` instead. ".concat(createDocUrl('variant'))); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/alert/container.js b/components/alert/container.js new file mode 100644 index 0000000000..1afff93bec --- /dev/null +++ b/components/alert/container.js @@ -0,0 +1,77 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classNames = _interopRequireDefault(require("../../utilities/class-names")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * CSS classes to be added to tag with `.slds-notify_alert`. Uses `classNames` [API](https://github.com/JedWatson/classnames). + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Alert components + */ + children: _propTypes.default.node +}; +/** + * A fixed container for alert banners. + */ + +var AlertContainer = +/*#__PURE__*/ +function (_React$Component) { + _inherits(AlertContainer, _React$Component); + + function AlertContainer() { + _classCallCheck(this, AlertContainer); + + return _possibleConstructorReturn(this, _getPrototypeOf(AlertContainer).apply(this, arguments)); + } + + _createClass(AlertContainer, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + className: (0, _classNames.default)('slds-notify-container', this.props.className) + }, this.props.children); + } + }]); + + return AlertContainer; +}(_react.default.Component); + +AlertContainer.displayName = _constants.ALERT_CONTAINER; +AlertContainer.propTypes = propTypes; +var _default = AlertContainer; +exports.default = _default; \ No newline at end of file diff --git a/components/alert/docs.json b/components/alert/docs.json new file mode 100644 index 0000000000..3b6e4db98c --- /dev/null +++ b/components/alert/docs.json @@ -0,0 +1,16 @@ +{ + "component": "alert", + "status": "prod", + "display-name": "Alerts", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/alert", + "dependencies": [ + { + "component": "container" + } + ], + "url-slug": "alerts" +} \ No newline at end of file diff --git a/components/alert/index.js b/components/alert/index.js new file mode 100644 index 0000000000..2002afe431 --- /dev/null +++ b/components/alert/index.js @@ -0,0 +1,264 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _classNames = _interopRequireDefault(require("../../utilities/class-names")); + +var _button = _interopRequireDefault(require("../button")); + +var _icon = _interopRequireDefault(require("../icon")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _constants = require("../../utilities/constants"); + +var _domElementFocus = _interopRequireDefault(require("../../utilities/dom-element-focus")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * **Assistive text for accessibility** + * This object is merged with the default props object on every render. + * * `closeButton`: This is a visually hidden label for the close button. + * _Tested with snapshot testing._ + */ + assistiveText: _propTypes.default.shape({ + closeButton: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]) + }), + + /** + * CSS classes to be added to tag with `.slds-notify_alert`. Uses `classNames` [API](https://github.com/JedWatson/classnames). + * _Tested with snapshot testing._ + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Allows user to click a close button. Banners should be dismissible only if they communicate future impact to the system, + * _Tested with snapshot testing._ + */ + dismissible: _propTypes.default.bool, + + /** + * Icon of type `~/components/icon`. This icon will be cloned and additional props appended. The default icons are: + * * info variant: `utility:info` + * * error variant: `utility:error` + * * offline variant: `utility:offline` + * * warning variant: `utility:warning` + * + * _Tested with snapshot testing._ + */ + icon: _propTypes.default.node, + + /** + * **Text labels for internationalization** + * This object is merged with the default props object on every render. + * * `heading`: text within heading tag + * * `headingLink`: Text of link that triggers `onClickHeadingLink`. Inline links should pass a keyed array of React components into `labels.heading`. + * + * _Tested with snapshot testing._ + */ + labels: _propTypes.default.shape({ + heading: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]), + headingLink: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]) + }), + + /** + * Triggered by link. _Tested with Mocha testing._ + */ + onClickHeadingLink: _propTypes.default.func, + + /** + * Triggered by close button. This is a controlled component. _Tested with Mocha testing._ + */ + onRequestClose: _propTypes.default.func, + + /** + * Custom styles to be passed to the component. _Tested with Mocha testing._ + */ + style: _propTypes.default.object, + + /** + * The type of alert. _Tested with snapshot testing._ + */ + variant: _propTypes.default.oneOf(['error', 'info', 'offline', 'warning']).isRequired +}; +var defaultProps = { + assistiveText: { + closeButton: 'Close' + }, + labels: {}, + variant: 'info' +}; +/** + * Alert banners communicate a state that affects the entire system, not just a feature or page. It persists over a session and appears without the user initiating the action. View [banner guidelines](https://www.lightningdesignsystem.com/guidelines/messaging/components/banners/). + */ + +var Alert = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Alert, _React$Component); + + function Alert(props) { + var _this; + + _classCallCheck(this, Alert); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Alert).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "saveButtonRef", function (component) { + _this.closeButton = component; + + if (_this.state.isInitialRender) { + _domElementFocus.default.storeActiveElement(); + + if (_this.closeButton) { + _this.closeButton.focus(); + } + + _this.setState({ + isInitialRender: false + }); + } + }); + + _this.state = { + isInitialRender: true + }; + return _this; + } + + _createClass(Alert, [{ + key: "componentWillMount", + value: function componentWillMount() { + // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + (0, _checkProps.default)(_constants.ALERT, this.props, _docs.default); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + _domElementFocus.default.returnFocusToStoredElement(); + } + }, { + key: "render", + value: function render() { + // Merge objects of strings with their default object + var assistiveText = (0, _lodash.default)({}, defaultProps.assistiveText, this.props.assistiveText); + var labels = (0, _lodash.default)({}, defaultProps.labels, this.props.labels); // BACKWARD COMPATIBILITY WITH NOTIFICATION + + var heading = labels.heading || this.props.content; // eslint-disable-line react/prop-types + + var onRequestClose = this.props.onRequestClose || this.props.onDismiss; // eslint-disable-line react/prop-types + + var assistiveTextVariant = { + info: 'info', + warning: 'warning', + error: 'error', + offline: 'offline' + }; + var defaultIcons = { + info: _react.default.createElement(_icon.default, { + category: "utility", + name: "info" + }), + offline: _react.default.createElement(_icon.default, { + category: "utility", + name: "offline" + }), + warning: _react.default.createElement(_icon.default, { + category: "utility", + name: "warning" + }), + error: _react.default.createElement(_icon.default, { + category: "utility", + name: "error" + }) + }; + var icon = this.props.icon ? this.props.icon : defaultIcons[this.props.variant]; // BACKWARD COMPATIBILITY WITH NOTIFICATION + + if (this.props.iconName && this.props.iconCategory) { + // eslint-disable-line react/prop-types + icon = _react.default.createElement(_icon.default, { + category: this.props.iconCategory, + name: this.props.iconName + }); + } + + var clonedIcon = _react.default.cloneElement(icon, { + containerClassName: 'slds-m-right_x-small', + inverse: true, + size: 'x-small' + }); + /* eslint-disable no-script-url */ + + + return _react.default.createElement("div", { + className: (0, _classNames.default)('slds-notify slds-notify_alert slds-theme_alert-texture', { + 'slds-theme_info': this.props.variant === 'info', + 'slds-theme_warning': this.props.variant === 'warning', + 'slds-theme_error': this.props.variant === 'error', + 'slds-theme_offline': this.props.variant === 'offline' + }, this.props.className), + role: "alert", + style: this.props.style + }, _react.default.createElement("span", { + className: "slds-assistive-text" + }, assistiveTextVariant[this.props.variant]), clonedIcon, _react.default.createElement("h2", null, heading, ' ', labels.headingLink ? _react.default.createElement("a", { + onClick: this.props.onClickHeadingLink, + href: "javascript:void(0);" + }, labels.headingLink) : null), this.props.dismissible ? _react.default.createElement(_button.default, { + assistiveText: { + icon: assistiveText.closeButton + }, + buttonRef: this.saveButtonRef, + className: "slds-notify__close", + iconCategory: "utility", + iconName: "close", + iconSize: "medium", + inverse: true, + onClick: onRequestClose, + title: assistiveText.closeButton, + variant: "icon" + }) : null); + } + }]); + + return Alert; +}(_react.default.Component); + +Alert.defaultProps = defaultProps; +Alert.displayName = _constants.ALERT; +Alert.propTypes = propTypes; +var _default = Alert; +exports.default = _default; \ No newline at end of file diff --git a/components/app-launcher/__docs__/site-stories.js b/components/app-launcher/__docs__/site-stories.js new file mode 100644 index 0000000000..fa5d58ae1a --- /dev/null +++ b/components/app-launcher/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/app-launcher/__examples__/default.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/app-launcher/__docs__/storybook-stories.js b/components/app-launcher/__docs__/storybook-stories.js new file mode 100644 index 0000000000..81ec85b941 --- /dev/null +++ b/components/app-launcher/__docs__/storybook-stories.js @@ -0,0 +1,788 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _constants = require("../../../utilities/constants"); + +var _appLauncher = _interopRequireDefault(require("../../app-launcher")); + +var _tile = _interopRequireDefault(require("../../app-launcher/tile")); + +var _section = _interopRequireDefault(require("../../app-launcher/section")); + +var _icon = _interopRequireDefault(require("../../icon")); + +var _button = _interopRequireDefault(require("../../button")); + +var _search = _interopRequireDefault(require("../../input/search")); + +var _globalNavigationBar = _interopRequireDefault(require("../../global-navigation-bar")); + +var _region = _interopRequireDefault(require("../../global-navigation-bar/region")); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _SLDSSettings = _interopRequireDefault(require("../../SLDSSettings")); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _executionEnvironment = require("../../../utilities/execution-environment"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// used by Modal component +if (_executionEnvironment.canUseDOM && document.querySelector('#root')) { + _SLDSSettings.default.setAppElement('#root'); +} else { + _SLDSSettings.default.setAppElement(document.createElement('div')); +} + +var standardTileDemoStyles = { + width: '20rem', + paddingLeft: '.5rem', + paddingRight: '.5rem' +}; +var smallTileDemoStyles = { + width: '6rem', + paddingLeft: '.5rem', + paddingRight: '.5rem' +}; + +var DemoAppLauncherTile = +/*#__PURE__*/ +function (_React$Component) { + _inherits(DemoAppLauncherTile, _React$Component); + + function DemoAppLauncherTile() { + _classCallCheck(this, DemoAppLauncherTile); + + return _possibleConstructorReturn(this, _getPrototypeOf(DemoAppLauncherTile).apply(this, arguments)); + } + + _createClass(DemoAppLauncherTile, [{ + key: "render", + value: function render() { + return _react.default.createElement(_tile.default, { + title: "Marketing Cloud", + iconText: "MC", + description: "Send emails, track emails, read emails! Emails!", + href: "https://www.marketingcloud.com/", + onClick: (0, _addonActions.action)('Tile clicked! Actual href should be ignored'), + search: this.props.search, + size: this.props.size + }); + } + }]); + + return DemoAppLauncherTile; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherTile, "displayName", 'DemoAppLauncherTile'); + +_defineProperty(DemoAppLauncherTile, "propTypes", { + search: _propTypes.default.string, + size: _propTypes.default.string +}); + +var DemoAppLauncherSmallTile = +/*#__PURE__*/ +function (_React$Component2) { + _inherits(DemoAppLauncherSmallTile, _React$Component2); + + function DemoAppLauncherSmallTile() { + _classCallCheck(this, DemoAppLauncherSmallTile); + + return _possibleConstructorReturn(this, _getPrototypeOf(DemoAppLauncherSmallTile).apply(this, arguments)); + } + + _createClass(DemoAppLauncherSmallTile, [{ + key: "render", + value: function render() { + return _react.default.createElement(_tile.default, { + title: "Journey Builder", + iconText: "JB", + size: "small", + onClick: (0, _addonActions.action)('Tiny tile clicked!') + }); + } + }]); + + return DemoAppLauncherSmallTile; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherSmallTile, "displayName", 'DemoAppLauncherSmallTile'); + +var DemoAppLauncherTileWithIconNode = +/*#__PURE__*/ +function (_React$Component3) { + _inherits(DemoAppLauncherTileWithIconNode, _React$Component3); + + function DemoAppLauncherTileWithIconNode() { + _classCallCheck(this, DemoAppLauncherTileWithIconNode); + + return _possibleConstructorReturn(this, _getPrototypeOf(DemoAppLauncherTileWithIconNode).apply(this, arguments)); + } + + _createClass(DemoAppLauncherTileWithIconNode, [{ + key: "render", + value: function render() { + var icon = _react.default.createElement(_icon.default, { + name: "campaign", + category: "standard", + size: "large" + }); + + return _react.default.createElement(_tile.default, { + title: "Sales Cloud", + description: "The primary internal Salesforce org.", + href: "https://www.salesforce.com/", + iconNode: icon, + onClick: (0, _addonActions.action)('Tile with icon node clicked!'), + search: this.props.search, + size: this.props.size + }); + } + }]); + + return DemoAppLauncherTileWithIconNode; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherTileWithIconNode, "displayName", 'DemoAppLauncherTileWithIconNode'); + +_defineProperty(DemoAppLauncherTileWithIconNode, "propTypes", { + search: _propTypes.default.string, + size: _propTypes.default.string +}); + +var DemoAppLauncherTileWithIconText = +/*#__PURE__*/ +function (_React$Component4) { + _inherits(DemoAppLauncherTileWithIconText, _React$Component4); + + function DemoAppLauncherTileWithIconText() { + _classCallCheck(this, DemoAppLauncherTileWithIconText); + + return _possibleConstructorReturn(this, _getPrototypeOf(DemoAppLauncherTileWithIconText).apply(this, arguments)); + } + + _createClass(DemoAppLauncherTileWithIconText, [{ + key: "render", + value: function render() { + return _react.default.createElement(_tile.default, { + title: "Sales Cloud", + description: "The primary internal Salesforce org.", + iconText: "SC", + onClick: (0, _addonActions.action)('Tile with icon text clicked!'), + search: this.props.search, + size: this.props.size + }); + } + }]); + + return DemoAppLauncherTileWithIconText; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherTileWithIconText, "displayName", 'DemoAppLauncherTileWithIconText'); + +_defineProperty(DemoAppLauncherTileWithIconText, "propTypes", { + search: _propTypes.default.string, + size: _propTypes.default.string +}); + +var DemoAppLauncherTileWithTruncatedText = +/*#__PURE__*/ +function (_React$Component5) { + _inherits(DemoAppLauncherTileWithTruncatedText, _React$Component5); + + function DemoAppLauncherTileWithTruncatedText() { + _classCallCheck(this, DemoAppLauncherTileWithTruncatedText); + + return _possibleConstructorReturn(this, _getPrototypeOf(DemoAppLauncherTileWithTruncatedText).apply(this, arguments)); + } + + _createClass(DemoAppLauncherTileWithTruncatedText, [{ + key: "render", + value: function render() { + return _react.default.createElement(_tile.default, { + title: "Call Center", + description: "The key to call center and contact center is not to use too many words!", + iconText: "CC", + onClick: (0, _addonActions.action)('Tile with icon text clicked!'), + search: this.props.search, + size: this.props.size + }); + } + }]); + + return DemoAppLauncherTileWithTruncatedText; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherTileWithTruncatedText, "displayName", 'DemoAppLauncherTileWithTruncatedText'); + +_defineProperty(DemoAppLauncherTileWithTruncatedText, "propTypes", { + search: _propTypes.default.string, + size: _propTypes.default.string +}); + +var DemoAppLauncherTileWithDescriptionHeading = +/*#__PURE__*/ +function (_React$Component6) { + _inherits(DemoAppLauncherTileWithDescriptionHeading, _React$Component6); + + function DemoAppLauncherTileWithDescriptionHeading() { + _classCallCheck(this, DemoAppLauncherTileWithDescriptionHeading); + + return _possibleConstructorReturn(this, _getPrototypeOf(DemoAppLauncherTileWithDescriptionHeading).apply(this, arguments)); + } + + _createClass(DemoAppLauncherTileWithDescriptionHeading, [{ + key: "render", + value: function render() { + return _react.default.createElement(_tile.default, { + title: "Journey Builder", + description: "Build 1:1 journeys blah blah blah and use way too many words", + descriptionHeading: "Journey Builder", + iconText: "JB", + onClick: (0, _addonActions.action)('Tile with description heading clicked!'), + search: this.props.search, + size: this.props.size + }); + } + }]); + + return DemoAppLauncherTileWithDescriptionHeading; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherTileWithDescriptionHeading, "displayName", 'DemoAppLauncherTileWithDescriptionHeading'); + +_defineProperty(DemoAppLauncherTileWithDescriptionHeading, "propTypes", { + search: _propTypes.default.string, + size: _propTypes.default.string +}); + +_defineProperty(DemoAppLauncherTileWithDescriptionHeading, "defaultProps", { + search: 'journey' +}); + +var DemoAppLauncherTileWithSearchText = +/*#__PURE__*/ +function (_React$Component7) { + _inherits(DemoAppLauncherTileWithSearchText, _React$Component7); + + function DemoAppLauncherTileWithSearchText() { + _classCallCheck(this, DemoAppLauncherTileWithSearchText); + + return _possibleConstructorReturn(this, _getPrototypeOf(DemoAppLauncherTileWithSearchText).apply(this, arguments)); + } + + _createClass(DemoAppLauncherTileWithSearchText, [{ + key: "render", + value: function render() { + return _react.default.createElement(DemoAppLauncherTileWithTruncatedText, { + search: this.props.search, + size: this.props.size + }); + } + }]); + + return DemoAppLauncherTileWithSearchText; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherTileWithSearchText, "displayName", 'DemoAppLauncherTileWithSearchText'); + +_defineProperty(DemoAppLauncherTileWithSearchText, "propTypes", { + search: _propTypes.default.string, + size: _propTypes.default.string +}); + +_defineProperty(DemoAppLauncherTileWithSearchText, "defaultProps", { + search: 'Call' +}); + +var DemoAppLauncherSection = +/*#__PURE__*/ +function (_React$Component8) { + _inherits(DemoAppLauncherSection, _React$Component8); + + function DemoAppLauncherSection() { + _classCallCheck(this, DemoAppLauncherSection); + + return _possibleConstructorReturn(this, _getPrototypeOf(DemoAppLauncherSection).apply(this, arguments)); + } + + _createClass(DemoAppLauncherSection, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement(_section.default, { + assistiveText: { + collapseSection: 'Collapse Section' + }, + title: "All Items", + toggleable: true, + onToggleClick: (0, _addonActions.action)('Section `All Items` open -->') + }, _react.default.createElement(DemoAppLauncherTile, null), _react.default.createElement(DemoAppLauncherTileWithIconText, null), _react.default.createElement(DemoAppLauncherTileWithIconNode, null)), _react.default.createElement(_section.default, { + title: "All Apps", + onToggleClick: (0, _addonActions.action)('Section `All App` open -->') + }, _react.default.createElement(DemoAppLauncherTile, null), _react.default.createElement(DemoAppLauncherTileWithIconNode, null))); + } + }]); + + return DemoAppLauncherSection; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherSection, "displayName", 'DemoAppLauncherSection'); + +var DemoAppLauncherSectionWithSmallTiles = +/*#__PURE__*/ +function (_React$Component9) { + _inherits(DemoAppLauncherSectionWithSmallTiles, _React$Component9); + + function DemoAppLauncherSectionWithSmallTiles() { + _classCallCheck(this, DemoAppLauncherSectionWithSmallTiles); + + return _possibleConstructorReturn(this, _getPrototypeOf(DemoAppLauncherSectionWithSmallTiles).apply(this, arguments)); + } + + _createClass(DemoAppLauncherSectionWithSmallTiles, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement(_section.default, { + title: "All Items", + onToggleClick: (0, _addonActions.action)('Section `All Items` open -->') + }, _react.default.createElement(DemoAppLauncherTile, null), _react.default.createElement(DemoAppLauncherTileWithIconText, null), _react.default.createElement(DemoAppLauncherTileWithIconNode, null)), _react.default.createElement(_section.default, { + title: "All Apps", + onToggleClick: (0, _addonActions.action)('Section `All App` open -->') + }, _react.default.createElement(DemoAppLauncherTile, { + size: "small" + }), _react.default.createElement(DemoAppLauncherTileWithIconNode, { + size: "small" + }))); + } + }]); + + return DemoAppLauncherSectionWithSmallTiles; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherSectionWithSmallTiles, "displayName", 'DemoAppLauncherSectionWithSmallTiles'); + +var DemoAppLauncher = +/*#__PURE__*/ +function (_React$Component10) { + _inherits(DemoAppLauncher, _React$Component10); + + function DemoAppLauncher() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, DemoAppLauncher); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DemoAppLauncher)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + search: '', + appLauncherOpen: _this.props.isOpen || false, + // eslint-disable-line react/prop-types + allItemsSectionIsOpen: false + }); + + _defineProperty(_assertThisInitialized(_this), "onClear", function () { + _this.setState({ + search: '' + }); + }); + + _defineProperty(_assertThisInitialized(_this), "onSearch", function (event) { + _this.setState({ + search: event.target.value + }); + }); + + _defineProperty(_assertThisInitialized(_this), "toggleAppLauncher", function () { + _this.setState({ + appLauncherOpen: !_this.state.appLauncherOpen + }); + }); + + _defineProperty(_assertThisInitialized(_this), "toggleSection", function () { + _this.setState({ + allItemsSectionIsOpen: !_this.state.allItemsSectionIsOpen + }); + }); + + return _this; + } + + _createClass(DemoAppLauncher, [{ + key: "render", + value: function render() { + var search = _react.default.createElement(_search.default, { + clearable: this.state.search !== '', + onChange: this.onSearch, + onClear: this.onClear, + placeholder: "Find an app", + assistiveText: { + label: 'Find an app' + }, + value: this.state.search + }); + + var modalHeaderButton = _react.default.createElement(_button.default, { + label: "App Exchange", + onClick: (0, _addonActions.action)('Modal Button clicked!') + }); + + return _react.default.createElement(_globalNavigationBar.default, null, _react.default.createElement(_region.default, { + region: "primary" + }, _react.default.createElement(_appLauncher.default, { + assistiveText: { + trigger: 'Open App Launcher' + }, + triggerName: "App Name", + search: search, + modalClassName: "custom-modal-class", + modalHeaderButton: modalHeaderButton, + isOpen: this.state.appLauncherOpen, + triggerOnClick: this.toggleAppLauncher, + onClose: this.toggleAppLauncher + }, _react.default.createElement(_section.default, { + toggleable: true, + title: "All Items", + isOpen: this.state.allItemsSectionIsOpen, + onToggleClick: this.toggleSection + }, _react.default.createElement(DemoAppLauncherTile, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithIconNode, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithIconText, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTile, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithIconNode, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithIconText, { + search: this.state.search + })), _react.default.createElement(_section.default, { + title: "All Apps", + toggleable: true + }, _react.default.createElement(DemoAppLauncherTile, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithTruncatedText, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithDescriptionHeading, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTile, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithTruncatedText, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithDescriptionHeading, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTile, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithTruncatedText, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithDescriptionHeading, { + search: this.state.search + }))))); + } + }]); + + return DemoAppLauncher; +}(_react.default.Component); + +_defineProperty(DemoAppLauncher, "displayName", 'DemoAppLauncher'); + +var DemoAppLauncherNoHeaderButton = +/*#__PURE__*/ +function (_React$Component11) { + _inherits(DemoAppLauncherNoHeaderButton, _React$Component11); + + function DemoAppLauncherNoHeaderButton() { + var _getPrototypeOf3; + + var _this2; + + _classCallCheck(this, DemoAppLauncherNoHeaderButton); + + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + _this2 = _possibleConstructorReturn(this, (_getPrototypeOf3 = _getPrototypeOf(DemoAppLauncherNoHeaderButton)).call.apply(_getPrototypeOf3, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this2), "state", { + search: '', + appLauncherOpen: false, + allItemsSectionIsOpen: false + }); + + _defineProperty(_assertThisInitialized(_this2), "onSearch", function (event) { + _this2.setState({ + search: event.target.value + }); + }); + + _defineProperty(_assertThisInitialized(_this2), "toggleAppLauncher", function () { + _this2.setState({ + appLauncherOpen: !_this2.state.appLauncherOpen + }); + }); + + return _this2; + } + + _createClass(DemoAppLauncherNoHeaderButton, [{ + key: "render", + value: function render() { + var search = _react.default.createElement(_search.default, { + onChange: this.onSearch, + placeholder: "Find an app", + assistiveText: { + label: 'Find an app' + } + }); + + return _react.default.createElement(_globalNavigationBar.default, null, _react.default.createElement(_region.default, { + region: "primary" + }, _react.default.createElement(_appLauncher.default, { + triggerName: "App Name", + search: search, + isOpen: this.state.appLauncherOpen, + triggerOnClick: this.toggleAppLauncher, + onClose: this.toggleAppLauncher + }, _react.default.createElement(_section.default, { + toggleable: true, + title: "All Items" + }, _react.default.createElement(DemoAppLauncherTile, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithIconNode, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithIconText, { + search: this.state.search + })), _react.default.createElement(_section.default, { + title: "All Apps", + toggleable: true + }, _react.default.createElement(DemoAppLauncherTile, { + search: this.state.search + }), _react.default.createElement(DemoAppLauncherTileWithTruncatedText, { + search: this.state.search + }))))); + } + }]); + + return DemoAppLauncherNoHeaderButton; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherNoHeaderButton, "displayName", 'DemoAppLauncherNoHeaderButton'); + +var DemoAppLauncherNoSearch = +/*#__PURE__*/ +function (_React$Component12) { + _inherits(DemoAppLauncherNoSearch, _React$Component12); + + function DemoAppLauncherNoSearch() { + var _getPrototypeOf4; + + var _this3; + + _classCallCheck(this, DemoAppLauncherNoSearch); + + for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + _this3 = _possibleConstructorReturn(this, (_getPrototypeOf4 = _getPrototypeOf(DemoAppLauncherNoSearch)).call.apply(_getPrototypeOf4, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this3), "state", { + appLauncherOpen: false, + allItemsSectionIsOpen: false + }); + + _defineProperty(_assertThisInitialized(_this3), "toggleAppLauncher", function () { + _this3.setState({ + appLauncherOpen: !_this3.state.appLauncherOpen + }); + }); + + return _this3; + } + + _createClass(DemoAppLauncherNoSearch, [{ + key: "render", + value: function render() { + var modalHeaderButton = _react.default.createElement(_button.default, { + label: "App Exchange", + onclick: (0, _addonActions.action)('Modal Button clicked!') + }); + + return _react.default.createElement(_globalNavigationBar.default, null, _react.default.createElement(_region.default, { + region: "primary" + }, _react.default.createElement(_appLauncher.default, { + triggerName: "App Name", + modalHeaderButton: modalHeaderButton, + isOpen: this.state.appLauncherOpen, + triggerOnClick: this.toggleAppLauncher, + onClose: this.toggleAppLauncher + }, _react.default.createElement(_section.default, { + toggleable: true, + title: "All Items" + }, _react.default.createElement(DemoAppLauncherTile, null), _react.default.createElement(DemoAppLauncherTileWithIconNode, null), _react.default.createElement(DemoAppLauncherTileWithIconText, null)), _react.default.createElement(_section.default, { + title: "All Apps", + toggleable: true + }, _react.default.createElement(DemoAppLauncherTile, null), _react.default.createElement(DemoAppLauncherTileWithTruncatedText, null))))); + } + }]); + + return DemoAppLauncherNoSearch; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherNoSearch, "displayName", 'DemoAppLauncherNoSearch'); + +var DemoAppLauncherWithSeveralSections = +/*#__PURE__*/ +function (_React$Component13) { + _inherits(DemoAppLauncherWithSeveralSections, _React$Component13); + + function DemoAppLauncherWithSeveralSections() { + var _getPrototypeOf5; + + var _this4; + + _classCallCheck(this, DemoAppLauncherWithSeveralSections); + + for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; + } + + _this4 = _possibleConstructorReturn(this, (_getPrototypeOf5 = _getPrototypeOf(DemoAppLauncherWithSeveralSections)).call.apply(_getPrototypeOf5, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this4), "onSearch", function () {// stub + }); + + return _this4; + } + + _createClass(DemoAppLauncherWithSeveralSections, [{ + key: "render", + value: function render() { + var search = _react.default.createElement(_search.default, { + onChange: this.onSearch, + placeholder: "Find an app", + assistiveText: { + label: 'Find an app' + } + }); + + var modalHeaderButton = _react.default.createElement(_button.default, { + label: "App Exchange", + onclick: (0, _addonActions.action)('Modal Button clicked!') + }); + + return _react.default.createElement(_globalNavigationBar.default, null, _react.default.createElement(_region.default, { + region: "primary" + }, _react.default.createElement(_appLauncher.default, { + triggerName: "App Name", + search: search, + modalHeaderButton: modalHeaderButton + }, _react.default.createElement(_section.default, { + title: "First Section" + }, _react.default.createElement(DemoAppLauncherTile, null), _react.default.createElement(DemoAppLauncherTileWithIconNode, null), _react.default.createElement(DemoAppLauncherTileWithTruncatedText, null)), _react.default.createElement(_section.default, { + title: "Second Section" + }, _react.default.createElement(DemoAppLauncherTile, null), _react.default.createElement(DemoAppLauncherTileWithIconNode, null), _react.default.createElement(DemoAppLauncherTileWithTruncatedText, null)), _react.default.createElement(_section.default, { + title: "Third Section" + }, _react.default.createElement(DemoAppLauncherTile, null), _react.default.createElement(DemoAppLauncherTileWithIconNode, null), _react.default.createElement(DemoAppLauncherTileWithTruncatedText, null)), _react.default.createElement(_section.default, { + title: "Fourth Section" + }, _react.default.createElement(DemoAppLauncherTile, null), _react.default.createElement(DemoAppLauncherTileWithIconNode, null), _react.default.createElement(DemoAppLauncherTileWithTruncatedText, null)), _react.default.createElement(_section.default, { + title: "Fifth Section" + }, _react.default.createElement(DemoAppLauncherTile, null), _react.default.createElement(DemoAppLauncherTileWithIconNode, null), _react.default.createElement(DemoAppLauncherTileWithTruncatedText, null))))); + } + }]); + + return DemoAppLauncherWithSeveralSections; +}(_react.default.Component); + +_defineProperty(DemoAppLauncherWithSeveralSections, "displayName", 'DemoAppLauncherWithSeveralSections'); + +(0, _react2.storiesOf)(_constants.APP_LAUNCHER, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('App Launcher (open)', function () { + return _react.default.createElement(DemoAppLauncher, { + isOpen: true + }); +}).add('App Launcher', function () { + return _react.default.createElement(DemoAppLauncher, null); +}).add('App Launcher no header button', function () { + return _react.default.createElement(DemoAppLauncherNoHeaderButton, null); +}).add('App Launcher no search', function () { + return _react.default.createElement(DemoAppLauncherNoSearch, null); +}).add('App Launcher with several sections (no toggle)', function () { + return _react.default.createElement(DemoAppLauncherWithSeveralSections, null); +}).add('Tile', function () { + return _react.default.createElement("div", { + style: standardTileDemoStyles + }, _react.default.createElement(DemoAppLauncherTile, null)); +}).add('Small Tile', function () { + return _react.default.createElement("div", { + style: smallTileDemoStyles + }, _react.default.createElement(DemoAppLauncherSmallTile, null)); +}).add('Tile with Icon node', function () { + return _react.default.createElement("div", { + style: standardTileDemoStyles + }, _react.default.createElement(DemoAppLauncherTileWithIconNode, null)); +}).add('Tile with icon text', function () { + return _react.default.createElement("div", { + style: standardTileDemoStyles + }, _react.default.createElement(DemoAppLauncherTileWithIconText, null)); +}).add('Tile with search text', function () { + return _react.default.createElement("div", { + style: standardTileDemoStyles + }, _react.default.createElement(DemoAppLauncherTileWithSearchText, null)); +}).add('Tile with truncated text', function () { + return _react.default.createElement("div", { + style: standardTileDemoStyles + }, _react.default.createElement(DemoAppLauncherTileWithTruncatedText, null)); +}).add('Tile with description heading', function () { + return _react.default.createElement("div", { + style: standardTileDemoStyles + }, _react.default.createElement(DemoAppLauncherTileWithDescriptionHeading, null)); +}).add('Section', function () { + return _react.default.createElement(DemoAppLauncherSection, null); +}).add('Section with small tiles', function () { + return _react.default.createElement(DemoAppLauncherSectionWithSmallTiles, null); +}).add('Doc site example', function () { + return _react.default.createElement(_default.default, null); +}); \ No newline at end of file diff --git a/components/app-launcher/__examples__/default.js b/components/app-launcher/__examples__/default.js new file mode 100644 index 0000000000..648b64186c --- /dev/null +++ b/components/app-launcher/__examples__/default.js @@ -0,0 +1,122 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _appLauncher = _interopRequireDefault(require("../../../../components/app-launcher")); + +var _tile = _interopRequireDefault(require("../../../../components/app-launcher/tile")); + +var _section = _interopRequireDefault(require("../../../../components/app-launcher/section")); + +var _globalNavigationBar = _interopRequireDefault(require("../../../../components/global-navigation-bar")); + +var _region = _interopRequireDefault(require("../../../../components/global-navigation-bar/region")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _search = _interopRequireDefault(require("../../../../components/input/search")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var search = _react.default.createElement(_search.default, { + onChange: function onChange() { + console.log('Search term:', event.target.value); + }, + placeholder: "Find an app", + assistiveText: { + label: 'Find an app' + } + }); + + var headerButton = _react.default.createElement(_button.default, { + label: "App Exchange" + }); + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_globalNavigationBar.default, null, _react.default.createElement(_region.default, { + region: "primary" + }, _react.default.createElement(_appLauncher.default, { + triggerName: "App Name", + search: search, + modalHeaderButton: headerButton + }, _react.default.createElement(_section.default, { + title: "Tile Section" + }, _react.default.createElement(_tile.default, { + title: "Marketing Cloud", + iconText: "MC", + description: "Send emails, track emails, read emails! Emails!" + }), _react.default.createElement(_tile.default, { + title: "Call Center", + description: "The key to call center and contact center is not to use too many words!", + descriptionHeading: "Call Center", + iconText: "CC" + })), _react.default.createElement(_section.default, { + title: "Small Tile Section" + }, _react.default.createElement(_tile.default, { + title: "Journey Builder", + iconText: "JB", + size: "small" + }), _react.default.createElement(_tile.default, { + title: "Sales Cloud", + iconNode: _react.default.createElement(_icon.default, { + name: "campaign", + category: "standard", + size: "large" + }), + size: "small" + })))))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'AppLauncherExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/app-launcher/check-props.js b/components/app-launcher/check-props.js new file mode 100644 index 0000000000..9f962ce195 --- /dev/null +++ b/components/app-launcher/check-props.js @@ -0,0 +1,42 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _deprecatedProperty = _interopRequireDefault(require("../../utilities/warning/deprecated-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +var _oneOfComponent = _interopRequireDefault(require("../../utilities/warning/one-of-component")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + + if (COMPONENT === _constants.APP_LAUNCHER) { + if (props.modalHeaderButton !== undefined) { + (0, _oneOfComponent.default)(COMPONENT, props, 'modalHeaderButton', ['SLDSButton'], createDocUrl('modalHeaderButton')); + } + + (0, _deprecatedProperty.default)(COMPONENT, props.triggerAssistiveText, 'triggerAssistiveText', "assistiveText['trigger']", createDocUrl('assistiveText')); + } else if (COMPONENT === _constants.APP_LAUNCHER_SECTION) { + (0, _deprecatedProperty.default)(COMPONENT, props.collapseSectionAssistiveText, 'collapseSectionAssistiveText', "assistiveText['collapseSection']", createDocUrl('assistiveText')); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/app-launcher/docs.json b/components/app-launcher/docs.json new file mode 100644 index 0000000000..3aa902af46 --- /dev/null +++ b/components/app-launcher/docs.json @@ -0,0 +1,15 @@ +{ + "component": "app-launcher", + "status": "prototype", + "display-name": "App Launcher", + "SLDS-component-path": "/components/app-launcher/#flavor-default", + "dependencies": [ + { + "component": "section" + }, + { + "component": "tile" + } + ], + "url-slug": "app-launcher" +} \ No newline at end of file diff --git a/components/app-launcher/index.js b/components/app-launcher/index.js new file mode 100644 index 0000000000..70ffd6dabc --- /dev/null +++ b/components/app-launcher/index.js @@ -0,0 +1,309 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _lodash = _interopRequireDefault(require("lodash.isfunction")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _modal = _interopRequireDefault(require("../modal")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var defaultProps = { + assistiveText: { + trigger: 'Open App Launcher' + }, + ariaHideApp: true, + title: 'App Launcher' +}; +/** + * The App Launcher allows the user to quickly access all the apps and functionality with their organization. + * The App Launcher should generally only be used as a sub-component of the [Global Navigation Bar](/components/global-navigation-bar) + * + * USAGE EXAMPLE: + * ``` + * + * + * + * + * + * + * + * + * + * + * + * ``` + * + * By default, `Modal`, a child component of App Launcher, will add `aria-hidden=true` to the `body` tag, but this disables some assistive technologies. To prevent this you can add the following to your application with `#mount` being the root node of your application that you would like to hide from assistive technologies when the `Modal` is open. + * ``` + * import settings from 'design-system-react/components/settings'; + * settings.setAppElement('#mount'); + * ``` + */ + +var AppLauncher = +/*#__PURE__*/ +function (_React$Component) { + _inherits(AppLauncher, _React$Component); + + function AppLauncher() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, AppLauncher); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(AppLauncher)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + isOpen: false + }); + + _defineProperty(_assertThisInitialized(_this), "openAppLauncher", function (event) { + _this.setState({ + isOpen: true + }); + + if ((0, _lodash.default)(_this.props.triggerOnClick)) { + _this.props.triggerOnClick(event, {}); + } + }); + + _defineProperty(_assertThisInitialized(_this), "closeAppLauncher", function (event) { + _this.setState({ + isOpen: false + }); + + if ((0, _lodash.default)(_this.props.onClose)) { + _this.props.onClose(event, {}); + } + }); + + _defineProperty(_assertThisInitialized(_this), "renderSearch", function () { + var returnVal; + + if (_this.props.search) { + returnVal = _react.default.createElement("div", { + className: "slds-app-launcher__header-search", + ref: function ref(component) { + if (component) { + if (!_this.focusedOnSearch) { + var input = component.querySelector('input'); + + if (input) { + // push to end of stack so click event doesn't blur the focus + setTimeout(function () { + input.focus(); + _this.focusedOnSearch = true; + }, 0); + } + } + } else { + _this.focusedOnSearch = false; + } + } + }, _this.props.search); + } + + return returnVal; + }); + + return _this; + } + + _createClass(AppLauncher, [{ + key: "componentWillMount", + value: function componentWillMount() { + // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + (0, _checkProps.default)(_constants.APP_LAUNCHER, this.props, _docs.default); + } + }, { + key: "render", + value: function render() { + var isOpen = this.props.isOpen !== undefined ? this.props.isOpen : this.state.isOpen; // Should be removed in the future by adding a reset class of some sort. + + var style = this.props.noTruncate ? { + maxWidth: 'none' + } : null; + + var customModalHeader = _react.default.createElement("div", { + className: "slds-grid slds-grid_align-spread slds-grid_vertical-align-center" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, this.props.title), this.renderSearch(), this.props.modalHeaderButton ? this.props.modalHeaderButton : _react.default.createElement("span", { + className: "slds-size_1-of-7" + })); // Not present in SLDS, but is consistent with other implementations of App Launcher. This also prevents resizing/jumping around when filtering. It will start clipping the modal close button at 600px viewport height. + + + var modalContentStaticHeight = '90%'; + + var assistiveText = _objectSpread({}, defaultProps.assistiveText, this.props.assistiveText); + + var triggerAssistiveText = this.props.triggerAssistiveText || assistiveText.trigger; + return _react.default.createElement("div", { + className: "slds-context-bar__item slds-no-hover", + style: style + }, _react.default.createElement("div", { + className: "slds-context-bar__icon-action" + }, _react.default.createElement("button", { + "aria-haspopup": "true", + className: "slds-button slds-icon-waffle_container slds-context-bar__button", + onClick: this.openAppLauncher + }, _react.default.createElement("span", { + className: "slds-icon-waffle" + }, _react.default.createElement("span", { + className: "slds-r1" + }), _react.default.createElement("span", { + className: "slds-r2" + }), _react.default.createElement("span", { + className: "slds-r3" + }), _react.default.createElement("span", { + className: "slds-r4" + }), _react.default.createElement("span", { + className: "slds-r5" + }), _react.default.createElement("span", { + className: "slds-r6" + }), _react.default.createElement("span", { + className: "slds-r7" + }), _react.default.createElement("span", { + className: "slds-r8" + }), _react.default.createElement("span", { + className: "slds-r9" + })), triggerAssistiveText && _react.default.createElement("span", { + className: "slds-assistive-text" + }, triggerAssistiveText))), _react.default.createElement(_modal.default, { + ariaHideApp: this.props.ariaHideApp, + contentClassName: "slds-modal__content slds-app-launcher__content slds-p-around_medium", + contentStyle: { + minHeight: modalContentStaticHeight + }, + isOpen: isOpen, + onRequestClose: this.closeAppLauncher, + containerClassName: (0, _classnames.default)('app-launcher', this.props.modalClassName), + size: "large", + header: customModalHeader, + headerClassName: "slds-app-launcher__header" + }, this.props.children), this.props.triggerName ? _react.default.createElement("span", { + className: (0, _classnames.default)('slds-context-bar__label-action slds-context-bar__app-name', { + 'slds-truncate': !this.props.noTruncate + }) + }, this.props.triggerName) : null); + } + }]); + + return AppLauncher; +}(_react.default.Component); + +_defineProperty(AppLauncher, "displayName", _constants.APP_LAUNCHER); + +_defineProperty(AppLauncher, "propTypes", { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `trigger`: This is a visually hidden label for the app launcher icon. + */ + assistiveText: _propTypes.default.shape({ + trigger: _propTypes.default.string + }), + + /** + * Boolean indicating if the appElement should be hidden. + */ + ariaHideApp: _propTypes.default.bool, + + /** + * One or more ``s each containing one or more ``s + */ + children: _propTypes.default.node.isRequired, + + /** + * Control the open/close state of the App Launcher + */ + isOpen: _propTypes.default.bool, + + /** + * CSS classes to be added to App Launcher Modal. + */ + modalClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Button that exists in the upper right hand corner of the App Launcher modal + */ + modalHeaderButton: _propTypes.default.node, + + /** + * Allows longer application names without truncating them. + */ + noTruncate: _propTypes.default.bool, + + /** + * Callback when the App Launcher Modal is closed + */ + onClose: _propTypes.default.func, + + /** + * Search bar for the Modal's header. Will typically be an instance of `design-system-react/input/search` + */ + search: _propTypes.default.node, + + /** + * Set the App Launcher's title text (for localization) + */ + title: _propTypes.default.string, + + /** + * This is typically the name of the cloud or application + */ + triggerName: _propTypes.default.node, + + /** + * Callback when the App Launcher icon is clicked + */ + triggerOnClick: _propTypes.default.func +}); + +_defineProperty(AppLauncher, "defaultProps", defaultProps); + +var _default = AppLauncher; +exports.default = _default; \ No newline at end of file diff --git a/components/app-launcher/section.js b/components/app-launcher/section.js new file mode 100644 index 0000000000..0f1475124b --- /dev/null +++ b/components/app-launcher/section.js @@ -0,0 +1,179 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.isfunction")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _button = _interopRequireDefault(require("../button")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var defaultProps = { + assistiveText: { + collapseSection: 'Toggle visibility of section' + } +}; +/** + * App Launcher Sections allow users to categorize App Tiles as well as toggle their display + */ + +var AppLauncherSection = +/*#__PURE__*/ +function (_React$Component) { + _inherits(AppLauncherSection, _React$Component); + + function AppLauncherSection() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, AppLauncherSection); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(AppLauncherSection)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + isOpen: true + }); + + _defineProperty(_assertThisInitialized(_this), "toggleOpen", function (event) { + _this.setState({ + isOpen: !_this.state.isOpen + }); + + if ((0, _lodash.default)(_this.props.onToggleClick)) { + _this.props.onToggleClick(event, {}); + } + }); + + return _this; + } + + _createClass(AppLauncherSection, [{ + key: "componentWillMount", + value: function componentWillMount() { + (0, _checkProps.default)(_constants.APP_LAUNCHER_SECTION, this.props, _docs.default); + } + }, { + key: "render", + value: function render() { + var isOpen = this.props.isOpen !== undefined ? this.props.isOpen : this.state.isOpen; + var iconIsOpenClass = isOpen ? 'slds-is-open' : 'slds-is-close'; + var sectionIsOpenClass = isOpen ? 'slds-is-expanded' : 'slds-is-collapsed'; + + var assistiveText = _objectSpread({}, defaultProps.assistiveText, this.props.assistiveText); + + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-section', iconIsOpenClass) + }, _react.default.createElement("div", { + className: "slds-section__title" + }, this.props.toggleable || this.props.onToggleClick ? _react.default.createElement(_button.default, { + assistiveText: { + icon: this.props.collapseSectionAssistiveText || assistiveText.collapseSection + }, + iconCategory: "utility", + iconName: "switch", + onClick: this.toggleOpen, + className: (0, _classnames.default)({ + 'slds-button__icon slds-m-right_medium': true, + 'slds-button__icon_left': isOpen, + 'slds-accordion__summary-action-icon': !isOpen + }), + variant: "icon" + }) : null, _react.default.createElement("h3", null, this.props.title)), _react.default.createElement("div", { + className: "slds-section__content" + }, _react.default.createElement("ul", { + className: (0, _classnames.default)('slds-grid slds-grid_pull-padded slds-wrap', sectionIsOpenClass) + }, _react.default.Children.map(this.props.children, function (child) { + return _react.default.createElement("li", { + className: (0, _classnames.default)('slds-col_padded slds-grow-none', child.props.size === 'small' ? 'slds-size_xx-small' : 'slds-size_1-of-1 slds-medium-size_1-of-3') + }, child); + })))); + } + }]); + + return AppLauncherSection; +}(_react.default.Component); + +_defineProperty(AppLauncherSection, "displayName", _constants.APP_LAUNCHER_SECTION); + +_defineProperty(AppLauncherSection, "propTypes", { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `collapseSection`: The assistive text for the section collapse icons. + */ + assistiveText: _propTypes.default.shape({ + collapseSection: _propTypes.default.string + }), + + /** + * The title for this section of apps + */ + title: _propTypes.default.string.isRequired, + + /** + * Allows the user to show/hide the section + */ + toggleable: _propTypes.default.bool, + + /** + * An array of applications to display + */ + children: _propTypes.default.node.isRequired, + + /** + * Controls the open/closed state of the section + */ + isOpen: _propTypes.default.bool, + + /** + * Callback for when section is toggled. Passes "isOpen" bool. Forces `toggleable` to true + */ + onToggleClick: _propTypes.default.func +}); + +_defineProperty(AppLauncherSection, "defaultProps", defaultProps); + +var _default = AppLauncherSection; +exports.default = _default; \ No newline at end of file diff --git a/components/app-launcher/tile.js b/components/app-launcher/tile.js new file mode 100644 index 0000000000..cb7054aa4b --- /dev/null +++ b/components/app-launcher/tile.js @@ -0,0 +1,175 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.isfunction")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _truncate = _interopRequireDefault(require("../utilities/truncate")); + +var _highlighter = _interopRequireDefault(require("../utilities/highlighter")); + +var _tooltip = _interopRequireDefault(require("../tooltip")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable jsx-a11y/no-noninteractive-tabindex */ +// ## Children +var handleClick = function handleClick(event, href, onClick) { + event.preventDefault(); + onClick(event, { + href: href + }); +}; +/** + * App Launcher Tiles provide information and links to a user's apps + */ + + +var AppLauncherTile = function AppLauncherTile(props) { + var smallTile = props.size === 'small' || false; + return _react.default.createElement("a", { + href: props.href // eslint-disable-line no-script-url + , + onClick: (0, _lodash.default)(props.onClick) ? function (event) { + return handleClick(event, props.href, props.onClick); + } : null, + className: (0, _classnames.default)('slds-app-launcher__tile slds-text-link_reset', { + 'slds-app-launcher__tile_small': smallTile + }, props.className) + }, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-app-launcher__tile-figure', { + 'slds-app-launcher__tile-figure_small': smallTile + }) + }, props.iconNode || _react.default.createElement("span", { + className: "slds-avatar slds-avatar_large slds-align_absolute-center slds-icon-custom-27" + }, props.iconText)), smallTile ? _react.default.createElement("div", { + className: "slds-app-launcher__tile-body slds-app-launcher__tile-body_small" + }, _react.default.createElement("p", { + className: "slds-truncate" + }, _react.default.createElement(_highlighter.default, { + className: "slds-text-link", + search: props.search + }, props.title))) : _react.default.createElement("div", { + className: "slds-app-launcher__tile-body" + }, _react.default.createElement(_highlighter.default, { + className: "slds-text-link", + search: props.search + }, props.title), _react.default.createElement(_truncate.default, { + line: 2, + prefix: props.descriptionHeading && props.descriptionHeading.toUpperCase(), + suffix: props.moreLabel, + text: props.description, + textTruncateChild: _react.default.createElement(_tooltip.default, { + align: "bottom", + content: _react.default.createElement(_highlighter.default, { + search: props.search + }, props.description), + isOpen: props.isOpenTooltip + }, _react.default.createElement("span", { + className: "slds-app-launcher__tile-more slds-text-link", + tabIndex: "0" + }, props.moreLabel)), + wrapper: function wrapper(text, textTruncateChild) { + return _react.default.createElement("div", null, props.descriptionHeading && // inline style override + _react.default.createElement("span", { + className: "slds-text-heading_label", + style: { + letterSpacing: '0.025rem' + } + }, props.descriptionHeading, ' '), _react.default.createElement(_highlighter.default, { + search: props.search + }, text), textTruncateChild && ' ', textTruncateChild); + } + }))); +}; // ### Display Name +// Always use the canonical component name as the React display name. + + +AppLauncherTile.displayName = _constants.APP_LAUNCHER_TILE; +AppLauncherTile.defaultProps = { + href: 'javascript:void(0);', + // eslint-disable-line no-script-url + size: 'default', + moreLabel: ' More' +}; // ### Prop Types + +AppLauncherTile.propTypes = { + /** + * App name for the tile's title. + */ + title: _propTypes.default.string.isRequired, + + /** + * Size of the rendered tile. + */ + size: _propTypes.default.oneOf(['default', 'small']), + + /** + * The description of the app. Not visible on small tiles. + */ + description: _propTypes.default.string, + + /** + * Heading for app description + */ + descriptionHeading: _propTypes.default.string, + + /** + * The `href` attribute of the tile. Please pass in bookmarkable URLs from your routing library. If the `onClick` callback is specified this URL will be prevented from changing the browser's location. + */ + href: _propTypes.default.string, + + /** + * Open the More Tooltip + */ + isOpenTooltip: _propTypes.default.bool, + + /** + * The localized text for the "More information" tooltip. + */ + moreLabel: _propTypes.default.string, + + /** + * Class names to be added to the tile. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Function that will be executed when clicking on a tile + */ + onClick: _propTypes.default.func, + + /** + * Icon node for app tile. Takes priority over `iconText` + */ + iconNode: _propTypes.default.node, + + /** + * Text to be used as an icon. Only renders if iconNode is undefined + */ + iconText: _propTypes.default.string, + + /** + * Text used to highlight content in app tiles + */ + search: _propTypes.default.string // TODO: allow for passing iconBackgroundColor + // TODO: add Highlighter to Truncate text (https://github.com/ShinyChang/React-Text-Truncate/issues/32) + +}; +var _default = AppLauncherTile; +exports.default = _default; \ No newline at end of file diff --git a/components/avatar/__docs__/__snapshots__/storybook-stories.storyshot b/components/avatar/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..0a54087838 --- /dev/null +++ b/components/avatar/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,203 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSAvatar Base 1`] = ` +
    +
    +

    + Base Avatar +

    +
    + + Person Name + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAvatar Entity Icon 1`] = ` +
    +
    +

    + Entity Icon Avatar +

    +
    + + + + + Avatar icon avatar + + + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAvatar Entity Initials 1`] = ` +
    +
    +

    + Entity Initials Avatar +

    +
    + + + AC + + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAvatar Inverse User Initials 1`] = ` +
    +
    +

    + Inversed User Initials Avatar +

    +
    + + + AW + + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAvatar User Icon 1`] = ` +
    +
    +

    + User Icon Avatar +

    +
    + + + + + User Icon Avatar + + + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSAvatar User Initials 1`] = ` +
    +
    +

    + User Initials Avatar +

    +
    + + + AW + + +
    +
    +
    +`; diff --git a/components/avatar/__docs__/site-stories.js b/components/avatar/__docs__/site-stories.js new file mode 100644 index 0000000000..a91561da01 --- /dev/null +++ b/components/avatar/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/avatar/__examples__/base.jsx'), require('raw-loader!@salesforce/design-system-react/components/avatar/__examples__/user-initials.jsx'), require('raw-loader!@salesforce/design-system-react/components/avatar/__examples__/user-icon.jsx'), require('raw-loader!@salesforce/design-system-react/components/avatar/__examples__/entity-initials.jsx'), require('raw-loader!@salesforce/design-system-react/components/avatar/__examples__/entity-icon.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/avatar/__docs__/storybook-stories.js b/components/avatar/__docs__/storybook-stories.js new file mode 100644 index 0000000000..931ae17a66 --- /dev/null +++ b/components/avatar/__docs__/storybook-stories.js @@ -0,0 +1,64 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +var _inverseUserInitials = _interopRequireDefault(require("../__examples__/inverse-user-initials.jsx")); + +var _userIcon = _interopRequireDefault(require("../__examples__/user-icon.jsx")); + +var _userInitials = _interopRequireDefault(require("../__examples__/user-initials.jsx")); + +var _entityIcon = _interopRequireDefault(require("../__examples__/entity-icon.jsx")); + +var _entityInitials = _interopRequireDefault(require("../__examples__/entity-initials.jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* eslint-disable react/display-name */ +(0, _react2.storiesOf)(_constants.AVATAR, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base', function () { + return _react.default.createElement("div", null, _react.default.createElement("h1", { + style: { + marginBottom: '10px' + } + }, "Base Avatar"), _react.default.createElement(_base.default, null)); +}).add('Entity Icon', function () { + return _react.default.createElement("div", null, _react.default.createElement("h1", { + style: { + marginBottom: '10px' + } + }, "Entity Icon Avatar"), _react.default.createElement(_entityIcon.default, null)); +}).add('Entity Initials', function () { + return _react.default.createElement("div", null, _react.default.createElement("h1", { + style: { + marginBottom: '10px' + } + }, "Entity Initials Avatar"), _react.default.createElement(_entityInitials.default, null)); +}).add('User Icon', function () { + return _react.default.createElement("div", null, _react.default.createElement("h1", { + style: { + marginBottom: '10px' + } + }, "User Icon Avatar"), _react.default.createElement(_userIcon.default, null)); +}).add('User Initials', function () { + return _react.default.createElement("div", null, _react.default.createElement("h1", { + style: { + marginBottom: '10px' + } + }, "User Initials Avatar"), _react.default.createElement(_userInitials.default, null)); +}).add('Inverse User Initials', function () { + return _react.default.createElement("div", null, _react.default.createElement("h1", { + style: { + marginBottom: '10px' + } + }, "Inversed User Initials Avatar"), _react.default.createElement(_inverseUserInitials.default, null)); +}); \ No newline at end of file diff --git a/components/avatar/__examples__/avatar.jpg b/components/avatar/__examples__/avatar.jpg new file mode 100644 index 0000000000..be34303339 Binary files /dev/null and b/components/avatar/__examples__/avatar.jpg differ diff --git a/components/avatar/__examples__/base.js b/components/avatar/__examples__/base.js new file mode 100644 index 0000000000..0378dd09b6 --- /dev/null +++ b/components/avatar/__examples__/base.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _avatar = _interopRequireDefault(require("../../../../components/avatar")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_avatar.default, { + assistiveText: { + icon: 'Avatar image' + }, + imgSrc: "https://lightningdesignsystem.com/assets/images/avatar2.jpg", + imgAlt: "Person Name" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'AvatarExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/avatar/__examples__/entity-icon.js b/components/avatar/__examples__/entity-icon.js new file mode 100644 index 0000000000..ad4e356f72 --- /dev/null +++ b/components/avatar/__examples__/entity-icon.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _avatar = _interopRequireDefault(require("../../../../components/avatar")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_avatar.default, { + assistiveText: { + icon: 'Avatar icon avatar' + }, + title: "Avatar entity icon", + variant: "entity" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'AvatarExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/avatar/__examples__/entity-initials.js b/components/avatar/__examples__/entity-initials.js new file mode 100644 index 0000000000..79bb6376a2 --- /dev/null +++ b/components/avatar/__examples__/entity-initials.js @@ -0,0 +1,67 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _avatar = _interopRequireDefault(require("../../../../components/avatar")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_avatar.default, { + variant: "entity", + label: "Acme Communications", + size: "medium" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'AvatarExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/avatar/__examples__/inverse-user-initials.js b/components/avatar/__examples__/inverse-user-initials.js new file mode 100644 index 0000000000..47c452e9ea --- /dev/null +++ b/components/avatar/__examples__/inverse-user-initials.js @@ -0,0 +1,68 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _avatar = _interopRequireDefault(require("../../../../components/avatar")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_avatar.default, { + inverse: true, + variant: "user", + label: "Annie Wilson", + size: "medium" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'AvatarExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/avatar/__examples__/user-icon.js b/components/avatar/__examples__/user-icon.js new file mode 100644 index 0000000000..8088f11ff8 --- /dev/null +++ b/components/avatar/__examples__/user-icon.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _avatar = _interopRequireDefault(require("../../../../components/avatar")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_avatar.default, { + assistiveText: { + icon: 'User Icon Avatar' + }, + title: "User Icon Avatar", + variant: "user" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'AvatarExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/avatar/__examples__/user-initials.js b/components/avatar/__examples__/user-initials.js new file mode 100644 index 0000000000..1206fa97ca --- /dev/null +++ b/components/avatar/__examples__/user-initials.js @@ -0,0 +1,67 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _avatar = _interopRequireDefault(require("../../../../components/avatar")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_avatar.default, { + variant: "user", + label: "Annie Wilson", + size: "medium" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'AvatarExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/avatar/check-props.js b/components/avatar/check-props.js new file mode 100644 index 0000000000..39f009af21 --- /dev/null +++ b/components/avatar/check-props.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + + if (typeof props.assistiveText === 'string') { + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', "`assistiveText` as a string has been deprecated and is now an object to allow for multiple uses in the component. Please use `assistiveText.icon` instead. ".concat(createDocUrl('assistiveText'))); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/avatar/docs.json b/components/avatar/docs.json new file mode 100644 index 0000000000..a70b21c295 --- /dev/null +++ b/components/avatar/docs.json @@ -0,0 +1,11 @@ +{ + "component": "avatar", + "status": "prod", + "display-name": "Avatars", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/avatar", + "url-slug": "avatars" +} \ No newline at end of file diff --git a/components/avatar/index.js b/components/avatar/index.js new file mode 100644 index 0000000000..bc4dcca0a5 --- /dev/null +++ b/components/avatar/index.js @@ -0,0 +1,255 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _classNames = _interopRequireDefault(require("../../utilities/class-names")); + +var _constants = require("../../utilities/constants"); + +var _icon = _interopRequireDefault(require("../icon")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// ### Display Name Always use the canonical component name as the React display +// name. +var displayName = _constants.AVATAR; // ### Prop Types + +var propTypes = { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `icon`: Assistive text for accessibility that labels the icon. + */ + assistiveText: _propTypes.default.shape({ + icon: _propTypes.default.string + }), + + /** + * Alt attribute to be applied to image (base case) element. + */ + imgAlt: _propTypes.default.string, + + /** + * Source attribute to be applied to image (base case) element. + */ + imgSrc: _propTypes.default.string, + + /** + * Initials attribute to optionally pass in initials directly in case of "initials" fallback case. + */ + initials: _propTypes.default.string, + + /** + * Avatar with initials that are dark text on light background + */ + inverse: _propTypes.default.bool, + + /** + * Label attibute to display inside "initials" fallback case. Will be passed as title prop in `abbr` element to provide more specificity. + */ + label: _propTypes.default.string, + + /** + * Avatar variants to apply relevant styling (circle: user, square: entity) and icon rendering if applicable. + */ + variant: _propTypes.default.oneOf(['entity', 'user']).isRequired, + + /** + * Size of the icon in "icon" fallback case. + */ + size: _propTypes.default.oneOf(['x-small', 'small', 'medium', 'large']).isRequired, + + /** + * Title attribute for the avatar container. + */ + title: _propTypes.default.string +}; +var defaultProps = { + assistiveText: { + icon: 'User or Account Icon' + }, + imgAlt: '', + size: 'medium', + title: 'user avatar', + variant: 'user' +}; +/** + * The avatar component represents an object or entity. An image is the preferred format for an avatar. + If the `imgSrc` prop is undefined, and if a `label` or `initials` prop is available, the fallback avatar will render with initials. If initals are passed in directly in the `initials` prop, this will render in the fallback avatar. If `initals` prop is unavailable but a `label` prop is available, the fallback avatar will render with built initials of the user name or entity name. + + Intials built from the `label` prop will apply the following logic: If the label name contains two words, like first and last name, the first letter of each will be capitalized and returned. For labels that only have a single word name, the first two letters of that word, using one capital and one lower case letter, will be returned. For labels that contain three or more words, the first character of the first and last words will be capitalized and returned. + + If `initials` or `label` are not available, the fallback avatar will render a standard icon. If `variant='user'`, a user icon will + render. If `variant='entity'`, an account icon will render. + */ + +var Avatar = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Avatar, _React$Component); + + function Avatar(props) { + var _this; + + _classCallCheck(this, Avatar); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Avatar).call(this, props)); + _this.state = { + imgLoadError: false + }; + return _this; + } + + _createClass(Avatar, [{ + key: "componentWillMount", + value: function componentWillMount() { + (0, _checkProps.default)(_constants.AVATAR, this.props, _docs.default); + } + }, { + key: "buildInitials", + value: function buildInitials() { + var label = this.props.label; + var name = label.trim(); + var nameParts = name.split(' '); + + if (nameParts.length > 1) { + return nameParts[0].charAt(0).toUpperCase() + nameParts[nameParts.length - 1].charAt(0).toUpperCase(); + } + + return (name[0] || '').toUpperCase() + (name[1] || '').toLowerCase(); + } + }, { + key: "handleImageError", + value: function handleImageError() { + return this.setState(function () { + return { + imgLoadError: true + }; + }); + } + }, { + key: "renderBaseAvatar", + value: function renderBaseAvatar() { + var _this2 = this; + + var _this$props = this.props, + imgAlt = _this$props.imgAlt, + imgSrc = _this$props.imgSrc, + title = _this$props.title; + return _react.default.createElement("img", { + alt: imgAlt, + src: imgSrc, + onError: function onError() { + return _this2.handleImageError(); + }, + title: title + }); + } + }, { + key: "renderIconAvatar", + value: function renderIconAvatar() { + var variant = this.props.variant; + var iconAssistiveText = typeof this.props.assistiveText === 'string' ? this.props.assistiveText : _objectSpread({}, defaultProps.assistiveText, this.props.assistiveText).icon; + return _react.default.createElement(_icon.default, { + assistiveText: { + label: iconAssistiveText + }, + category: "standard", + name: variant === 'entity' ? 'account' : 'user' + }); + } + }, { + key: "renderInitialsAvatar", + value: function renderInitialsAvatar() { + var _this$props2 = this.props, + initials = _this$props2.initials, + inverse = _this$props2.inverse, + label = _this$props2.label, + variant = _this$props2.variant; + return _react.default.createElement("abbr", { + className: (0, _classNames.default)('slds-avatar__initials', { + 'slds-avatar__initials_inverse': inverse, + 'slds-icon-standard-account': variant === 'entity', + 'slds-icon-standard-user': variant === 'user' + }), + title: label + }, initials ? initials : this.buildInitials()); + } + }, { + key: "render", + value: function render() { + var _this3 = this; + + var _this$props3 = this.props, + imgSrc = _this$props3.imgSrc, + initials = _this$props3.initials, + variant = _this$props3.variant, + label = _this$props3.label, + size = _this$props3.size; + + var renderAvatar = function renderAvatar() { + /* eslint no-unneeded-ternary: */ + if (!_this3.state.imgLoadError && imgSrc) { + return _this3.renderBaseAvatar(); + } + + if (initials || label && label.trim()) { + return _this3.renderInitialsAvatar(); + } + + return _this3.renderIconAvatar(); + }; + + return _react.default.createElement("div", null, _react.default.createElement("span", { + className: (0, _classNames.default)('slds-avatar', { + 'slds-avatar_circle': variant === 'user', + 'slds-avatar_x-small': size === 'x-small', + 'slds-avatar_small': size === 'small', + 'slds-avatar_medium': size === 'medium', + 'slds-avatar_large': size === 'large' + }) + }, renderAvatar())); + } + }]); + + return Avatar; +}(_react.default.Component); + +Avatar.defaultProps = defaultProps; +Avatar.displayName = displayName; +Avatar.propTypes = propTypes; +var _default = Avatar; +exports.default = _default; \ No newline at end of file diff --git a/components/brand-band/__docs__/__snapshots__/storybook-stories.storyshot b/components/brand-band/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..fbbbcdc354 --- /dev/null +++ b/components/brand-band/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,229 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSBrandBand Default (medium) 1`] = ` +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSBrandBand Image with background size cover 1`] = ` +
    +
    +
    + + Hello World! + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSBrandBand Large 1`] = ` +
    +
    +
    + + Hello World! + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSBrandBand Lightning Blue Theme 1`] = ` +
    +
    + +
    +
    +

    + My App +

    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSBrandBand No Image 1`] = ` +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSBrandBand Small 1`] = ` +
    +
    +
    +
    +
    +`; diff --git a/components/brand-band/__docs__/site-stories.js b/components/brand-band/__docs__/site-stories.js new file mode 100644 index 0000000000..be574b6f5c --- /dev/null +++ b/components/brand-band/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/brand-band/__examples__/lightning-blue-theme.jsx'), require('raw-loader!@salesforce/design-system-react/components/brand-band/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/brand-band/__examples__/small.jsx'), require('raw-loader!@salesforce/design-system-react/components/brand-band/__examples__/large.jsx'), require('raw-loader!@salesforce/design-system-react/components/brand-band/__examples__/no-image.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/brand-band/__docs__/storybook-stories.js b/components/brand-band/__docs__/storybook-stories.js new file mode 100644 index 0000000000..22476e62bd --- /dev/null +++ b/components/brand-band/__docs__/storybook-stories.js @@ -0,0 +1,47 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _large = _interopRequireDefault(require("../__examples__/large")); + +var _lightningBlueTheme = _interopRequireDefault(require("../__examples__/lightning-blue-theme")); + +var _noImage = _interopRequireDefault(require("../__examples__/no-image")); + +var _small = _interopRequireDefault(require("../__examples__/small")); + +var _backgroundCover = _interopRequireDefault(require("../__examples__/background-cover")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// import IconSettings from '../../icon-settings'; +(0, _react2.storiesOf)(_constants.BRAND_BAND, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + style: { + bottom: '1rem', + left: '1rem', + overflow: 'auto', + position: 'absolute', + right: '1rem', + top: '1rem' + } + }, getStory()); +}).add('Default (medium)', function () { + return _react.default.createElement(_default.default, null); +}).add('Small', function () { + return _react.default.createElement(_small.default, null); +}).add('Large', function () { + return _react.default.createElement(_large.default, null); +}).add('No Image', function () { + return _react.default.createElement(_noImage.default, null); +}).add('Lightning Blue Theme', function () { + return _react.default.createElement(_lightningBlueTheme.default, null); +}).add('Image with background size cover', function () { + return _react.default.createElement(_backgroundCover.default, null); +}); \ No newline at end of file diff --git a/components/brand-band/__examples__/background-cover.js b/components/brand-band/__examples__/background-cover.js new file mode 100644 index 0000000000..917380b252 --- /dev/null +++ b/components/brand-band/__examples__/background-cover.js @@ -0,0 +1,64 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _brandBand = _interopRequireDefault(require("../../../../components/brand-band")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_brandBand.default, { + className: "custom-brand-band-class", + id: "brand-band-large", + size: "large", + backgroundSize: "cover" + }, _react.default.createElement("span", { + className: "slds-assistive-text" + }, "Hello World!")); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'BrandBandExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/brand-band/__examples__/default.js b/components/brand-band/__examples__/default.js new file mode 100644 index 0000000000..70fa712598 --- /dev/null +++ b/components/brand-band/__examples__/default.js @@ -0,0 +1,59 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _brandBand = _interopRequireDefault(require("../../../../components/brand-band")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_brandBand.default, { + id: "brand-band-default" + }); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'BrandBandExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/brand-band/__examples__/large.js b/components/brand-band/__examples__/large.js new file mode 100644 index 0000000000..28f4e6e6d7 --- /dev/null +++ b/components/brand-band/__examples__/large.js @@ -0,0 +1,63 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _brandBand = _interopRequireDefault(require("../../../../components/brand-band")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_brandBand.default, { + className: "custom-brand-band-class", + id: "brand-band-large", + size: "large" + }, _react.default.createElement("span", { + className: "slds-assistive-text" + }, "Hello World!")); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'BrandBandExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/brand-band/__examples__/lightning-blue-theme.js b/components/brand-band/__examples__/lightning-blue-theme.js new file mode 100644 index 0000000000..d8db76c0e0 --- /dev/null +++ b/components/brand-band/__examples__/lightning-blue-theme.js @@ -0,0 +1,65 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _brandBand = _interopRequireDefault(require("../../../../components/brand-band")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_brandBand.default, { + id: "brand-band-lightning-blue", + className: "slds-p-around_small", + theme: "lightning-blue" + }, _react.default.createElement("div", { + className: "slds-box slds-theme_default" + }, _react.default.createElement("h3", { + className: "slds-text-heading_label slds-truncate" + }, "My App"))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'BrandBandExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/brand-band/__examples__/no-image.js b/components/brand-band/__examples__/no-image.js new file mode 100644 index 0000000000..b5d702a01a --- /dev/null +++ b/components/brand-band/__examples__/no-image.js @@ -0,0 +1,66 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _brandBand = _interopRequireDefault(require("../../../../components/brand-band")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_brandBand.default, { + id: "brand-band-no-image", + image: "none", + style: { + zIndex: 1 + }, + styleContainer: { + border: '1px solid #eee' + } + }); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'BrandBandExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/brand-band/__examples__/small.js b/components/brand-band/__examples__/small.js new file mode 100644 index 0000000000..7dff6154eb --- /dev/null +++ b/components/brand-band/__examples__/small.js @@ -0,0 +1,60 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _brandBand = _interopRequireDefault(require("../../../../components/brand-band")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_brandBand.default, { + id: "brand-band-small", + size: "small" + }); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'BrandBandExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/brand-band/docs.json b/components/brand-band/docs.json new file mode 100644 index 0000000000..365f3f5b3e --- /dev/null +++ b/components/brand-band/docs.json @@ -0,0 +1,11 @@ +{ + "component": "brand-band", + "status": "prod", + "display-name": "BrandBand", + "last-accessibility-review": { + "date-iso-8601": "2018/08/27", + "commit-sha": "aef31ce8daf993b59ca94c656c5efd9f2e3266f7" + }, + "SLDS-component-path": "/components/brand-band", + "url-slug": "brand-band" +} \ No newline at end of file diff --git a/components/brand-band/index.js b/components/brand-band/index.js new file mode 100644 index 0000000000..66776abcd3 --- /dev/null +++ b/components/brand-band/index.js @@ -0,0 +1,171 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _classNames = _interopRequireDefault(require("../../utilities/class-names")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +/** + * The brand band provides theming capability that adds personality and improves information density and contrast. + * + * NOTE: you may find that themes other than 'default' fail to load the appropriate styling in your application. + * If this occurs the cause is very likely to be CSP settings on the server hosting your application protecting against style injections. + * Changing these settings is not recommended. Instead, add the following styles to any stylesheet provided by the server itself (such as an external stylesheet): + * + * When using 'lightning-theme': + * .slds-brand-band.dsr-brand-band_lightning-blue:before { + * background-image: url(/assets/images/themes/oneSalesforce/banner-brand-default.png), linear-gradient(to top, rgba(175, 197, 222, 0) 0, #1B5F9E); + * } + * .slds-brand-band.dsr-brand-band_lightning-blue:after { + * background-image: linear-gradient(to bottom, rgba(175, 197, 222, 0) 60%, #AFC5DE); + * } + * + * For more information on the problem, [see this Stack Overflow question](https://stackoverflow.com/questions/17766817/refused-to-apply-inline-style-because-it-violates-the-following-content-security) + */ +var BrandBand = +/*#__PURE__*/ +function (_React$Component) { + _inherits(BrandBand, _React$Component); + + _createClass(BrandBand, null, [{ + key: "injectLightningBlueStyles", + value: function injectLightningBlueStyles() { + return _react.default.createElement("style", null, ".slds-brand-band.dsr-brand-band_lightning-blue:before {\n\tbackground-image: url(/assets/images/themes/oneSalesforce/banner-brand-default.png), linear-gradient(to top, rgba(175, 197, 222, 0) 0, #1B5F9E);\n}\n.slds-brand-band.dsr-brand-band_lightning-blue:after {\n\tbackground-image: linear-gradient(to bottom, rgba(175, 197, 222, 0) 60%, #AFC5DE);\n}"); + } + }]); + + function BrandBand(props) { + var _this; + + _classCallCheck(this, BrandBand); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(BrandBand).call(this, props)); + _this.generatedId = _shortid.default.generate(); + return _this; + } + + _createClass(BrandBand, [{ + key: "getId", + value: function getId() { + return this.props.id || this.generatedId; + } + }, { + key: "render", + value: function render() { + var props = this.props; + return _react.default.createElement("div", { + style: _objectSpread({ + background: props.theme === 'lightning-blue' ? 'rgb(176, 196, 223)' : 'rgb(250, 250, 249)', + height: '100%', + position: 'relative', + width: '100%', + zIndex: 1 + }, props.styleContainer) + }, props.theme === 'lightning-blue' && BrandBand.injectLightningBlueStyles(), _react.default.createElement("div", { + className: (0, _classNames.default)('slds-brand-band', { + 'slds-brand-band_small': props.size === 'small', + 'slds-brand-band_medium': props.size === 'medium', + 'slds-brand-band_large': props.size === 'large', + 'slds-brand-band_cover': props.backgroundSize === 'cover', + 'slds-brand-band_none': props.image === 'none', + 'dsr-brand-band_lightning-blue': props.theme === 'lightning-blue' + }, props.className), + id: this.getId(), + style: props.style + }, props.children)); + } + }]); + + return BrandBand; +}(_react.default.Component); + +BrandBand.displayName = _constants.BRAND_BAND; +BrandBand.propTypes = { + /** + * Primary application grid layout or a white background component such as a `Card` should be passed into this component. + */ + children: _propTypes.default.node, + + /** + * CSS classes that are applied to the component + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Id of component, if desired. If not provided an id is automatically generated + */ + id: _propTypes.default.string, + + /** + * Image of the brand band + */ + image: _propTypes.default.oneOf(['default', 'none']), + + /** + * Background size of the brand band. Default is 'contain' + */ + backgroundSize: _propTypes.default.oneOf(['contain', 'cover']), + + /** + * Size of the brand band. Default is 'medium' + */ + size: _propTypes.default.oneOf(['small', 'medium', 'large']), + + /** + * Custom styles to be passed to the component + */ + style: _propTypes.default.object, + + /** + * Custom styles to be passed to the component container + */ + styleContainer: _propTypes.default.object, + + /** + * Different brand band styling. + * NOTE: using 'lightning-blue' may result in incorrect styling depending on server CSP settings. See opening component documentation above for details. + */ + theme: _propTypes.default.oneOf(['default', 'lightning-blue']) +}; +BrandBand.defaultProps = { + backgroundSize: 'contain', + image: 'default', + size: 'medium', + theme: 'default' +}; +var _default = BrandBand; +exports.default = _default; \ No newline at end of file diff --git a/components/bread-crumb/index.js b/components/bread-crumb/index.js new file mode 100644 index 0000000000..d65d06d488 --- /dev/null +++ b/components/bread-crumb/index.js @@ -0,0 +1,25 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _breadcrumb = _interopRequireDefault(require("../breadcrumb")); + +var _componentHasMoved = _interopRequireDefault(require("../../utilities/warning/component-has-moved")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// Alias +(0, _componentHasMoved.default)(_constants.BREADCRUMB, { + oldFileLocation: 'components/bread-crumb', + newFileLocation: 'components/breadcrumb' +}); +var _default = _breadcrumb.default; +exports.default = _default; \ No newline at end of file diff --git a/components/breadcrumb/__docs__/__snapshots__/storybook-stories.storyshot b/components/breadcrumb/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..ce60dc7691 --- /dev/null +++ b/components/breadcrumb/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSBreadcrumb 1 Item 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSBreadcrumb 2 Items 1`] = ` + +`; diff --git a/components/breadcrumb/__docs__/site-stories.js b/components/breadcrumb/__docs__/site-stories.js new file mode 100644 index 0000000000..24968fd5f8 --- /dev/null +++ b/components/breadcrumb/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/breadcrumb/__examples__/base.jsx'), require('raw-loader!@salesforce/design-system-react/components/breadcrumb/__examples__/one-item.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/breadcrumb/__docs__/storybook-stories.js b/components/breadcrumb/__docs__/storybook-stories.js new file mode 100644 index 0000000000..ad4523546d --- /dev/null +++ b/components/breadcrumb/__docs__/storybook-stories.js @@ -0,0 +1,23 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +var _oneItem = _interopRequireDefault(require("../__examples__/one-item")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.BREADCRUMB, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('2 Items', function () { + return _react.default.createElement(_base.default, null); +}).add('1 Item', function () { + return _react.default.createElement(_oneItem.default, null); +}); \ No newline at end of file diff --git a/components/breadcrumb/__examples__/base.js b/components/breadcrumb/__examples__/base.js new file mode 100644 index 0000000000..beee186dab --- /dev/null +++ b/components/breadcrumb/__examples__/base.js @@ -0,0 +1,75 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _breadcrumb = _interopRequireDefault(require("../../../../components/breadcrumb")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var trail = [_react.default.createElement("a", { + id: "parent-entity", + href: "javascript:void(0);" + }, "Parent Entity"), _react.default.createElement("a", { + href: "javascript:void(0);" + }, "Parent Record Name")]; + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_breadcrumb.default, { + assistiveText: { + label: 'Two item breadcrumb' + }, + trail: trail + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'BreadCrumbExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/breadcrumb/__examples__/one-item.js b/components/breadcrumb/__examples__/one-item.js new file mode 100644 index 0000000000..a5dae08cc4 --- /dev/null +++ b/components/breadcrumb/__examples__/one-item.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _breadcrumb = _interopRequireDefault(require("../../../../components/breadcrumb")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var trail = [_react.default.createElement("a", { + href: "javascript:void(0);" + }, "Parent Entity")]; + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_breadcrumb.default, { + trail: trail + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'BreadCrumbExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/breadcrumb/check-props.js b/components/breadcrumb/check-props.js new file mode 100644 index 0000000000..8265e03c0c --- /dev/null +++ b/components/breadcrumb/check-props.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + + if (typeof props.assistiveText === 'string') { + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', "`assistiveText` as a string has been deprecated and is now an object to allow for multiple uses in the component. Please use `assistiveText.label` instead. ".concat(createDocUrl('assistiveText'))); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/breadcrumb/docs.json b/components/breadcrumb/docs.json new file mode 100644 index 0000000000..50ecb5cf66 --- /dev/null +++ b/components/breadcrumb/docs.json @@ -0,0 +1,11 @@ +{ + "component": "breadcrumb", + "status": "prod", + "display-name": "Breadcrumbs", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/breadcrumbs", + "url-slug": "breadcrumbs" +} \ No newline at end of file diff --git a/components/breadcrumb/index.js b/components/breadcrumb/index.js new file mode 100644 index 0000000000..211c85242c --- /dev/null +++ b/components/breadcrumb/index.js @@ -0,0 +1,72 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var defaultProps = { + assistiveText: { + label: 'Breadcrumbs' + } +}; +/** + * Use breadcrumbs to note the path of a record and help the user to navigate back to the parent.Breadcrumb based on SLDS 2.1.0-dev + */ + +var Breadcrumb = function Breadcrumb(props) { + (0, _checkProps.default)(_constants.BREADCRUMB, props, _docs.default); + var trail = props.trail; + var assistiveText = typeof props.assistiveText === 'string' ? props.assistiveText : _objectSpread({}, defaultProps.assistiveText, props.assistiveText).label; + return _react.default.createElement("nav", { + role: "navigation", + "aria-label": assistiveText + }, _react.default.createElement("ol", { + className: "slds-breadcrumb slds-list_horizontal" + }, trail.map(function (crumb, index) { + return ( + /* eslint-disable react/no-array-index-key */ + _react.default.createElement("li", { + key: index // There isn't any better reasonable way to identity these + , + className: "slds-breadcrumb__item" + }, crumb) + ); + }))); +}; + +Breadcrumb.displayName = _constants.BREADCRUMB; +Breadcrumb.propTypes = { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `label`: The assistive text for the breadcrumb trail. + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string + }), + + /** + * An array of react elements presumably anchor elements. + */ + trail: _propTypes.default.array +}; +Breadcrumb.defaultProps = defaultProps; +var _default = Breadcrumb; +exports.default = _default; \ No newline at end of file diff --git a/components/button-group/__docs__/__snapshots__/storybook-stories.storyshot b/components/button-group/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..e04672975f --- /dev/null +++ b/components/button-group/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,410 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSButtonGroup Checkbox 1`] = ` +
    +
    + + Scheduled Day(s) + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSButtonGroup Checkbox Error 1`] = ` +
    +
    + + Scheduled Day(s) + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    +
    + This field is required +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSButtonGroup Icon Group 1`] = ` +
    +
    + + +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSButtonGroup More Icon 1`] = ` +
    +
    + + + +
    + +
    +
    +
    +`; diff --git a/components/button-group/__docs__/site-stories.js b/components/button-group/__docs__/site-stories.js new file mode 100644 index 0000000000..0828c26a77 --- /dev/null +++ b/components/button-group/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/button-group/__examples__/more-icon.jsx'), require('raw-loader!@salesforce/design-system-react/components/button-group/__examples__/icon-group.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/button-group/__docs__/storybook-stories.js b/components/button-group/__docs__/storybook-stories.js new file mode 100644 index 0000000000..6988deac09 --- /dev/null +++ b/components/button-group/__docs__/storybook-stories.js @@ -0,0 +1,36 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _moreIcon = _interopRequireDefault(require("../__examples__/more-icon")); + +var _iconGroup = _interopRequireDefault(require("../__examples__/icon-group")); + +var _checkbox = _interopRequireDefault(require("../__examples__/checkbox")); + +var _checkboxError = _interopRequireDefault(require("../__examples__/checkbox-error")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* eslint-disable react/display-name */ +(0, _react2.storiesOf)(_constants.BUTTON_GROUP, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('More Icon', function () { + return _react.default.createElement(_moreIcon.default, null); +}).add('Icon Group', function () { + return _react.default.createElement(_iconGroup.default, null); +}).add('Checkbox', function () { + return _react.default.createElement(_checkbox.default, null); +}).add('Checkbox Error', function () { + return _react.default.createElement(_checkboxError.default, null); +}); \ No newline at end of file diff --git a/components/button-group/__examples__/checkbox-error.js b/components/button-group/__examples__/checkbox-error.js new file mode 100644 index 0000000000..2f9cdf2bf0 --- /dev/null +++ b/components/button-group/__examples__/checkbox-error.js @@ -0,0 +1,82 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _buttonGroup = _interopRequireDefault(require("../../../../components/button-group")); + +var _checkbox = _interopRequireDefault(require("../../../../components/checkbox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_buttonGroup.default, { + labels: { + error: 'This field is required', + label: 'Scheduled Day(s)' + }, + variant: "checkbox" + }, _react.default.createElement(_checkbox.default, { + id: "ButtonGroupExampleMon", + label: "Mon" + }), _react.default.createElement(_checkbox.default, { + id: "ButtonGroupExampleTue", + label: "Tue" + }), _react.default.createElement(_checkbox.default, { + id: "ButtonGroupExampleWed", + label: "Wed" + }), _react.default.createElement(_checkbox.default, { + id: "ButtonGroupExampleThu", + label: "Thu" + }), _react.default.createElement(_checkbox.default, { + id: "ButtonGroupExampleFri", + label: "Fri" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ButtonGroupExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/button-group/__examples__/checkbox.js b/components/button-group/__examples__/checkbox.js new file mode 100644 index 0000000000..261a396e09 --- /dev/null +++ b/components/button-group/__examples__/checkbox.js @@ -0,0 +1,81 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _buttonGroup = _interopRequireDefault(require("../../../../components/button-group")); + +var _checkbox = _interopRequireDefault(require("../../../../components/checkbox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_buttonGroup.default, { + labels: { + label: 'Scheduled Day(s)' + }, + variant: "checkbox" + }, _react.default.createElement(_checkbox.default, { + id: "ButtonGroupExampleMon", + label: "Mon" + }), _react.default.createElement(_checkbox.default, { + id: "ButtonGroupExampleTue", + label: "Tue" + }), _react.default.createElement(_checkbox.default, { + id: "ButtonGroupExampleWed", + label: "Wed" + }), _react.default.createElement(_checkbox.default, { + id: "ButtonGroupExampleThu", + label: "Thu" + }), _react.default.createElement(_checkbox.default, { + id: "ButtonGroupExampleFri", + label: "Fri" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ButtonGroupExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/button-group/__examples__/icon-group.js b/components/button-group/__examples__/icon-group.js new file mode 100644 index 0000000000..608b5bc008 --- /dev/null +++ b/components/button-group/__examples__/icon-group.js @@ -0,0 +1,104 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _buttonGroup = _interopRequireDefault(require("../../../../components/button-group")); + +var _buttonStateful = _interopRequireDefault(require("../../../../components/button-stateful")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_buttonGroup.default, null, _react.default.createElement(_buttonStateful.default, { + assistiveText: { + icon: 'Show Chart' + }, + buttonVariant: "icon", + iconName: "chart", + iconVariant: "border", + variant: "icon" + }), _react.default.createElement(_buttonStateful.default, { + assistiveText: { + icon: 'Filter List' + }, + iconName: "filterList", + iconVariant: "border", + variant: "icon" + }), _react.default.createElement(_menuDropdown.default, { + assistiveText: { + icon: 'Settings' + }, + checkmark: true, + iconCategory: "utility", + iconName: "settings", + iconVariant: "more", + id: "icon-dropdown-example", + onSelect: function onSelect(item) { + console.log(item.label, 'selected'); + }, + openOn: "click", + options: [{ + label: 'Bring left panel to front', + value: 'A0' + }, { + label: 'Bring right panel to front', + value: 'B0' + }], + value: "A0", + variant: "icon" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ButtonGroupExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/button-group/__examples__/more-icon.js b/components/button-group/__examples__/more-icon.js new file mode 100644 index 0000000000..297846f02a --- /dev/null +++ b/components/button-group/__examples__/more-icon.js @@ -0,0 +1,96 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _buttonGroup = _interopRequireDefault(require("../../../../components/button-group")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_buttonGroup.default, null, _react.default.createElement(_button.default, { + label: "Refresh" + }), _react.default.createElement(_button.default, { + label: "Edit" + }), _react.default.createElement(_button.default, { + label: "Save" + }), _react.default.createElement(_menuDropdown.default, { + id: "ButtonGroupExampleDropdown", + assistiveText: { + icon: 'More Options' + }, + buttonVariant: "icon", + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + onSelect: function onSelect(item) { + console.log(item.label, 'selected'); + }, + openOn: "click", + options: [{ + label: 'undo', + value: 'A0' + }, { + label: 'redo', + value: 'B0' + }, { + label: 'activate', + value: 'C0' + }] + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ButtonGroupExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/button-group/docs.json b/components/button-group/docs.json new file mode 100644 index 0000000000..f094d0ed26 --- /dev/null +++ b/components/button-group/docs.json @@ -0,0 +1,7 @@ +{ + "component": "button-group", + "status": "prod", + "display-name": "Button Groups", + "SLDS-component-path": "/components/button-groups", + "url-slug": "button-groups" +} \ No newline at end of file diff --git a/components/button-group/index.js b/components/button-group/index.js new file mode 100644 index 0000000000..1a2a35772a --- /dev/null +++ b/components/button-group/index.js @@ -0,0 +1,114 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// Implements the [Button Group design pattern](https://lightningdesignsystem.com/components/button-groups/) in React. +// Based on SLDS v2.1.1 +var propTypes = { + /** + * Children are expected to be components. If last button triggers a dropdown menu, use Dropdown instead of Button. _Tested with snapshot testing._ + */ + children: _propTypes.default.node.isRequired, + + /** + * CSS classes added to `slds-button-group` or `slds-checkbox_button-group` tag + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * **Text labels for internationalization** + * This object is merged with the default props object on every render. + * * `error`: Message to display when any of Checkboxes are in an error state. _Tested with snapshot testing._ + * * `label`: This label appears above the button group. _Tested with snapshot testing._ + */ + labels: _propTypes.default.shape({ + error: _propTypes.default.string, + label: _propTypes.default.string + }), + + /** + * Use checkbox variant for "Checkbox Button Group" styling and add Checkbox components as children _Tested with snapshot testing._ + */ + variant: _propTypes.default.oneOf(['checkbox']) +}; +var defaultProps = { + labels: {} +}; +/** + * The ButtonGroup component wraps other components (ie. Button, MenuDropdown, PopoverTooltip, Checkboxes, etc). + */ + +var ButtonGroup = function ButtonGroup(props) { + // Merge objects of strings with their default object + var labels = props ? (0, _lodash.default)({}, defaultProps.labels, props.labels) : defaultProps.labels; + var children = props.children; + var zeroIndexLength = _react.default.Children.count(props.children) - 1; + + if (zeroIndexLength > 0) { + children = _react.default.Children.map(props.children, function (child, index) { + var newChild; + + if (index === zeroIndexLength) { + newChild = _react.default.cloneElement(child, { + triggerClassName: 'slds-button_last' + }); + } + + return newChild || child; + }); + } + + if (props.variant === 'checkbox') { + children = _react.default.Children.map(props.children, function (child) { + return _react.default.cloneElement(child, { + variant: 'button-group' + }); + }); + } + + if (props.variant === 'checkbox') { + return _react.default.createElement("fieldset", { + className: (0, _classnames.default)('slds-form-element', { + 'slds-has-error': labels.error + }) + }, _react.default.createElement("legend", { + className: "slds-form-element__legend slds-form-element__label" + }, props.labels.label), _react.default.createElement("div", { + className: "slds-form-element__control" + }, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-checkbox_button-group', props.className) + }, children), labels.error ? _react.default.createElement("div", { + className: "slds-form-element__help" + }, labels.error) : null)); + } // default + + + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-button-group', props.className), + role: "group" + }, children); +}; + +ButtonGroup.displayName = _constants.BUTTON_GROUP; +ButtonGroup.propTypes = propTypes; +ButtonGroup.defaultProps = defaultProps; +var _default = ButtonGroup; +exports.default = _default; \ No newline at end of file diff --git a/components/button-stateful/__docs__/__snapshots__/storybook-stories.storyshot b/components/button-stateful/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..f8b5a58199 --- /dev/null +++ b/components/button-stateful/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,289 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSButtonStateful Base 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSButtonStateful Disabled 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSButtonStateful Doc site Icon Button 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSButtonStateful Doc site Icon Text Button 1`] = ` +
    +
    + +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSButtonStateful Icon 1`] = ` +
    + +
    +`; diff --git a/components/button-stateful/__docs__/site-stories.js b/components/button-stateful/__docs__/site-stories.js new file mode 100644 index 0000000000..c26d0536dc --- /dev/null +++ b/components/button-stateful/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/button-stateful/__examples__/icon.jsx'), require('raw-loader!@salesforce/design-system-react/components/button-stateful/__examples__/icon-text.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/button-stateful/__docs__/storybook-stories.js b/components/button-stateful/__docs__/storybook-stories.js new file mode 100644 index 0000000000..0004e8b574 --- /dev/null +++ b/components/button-stateful/__docs__/storybook-stories.js @@ -0,0 +1,58 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _buttonStateful = _interopRequireDefault(require("../../button-stateful")); + +var _iconText = _interopRequireDefault(require("../__examples__/icon-text")); + +var _icon = _interopRequireDefault(require("../__examples__/icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +var getButtonStateful = function getButtonStateful(props) { + return _react.default.createElement(_buttonStateful.default, _extends({}, props, { + onClick: (0, _addonActions.action)('click') + })); +}; + +(0, _react2.storiesOf)(_constants.BUTTON_STATEFUL, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base', function () { + return getButtonStateful(); +}).add('Disabled', function () { + return getButtonStateful({ + disabled: true + }); +}).add('Icon', function () { + return getButtonStateful({ + assistiveText: { + icon: 'Icon button' + }, + variant: 'icon', + label: 'Neutral Icon', + iconName: 'check', + onFocus: (0, _addonActions.action)('hover'), + onMouseEnter: function onMouseEnter(e) { + console.log('target is ', e.target); + } + }); +}).add('Doc site Icon Text Button', function () { + return _react.default.createElement(_iconText.default, null); +}).add('Doc site Icon Button', function () { + return _react.default.createElement(_icon.default, null); +}); \ No newline at end of file diff --git a/components/button-stateful/__examples__/icon-text.js b/components/button-stateful/__examples__/icon-text.js new file mode 100644 index 0000000000..ac313ac846 --- /dev/null +++ b/components/button-stateful/__examples__/icon-text.js @@ -0,0 +1,87 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _buttonStateful = _interopRequireDefault(require("../../../../components/button-stateful")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-x-small-buttons_horizontal" + }, _react.default.createElement(_buttonStateful.default, null), _react.default.createElement("div", { + style: { + backgroundColor: '#ededed', + padding: '10px', + display: 'inline-block' + }, + className: "slds-m-horizontal_small" + }, _react.default.createElement(_buttonStateful.default, { + inverse: true, + stateOne: { + iconName: 'add', + label: 'Join' + }, + stateTwo: { + iconName: 'check', + label: 'Member' + }, + stateThree: { + iconName: 'close', + label: 'Leave' + } + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ButtonStatefulExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/button-stateful/__examples__/icon.js b/components/button-stateful/__examples__/icon.js new file mode 100644 index 0000000000..bec94cd7f8 --- /dev/null +++ b/components/button-stateful/__examples__/icon.js @@ -0,0 +1,91 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _buttonStateful = _interopRequireDefault(require("../../../../components/button-stateful")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + isActive: false + }); + + _defineProperty(_assertThisInitialized(_this), "handleOnclick", function () { + _this.setState({ + isActive: !_this.state.isActive + }); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_buttonStateful.default, { + assistiveText: { + icon: this.state.isActive ? 'liked' : 'not liked' + }, + iconName: "like", + iconSize: "large", + variant: "icon" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ButtonStatefulExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/button-stateful/check-props.js b/components/button-stateful/check-props.js new file mode 100644 index 0000000000..3f4c55c941 --- /dev/null +++ b/components/button-stateful/check-props.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + + if (typeof props.assistiveText === 'string') { + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', "`assistiveText` as a string has been deprecated and is now an object to allow for multiple uses in the component. Please use `assistiveText.icon` instead. ".concat(createDocUrl('assistiveText'))); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/button-stateful/docs.json b/components/button-stateful/docs.json new file mode 100644 index 0000000000..c9b4fbf385 --- /dev/null +++ b/components/button-stateful/docs.json @@ -0,0 +1,7 @@ +{ + "component": "button-stateful", + "status": "prod", + "display-name": "Stateful Buttons", + "SLDS-component-path": "/components/button/#flavor-stateful", + "url-slug": "stateful-buttons" +} \ No newline at end of file diff --git a/components/button-stateful/index.js b/components/button-stateful/index.js new file mode 100644 index 0000000000..ed2f744c4d --- /dev/null +++ b/components/button-stateful/index.js @@ -0,0 +1,324 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _lodash = _interopRequireDefault(require("lodash.isfunction")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _buttonIcon = _interopRequireDefault(require("../icon/button-icon")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * Specifies the current state of the button. If set, the button will act as a ['controlled' component](https://facebook.github.io/react/docs/forms.html#controlled-components). + */ + active: _propTypes.default.bool, + + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `icon`: Text that is visually hidden but read aloud by screenreaders to tell the user what the icon means. This should also include the state of the button. If the button has an icon and a visible label, you can omit the icon prop and use the label prop. + */ + assistiveText: _propTypes.default.shape({ + icon: _propTypes.default.string + }), + + /** + * Disables the button and adds disabled styling. + */ + disabled: _propTypes.default.bool, + + /** + * Name of the icon. Visit Lightning Design System Icons to reference icon names. + */ + iconName: _propTypes.default.string, + + /** + * Determines the size of the icon. + */ + iconSize: _propTypes.default.oneOf(['x-small', 'small', 'medium', 'large']), + + /** + * Triggered when focus is removed. + */ + onBlur: _propTypes.default.func, + + /** + * Triggered when the button is clicked. + */ + onClick: _propTypes.default.func, + + /** + * Triggered when component is focused. + */ + onFocus: _propTypes.default.func, + + /** + * Triggered when a key is pressed down + */ + onKeyDown: _propTypes.default.func, + + /** + * Triggered when a key is pressed and released + */ + onKeyPress: _propTypes.default.func, + + /** + * Triggered when a key is released + */ + onKeyUp: _propTypes.default.func, + + /** + * Triggered when a mouse button is pressed down + */ + onMouseDown: _propTypes.default.func, + + /** + * Triggered when a mouse arrow hovers + */ + onMouseEnter: _propTypes.default.func, + + /** + * If true, button scales to 100% width on small form factors. + */ + responsive: _propTypes.default.bool, + + /** + * Initial label and icon (optional) of button. + */ + stateOne: _propTypes.default.object, + + /** + * Selected label and icon (optional) of button. + */ + stateTwo: _propTypes.default.object, + + /** + * Deselect label and icon (optional) of button. + */ + stateThree: _propTypes.default.object, + + /** + * Write "-1" if you don't want the user to tab to the button. + */ + tabIndex: _propTypes.default.string, + + /** + * Different types of buttons + */ + variant: _propTypes.default.oneOf(['base', 'neutral', 'brand', 'destructive', 'icon']) +}; // i18n + +var defaultProps = { + assistiveText: { + icon: '' + }, + disabled: false, + iconSize: 'medium', + responsive: false, + stateOne: { + iconName: 'add', + label: 'Follow' + }, + stateTwo: { + iconName: 'check', + label: 'Following' + }, + stateThree: { + iconName: 'close', + label: 'Unfollow' + } +}; +/** + * The ButtonStateful component is a variant of the Lightning Design System Button component. It is used for buttons that have a state of unselected or selected. + * For icon buttons, use variant='icon'. For buttons with labels or buttons with labels and icons, pass data to the state props (ie. stateOne={{iconName: 'add', label: 'Join'}}). + */ + +var ButtonStateful = +/*#__PURE__*/ +function (_React$Component) { + _inherits(ButtonStateful, _React$Component); + + function ButtonStateful(props) { + var _this; + + _classCallCheck(this, ButtonStateful); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(ButtonStateful).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "handleBlur", function (e) { + if (_this.props.onBlur) _this.props.onBlur(e); + e.currentTarget.blur(); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function (e) { + if ((0, _lodash.default)(_this.props.onClick)) _this.props.onClick(e); + + if (typeof _this.props.active !== 'boolean') { + _this.setState(function (prevState) { + return { + active: !prevState.active + }; + }); + } + }); + + _this.state = { + active: false + }; + return _this; + } + + _createClass(ButtonStateful, [{ + key: "componentWillMount", + value: function componentWillMount() { + (0, _checkProps.default)(_constants.BUTTON_STATEFUL, this.props, _docs.default); + } + }, { + key: "getClassName", + value: function getClassName(active) { + return (0, _classnames.default)(this.props.className, 'slds-button', { + 'slds-button_neutral': this.props.variant !== 'icon', + 'slds-button_inverse': this.props.variant === 'inverse', + 'slds-not-selected': !active, + 'slds-is-selected': active, + 'slds-max-small-button_stretch': this.props.responsive, + 'slds-button_icon-border': this.props.variant === 'icon' + }); + } + }, { + key: "render", + value: function render() { + var _this$props = this.props, + active = _this$props.active, + disabled = _this$props.disabled, + iconName = _this$props.iconName, + iconSize = _this$props.iconSize, + id = _this$props.id, + onFocus = _this$props.onFocus, + onKeyDown = _this$props.onKeyDown, + onKeyPress = _this$props.onKeyPress, + onKeyUp = _this$props.onKeyUp, + onMouseDown = _this$props.onMouseDown, + onMouseEnter = _this$props.onMouseEnter, + stateOne = _this$props.stateOne, + stateTwo = _this$props.stateTwo, + stateThree = _this$props.stateThree, + tabIndex = _this$props.tabIndex, + variant = _this$props.variant; + var iconAssistiveText = typeof this.props.assistiveText === 'string' ? this.props.assistiveText : _objectSpread({}, defaultProps.assistiveText, this.props.assistiveText).icon; + var isActive = typeof active === 'boolean' ? active : this.state.active; + + if (variant === 'icon') { + return _react.default.createElement("button", { + "aria-live": "polite", + className: this.getClassName(isActive), + disabled: disabled, + id: id, + onBlur: this.handleBlur, + onClick: this.handleClick, + onFocus: onFocus, + onKeyDown: onKeyDown, + onKeyPress: onKeyPress, + onKeyUp: onKeyUp, + onMouseDown: onMouseDown, + onMouseEnter: onMouseEnter, + onMouseLeave: this.handleBlur, + tabIndex: tabIndex + }, _react.default.createElement(_buttonIcon.default, { + disabled: disabled, + name: iconName, + size: iconSize, + className: "slds-button__icon_stateful" + }), iconAssistiveText ? _react.default.createElement("span", { + className: "slds-assistive-text" + }, iconAssistiveText) : null); + } + + return _react.default.createElement("button", { + "aria-live": "assertive", + className: this.getClassName(isActive), + disabled: disabled, + id: id, + onBlur: this.handleBlur, + onClick: this.handleClick, + onFocus: onFocus, + onKeyDown: onKeyDown, + onKeyPress: onKeyPress, + onKeyUp: onKeyUp, + onMouseEnter: onMouseEnter, + onMouseLeave: this.handleBlur, + tabIndex: tabIndex + }, _react.default.createElement("span", { + className: "slds-text-not-selected" + }, _react.default.createElement(_buttonIcon.default, { + disabled: disabled, + name: stateOne.iconName, + size: "small", + position: "left", + className: "slds-button__icon_stateful" + }), stateOne.label), _react.default.createElement("span", { + className: "slds-text-selected" + }, _react.default.createElement(_buttonIcon.default, { + disabled: disabled, + name: stateTwo.iconName, + size: "small", + position: "left", + className: "slds-button__icon_stateful" + }), stateTwo.label), _react.default.createElement("span", { + className: "slds-text-selected-focus" + }, _react.default.createElement(_buttonIcon.default, { + disabled: disabled, + name: stateThree.iconName, + size: "small", + position: "left", + className: "slds-button__icon_stateful" + }), stateThree.label)); + } + }]); + + return ButtonStateful; +}(_react.default.Component); + +ButtonStateful.displayName = _constants.BUTTON_STATEFUL; +ButtonStateful.propTypes = propTypes; +ButtonStateful.defaultProps = defaultProps; +var _default = ButtonStateful; +exports.default = _default; \ No newline at end of file diff --git a/components/button/__docs__/__snapshots__/storybook-stories.storyshot b/components/button/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..ee8d117eaa --- /dev/null +++ b/components/button/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,661 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSButton Base 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSButton Disabled 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSButton Doc site Base Neutral 1`] = ` +
    +
    +
    +
    + + + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSButton Doc site Brand Disabled 1`] = ` +
    +
    +
    +
    + + + + +
    + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSButton Doc site Button Icons 1`] = ` +
    +
    +
    +
    + + +
    + + +
    + +
    + +
    +
    + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSButton Dropdown Icon inverse 1`] = ` +
    +
    + +
    +
    +`; + +exports[`DOM snapshots SLDSButton Icon Container Small 1`] = ` +
    +
    + +
    +
    +`; + +exports[`DOM snapshots SLDSButton Icon large 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSButton Icon with external path 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSButton Neutral 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSButton Neutral Icon 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSButton Neutral with id 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSButton Outline brand button 1`] = ` +
    +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSButton Small Icon Hint inverse 1`] = ` +
    +
    +
    + +
    +
    +
    +`; diff --git a/components/button/__docs__/site-stories.js b/components/button/__docs__/site-stories.js new file mode 100644 index 0000000000..778a5e6b73 --- /dev/null +++ b/components/button/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/button/__examples__/base-neutral.jsx'), require('raw-loader!@salesforce/design-system-react/components/button/__examples__/brand-disabled-destructive-inverse.jsx'), require('raw-loader!@salesforce/design-system-react/components/button/__examples__/button-icons.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/button/__docs__/storybook-stories.js b/components/button/__docs__/storybook-stories.js new file mode 100644 index 0000000000..3c34f96a51 --- /dev/null +++ b/components/button/__docs__/storybook-stories.js @@ -0,0 +1,153 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _button = _interopRequireDefault(require("../../button")); + +var _baseNeutral = _interopRequireDefault(require("../__examples__/base-neutral")); + +var _brandDisabledDestructiveInverse = _interopRequireDefault(require("../__examples__/brand-disabled-destructive-inverse")); + +var _buttonIcons = _interopRequireDefault(require("../__examples__/button-icons")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +var getButton = function getButton(props) { + return _react.default.createElement(_button.default, _extends({}, props, { + onClick: (0, _addonActions.action)('click') + })); +}; + +var getIconButton = function getIconButton(props) { + return getButton(_objectSpread({ + variant: 'icon' + }, props)); +}; + +(0, _react2.storiesOf)(_constants.BUTTON, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base', function () { + return getButton({ + label: 'Base', + variant: 'base' + }); +}).add('Neutral', function () { + return getButton({ + label: 'Neutral' + }); +}).add('Neutral with id', function () { + return getButton({ + label: 'Neutral', + id: 'custom-id' + }); +}).add('Neutral Icon', function () { + return getButton({ + label: 'Neutral Icon', + iconCategory: 'utility', + iconName: 'download', + iconPosition: 'left', + onFocus: (0, _addonActions.action)('focus'), + onKeyDown: (0, _addonActions.action)('keyDown') + }); +}).add('Disabled', function () { + return getButton({ + label: 'Disabled', + disabled: true + }); +}).add('Icon large', function () { + return getIconButton({ + assistiveText: { + icon: 'Icon' + }, + iconSize: 'large', + iconCategory: 'utility', + iconName: 'answer', + title: 'chat' + }); +}).add('Icon with external path', function () { + return getIconButton({ + assistiveText: { + icon: 'Icon' + }, + iconSize: 'large', + iconPath: '/assets/icons/utility-sprite/svg/symbols.svg#announcement', + title: 'announcement' + }); +}).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium slds-hint-parent", + style: { + backgroundColor: '#16325c' + } + }, getStory()); +}).add('Icon Container Small', function () { + return getIconButton({ + assistiveText: { + icon: 'Icon container small' + }, + iconCategory: 'utility', + iconName: 'settings', + iconSize: 'large', + iconVariant: 'border', + inverse: true + }); +}).add('Dropdown Icon inverse', function () { + return getIconButton({ + 'aria-haspopup': true, + assistiveText: { + icon: 'Dropdown Icon inverse' + }, + iconCategory: 'utility', + iconName: 'settings', + iconVariant: 'more', + inverse: true + }); +}).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-hint-parent", + style: { + backgroundColor: '#16325c' + } + }, getStory()); +}).add('Small Icon Hint inverse', function () { + return getIconButton({ + assistiveText: { + icon: 'Small icon hint inverse' + }, + iconCategory: 'utility', + iconName: 'down', + iconVariant: 'border', + iconSize: 'small', + hint: true, + inverse: true + }); +}).add('Outline brand button', function () { + return getButton({ + label: 'Outline brand button', + variant: 'outline-brand' + }); +}).add('Doc site Base Neutral', function () { + return _react.default.createElement(_baseNeutral.default, null); +}).add('Doc site Brand Disabled', function () { + return _react.default.createElement(_brandDisabledDestructiveInverse.default, null); +}).add('Doc site Button Icons', function () { + return _react.default.createElement(_buttonIcons.default, null); +}); \ No newline at end of file diff --git a/components/button/__examples__/base-neutral.js b/components/button/__examples__/base-neutral.js new file mode 100644 index 0000000000..7822a206f6 --- /dev/null +++ b/components/button/__examples__/base-neutral.js @@ -0,0 +1,82 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "-x-small-buttons--horizontal" + }, _react.default.createElement(_button.default, { + label: "Base", + onClick: function onClick(e) { + console.log('Base Button e.target:', e.target); + }, + variant: "base" + }), _react.default.createElement(_button.default, { + label: "Neutral" + }), _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "download", + iconPosition: "left", + label: "Neutral Icon" + }), _react.default.createElement(_button.default, { + label: "Responsive", + responsive: true + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ButtonExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/button/__examples__/brand-disabled-destructive-inverse.js b/components/button/__examples__/brand-disabled-destructive-inverse.js new file mode 100644 index 0000000000..7504257c2d --- /dev/null +++ b/components/button/__examples__/brand-disabled-destructive-inverse.js @@ -0,0 +1,93 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "-x-small-buttons--horizontal" + }, _react.default.createElement(_button.default, { + label: "Brand", + variant: "brand" + }), _react.default.createElement(_button.default, { + disabled: true, + label: "Disabled", + onClick: function onClick() { + console.log('Disabled Button Clicked'); + }, + variant: "brand" + }), _react.default.createElement(_button.default, { + label: "Destructive", + variant: "destructive" + }), _react.default.createElement(_button.default, { + label: "Outline Brand", + variant: "outline-brand" + }), _react.default.createElement("div", { + style: { + backgroundColor: '#16325c', + padding: '10px', + display: 'inline-block' + }, + className: "-m-horizontal--small" + }, _react.default.createElement(_button.default, { + inverse: true, + label: "Inverse", + variant: "base" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ButtonExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/button/__examples__/button-icons.js b/components/button/__examples__/button-icons.js new file mode 100644 index 0000000000..c0d91382c6 --- /dev/null +++ b/components/button/__examples__/button-icons.js @@ -0,0 +1,151 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "-x-small-buttons--horizontal" + }, _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Icon Bare Small' + }, + iconCategory: "utility", + iconName: "settings", + iconSize: "small", + iconVariant: "bare", + onClick: function onClick() { + console.log('Icon Bare Clicked'); + }, + variant: "icon" + }), _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Icon Container Small' + }, + iconCategory: "utility", + iconName: "settings", + iconSize: "small", + iconVariant: "container", + variant: "icon" + }), _react.default.createElement("div", { + style: { + backgroundColor: '#4BC076', + padding: '10px', + display: 'inline-block' + }, + className: "-m-horizontal--small" + }, _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Icon Border medium' + }, + iconCategory: "utility", + iconName: "settings", + iconVariant: "border", + variant: "icon" + }), _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Icon Border-filled medium' + }, + iconCategory: "utility", + iconName: "settings", + iconVariant: "border-filled", + variant: "icon" + })), _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Icon More large' + }, + iconCategory: "utility", + iconName: "settings", + iconSize: "large", + iconVariant: "more", + variant: "icon" + }), _react.default.createElement("div", { + style: { + backgroundColor: '#16325c', + padding: '10px', + display: 'inline-block' + }, + className: "-m-horizontal--small" + }, _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Icon inverse' + }, + iconCategory: "utility", + iconName: "settings", + iconSize: "large", + inverse: true, + variant: "icon" + })), _react.default.createElement("div", { + style: { + backgroundColor: '#FFB75D', + padding: '10px 50px', + display: 'inline-block' + }, + className: "-hint-parent -m-horizontal--small" + }, _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Icon hint large' + }, + hint: true, + iconCategory: "utility", + iconName: "settings", + iconSize: "large", + variant: "icon" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ButtonExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/button/check-props.js b/components/button/check-props.js new file mode 100644 index 0000000000..db36b5905e --- /dev/null +++ b/components/button/check-props.js @@ -0,0 +1,41 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +var _ifOneThenBothRequiredProperty = _interopRequireDefault(require("../../utilities/warning/if-one-then-both-required-property")); + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + /* eslint-disable max-len */ + // If iconName is set, iconCategory must also be set. + + (0, _ifOneThenBothRequiredProperty.default)(COMPONENT, props, { + iconName: props.iconName, + iconCategory: props.iconCategory + }, createDocUrl('iconCategory')); + + if (typeof props.assistiveText === 'string') { + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', "`assistiveText` as a string has been deprecated and is now an object to allow for multiple uses in the component. Please use `assistiveText.icon` instead. ".concat(createDocUrl('assistiveText'))); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/button/docs.json b/components/button/docs.json new file mode 100644 index 0000000000..95cf8ed3da --- /dev/null +++ b/components/button/docs.json @@ -0,0 +1,11 @@ +{ + "component": "button", + "status": "prod", + "display-name": "Buttons", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/buttons", + "url-slug": "buttons" +} \ No newline at end of file diff --git a/components/button/index.js b/components/button/index.js new file mode 100644 index 0000000000..baf826c0cb --- /dev/null +++ b/components/button/index.js @@ -0,0 +1,375 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _reactRequiredIf = _interopRequireDefault(require("react-required-if")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _buttonIcon = _interopRequireDefault(require("../icon/button-icon")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _tooltip = _interopRequireDefault(require("../tooltip")); + +var _getAriaProps = _interopRequireDefault(require("../../utilities/get-aria-props")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var defaultProps = { + assistiveText: { + icon: '' + }, + disabled: false, + hint: false, + iconSize: 'medium', + responsive: false, + type: 'button', + variant: 'neutral' +}; +/** + * The Button component is the Lightning Design System Button component. The Button should be used for label buttons, icon buttons, or buttons that have both labels and icons. + * Either a label or assistiveText.icon is required; see the Prop Details table below. For buttons that maintain selected/unselected states, use the ButtonStateful component. + * Although not listed in the prop table, all `aria-*` props will be added to the `button` element if passed in. + */ + +var Button = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Button, _React$Component); + + function Button() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Button); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Button)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "getClassName", function () { + var _classNames; + + var isIcon = _this.props.variant === 'icon'; + var iconVariant = _this.props.iconVariant; + var iconMore = iconVariant === 'more'; + var iconBorder = iconVariant === 'border'; + var iconGlobalHeader = iconVariant === 'global-header'; + var showButtonVariant = _this.props.variant !== 'base' && !iconVariant && !_this.props.inverse && _this.props.variant !== 'link' || iconVariant === 'bare'; + var plainInverseBtn = _this.props.inverse && !isIcon; + var plainInverseIcon = _this.props.inverse && isIcon && !iconMore && !iconBorder; + var moreInverseIcon = _this.props.inverse && iconMore; + var borderInverseIcon = _this.props.inverse && iconBorder; // After hijacking `iconVariant` to let `Button` know it's in the header, we reset to container style for the actual button CSS. + + if (iconVariant === 'global-header') { + iconVariant = 'container'; + } + + return (0, _classnames.default)((_classNames = { + 'slds-button': _this.props.variant !== 'link' + }, _defineProperty(_classNames, "slds-button_".concat(_this.props.variant), showButtonVariant), _defineProperty(_classNames, 'slds-button_inverse', plainInverseBtn), _defineProperty(_classNames, 'slds-button_icon-inverse', plainInverseIcon || moreInverseIcon), _defineProperty(_classNames, 'slds-button_icon-border-inverse', borderInverseIcon), _defineProperty(_classNames, "slds-button_icon-".concat(iconVariant), iconVariant && !borderInverseIcon), _defineProperty(_classNames, 'slds-global-header__button_icon', iconGlobalHeader), _defineProperty(_classNames, "slds-button_icon-".concat(_this.props.iconSize), iconVariant && _this.props.iconSize !== 'medium'), _defineProperty(_classNames, 'slds-button_reset', _this.props.variant === 'link'), _defineProperty(_classNames, 'slds-text-link', _this.props.variant === 'link'), _classNames), _this.props.className); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function (event) { + if (_this.props.onClick) { + _this.props.onClick(event, {}); + } + }); + + _defineProperty(_assertThisInitialized(_this), "renderIcon", function (name) { + var iconSize = _this.props.iconSize === '' || _this.props.iconVariant ? null : _this.props.iconSize; + return _react.default.createElement(_buttonIcon.default, { + category: _this.props.iconCategory || 'utility' // BREAKING CHANGE we will introduce in 1.0. For the moment, set default prop here if none specified. + , + className: (0, _classnames.default)({ + 'slds-global-header__icon': _this.props.iconVariant === 'global-header' + }, _this.props.iconClassName), + hint: _this.props.hint, + inverse: _this.props.inverse, + name: name, + path: _this.props.iconPath, + position: _this.props.iconPosition, + size: iconSize + }); + }); + + _defineProperty(_assertThisInitialized(_this), "renderLabel", function () { + var iconOnly = _this.props.iconName || _this.props.iconPath; + var assistiveTextIcon = typeof _this.props.assistiveText === 'string' ? _this.props.assistiveText : _objectSpread({}, defaultProps.assistiveText, _this.props.assistiveText).icon; + return iconOnly && assistiveTextIcon ? _react.default.createElement("span", { + className: "slds-assistive-text" + }, assistiveTextIcon) : _this.props.label; + }); + + _defineProperty(_assertThisInitialized(_this), "renderButton", function () { + var ariaProps = (0, _getAriaProps.default)(_this.props); + return _react.default.createElement("button", _extends({ + className: _this.getClassName(), + disabled: _this.props.disabled, + id: _this.props.id, + onBlur: _this.props.onBlur, + onClick: _this.handleClick, + onFocus: _this.props.onFocus, + onKeyDown: _this.props.onKeyDown, + onKeyPress: _this.props.onKeyPress, + onKeyUp: _this.props.onKeyUp, + onMouseDown: _this.props.onMouseDown, + onMouseEnter: _this.props.onMouseEnter, + onMouseLeave: _this.props.onMouseLeave, + onMouseUp: _this.props.onMouseUp, + ref: function ref(component) { + if (_this.props.buttonRef) { + _this.props.buttonRef(component); + } + }, + tabIndex: _this.props.tabIndex, + title: _this.props.title, + type: _this.props.type, + style: _this.props.style + }, ariaProps), _this.props.iconPosition === 'right' ? _this.renderLabel() : null, _this.props.iconName || _this.props.iconPath ? _this.renderIcon(_this.props.iconName) : null, _this.props.iconVariant === 'more' ? _react.default.createElement(_buttonIcon.default, { + category: "utility", + name: "down", + size: "x-small", + className: _this.props.iconClassName + }) : null, _this.props.iconPosition === 'left' || !_this.props.iconPosition ? _this.renderLabel() : null, _this.props.children // eslint-disable-line react/prop-types + ); + }); + + _defineProperty(_assertThisInitialized(_this), "renderTooltip", function () { + return _react.default.createElement(_tooltip.default, { + content: _this.props.tooltip + }, _this.renderButton); + }); + + return _this; + } + + _createClass(Button, [{ + key: "componentWillMount", + value: function componentWillMount() { + // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + (0, _checkProps.default)(_constants.BUTTON, this.props, _docs.default); + } + }, { + key: "render", + value: function render() { + return this.props.tooltip ? this.renderTooltip() : this.renderButton(); + } + }]); + + return Button; +}(_react.default.Component); + +_defineProperty(Button, "displayName", _constants.BUTTON); + +_defineProperty(Button, "propTypes", { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `icon`: Text that is visually hidden but read aloud by screenreaders to tell the user what the icon means. If the button has an icon and a visible label, you can omit the assistiveText.icon prop and use the label prop. + */ + assistiveText: _propTypes.default.shape({ + icon: _propTypes.default.string + }), + + /** + * Callback that passes in the DOM reference of the ` + +
    +
    +
    +
    +
    +
    + +
    + + + + +
    +
    +
    +
    + +
    + +
    + + + + + + + + + + + + + + + + + +
    +
    + Opportunity Name +
    +
    +
    + + Cloudhub + +
    +
    +
    + + Cloudhub + Anypoint Connectors + +
    +
    +
    + + Cloud City + +
    +
    +
    +
    + Card Footer +
    + + + +`; + +exports[`DOM snapshots SLDSCard Custom Heading 1`] = ` +
    +
    +
    +
    +
    +
    + + + + + +
    +
    +

    + + To Wanda! This is custom! + +

    +
    +
    +
    +
    + +
    + + + + +
    +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + +
    +
    + Opportunity Name +
    +
    +
    + + Cloudhub + +
    +
    +
    + + Cloudhub + Anypoint Connectors + +
    +
    +
    + + Cloud City + +
    +
    +
    +
    + Card Footer +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCard Doc site Related List With Table 1`] = ` +
    +
    +
    +
    +
    +
    + + + + + +
    +
    +

    + Releated Items +

    +
    +
    +
    +
    + +
    + + + + +
    +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + +
    +
    + Opportunity Name +
    +
    +
    + Cloudhub +
    +
    +
    + Cloudhub + Anypoint Connectors +
    +
    +
    + Cloud City +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCard Empty 1`] = ` +
    +
    +
    +
    +
    +
    + + + + + +
    +
    +

    + Related Items +

    +
    +
    +
    + +
    +
    +
    +
    +
    +

    + No Related Items +

    +
    +
    +
    +
    + Card Footer +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCard Set height card 1`] = ` +
    +
    +
    +
    +
    + + + + + +
    +
    +

    + Card with set height +

    +
    +
    +
    +
    +
    +
    +
    + asdf +
    +
    + asdf +
    +
    + asdf +
    +
    + asdf +
    +
    + asdf +
    +
    + asdf +
    +
    + asdf +
    +
    + asdf +
    +
    + asdf +
    +
    + asdf +
    +
    + asdf +
    +
    + asdf +
    +
    + asdf +
    +
    +
    + +
    +
    +`; + +exports[`DOM snapshots SLDSCard w/ Items 1`] = ` +
    +
    +
    +
    +
    +
    + + + + + +
    +
    +

    + Related Items (3) +

    +
    +
    +
    +
    + +
    + + + + +
    +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + +
    +
    + Opportunity Name +
    +
    +
    + + Cloudhub + +
    +
    +
    + + Cloudhub + Anypoint Connectors + +
    +
    +
    + + Cloud City + +
    +
    +
    +
    + Card Footer +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCard w/o Header 1`] = ` +
    +
    +
    + + + + + + + + + + + + + + + + + +
    +
    + Opportunity Name +
    +
    +
    + + Cloudhub + +
    +
    +
    + + Cloudhub + Anypoint Connectors + +
    +
    +
    + + Cloud City + +
    +
    +
    + +
    +
    +`; diff --git a/components/card/__docs__/site-stories.js b/components/card/__docs__/site-stories.js new file mode 100644 index 0000000000..6c4fd4818c --- /dev/null +++ b/components/card/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/card/__examples__/related-list-with-table.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/card/__docs__/storybook-stories.js b/components/card/__docs__/storybook-stories.js new file mode 100644 index 0000000000..bb774e605d --- /dev/null +++ b/components/card/__docs__/storybook-stories.js @@ -0,0 +1,302 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _button = _interopRequireDefault(require("../../button")); + +var _card = _interopRequireDefault(require("../../card")); + +var _empty = _interopRequireDefault(require("../../card/empty")); + +var _filter = _interopRequireDefault(require("../../card/filter")); + +var _dataTable = _interopRequireDefault(require("../../data-table")); + +var _column = _interopRequireDefault(require("../../data-table/column")); + +var _highlightCell = _interopRequireDefault(require("../../data-table/highlight-cell")); + +var _icon = _interopRequireDefault(require("../../icon")); + +var _mediaObject = _interopRequireDefault(require("../../media-object")); + +var _inline = _interopRequireDefault(require("../../forms/input/inline")); + +var _relatedListWithTable = _interopRequireDefault(require("../__examples__/related-list-with-table")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var sampleItems = [{ + id: '0', + name: 'Cloudhub' +}, { + id: '1', + name: 'Cloudhub + Anypoint Connectors' +}, { + id: '2', + name: 'Cloud City' +}]; +var currentId = 3; + +var DemoCard = +/*#__PURE__*/ +function (_React$Component) { + _inherits(DemoCard, _React$Component); + + function DemoCard() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, DemoCard); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DemoCard)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + filter: null, + items: _this.props.items + }); + + _defineProperty(_assertThisInitialized(_this), "handleFilterChange", function (event) { + for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + rest[_key2 - 1] = arguments[_key2]; + } + + (0, _addonActions.action)('filter').apply(void 0, [event].concat(rest)); + var filter = event.target.value !== '' ? RegExp(event.target.value, 'i') : null; + + _this.setState({ + filter: filter + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleDeleteAllItems", function () { + (0, _addonActions.action)('delete all').apply(void 0, arguments); + + _this.setState({ + filter: null, + items: [] + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleAddItem", function () { + (0, _addonActions.action)('add').apply(void 0, arguments); + + _this.setState({ + items: [{ + id: currentId++, + name: "New item #".concat(_shortid.default.generate()) + }].concat(_toConsumableArray(_this.state.items)) + }); + }); + + return _this; + } + + _createClass(DemoCard, [{ + key: "render", + value: function render() { + var _this2 = this; + + var items = this.state.items; + + if (this.state.filter) { + items = items.filter(function (item) { + return _this2.state.filter.test(item.name); + }); + } + + var isEmpty = items.length === 0; + var heading = this.props.heading; + + if (!this.props.heading) { + heading = items.length > 0 ? "Related Items (".concat(items.length, ")") : 'Related Items'; + } + + return _react.default.createElement("div", { + className: "slds-grid slds-grid_vertical" + }, _react.default.createElement(_card.default, { + id: "ExampleCard", + filter: !isEmpty || this.state.filter ? _react.default.createElement(_filter.default, { + onChange: this.handleFilterChange + }) : null, + header: this.props.header, + headerActions: !isEmpty ? _react.default.createElement(_button.default, { + label: "Delete All Items", + onClick: this.handleDeleteAllItems + }) : _react.default.createElement(_button.default, { + label: "New", + onClick: this.handleAddItem + }), + footer: "Card Footer", + heading: heading, + icon: _react.default.createElement(_icon.default, { + category: "standard", + name: "document", + size: "small" + }), + empty: isEmpty ? _react.default.createElement(_empty.default, { + heading: "No Related Items" + }) : null + }, _react.default.createElement(_dataTable.default, { + id: "SLDSDataTableExample-1", + items: items + }, _react.default.createElement(_column.default, { + label: "Opportunity Name", + property: "name", + truncate: true + }, _react.default.createElement(_highlightCell.default, { + search: this.state.filter + }))))); + } + }]); + + return DemoCard; +}(_react.default.Component); + +_defineProperty(DemoCard, "displayName", 'DemoCard'); + +_defineProperty(DemoCard, "propTypes", { + items: _propTypes.default.array, + header: _propTypes.default.node, + heading: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]) +}); + +var SetHeightCard = function SetHeightCard() { + return _react.default.createElement(_card.default, { + bodyClassName: "slds-grow slds-scrollable_y", + className: "slds-grid slds-grid_vertical", + footer: _react.default.createElement("a", { + href: "javascript:void(0);" + }, "Footer text") // eslint-disable-line no-script-url + , + heading: "Card with set height", + icon: _react.default.createElement(_icon.default, { + category: "standard", + name: "document", + size: "small" + }), + style: { + height: '300px' + } + }, _react.default.createElement("div", { + className: "slds-card__body_inner" + }, _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"), _react.default.createElement("div", null, "asdf"))); +}; + +SetHeightCard.displayName = 'SET_HEIGHT_CARD'; + +var DemoCardWithoutHeader = function DemoCardWithoutHeader() { + return _react.default.createElement(_card.default, { + bodyClassName: "slds-grow slds-scrollable_y", + className: "slds-grid slds-grid_vertical", + footer: _react.default.createElement("a", { + href: "javascript:void(0);" + }, "Footer text") // eslint-disable-line no-script-url + , + hasNoHeader: true, + icon: _react.default.createElement(_icon.default, { + category: "standard", + name: "document", + size: "small" + }), + style: { + height: '300px' + } + }, _react.default.createElement(_dataTable.default, { + id: "SLDSDataTableExample-1", + items: sampleItems + }, _react.default.createElement(_column.default, { + label: "Opportunity Name", + property: "name", + truncate: true + }, _react.default.createElement(_highlightCell.default, null)))); +}; + +DemoCardWithoutHeader.displayName = 'CARD_WITHOUT_HEADER'; +(0, _react2.storiesOf)(_constants.CARD, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('w/ Items', function () { + return _react.default.createElement(DemoCard, { + items: sampleItems + }); +}).add('Empty', function () { + return _react.default.createElement(DemoCard, { + items: [] + }); +}).add('Custom Header', function () { + return _react.default.createElement(DemoCard, { + header: _react.default.createElement(_mediaObject.default, { + body: _react.default.createElement(_inline.default, { + className: "slds-text-heading_small slds-truncate", + name: "inline-edit-standard", + value: "Write your own heading", + id: "inline-edit-standard" + }) + }), + items: sampleItems + }); +}).add('Custom Heading', function () { + return _react.default.createElement(DemoCard, { + items: sampleItems, + heading: _react.default.createElement("span", { + style: { + color: 'red' + } + }, "To Wanda! This is custom!") + }); +}).add('Set height card', function () { + return _react.default.createElement(SetHeightCard, null); +}).add('w/o Header', function () { + return _react.default.createElement(DemoCardWithoutHeader, null); +}).add('Doc site Related List With Table', function () { + return _react.default.createElement(_relatedListWithTable.default, null); +}); \ No newline at end of file diff --git a/components/card/__examples__/related-list-with-table.js b/components/card/__examples__/related-list-with-table.js new file mode 100644 index 0000000000..4d1d643d1e --- /dev/null +++ b/components/card/__examples__/related-list-with-table.js @@ -0,0 +1,156 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _card = _interopRequireDefault(require("../../../../components/card")); + +var _empty = _interopRequireDefault(require("../../../../components/card/empty")); + +var _filter = _interopRequireDefault(require("../../../../components/card/filter")); + +var _dataTable = _interopRequireDefault(require("../../../../components/data-table")); + +var _column = _interopRequireDefault(require("../../../../components/data-table/column")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var sampleItems = [{ + id: '1', + name: 'Cloudhub' +}, { + id: '2', + name: 'Cloudhub + Anypoint Connectors' +}, { + id: '3', + name: 'Cloud City' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + items: sampleItems, + isFiltering: false + }); + + _defineProperty(_assertThisInitialized(_this), "handleFilterChange", function (event) { + var filteredItems = sampleItems.filter(function (item) { + return RegExp(event.target.value, 'i').test(item.name); + }); + + _this.setState({ + isFiltering: true, + items: filteredItems + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleDeleteAllItems", function () { + _this.setState({ + isFiltering: false, + items: [] + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleAddItem", function () { + _this.setState({ + items: sampleItems + }); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var isEmpty = this.state.items.length === 0; + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_vertical" + }, _react.default.createElement(_card.default, { + id: "ExampleCard", + filter: (!isEmpty || this.state.isFiltering) && _react.default.createElement(_filter.default, { + onChange: this.handleFilterChange + }), + headerActions: !isEmpty && _react.default.createElement(_button.default, { + label: "Delete All Items", + onClick: this.handleDeleteAllItems + }), + heading: "Releated Items", + icon: _react.default.createElement(_icon.default, { + category: "standard", + name: "document", + size: "small" + }), + empty: isEmpty ? _react.default.createElement(_empty.default, { + heading: "No Related Items" + }, _react.default.createElement(_button.default, { + label: "Add Item", + onClick: this.handleAddItem + })) : null + }, _react.default.createElement(_dataTable.default, { + items: this.state.items, + id: "DataTableExample-1" + }, _react.default.createElement(_column.default, { + label: "Opportunity Name", + property: "name", + truncate: true + }))))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'CardExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/card/docs.json b/components/card/docs.json new file mode 100644 index 0000000000..3bf3063f83 --- /dev/null +++ b/components/card/docs.json @@ -0,0 +1,19 @@ +{ + "component": "card", + "status": "prod", + "display-name": "Cards", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/cards", + "dependencies": [ + { + "component": "empty" + }, + { + "component": "filter" + } + ], + "url-slug": "cards" +} \ No newline at end of file diff --git a/components/card/empty.js b/components/card/empty.js new file mode 100644 index 0000000000..351da07058 --- /dev/null +++ b/components/card/empty.js @@ -0,0 +1,54 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// ### React +// React is an external dependency of the project. + +/** + * A default empty state for Cards. + */ +var CardEmpty = function CardEmpty(props) { + return _react.default.createElement("div", { + className: "slds-p-horizontal_small" + }, _react.default.createElement("div", { + className: "slds-text-align_center slds-m-bottom_x-large" + }, _react.default.createElement("h3", { + className: "slds-text-heading_small slds-p-top_large slds-p-bottom_large" + }, props.heading), props.children)); +}; // ### Display Name +// Always use the canonical component name as the React display name. + + +CardEmpty.displayName = _constants.CARD_EMPTY; // ### Prop Types + +CardEmpty.propTypes = { + /** + * Additional call to actions that will render under the heading. Often this is an "Add Item" button. + */ + children: _propTypes.default.node, + + /** + * Primary text for an Empty Card. + */ + heading: _propTypes.default.string +}; +CardEmpty.defaultProps = { + heading: 'No Related Items' +}; +var _default = CardEmpty; +exports.default = _default; \ No newline at end of file diff --git a/components/card/filter.js b/components/card/filter.js new file mode 100644 index 0000000000..266cd84bb7 --- /dev/null +++ b/components/card/filter.js @@ -0,0 +1,73 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _input = _interopRequireDefault(require("../input")); + +var _inputIcon = _interopRequireDefault(require("../icon/input-icon")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +/** + * A default filter or search input for Cards that contain items. + */ +var Filter = function Filter(props) { + var id = props.id, + placeholder = props.placeholder, + onChange = props.onChange, + rest = _objectWithoutProperties(props, ["id", "placeholder", "onChange"]); + + return _react.default.createElement(_input.default, _extends({}, rest, { + assistiveText: { + label: placeholder + }, + iconLeft: _react.default.createElement(_inputIcon.default, { + name: "search", + category: "utility" + }), + id: id, + onChange: onChange, + placeholder: placeholder + })); +}; // ### Display Name +// Always use the canonical component name as the React display name. + + +Filter.displayName = _constants.CARD_FILTER; // ### Prop Types + +Filter.propTypes = { + /** + * The HTML `id` from the card with a suffixe. + */ + id: _propTypes.default.string, + + /** + * This callback fires when the input changes. + */ + onChange: _propTypes.default.func, + + /** + * Text present in input until the user enters text. This text will also be used for a visually hidden label on the filter `input` element for accessibility. + */ + placeholder: _propTypes.default.string.isRequired +}; +Filter.defaultProps = { + placeholder: 'Find in List' +}; +var _default = Filter; +exports.default = _default; \ No newline at end of file diff --git a/components/card/index.js b/components/card/index.js new file mode 100644 index 0000000000..5efaee2173 --- /dev/null +++ b/components/card/index.js @@ -0,0 +1,161 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.idSuffixes = exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _header = _interopRequireDefault(require("./private/header")); + +var _body = _interopRequireDefault(require("./private/body")); + +var _footer = _interopRequireDefault(require("./private/footer")); + +var _empty = _interopRequireDefault(require("./empty")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// # Card Component +// Implements the [Card design pattern](https://www.lightningdesignsystem.com/components/cards/) in React. +// Based on SLDS v2.2.1 +// ### React +// ### classNames +// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames) +// This project uses `classnames`, "a simple javascript utility for conditionally +// joining classNames together." +// ## Children +var idSuffixes = { + body: '__body', + headerActions: '__header-actions', + heading: '__heading', + filter: '__filter-input' +}; +/** + * Cards are used to apply a container around a related grouping of information. It has a header, a body, and an optional footer. It often contains a DataTable or Tile (coming soon). Actions associated with selected items or with all items are included within the header actions. Footer often contains pagination. + */ + +exports.idSuffixes = idSuffixes; + +var Card = function Card(props) { + var bodyId = props.id ? props.id + idSuffixes.body : null; + var filterId = props.id ? props.id + idSuffixes.filter : null; + var headingId = props.id ? props.id + idSuffixes.heading : null; + var headerActionsId = props.id ? props.id + idSuffixes.headerActions : null; + var empty = props.empty; + + if (empty === true) { + // Can be overridden by passing in a node to the empty prop + empty = _react.default.createElement(_empty.default, { + id: props.id, + heading: props.heading + }); + } + + return _react.default.createElement("article", { + id: props.id, + className: (0, _classnames.default)('slds-card', props.className), + style: props.style + }, !props.hasNoHeader && _react.default.createElement(_header.default, { + header: props.header, + headingId: headingId, + icon: props.icon, + filter: props.filter, + filterId: filterId, + heading: props.heading, + headerActions: props.headerActions, + headerActionsId: headerActionsId + }), !empty ? _react.default.createElement(_body.default, { + id: bodyId, + className: props.bodyClassName + }, props.children) : _react.default.createElement(_body.default, { + id: bodyId, + className: props.bodyClassName + }, empty), props.footer ? _react.default.createElement(_footer.default, null, props.footer) : null); +}; // ### Display Name +// Always use the canonical component name as the React display name. + + +Card.displayName = _constants.CARD; +Card.defaultProps = { + heading: 'Related Items' +}; // ### Prop Types + +Card.propTypes = { + /** + * CSS classes to be added to the card body (wraps children). + */ + bodyClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * The main section of the card. It often contains a `DataTable` or `Tile`. + */ + children: _propTypes.default.node, + + /** + * CSS classes to be added to the card. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Replaces the body (that is the children) with the specified empty state, this will also remove header actions, the filter, and the icon. If the default empty state is wanted, set to `true`. + */ + empty: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.node]), + + /** + * Adds a filter input to the card header. + */ + filter: _propTypes.default.node, + + /** + * Footer often contains pagination. + */ + footer: _propTypes.default.node, + + /** + * Allows card to have no header, and ignores header related props altogether. + */ + hasNoHeader: _propTypes.default.bool, + + /** + * Allows a custom header (the media object with the icon in the first column). `icon`, `heading` and other props are passed into the media object from Card if present. Use `design-system-react/components/media-object` to create your own custom header. + */ + header: _propTypes.default.node, + + /** + * The heading is the name of the related item group and should only contain inline elements. + */ + heading: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]).isRequired, + + /** + * Actions to perform on selected items or actions that are not specific to one item such as adding an item. If no group actions are needed, then the number of selected items is often present. + */ + headerActions: _propTypes.default.node, + + /** + * Icon associated with the items within the `body`. + */ + icon: _propTypes.default.node, + + /** + * Set the HTML `id` of the card. This also sets the `id` of the filter and the header actions. + */ + id: _propTypes.default.string, + + /** + * Custom styles to be added to the card. + */ + style: _propTypes.default.object +}; +var _default = Card; +exports.default = _default; \ No newline at end of file diff --git a/components/card/private/body.js b/components/card/private/body.js new file mode 100644 index 0000000000..7ed09672b3 --- /dev/null +++ b/components/card/private/body.js @@ -0,0 +1,50 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// ### React +// ### classNames +// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames) +// This project uses `classnames`, "a simple javascript utility for conditionally joining classNames together." +var CardBody = function CardBody(props) { + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-card__body', props.className), + id: props.id + }, props.children); +}; + +CardBody.displayName = _constants.CARD_BODY; +CardBody.propTypes = { + /** + * Elements to place in the body. + */ + children: _propTypes.default.node, + + /** + * CSS classes to be added to the card. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Set the HTML `id` of the body. + */ + id: _propTypes.default.string +}; +var _default = CardBody; +exports.default = _default; \ No newline at end of file diff --git a/components/card/private/footer.js b/components/card/private/footer.js new file mode 100644 index 0000000000..fe88a896e8 --- /dev/null +++ b/components/card/private/footer.js @@ -0,0 +1,34 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// ### React +var CardFooter = function CardFooter(props) { + return _react.default.createElement("div", { + className: "slds-card__footer" + }, props.children); +}; + +CardFooter.displayName = _constants.CARD_FOOTER; +CardFooter.propTypes = { + /** + * Elements to place in the footer. + */ + children: _propTypes.default.node +}; +var _default = CardFooter; +exports.default = _default; \ No newline at end of file diff --git a/components/card/private/header.js b/components/card/private/header.js new file mode 100644 index 0000000000..aaf6f3da0c --- /dev/null +++ b/components/card/private/header.js @@ -0,0 +1,137 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.idSuffixes = exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _mediaObject = _interopRequireDefault(require("../../media-object")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// Allow for predicatable DOM queries with `querySelectorAll(cssClasses.base)` +var idSuffixes = { + headerActions: '__header-actions', + heading: '__heading', + filter: '__filter-input' +}; +exports.idSuffixes = idSuffixes; + +var renderFilter = function renderFilter(filter, id) { + // allow id to be set by custom header component passed in + var clonedFilter = _react.default.cloneElement(filter, { + id: filter.props.id || id + }); + + return _react.default.createElement("div", { + className: "slds-input-has-icon slds-input-has-icon_left slds-size_1-of-3" + }, clonedFilter); +}; + +renderFilter.displayName = 'renderFilter'; +/** + * Card Header is a private component and is not meant to be imported or used for Card's `header` prop. It just happens to have the same file name. + */ + +var CardHeader = function CardHeader(props) { + var title = null; + + if (typeof props.heading === 'string' || props.heading instanceof String) { + title = props.heading; + } + + var heading = _react.default.createElement("h2", { + id: props.headingId, + className: "slds-text-heading_small slds-truncate", + title: title + }, props.heading); + + var Header; + + if (props.header) { + Header = _react.default.cloneElement(props.header, _objectSpread({ + figure: props.icon, + body: heading, + verticalCenter: true, + canTruncate: true + }, props.header.props)); + } else { + Header = _react.default.createElement(_mediaObject.default, { + figure: props.icon, + body: heading, + verticalCenter: true, + canTruncate: true + }); + } + + var hasFilter = props.filter ? true : null; + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-card__header', 'slds-grid') + }, Header, props.filter ? renderFilter(props.filter, props.filterId) : null, _react.default.createElement("div", { + id: props.headerActionsId, + className: (0, _classnames.default)('slds-no-flex', { + 'slds-size_1-of-3': hasFilter, + 'slds-text-align_right': hasFilter + }) + }, props.headerActions)); +}; // ### Display Name +// Always use the canonical component name as the React display name. + + +CardHeader.displayName = _constants.CARD_HEADER; // ### Prop Types + +CardHeader.propTypes = { + /** + * Adds a filter input to the card header + */ + filter: _propTypes.default.node, + + /** + * Set the HTML `id` of the card filter. + */ + filterId: _propTypes.default.string, + + /** + * Allows a custom header (the media object with the icon in the first column). `icon`, `heading` and other props are passed in the media object from Card. Use `design-system-react/components/media-object` to create your own. + */ + header: _propTypes.default.node, + + /** + * Actions performed on selected items or that relate to the entire group of items such as "Add Item."" + */ + headerActions: _propTypes.default.node, + + /** + * Set the HTML `id` of the card header actions. + */ + headerActionsId: _propTypes.default.string, + + /** + * The heading is the name of the related item group. + */ + heading: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.string]).isRequired, + + /** + * Set the HTML `id` of the card heading. + */ + headingId: _propTypes.default.string, + + /** + * Icon associated with grouped items + */ + icon: _propTypes.default.node +}; +var _default = CardHeader; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/__docs__/__snapshots__/storybook-stories.storyshot b/components/carousel/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..d40e486830 --- /dev/null +++ b/components/carousel/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,4657 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSCarousel 3 items NoImageTest 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSCarousel 3 items with AutoPlay NoImageTest 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSCarousel 5 items NoImageTest 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSCarousel Default (1 item) NoImageTest 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSCarousel Default with AutoPlay NoImageTest 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSCarousel Default with navigation indicators NoImageTest 1`] = ` +
    + +
    +`; + +exports[`DOM snapshots SLDSCarousel With custom items NoImageTest 1`] = ` +
    +
    + +
    +
    +`; diff --git a/components/carousel/__docs__/site-stories.js b/components/carousel/__docs__/site-stories.js new file mode 100644 index 0000000000..5e2fe5e850 --- /dev/null +++ b/components/carousel/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/carousel/__examples__/three-items.jsx'), require('raw-loader!@salesforce/design-system-react/components/carousel/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/carousel/__examples__/default-with-navigation.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/carousel/__docs__/storybook-stories.js b/components/carousel/__docs__/storybook-stories.js new file mode 100644 index 0000000000..2ddc190447 --- /dev/null +++ b/components/carousel/__docs__/storybook-stories.js @@ -0,0 +1,55 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _addonActions = require("@storybook/addon-actions"); + +var _react2 = require("@storybook/react"); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _defaultWithAutoplay = _interopRequireDefault(require("../__examples__/default-with-autoplay")); + +var _defaultWithNavigation = _interopRequireDefault(require("../__examples__/default-with-navigation")); + +var _fiveItems = _interopRequireDefault(require("../__examples__/five-items")); + +var _threeItems = _interopRequireDefault(require("../__examples__/three-items")); + +var _threeItemsWithAutoplay = _interopRequireDefault(require("../__examples__/three-items-with-autoplay")); + +var _withCustomItems = _interopRequireDefault(require("../__examples__/with-custom-items")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.CAROUSEL, module).add('Default (1 item) NoImageTest', function () { + return _react.default.createElement(_default.default, { + action: _addonActions.action + }); +}).add('Default with navigation indicators NoImageTest', function () { + return _react.default.createElement(_defaultWithNavigation.default, { + action: _addonActions.action + }); +}).add('Default with AutoPlay NoImageTest', function () { + return _react.default.createElement(_defaultWithAutoplay.default, { + action: _addonActions.action + }); +}).add('3 items NoImageTest', function () { + return _react.default.createElement(_threeItems.default, { + action: _addonActions.action + }); +}).add('3 items with AutoPlay NoImageTest', function () { + return _react.default.createElement(_threeItemsWithAutoplay.default, { + action: _addonActions.action + }); +}).add('5 items NoImageTest', function () { + return _react.default.createElement(_fiveItems.default, { + action: _addonActions.action + }); +}).add('With custom items NoImageTest', function () { + return _react.default.createElement(_withCustomItems.default, { + action: _addonActions.action + }); +}); \ No newline at end of file diff --git a/components/carousel/__examples__/default-with-autoplay.js b/components/carousel/__examples__/default-with-autoplay.js new file mode 100644 index 0000000000..0367dd9e5b --- /dev/null +++ b/components/carousel/__examples__/default-with-autoplay.js @@ -0,0 +1,134 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _carousel = _interopRequireDefault(require("../../../../components/carousel")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _log = _interopRequireDefault(require("../../../../utilities/log")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var items = [{ + id: 1, + heading: 'Visit App Exchange', + description: 'Extend Salesforce with the #1 business marketplace.', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + id: 2, + heading: 'Click to Customize', + description: 'Use the Object Manager to add fields, build layouts, and more.', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + id: 3, + heading: 'Download SalesforceA', + description: "Get the mobile app that's just for Salesforce admins.", + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + id: 4, + heading: 'Carousel Item 4', + description: 'Description for carousel item #4', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + id: 5, + heading: 'Carousel Item 5', + description: 'Description for carousel item #5', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + id: 6, + heading: 'Carousel Item 6', + description: 'Description for carousel item #6', + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + id: 7, + heading: 'Carousel Item 7', + description: 'Description for carousel item #7', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + maxWidth: '1280px' + } + }, _react.default.createElement(_carousel.default, { + hasAutoplay: true, + id: "carousel-default-with-auto-play-example", + items: items, + onItemClick: function onItemClick(event, data) { + event.preventDefault(); + (0, _log.default)({ + action: _this.props.action, + event: event, + eventName: 'Item Clicked', + data: data + }); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'DefaultWithAutoPlayExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/__examples__/default-with-navigation.js b/components/carousel/__examples__/default-with-navigation.js new file mode 100644 index 0000000000..0812586335 --- /dev/null +++ b/components/carousel/__examples__/default-with-navigation.js @@ -0,0 +1,134 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _carousel = _interopRequireDefault(require("../../../../components/carousel")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _log = _interopRequireDefault(require("../../../../utilities/log")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var items = [{ + id: 1, + heading: 'Visit App Exchange', + description: 'Extend Salesforce with the #1 business marketplace.', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + id: 2, + heading: 'Click to Customize', + description: 'Use the Object Manager to add fields, build layouts, and more.', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + id: 3, + heading: 'Download SalesforceA', + description: "Get the mobile app that's just for Salesforce admins.", + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + id: 4, + heading: 'Carousel Item 4', + description: 'Description for carousel item #4', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + id: 5, + heading: 'Carousel Item 5', + description: 'Description for carousel item #5', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + id: 6, + heading: 'Carousel Item 6', + description: 'Description for carousel item #6', + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + id: 7, + heading: 'Carousel Item 7', + description: 'Description for carousel item #7', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + maxWidth: '1280px' + } + }, _react.default.createElement(_carousel.default, { + hasPreviousNextPanelNavigation: true, + id: "carousel-default-with-navigation-example", + items: items, + onItemClick: function onItemClick(event, data) { + event.preventDefault(); + (0, _log.default)({ + action: _this.props.action, + event: event, + eventName: 'Item Clicked', + data: data + }); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'DefaultWithNavigationExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/__examples__/default.js b/components/carousel/__examples__/default.js new file mode 100644 index 0000000000..fc1ebebc6f --- /dev/null +++ b/components/carousel/__examples__/default.js @@ -0,0 +1,133 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _carousel = _interopRequireDefault(require("../../../../components/carousel")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _log = _interopRequireDefault(require("../../../../utilities/log")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var items = [{ + id: 1, + heading: 'Visit App Exchange', + description: 'Extend Salesforce with the #1 business marketplace.', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + id: 2, + heading: 'Click to Customize', + description: 'Use the Object Manager to add fields, build layouts, and more.', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + id: 3, + heading: 'Download SalesforceA', + description: "Get the mobile app that's just for Salesforce admins.", + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + id: 4, + heading: 'Carousel Item 4', + description: 'Description for carousel item #4', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + id: 5, + heading: 'Carousel Item 5', + description: 'Description for carousel item #5', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + id: 6, + heading: 'Carousel Item 6', + description: 'Description for carousel item #6', + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + id: 7, + heading: 'Carousel Item 7', + description: 'Description for carousel item #7', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + maxWidth: '1280px' + } + }, _react.default.createElement(_carousel.default, { + id: "carousel-default-example", + items: items, + onItemClick: function onItemClick(event, data) { + event.preventDefault(); + (0, _log.default)({ + action: _this.props.action, + event: event, + eventName: 'Item Clicked', + data: data + }); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'DefaultExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/__examples__/five-items.js b/components/carousel/__examples__/five-items.js new file mode 100644 index 0000000000..cdc5bed060 --- /dev/null +++ b/components/carousel/__examples__/five-items.js @@ -0,0 +1,142 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _carousel = _interopRequireDefault(require("../../../../components/carousel")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _log = _interopRequireDefault(require("../../../../utilities/log")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var items = [{ + buttonLabel: 'Get Started', + id: 1, + heading: 'Visit App Exchange', + description: 'Extend Salesforce with the #1 business marketplace.', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 2, + heading: 'Click to Customize', + description: 'Use the Object Manager to add fields, build layouts, and more.', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 3, + heading: 'Download SalesforceA', + description: "Get the mobile app that's just for Salesforce admins.", + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 4, + heading: 'Carousel Item 4', + description: 'Description for carousel item #4', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 5, + heading: 'Carousel Item 5', + description: 'Description for carousel item #5', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 6, + heading: 'Carousel Item 6', + description: 'Description for carousel item #6', + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 7, + heading: 'Carousel Item 7', + description: 'Description for carousel item #7', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + maxWidth: '1280px' + } + }, _react.default.createElement(_carousel.default, { + hasPreviousNextPanelNavigation: true, + id: "carousel-five-items-example", + items: items, + itemsPerPanel: 5, + onItemClick: function onItemClick(event, data) { + event.preventDefault(); + (0, _log.default)({ + action: _this.props.action, + event: event, + eventName: 'Item Clicked', + data: data + }); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'FiveItemsExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/__examples__/three-items-with-autoplay.js b/components/carousel/__examples__/three-items-with-autoplay.js new file mode 100644 index 0000000000..1de27f53dc --- /dev/null +++ b/components/carousel/__examples__/three-items-with-autoplay.js @@ -0,0 +1,142 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _carousel = _interopRequireDefault(require("../../../../components/carousel")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _log = _interopRequireDefault(require("../../../../utilities/log")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var items = [{ + buttonLabel: 'Get Started', + id: 1, + heading: 'Visit App Exchange', + description: 'Extend Salesforce with the #1 business marketplace.', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 2, + heading: 'Click to Customize', + description: 'Use the Object Manager to add fields, build layouts, and more.', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 3, + heading: 'Download SalesforceA', + description: "Get the mobile app that's just for Salesforce admins.", + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 4, + heading: 'Carousel Item 4', + description: 'Description for carousel item #4', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 5, + heading: 'Carousel Item 5', + description: 'Description for carousel item #5', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 6, + heading: 'Carousel Item 6', + description: 'Description for carousel item #6', + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 7, + heading: 'Carousel Item 7', + description: 'Description for carousel item #7', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + maxWidth: '1280px' + } + }, _react.default.createElement(_carousel.default, { + hasAutoplay: true, + id: "carousel-three-items-with-auto-play-example", + items: items, + itemsPerPanel: 3, + onItemClick: function onItemClick(event, data) { + event.preventDefault(); + (0, _log.default)({ + action: _this.props.action, + event: event, + eventName: 'Item Clicked', + data: data + }); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ThreeItemsWithAutoplayExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/__examples__/three-items.js b/components/carousel/__examples__/three-items.js new file mode 100644 index 0000000000..243cc8c605 --- /dev/null +++ b/components/carousel/__examples__/three-items.js @@ -0,0 +1,142 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _carousel = _interopRequireDefault(require("../../../../components/carousel")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _log = _interopRequireDefault(require("../../../../utilities/log")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var items = [{ + buttonLabel: 'Get Started', + id: 1, + heading: 'Visit App Exchange', + description: 'Extend Salesforce with the #1 business marketplace.', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 2, + heading: 'Click to Customize', + description: 'Use the Object Manager to add fields, build layouts, and more.', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 3, + heading: 'Download SalesforceA', + description: "Get the mobile app that's just for Salesforce admins.", + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 4, + heading: 'Carousel Item 4', + description: 'Description for carousel item #4', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 5, + heading: 'Carousel Item 5', + description: 'Description for carousel item #5', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 6, + heading: 'Carousel Item 6', + description: 'Description for carousel item #6', + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 7, + heading: 'Carousel Item 7', + description: 'Description for carousel item #7', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + maxWidth: '1280px' + } + }, _react.default.createElement(_carousel.default, { + hasPreviousNextPanelNavigation: true, + id: "carousel-three-items-example", + items: items, + itemsPerPanel: 3, + onItemClick: function onItemClick(event, data) { + event.preventDefault(); + (0, _log.default)({ + action: _this.props.action, + event: event, + eventName: 'Item Clicked', + data: data + }); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ThreeItemsExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/__examples__/with-custom-items.js b/components/carousel/__examples__/with-custom-items.js new file mode 100644 index 0000000000..cd614ca33e --- /dev/null +++ b/components/carousel/__examples__/with-custom-items.js @@ -0,0 +1,199 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _carousel = _interopRequireDefault(require("../../../../components/carousel")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _log = _interopRequireDefault(require("../../../../utilities/log")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var items = [{ + buttonLabel: 'Get Started', + id: 1, + heading: 'Visit App Exchange', + description: 'Extend Salesforce with the #1 business marketplace.', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 2, + heading: 'Click to Customize', + description: 'Use the Object Manager to add fields, build layouts, and more.', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 3, + heading: 'Download SalesforceA', + description: "Get the mobile app that's just for Salesforce admins.", + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Get Started', + id: 4, + heading: 'Carousel Item 4', + description: 'Description for carousel item #4', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 5, + heading: 'Carousel Item 5', + description: 'Description for carousel item #5', + imageAssistiveText: 'Appy', + src: '/assets/images/carousel/carousel-01.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 6, + heading: 'Carousel Item 6', + description: 'Description for carousel item #6', + imageAssistiveText: 'SalesforceA', + src: '/assets/images/carousel/carousel-03.jpg', + href: 'https://www.salesforce.com' +}, { + buttonLabel: 'Learn More', + id: 7, + heading: 'Carousel Item 7', + description: 'Description for carousel item #7', + imageAssistiveText: 'Apps', + src: '/assets/images/carousel/carousel-02.jpg', + href: 'https://www.salesforce.com' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "renderCustomItem", function (_ref) { + var item = _ref.item; + + var onButtonClick = function onButtonClick(event) { + event.preventDefault(); + (0, _log.default)({ + action: _this.props.action, + event: event, + eventName: 'Button Clicked', + data: { + item: item + } + }); + }; + + return _react.default.createElement("div", { + className: "slds-carousel-custom-rendering", + style: { + padding: '0 8px', + margin: 0, + textAlign: 'center' + } + }, _react.default.createElement("div", { + className: "slds-carousel__content-title" + }, item.heading), _react.default.createElement("div", { + className: "slds-carousel__image" + }, _react.default.createElement("img", { + src: item.src, + alt: item.imageAssistiveText + })), _react.default.createElement(_button.default, { + className: "slds-button_outline-brand slds-m-around_small", + label: "Button1", + onClick: function onClick(event) { + onButtonClick(event, item); + }, + tabIndex: item.isInCurrentPanel ? '0' : '-1' + }), _react.default.createElement(_button.default, { + className: "slds-button_outline-brand slds-m-around_small", + label: "Button2", + onClick: function onClick(event) { + onButtonClick(event, item); + }, + tabIndex: item.isInCurrentPanel ? '0' : '-1' + })); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + style: { + bottom: '1rem', + left: '1rem', + overflow: 'auto', + position: 'absolute', + right: '1rem', + top: '1rem' + } + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + maxWidth: '1280px' + } + }, _react.default.createElement(_carousel.default, { + hasPreviousNextPanelNavigation: true, + id: "carousel-with-custom-items-example", + items: items, + itemsPerPanel: 3, + onRenderItem: this.renderCustomItem + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'WithCustomItemsExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/check-props.js b/components/carousel/check-props.js new file mode 100644 index 0000000000..0ca6ef9db4 --- /dev/null +++ b/components/carousel/check-props.js @@ -0,0 +1,29 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _componentIsPrototype = _interopRequireDefault(require("../../utilities/warning/component-is-prototype")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + (0, _componentIsPrototype.default)(COMPONENT, createDocUrl()); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/docs.json b/components/carousel/docs.json new file mode 100644 index 0000000000..4c08f40f4a --- /dev/null +++ b/components/carousel/docs.json @@ -0,0 +1,7 @@ +{ + "component": "carousel", + "status": "prototype", + "display-name": "Carousel", + "SLDS-component-path": "/components/carousel", + "url-slug": "carousel" +} diff --git a/components/carousel/index.js b/components/carousel/index.js new file mode 100644 index 0000000000..c1a4e385a4 --- /dev/null +++ b/components/carousel/index.js @@ -0,0 +1,395 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _constants = require("../../utilities/constants"); + +var _executionEnvironment = require("../../utilities/execution-environment"); + +var _carouselIndicators = _interopRequireDefault(require("./private/carousel-indicators")); + +var _previousNextCarouselNavigator = _interopRequireDefault(require("./private/previous-next-carousel-navigator")); + +var _carouselItem = _interopRequireDefault(require("./private/carousel-item")); + +var _autoPlayButton = _interopRequireDefault(require("./private/auto-play-button")); + +var _keyCode = _interopRequireDefault(require("../../utilities/key-code")); + +var _event = _interopRequireDefault(require("../../utilities/event")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable jsx-a11y/no-static-element-interactions */ +// ### Default Props +var defaultProps = { + assistiveText: { + autoPlayButton: 'Start / Stop auto-play', + nextPanel: 'Next Panel', + previousPanel: 'Previous Panel' + }, + autoplayInterval: 4000, + hasAutoplay: false, + hasPreviousNextPanelNavigation: false, + isInfinite: false, + itemsPerPanel: 1 +}; +/** + * A carousel allows multiple pieces of featured content to occupy an allocated amount of space. + * Currently panel index and auto play cannot be controlled by the app. + */ + +var Carousel = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Carousel, _React$Component); + + // ### Display Name + // Always use the canonical component name as the React display name. + // ### Prop Types + // ### Default Props + function Carousel(props) { + var _this; + + _classCallCheck(this, Carousel); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Carousel).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "onNextPanelHandler", function () { + var next = _this.state.currentPanel % _this.nrOfPanels + 1; + + _this.setCurrentPanel(next, _this.changeTranslationAutomatically); + }); + + _defineProperty(_assertThisInitialized(_this), "onPreviousPanelHandler", function () { + var prev = (_this.state.currentPanel + _this.nrOfPanels - 1) % _this.nrOfPanels; + + _this.setCurrentPanel(prev, _this.changeTranslationAutomatically); + }); + + _defineProperty(_assertThisInitialized(_this), "onIndicatorClickHandler", function (panel) { + _this.setCurrentPanel(panel, _this.changeTranslationAutomatically); + }); + + _defineProperty(_assertThisInitialized(_this), "onAutoPlayBtnClick", function () { + var isAutoPlayOn = _this.state.isAutoPlayOn; + var actionToTake = isAutoPlayOn ? _this.stopAutoplay : _this.startAutoplay; + + _this.setState({ + isAutoPlayOn: !isAutoPlayOn + }); + + actionToTake(); + }); + + _defineProperty(_assertThisInitialized(_this), "setDimensions", function () { + if (_executionEnvironment.canUseDOM && _this.stageItem !== undefined && _this.stageItem.current !== undefined && _this.stageItem.current.offsetWidth !== undefined) { + _this.setState({ + stageWidth: _this.stageItem.current.offsetWidth + }, _this.changeTranslationAutomatically); + } + }); + + _defineProperty(_assertThisInitialized(_this), "setTranslationAmount", function (amount, cb) { + _this.setState({ + translateX: amount + }, cb); + }); + + _defineProperty(_assertThisInitialized(_this), "setCurrentPanel", function (amount, cb) { + _this.setState({ + currentPanel: amount + }, cb); + }); + + _defineProperty(_assertThisInitialized(_this), "startAutoplay", function () { + _this.autoplayId = setInterval(function () { + if (_this.canGoToNext()) { + _this.onNextPanelHandler(); + } else { + _this.stopAutoplay(); + } + }, _this.props.autoplayInterval); + }); + + _defineProperty(_assertThisInitialized(_this), "stopAutoplay", function () { + if (_this.autoplayId) { + clearInterval(_this.autoplayId); + } + + _this.setState({ + isAutoPlayOn: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "changeTranslationAutomatically", function () { + _this.setTranslationAmount(-((_this.state.stageWidth || _this.stageWidth) * (_this.state.currentPanel - 1))); + }); + + _defineProperty(_assertThisInitialized(_this), "canGoToNext", function () { + return _this.state.currentPanel < _this.nrOfPanels; + }); + + _defineProperty(_assertThisInitialized(_this), "canGoToPrevious", function () { + return _this.state.currentPanel > 1; + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) { + var _keyDownCallbacks; + + var keyDownCallbacks = (_keyDownCallbacks = {}, _defineProperty(_keyDownCallbacks, _keyCode.default.LEFT, function () { + if (_this.canGoToPrevious()) { + _this.onPreviousPanelHandler(); + } + }), _defineProperty(_keyDownCallbacks, _keyCode.default.RIGHT, function () { + if (_this.canGoToNext()) { + _this.onNextPanelHandler(); + } + }), _keyDownCallbacks); + + if (keyDownCallbacks[event.keyCode]) { + _event.default.trapImmediate(event); + + keyDownCallbacks[event.keyCode](); + } + }); + + var _this$props = _this.props, + items = _this$props.items, + itemsPerPanel = _this$props.itemsPerPanel; + _this.nrOfPanels = Math.ceil(items.length / itemsPerPanel); + _this.stageItem = _react.default.createRef(); + _this.state = { + translateX: -1000000, + currentPanel: 1, + isAutoPlayOn: _this.props.hasAutoplay, + stageWidth: 0 + }; + return _this; + } + + _createClass(Carousel, [{ + key: "componentWillMount", + value: function componentWillMount() { + this.generatedId = _shortid.default.generate(); + (0, _checkProps.default)(_constants.CAROUSEL, _docs.default); + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + this.setTranslationAmount(0); + + if (this.props.hasAutoplay) { + this.startAutoplay(); + } + + if (_executionEnvironment.canUseDOM && this.stageItem !== undefined && this.stageItem.current !== undefined && this.stageItem.current.offsetWidth !== undefined) { + this.stageWidth = this.stageItem.current.offsetWidth; + } + + if (_executionEnvironment.canUseEventListeners) { + window.addEventListener('resize', this.setDimensions, false); + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + if (_executionEnvironment.canUseEventListeners) { + window.removeEventListener('resize', this.setDimensions, false); + } + + this.stopAutoplay(); + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var _this$props2 = this.props, + hasAutoplay = _this$props2.hasAutoplay, + hasPreviousNextPanelNavigation = _this$props2.hasPreviousNextPanelNavigation, + isInfinite = _this$props2.isInfinite; + var id = this.props.id || this.generatedId; + var isPreviousBtnDisabled = !(isInfinite || this.canGoToPrevious()); + var isNextBtnDisabled = !(isInfinite || this.canGoToNext()); + var itemWidth = (this.state.stageWidth || this.stageWidth) / this.props.itemsPerPanel; + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-carousel', this.props.className), + id: id, + onKeyDown: this.handleKeyDown + }, _react.default.createElement("div", { + className: "slds-grid_vertical slds-col slds-path__scroller" + }, hasAutoplay && _react.default.createElement(_autoPlayButton.default, { + assistiveText: this.props.assistiveText.autoPlayButton, + isAutoPlayOn: this.state.isAutoPlayOn, + onClick: this.onAutoPlayBtnClick + }), _react.default.createElement("div", { + className: "slds-is-relative", + style: { + marginLeft: '60px', + marginRight: '60px' + } + }, hasPreviousNextPanelNavigation && _react.default.createElement(_previousNextCarouselNavigator.default, { + assistiveText: this.props.assistiveText.previousPanel, + iconName: "left", + isDisabled: isPreviousBtnDisabled, + onClick: this.onPreviousPanelHandler, + inlineStyle: { + left: '-60px' + } + }), _react.default.createElement("div", { + ref: this.stageItem, + className: "slds-carousel__stage slds-show" + }, _react.default.createElement("div", { + className: "slds-carousel__panels slds-is-relative", + style: { + transform: "translateX(".concat(this.state.translateX, "px)") + } + }, this.props.items.map(function (item, index) { + return _react.default.createElement(_carouselItem.default, _extends({ + onClick: function onClick(event) { + _this2.props.onItemClick(event, { + item: item + }); + }, + onRenderItem: _this2.props.onRenderItem + }, item, { + isInCurrentPanel: index >= (_this2.state.currentPanel - 1) * _this2.props.itemsPerPanel && index < (_this2.state.currentPanel - 1) * _this2.props.itemsPerPanel + _this2.props.itemsPerPanel, + itemWidth: itemWidth, + key: item.id + })); + }))), hasPreviousNextPanelNavigation && _react.default.createElement(_previousNextCarouselNavigator.default, { + assistiveText: this.props.assistiveText.nextPanel, + iconName: "right", + isDisabled: isNextBtnDisabled, + onClick: this.onNextPanelHandler, + inlineStyle: { + right: '-60px' + } + })), _react.default.createElement(_carouselIndicators.default, { + style: this.props.indicatorStyles, + noOfIndicators: this.nrOfPanels, + currentIndex: this.state.currentPanel, + onClick: this.onIndicatorClickHandler, + items: this.props.items, + itemsPerPanel: this.props.itemsPerPanel + }))); + } + }]); + + return Carousel; +}(_react.default.Component); + +_defineProperty(Carousel, "displayName", _constants.CAROUSEL); + +_defineProperty(Carousel, "propTypes", { + /** + * Description of the carousel items for screen-readers. + */ + assistiveText: _propTypes.default.object, + + /** + * Interval for the autoplay iteration + */ + autoplayInterval: _propTypes.default.number, + + /** + * CSS classes that are applied to the main 'slds-carousel' classed component container + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Boolean showing whether the autoplay feature is available or not + */ + hasAutoplay: _propTypes.default.bool, + + /** + * Boolean for displaying the navigation indicators (left/right arrows) of the carousel + */ + hasPreviousNextPanelNavigation: _propTypes.default.bool, + + /** + * Id of component, if desired. If not provided an id is automatically generated + */ + id: _propTypes.default.string, + + /** + * CSS that is applied to carousel indicators + */ + indicatorStyles: _propTypes.default.object, + + /** + * Boolean for infinite loop navigation + */ + isInfinite: _propTypes.default.bool, + + /** + * * **Array of item objects used by the default carousel item renderer.** + * Each object can contain: + * * `id`: The id of the carousel item. [REQUIRED] + * * `heading`: Primary string that will be used as the heading + * * `description`: Secondary string that is used to describe the item + * * `buttonLabel`: If assigned a call to button action will be rendered with this text, if unassigned no button is rendered + * * `imageAssistiveText`: Image alt text, if not present heading will be used instead + * * `href`: Used for item link, if not provided 'javascript:void(0);' is used instead + * * `src`: Item image src value + */ + items: _propTypes.default.array.isRequired, + + /** + * Number of items to be displayed at a time in the carousel + */ + itemsPerPanel: _propTypes.default.number, + + /** + * Accepts a custom carousel item rendering function + */ + onRenderItem: _propTypes.default.func, + + /** + * Handler for clicking on a carousel item + */ + onItemClick: _propTypes.default.func +}); + +_defineProperty(Carousel, "defaultProps", defaultProps); + +var _default = Carousel; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/private/auto-play-button.js b/components/carousel/private/auto-play-button.js new file mode 100644 index 0000000000..eea8aff3fe --- /dev/null +++ b/components/carousel/private/auto-play-button.js @@ -0,0 +1,66 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _button = _interopRequireDefault(require("../../../components/button")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// ### React + +/** + * AutoPlayButton is used to start/pause the autoplay iteration of the carousel + */ +var AutoPlayButton = function AutoPlayButton(props) { + return _react.default.createElement("span", { + className: "slds-carousel__autoplay" + }, _react.default.createElement(_button.default, { + assistiveText: { + icon: props.assistiveText + }, + className: "slds-button_icon", + disabled: props.isDisabled, + iconCategory: "utility", + iconName: props.isAutoPlayOn ? 'pause' : 'play', + iconVariant: "border-filled", + iconSize: "x-small", + onClick: props.onClick, + variant: "icon" + })); +}; + +AutoPlayButton.displayName = _constants.CAROUSEL_AUTOPLAY_BUTTON; // ### Prop Types + +AutoPlayButton.propTypes = { + /** + * Description of the start/pause autoplay button for screen-readers. + */ + assistiveText: _propTypes.default.string, + + /** + * Indicates whether autoPlay is enabled + */ + isAutoPlayOn: _propTypes.default.bool, + + /** + * Triggered when the autoplay button is clicked. + */ + onClick: _propTypes.default.func +}; +AutoPlayButton.defaultProps = { + isAutoPlayOn: false +}; +var _default = AutoPlayButton; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/private/carousel-indicators.js b/components/carousel/private/carousel-indicators.js new file mode 100644 index 0000000000..a8c95fd005 --- /dev/null +++ b/components/carousel/private/carousel-indicators.js @@ -0,0 +1,184 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * CarouselIndicators is used to display the list of indicators associated to the number of panels + * a carousel has + */ +var CarouselIndicators = +/*#__PURE__*/ +function (_React$Component) { + _inherits(CarouselIndicators, _React$Component); + + function CarouselIndicators() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, CarouselIndicators); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(CarouselIndicators)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "onFocus", function () { + _this["indicator".concat(_this.props.currentIndex)].focus(); + }); + + return _this; + } + + _createClass(CarouselIndicators, [{ + key: "render", + value: function render() { + var _this2 = this; + + var props = this.props; + return _react.default.createElement("ul", { + className: "slds-carousel__indicators slds-col slds-text-align_center", + role: "tablist" + }, _toConsumableArray(Array(props.noOfIndicators).keys()).map(function (key) { + var index = key + 1; + var isSelectedPanel = index === props.currentIndex; + var indicatorActionClassName = (0, _classnames.default)('slds-carousel__indicator-action', props.className, { + 'slds-is-active': isSelectedPanel + }); + var assistiveText = "".concat(index); + var title = "".concat(index); + + if (props.items && props.items.length > 0) { + var startItemIndex = (index - 1) * props.itemsPerPanel; + var autoIndicatorText = ''; + + for (var i = startItemIndex; i < startItemIndex + props.itemsPerPanel; i++) { + if (props.items[i] && props.items[i].heading) { + autoIndicatorText = !autoIndicatorText ? '' : "".concat(autoIndicatorText, ", "); + autoIndicatorText += props.items[i].heading; + } + } + + if (autoIndicatorText) { + assistiveText = autoIndicatorText; + title = autoIndicatorText; + } + } + + if (isSelectedPanel && _this2["indicator".concat(index)]) { + _this2["indicator".concat(index)].focus(); + } + + return _react.default.createElement("li", { + className: "slds-carousel__indicator slds-m-horizontal_xx-small", + key: index, + role: "presentation", + style: { + margin: 0, + padding: '0 8px' + } + }, _react.default.createElement("a", { + ref: function ref(component) { + _this2["indicator".concat(index)] = component; + }, + id: "indicator-id-".concat(index), + className: indicatorActionClassName, + role: "tab", + tabIndex: isSelectedPanel ? '0' : '-1', + "aria-selected": isSelectedPanel, + "aria-controls": "panel-".concat(index), + title: title, + onClick: function onClick() { + return props.onClick(index); + }, + onFocus: _this2.onFocus + }, _react.default.createElement("span", { + className: "slds-assistive-text" + }, assistiveText))); + })); + } + }]); + + return CarouselIndicators; +}(_react.default.Component); + +CarouselIndicators.displayName = _constants.CAROUSEL_INDICATORS; +CarouselIndicators.defaultProps = { + currentIndex: 0 +}; // ### Prop Types + +CarouselIndicators.propTypes = { + /** + * CSS classes that are applied to the component + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Selected indicator + */ + currentIndex: _propTypes.default.number, + + /** + * Array of objects with shape, needed for building a carousel items + */ + items: _propTypes.default.array, + + /** + * Number of items to be displayed at a time in the carousel + */ + itemsPerPanel: _propTypes.default.number, + + /** + * Number of indicators to be displayed (corresponds to the number of panels in the carousel) + */ + noOfIndicators: _propTypes.default.number.isRequired, + + /** + * Triggered when the indicator is clicked. + */ + onClick: _propTypes.default.func +}; +var _default = CarouselIndicators; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/private/carousel-item.js b/components/carousel/private/carousel-item.js new file mode 100644 index 0000000000..7fee1082b9 --- /dev/null +++ b/components/carousel/private/carousel-item.js @@ -0,0 +1,131 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _button = _interopRequireDefault(require("../../button")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// # CarouselItem Component +// Implements the [CarouselItem design pattern](https://www.lightningdesignsystem.com/components/carousel/) in React. + +/** + * A carousel allows multiple pieces of featured content to occupy an allocated amount of space. + */ +var CarouselItem = function CarouselItem(props) { + return _react.default.createElement("div", { + id: "content-id-".concat(props.id), + className: "slds-carousel__panel slds-m-horizontal_xx-small slds-list_horizontal", + role: "tabpanel", + "aria-hidden": "false", + "aria-labelledby": "indicator-id-".concat(props.id), + style: { + margin: 0, + maxWidth: "".concat(props.itemWidth, "px"), + padding: '0 8px' + } + }, props.onRenderItem ? props.onRenderItem({ + item: props + }) : _react.default.createElement("a", { + className: "slds-carousel__panel-action slds-text-link_reset", + href: props.href, + onClick: props.onClick, + style: { + backgroundColor: 'white', + margin: 'auto' + }, + tabIndex: props.isInCurrentPanel ? '0' : '-1' + }, _react.default.createElement("div", { + className: "slds-carousel__image" + }, _react.default.createElement("img", { + src: props.src, + alt: props.imageAssistiveText || props.heading + })), _react.default.createElement("div", { + className: "slds-carousel__content", + style: { + height: 'auto' + } + }, _react.default.createElement("h2", { + className: "slds-carousel__content-title" + }, props.heading), _react.default.createElement("div", { + className: "slds-p-bottom_x-small slds-text-body_small", + style: { + minHeight: '40px' + } + }, props.description), props.buttonLabel && _react.default.createElement(_button.default, { + className: "slds-button_outline-brand", + label: props.buttonLabel, + tabIndex: props.isInCurrentPanel ? '0' : '-1' + })))); +}; + +CarouselItem.displayName = _constants.CAROUSEL_ITEM; +CarouselItem.propTypes = { + /** + * Label of the button to be displayed. If not provided, no button will be rendered. + */ + buttonLabel: _propTypes.default.string, + + /** + * CSS classes that are applied to the component + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Visible paragraph text to be displayed on the carousel item + */ + description: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]), + + /** + * Carousel Item's visible heading + */ + heading: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object]).isRequired, + href: _propTypes.default.string, + + /** + * Id of the item component. + */ + id: _propTypes.default.number.isRequired, + + /** + * Image alt text + */ + imageAssistiveText: _propTypes.default.string, + + /** + * Boolean indicating whether this item is currently visible in the active parent carousel panel + */ + isInCurrentPanel: _propTypes.default.bool, + + /** + * Width of the carousel item + */ + itemWidth: _propTypes.default.number, + + /** + * Accepts a custom carousel item rendering function + */ + onRenderItem: _propTypes.default.func, + + /** + * Path of the image to be used + */ + src: _propTypes.default.string.isRequired +}; +CarouselItem.defaultProps = { + href: 'javascript:void(0);' +}; +var _default = CarouselItem; +exports.default = _default; \ No newline at end of file diff --git a/components/carousel/private/previous-next-carousel-navigator.js b/components/carousel/private/previous-next-carousel-navigator.js new file mode 100644 index 0000000000..cbb0216bdd --- /dev/null +++ b/components/carousel/private/previous-next-carousel-navigator.js @@ -0,0 +1,77 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _button = _interopRequireDefault(require("../../../components/button")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * previousNextCarouselNavigator is used to display previous/next navigation items of the carousel + */ +var previousNextCarouselNavigator = function previousNextCarouselNavigator(props) { + return _react.default.createElement("div", { + className: "slds-carousel__col-center slds-is-absolute", + style: _objectSpread({}, props.inlineStyle, { + margin: '0 25px', + top: '50%' + }) + }, _react.default.createElement(_button.default, { + assistiveText: { + icon: props.assistiveText + }, + className: "slds-button_icon slds-carousel__button", + disabled: props.isDisabled, + iconCategory: "utility", + iconName: props.iconName, + iconVariant: "border-filled", + iconSize: "x-small", + onClick: props.onClick, + variant: "icon" + })); +}; // /assets/icons/utility-sprite/svg/symbols.svg#right + + +previousNextCarouselNavigator.displayName = _constants.CAROUSEL_NAVIGATORS; // ### Prop Types + +previousNextCarouselNavigator.propTypes = { + /** + * Description of the previous/next navigation icons for screen-readers. + */ + assistiveText: _propTypes.default.string, + + /** + * Name of icon displayed within the navigation button + */ + iconName: _propTypes.default.oneOf(['left', 'right']), + + /** + * Determines where the navigator indicator has been disabled + */ + isDisabled: _propTypes.default.bool, + + /** + * Additional styles to be applied to the container + */ + inlineStyle: _propTypes.default.object, + + /** + * Triggered when the indicator is clicked. + */ + onClick: _propTypes.default.func +}; +var _default = previousNextCarouselNavigator; +exports.default = _default; \ No newline at end of file diff --git a/components/checkbox/__docs__/__snapshots__/storybook-stories.storyshot b/components/checkbox/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..46ab0305a4 --- /dev/null +++ b/components/checkbox/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,1886 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSCheckbox Checkbox (assistive text) 1`] = ` +
    +
    +
    +
    + + + + +
    +
    +
    +

    + This example has assistive text. In Safari on Mac you can turn assistive text on by using the keyboard combination: + + Command + F5 + + . +

    +

    + Once you have enabled it, use your tab key to focus on the checkbox input, and the system should read you what is supplied to the checkbox as the + + assistiveText + + property. +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Checkbox (checked) 1`] = ` +
    +
    +
    + + + + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Checkbox (default, indeterminate, required, disabled 1`] = ` +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    + + + * + + + + +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Checkbox (indeterminate) 1`] = ` +
    +
    + + + +

    + + Current State: + + + Indeterminate +

    +
    +
    + + + + +
    +
    +
    +

    + This example has an + + indeterminate + + checkbox. +

    +

    + It is set by providing the + + indeterminate + + prop as + + + + true + + + . +

    +

    + Once it is clicked, there is no way to make it go + + back + + to the indeterminate state, + + + it must be done programatically, through JavaScript + + . +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Checkbox Toggle (assistive text) 1`] = ` +
    +
    +
    + +
    +
    +

    + This example has assistive text. In Safari on Mac you can turn assistive text on by using the keyboard combination: + + Command + F5 + + . +

    +

    + Once you have enabled it, use your tab key to focus on the checkbox input, and the system should read you what is supplied to the checkbox as the + + assistiveText + + property. +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Checkbox Toggle (checked) 1`] = ` +
    +
    + +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Checkbox Toggle (disabled) 1`] = ` +
    +
    + +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Checkbox Toggle (required) 1`] = ` +
    +
    + +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Checkbox Toggle (with error) 1`] = ` +
    +
    + +
    + This field has an error. +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Checkbox Toggle 1`] = ` +
    +
    + +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Doc site Error 1`] = ` +
    +
    +
    +
    +
    + + + + +
    +
    + This field is required +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    + + + * + + + + +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Doc site Snapshot Base 1`] = ` +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    + + + + +
    +
    + This field has an error +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    + + + * + + + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Doc site Snapshot Toggle 1`] = ` +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    + This field has an error +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCheckbox Doc site Toggle 1`] = ` +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    + This field has an error +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +`; diff --git a/components/checkbox/__docs__/site-stories.js b/components/checkbox/__docs__/site-stories.js new file mode 100644 index 0000000000..88317f6c58 --- /dev/null +++ b/components/checkbox/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/checkbox/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/checkbox/__examples__/error.jsx'), require('raw-loader!@salesforce/design-system-react/components/checkbox/__examples__/toggle.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/checkbox/__docs__/storybook-stories.js b/components/checkbox/__docs__/storybook-stories.js new file mode 100644 index 0000000000..a6bcdea7d6 --- /dev/null +++ b/components/checkbox/__docs__/storybook-stories.js @@ -0,0 +1,260 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _ = _interopRequireDefault(require("../")); + +var _button = _interopRequireDefault(require("../../button")); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _error = _interopRequireDefault(require("../__examples__/error")); + +var _snapshotBase = _interopRequireDefault(require("../__examples__/snapshot-base")); + +var _snapshotToggle = _interopRequireDefault(require("../__examples__/snapshot-toggle")); + +var _toggle = _interopRequireDefault(require("../__examples__/toggle")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var CheckboxIndeterminate = +/*#__PURE__*/ +function (_React$Component) { + _inherits(CheckboxIndeterminate, _React$Component); + + function CheckboxIndeterminate() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, CheckboxIndeterminate); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(CheckboxIndeterminate)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + indeterminate: true, + checked: true, + currentStateHelper: 'Indeterminate' + }); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (checked, event, data) { + var checkedLabel = data.checked ? 'Checked' : 'Unchecked'; + + _this.setState({ + checked: data.checked, + currentStateHelper: data.indeterminate ? 'Indeterminate' : checkedLabel, + indeterminate: data.indeterminate + }); + + (0, _addonActions.action)('handleChange')(checked, event, "checked: ".concat(data.checked, ",\n\t\t\tindeterminate: ").concat(data.indeterminate)); + }); + + _defineProperty(_assertThisInitialized(_this), "changeToIndeterminate", function (event) { + _this.setState({ + currentStateHelper: 'Indeterminate', + checked: true, + indeterminate: true + }); + + (0, _addonActions.action)('changeToIndeterminate')(event, 'checked: true, indeterminate: true'); + }); + + _defineProperty(_assertThisInitialized(_this), "changeToCheck", function (event) { + _this.setState({ + currentStateHelper: 'Checked', + checked: true, + indeterminate: false + }); + + (0, _addonActions.action)('changeToCheck')(event, 'checked: true, indeterminate: false'); + }); + + _defineProperty(_assertThisInitialized(_this), "changeToUnChecked", function (event) { + _this.setState({ + currentStateHelper: 'Unchecked', + checked: false, + indeterminate: false + }); + + (0, _addonActions.action)('changeToUnChecked')(event, 'checked: false, indeterminate: false'); + }); + + return _this; + } + + _createClass(CheckboxIndeterminate, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement(_button.default, { + onClick: this.changeToIndeterminate, + label: "Indeterminate" + }), _react.default.createElement(_button.default, { + onClick: this.changeToCheck, + label: "Check" + }), _react.default.createElement(_button.default, { + onClick: this.changeToUnChecked, + label: "Uncheck" + }), _react.default.createElement("p", null, _react.default.createElement("strong", null, "Current State:"), " ", this.state.currentStateHelper), _react.default.createElement(_.default, { + assistiveText: { + label: 'Checkbox (indeterminate)' + }, + id: "checkbox-example-standard-indeterminate", + label: "Checkbox Label", + name: "checkbox-example-standard-indeterminate", + checked: this.state.checked, + indeterminate: this.state.indeterminate, + onChange: this.handleChange + }), _react.default.createElement("div", { + className: "slds-box slds-text-longform slds-m-top_large" + }, _react.default.createElement("p", null, "This example has an ", _react.default.createElement("em", null, "indeterminate"), " checkbox."), _react.default.createElement("p", null, "It is set by providing the ", _react.default.createElement("code", null, "indeterminate"), " prop as", ' ', _react.default.createElement("code", null, _react.default.createElement("strong", null, "true")), "."), _react.default.createElement("p", null, "Once it is clicked, there is no way to make it go ", _react.default.createElement("em", null, "back"), " to the indeterminate state,", ' ', _react.default.createElement("a", { + href: "https://developer.mozilla.org/en-US/docs/Web/CSS/:indeterminate#Checkbox_radio_button" + }, "it must be done programatically, through JavaScript"), "."))); + } + }]); + + return CheckboxIndeterminate; +}(_react.default.Component); + +_defineProperty(CheckboxIndeterminate, "displayName", "".concat(_constants.CHECKBOX, "_INDETERMINATE")); + +(0, _react2.storiesOf)(_constants.CHECKBOX, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Checkbox (default, indeterminate, required, disabled', function () { + return _react.default.createElement(_default.default, null); +}).add('Checkbox (assistive text)', function () { + return _react.default.createElement("div", null, _react.default.createElement(_.default, { + assistiveText: { + label: "This is my checkbox.\n\t\t\t\t\t\t\tThere are many like it, but this one is mine.\n\t\t\t\t\t\t\tMy checkbox is my best friend.\n\t\t\t\t\t\t\tIt is my life.\n\t\t\t\t\t\t\tI must master it as I must master my life.\n\t\t\t\t\t\t\tWithout me, my checkbox is useless. Without my checkbox, I am useless.\n\t\t\t\t\t\t\tI must make my checkbox true.\n\t\t\t\t\t\t\tI must make it truer than my radio button who is trying to... " + }, + id: "checkbox-example-base-assistiveText", + label: "Checkbox Label", + name: "checkbox-example-base-assistiveText", + onChange: (0, _addonActions.action)('change') + }), _react.default.createElement("div", { + className: "slds-box slds-text-longform slds-m-top_large" + }, _react.default.createElement("p", null, "This example has assistive text. In Safari on Mac you can turn assistive text on by using the keyboard combination:", _react.default.createElement("strong", null, "Command + F5"), "."), _react.default.createElement("p", null, "Once you have enabled it, use your tab key to focus on the checkbox input, and the system should read you what is supplied to the checkbox as the ", _react.default.createElement("code", null, "assistiveText"), "property."))); +}).add('Checkbox (checked)', function () { + return _react.default.createElement(_.default, { + checked: true, + id: "checkbox-example-base-checked", + label: "Checkbox Label", + name: "checkbox-example-base-checked", + onChange: (0, _addonActions.action)('change') + }); +}).add('Checkbox (indeterminate)', function () { + return _react.default.createElement(CheckboxIndeterminate, null); +}).add('Checkbox Toggle', function () { + return _react.default.createElement(_.default, { + id: "checkbox-example-toggle", + label: "Checkbox Toggle Label", + name: "checkbox-example-toggle", + onChange: (0, _addonActions.action)('change'), + onBlur: function onBlur(e) { + console.log('bluring ', e.target); + }, + variant: "toggle" + }); +}).add('Checkbox Toggle (with error)', function () { + return _react.default.createElement(_.default, { + id: "checkbox-example-toggle-error", + label: "Checkbox Toggle Label", + name: "checkbox-example-toggle-error", + errorText: "This field has an error.", + onChange: (0, _addonActions.action)('change'), + onBlur: function onBlur(e) { + console.log('bluring ', e.target); + }, + variant: "toggle" + }); +}).add('Checkbox Toggle (required)', function () { + return _react.default.createElement(_.default, { + id: "checkbox-example-toggle-required", + label: "Checkbox Toggle Label", + name: "checkbox-example-toggle-required", + onChange: (0, _addonActions.action)('change'), + onBlur: function onBlur(e) { + console.log('bluring ', e.target); + }, + variant: "toggle", + required: true + }); +}).add('Checkbox Toggle (disabled)', function () { + return _react.default.createElement(_.default, { + id: "checkbox-example-toggle-disabled", + label: "Checkbox Toggle Label", + name: "checkbox-example-toggle-disabled", + onChange: (0, _addonActions.action)('change'), + onBlur: function onBlur(e) { + console.log('bluring ', e.target); + }, + variant: "toggle", + disabled: true + }); +}).add('Checkbox Toggle (assistive text)', function () { + return _react.default.createElement("div", null, _react.default.createElement(_.default, { + assistiveText: { + label: "This is my checkbox.\n\t\t\t\t\t\t\tThere are many like it, but this one is mine.\n\t\t\t\t\t\t\tMy checkbox is my best friend.\n\t\t\t\t\t\t\tIt is my life.\n\t\t\t\t\t\t\tI must master it as I must master my life.\n\t\t\t\t\t\t\tWithout me, my checkbox is useless. Without my checkbox, I am useless.\n\t\t\t\t\t\t\tI must make my checkbox true.\n\t\t\t\t\t\t\tI must make it truer than my radio button who is trying to... " + }, + id: "checkbox-example-base-assistiveText", + label: "Checkbox Label", + name: "checkbox-example-base-assistiveText", + onChange: (0, _addonActions.action)('change'), + variant: "toggle" + }), _react.default.createElement("div", { + className: "slds-box slds-text-longform slds-m-top_large" + }, _react.default.createElement("p", null, "This example has assistive text. In Safari on Mac you can turn assistive text on by using the keyboard combination:", _react.default.createElement("strong", null, "Command + F5"), "."), _react.default.createElement("p", null, "Once you have enabled it, use your tab key to focus on the checkbox input, and the system should read you what is supplied to the checkbox as the ", _react.default.createElement("code", null, "assistiveText"), "property."))); +}).add('Checkbox Toggle (checked)', function () { + return _react.default.createElement(_.default, { + checked: true, + id: "checkbox-example-toggle-checked", + label: "Checkbox Label", + name: "checkbox-example-toggle-checked", + onChange: (0, _addonActions.action)('change'), + variant: "toggle" + }); +}).add('Doc site Error', function () { + return _react.default.createElement(_error.default, null); +}).add('Doc site Snapshot Base', function () { + return _react.default.createElement(_snapshotBase.default, null); +}).add('Doc site Snapshot Toggle', function () { + return _react.default.createElement(_snapshotToggle.default, null); +}).add('Doc site Toggle', function () { + return _react.default.createElement(_toggle.default, null); +}); \ No newline at end of file diff --git a/components/checkbox/__examples__/default.js b/components/checkbox/__examples__/default.js new file mode 100644 index 0000000000..4227b5772d --- /dev/null +++ b/components/checkbox/__examples__/default.js @@ -0,0 +1,120 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _checkbox = _interopRequireDefault(require("../../../../components/checkbox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Default' + }, + id: "checkbox-example", + labels: { + label: 'Default' + }, + onChange: function onChange(e) { + console.log('onChange ', e.target); + } + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Indeterminate' + }, + id: "checkbox-example-indeterminate", + indeterminate: true, + labels: { + label: 'Indeterminate' + }, + onChange: function onChange(e) { + console.log('onChange ', e.target); + } + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Indeterminate' + }, + id: "checkbox-example-required", + labels: { + label: 'Required' + }, + required: true, + onChange: function onChange(e) { + console.log('onChange ', e.target); + } + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Disabled' + }, + id: "checkbox-example-disabled", + labels: { + label: 'Disabled' + }, + disabled: true, + onChange: function onChange(e) { + console.log('onChange ', e.target); + } + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'CheckboxExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/checkbox/__examples__/error.js b/components/checkbox/__examples__/error.js new file mode 100644 index 0000000000..1d3a64d312 --- /dev/null +++ b/components/checkbox/__examples__/error.js @@ -0,0 +1,98 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _checkbox = _interopRequireDefault(require("../../../../components/checkbox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Error state' + }, + errorText: "This field is required", + id: "checkbox-error-example", + label: "Checkbox Label" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Indeterminate' + }, + id: "checkbox-indeterminate-example", + indeterminate: true, + label: "Indeterminate" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Indeterminate' + }, + id: "checkbox-indeterminate-required-example", + label: "Required", + required: true + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Disabled' + }, + id: "checkbox-disabled-example", + label: "Disabled", + disabled: true + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'CheckboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/checkbox/__examples__/snapshot-base.js b/components/checkbox/__examples__/snapshot-base.js new file mode 100644 index 0000000000..5c07ac4866 --- /dev/null +++ b/components/checkbox/__examples__/snapshot-base.js @@ -0,0 +1,109 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _checkbox = _interopRequireDefault(require("../../../../components/checkbox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Checkbox", + id: "checkbox-base-example" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Checkbox", + id: "checkbox-base-example--error", + errorText: "This field has an error" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Checkbox (disabled)", + id: "checkbox-base-example--disabled", + disabled: true + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Checkbox (required)", + id: "checkbox-base-example--required", + required: true + }))), _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Checkbox (with assistive text)' + }, + id: "checkbox-base-example--assistive-text" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Checkbox (checked)", + id: "checkbox-base-example--checked", + checked: true + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Checkbox (checked + disabled)", + id: "checkbox-base-example--checked-disabled", + checked: true, + disabled: true + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Checkbox (indeterminate)", + id: "checkbox-base-example--indeterminate", + indeterminate: true + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'CheckboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/checkbox/__examples__/snapshot-toggle.js b/components/checkbox/__examples__/snapshot-toggle.js new file mode 100644 index 0000000000..a37ca64bb6 --- /dev/null +++ b/components/checkbox/__examples__/snapshot-toggle.js @@ -0,0 +1,110 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _checkbox = _interopRequireDefault(require("../../../../components/checkbox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Toggle", + id: "checkbox-toggle-example", + variant: "toggle" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Toggle", + id: "checkbox-toggle-example--error", + errorText: "This field has an error", + variant: "toggle" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Toggle (disabled)", + id: "checkbox-toggle-example--disabled", + variant: "toggle", + disabled: true + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Toggle (required)", + id: "checkbox-toggle-example--required", + variant: "toggle", + required: true + }))), _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Toggle (with assistive text)' + }, + id: "checkbox-toggle-example--assitive-text", + variant: "toggle" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Toggle (checked)", + id: "checkbox-toggle-example--checked", + variant: "toggle", + checked: true + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + id: "checkbox-toggle-example--checked-disabled", + label: "Toggle (checked + disabled)", + variant: "toggle", + checked: true, + disabled: true + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'CheckboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/checkbox/__examples__/toggle.js b/components/checkbox/__examples__/toggle.js new file mode 100644 index 0000000000..c8d85651a2 --- /dev/null +++ b/components/checkbox/__examples__/toggle.js @@ -0,0 +1,114 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _checkbox = _interopRequireDefault(require("../../../../components/checkbox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Toggle", + id: "checkbox-toggle-example", + variant: "toggle" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Toggle", + id: "checkbox-toggle-example--error", + errorText: "This field has an error", + variant: "toggle" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Toggle (disabled)", + id: "checkbox-toggle-example--disabled", + variant: "toggle", + disabled: true + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Toggle (required)", + id: "checkbox-toggle-example--required", + variant: "toggle", + required: true + }))), _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Toggle (with assistive text)' + }, + id: "checkbox-toggle-example--assitive-text", + variant: "toggle" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + label: "Toggle (checked)", + id: "checkbox-toggle-example--checked", + variant: "toggle", + checked: true + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_checkbox.default, { + id: "checkbox-toggle-example--checked-disabled", + label: "Toggle (checked + disabled)", + variant: "toggle", + checked: true, + disabled: true + }))))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'CheckboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/checkbox/check-props.js b/components/checkbox/check-props.js new file mode 100644 index 0000000000..90c1ac9874 --- /dev/null +++ b/components/checkbox/check-props.js @@ -0,0 +1,44 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _deprecatedEventParameter = _interopRequireDefault(require("../../utilities/warning/deprecated-event-parameter")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +var _onlyOneOfProperties = _interopRequireDefault(require("../../utilities/warning/only-one-of-properties")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ + +/* eslint-disable max-len */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + (0, _deprecatedEventParameter.default)(COMPONENT, { + oldEventParameterOrder: props.oldEventParameterOrder, + propAsString: 'onChange', + propAsValue: props.onChange + }, "`components/forms/checkbox` is deprecated. `components/checkbox` should be used. When this path update is made `onChange` event parameters will change from `onChange(value, event, { value }) to `onChange(event, { value }). Please update your event parameters when you change paths.` If you are using the CommonJS named import, `Checkbox` events will break at v1.0 and this warning will be present until then. Please review https://github.com/salesforce/design-system-react/releases when you upgrade. ".concat(createDocUrl('onChange'))); + + if (props.variant === 'toggle' && props.indeterminate === true) { + (0, _onlyOneOfProperties.default)(COMPONENT, { + variant: props.variant, + indeterminate: props.indeterminate + }, "Currently SLDS does not support the `indeterminate` state in Checkbox Toggle. See SLDS documentation about [Checkbox Toggle](https://lightningdesignsystem.com/components/forms/#flavor-checkbox-toggle-checkbox-toggle) for more information. ".concat(createDocUrl('variant'))); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/checkbox/docs.json b/components/checkbox/docs.json new file mode 100644 index 0000000000..df387b9e13 --- /dev/null +++ b/components/checkbox/docs.json @@ -0,0 +1,11 @@ +{ + "component": "checkbox", + "status": "prod", + "display-name": "Checkboxes", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/checkbox", + "url-slug": "checkboxes" +} \ No newline at end of file diff --git a/components/checkbox/index.js b/components/checkbox/index.js new file mode 100644 index 0000000000..8b816bb921 --- /dev/null +++ b/components/checkbox/index.js @@ -0,0 +1,434 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _keyCode = _interopRequireDefault(require("../../utilities/key-code")); + +var _event = _interopRequireDefault(require("../../utilities/event")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * An HTML ID that is shared with ARIA-supported devices with the + * `aria-controls` attribute in order to relate the input with + * another region of the page. An example would be a select box + * that shows or hides a panel. + */ + 'aria-controls': _propTypes.default.string, + + /** + * The `aria-describedby` attribute is used to indicate the IDs of the elements that describe the object. It is used to establish a relationship between widgets or groups and text that described them. This is very similar to aria-labelledby: a label describes the essence of an object, while a description provides more information that the user might need. + */ + 'aria-describedby': _propTypes.default.string, + + /** + * `aria-owns` indicate that an element depends on the current one when the relation can't be determined by the hierarchy structure. + */ + 'aria-owns': _propTypes.default.string, + + /** + * The `aria-required` attribute is used to indicate that user input is required on an element before a form can be submitted. + */ + 'aria-required': _propTypes.default.bool, + + /** + * **Assistive text for accessibility** + * This object is merged with the default props object on every render. + * * `label`: This is used as a visually hidden label if, no `labels.label` is provided. + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string + }), + + /** + * The Checkbox should be a controlled component, and will always be in the state specified. If checked is not defined, the state of the uncontrolled native `input` component will be used. + */ + checked: _propTypes.default.bool, + + /** + * This is the initial value of an uncontrolled form element and is present only + * to provide compatibility with hybrid framework applications that are not + * entirely React. It should only be used in an application without centralized + * state (Redux, Flux). "Controlled components" with centralized state is highly recommended. See [Code Overview](https://github.com/salesforce/design-system-react/blob/master/docs/codebase-overview.md#controlled-and-uncontrolled-components) for more information. + */ + defaultChecked: _propTypes.default.bool, + + /** + * Class names to be added to the outer container of the Checkbox. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Disables the Checkbox and prevents clicking it. + */ + disabled: _propTypes.default.bool, + + /** + * Message to display when the Checkbox is in an error state. When this is present, also visually highlights the component as in error. + */ + errorText: _propTypes.default.string, + + /** + * A unique ID is needed in order to support keyboard navigation and ARIA support. This ID is added to the `input` element + */ + id: _propTypes.default.string, + + /** + * The Checkbox will be indeterminate if its state can not be figured out or is partially checked. Once a checkbox is indeterminate, a click should cause it to be checked. Since a user cannot put a checkbox into an indeterminate state, it is assumed you are controlling the value of `checked` with the parent, also, and that this is a controlled component. **Note:** `indeterminate` proptype does nothing in the `toggle` variant, as [SLDS does not support it](https://lightningdesignsystem.com/components/forms/#flavor-checkbox-toggle-checkbox-toggle). + */ + indeterminate: _propTypes.default.bool, + + /** + * **Text labels for internationalization** + * This object is merged with the default props object on every render. + * * `label`: Label for the _enabled_ state of the Toggle variant. Defaults to "Enabled". + * * `toggleDisabled`: Label for the _disabled_ state of the Toggle variant. Defaults to "Disabled". Note that this uses SLDS language, and meaning, of "Enabled" and "Disabled"; referring to the state of whatever the checkbox is _toggling_, not whether the checkbox itself is enabled or disabled. + * * `toggleEnabled`: Label for the _enabled_ state of the Toggle variant. Defaults to "Enabled". + */ + labels: _propTypes.default.shape({ + label: _propTypes.default.string, + toggleDisabled: _propTypes.default.string, + toggleEnabled: _propTypes.default.string + }), + + /** + * Name of the submitted form parameter. + */ + name: _propTypes.default.string, + + /** + * This event fires when the Checkbox looses focus. It passes in `{ event }`. + */ + onBlur: _propTypes.default.func, + + /** + * This event fires when the Checkbox changes. Passes in `event, { checked }`. This used to be `checked, event, { checked }`. + */ + onChange: _propTypes.default.func, + + /** + * This event fires when the Checkbox is focused. It passes in `{ event }`. + */ + onFocus: _propTypes.default.func, + + /** + * This event fires when a key is pressed down. It passes in `{ event }`. + */ + onKeyDown: _propTypes.default.func, + + /** + * This event fires when a character is typed. See [this article](http://www.bloggingdeveloper.com/post/KeyPress-KeyDown-KeyUp-The-Difference-Between-Javascript-Key-Events.aspx) for more information. It passes in `{ event }`. + */ + onKeyPress: _propTypes.default.func, + + /** + * This event fires when a pressed key is released. It passes in `{ event }`. + */ + onKeyUp: _propTypes.default.func, + + /** + * Displays the value of the input, but does not allow changes. + */ + readOnly: _propTypes.default.bool, + + /** + * Highlights the Checkbox as a required field (does not perform any validation). + */ + required: _propTypes.default.bool, + + /** + * The aria-role of the checkbox. + */ + role: _propTypes.default.string, + + /** + * Which UX pattern of checkbox? The default is `base` while other option is `toggle`. (**Note:** `toggle` variant does not support the `indeterminate` feature, because [SLDS does not support it](https://lightningdesignsystem.com/components/forms/#flavor-checkbox-toggle-checkbox-toggle).) + */ + variant: _propTypes.default.oneOf(['base', 'toggle', 'button-group']) +}; +var defaultProps = { + assistiveText: {}, + labels: { + toggleDisabled: 'Disabled', + toggleEnabled: 'Enabled' + }, + variant: 'base' +}; +/** + * The ability to style checkboxes with CSS varies across browsers. Using this component ensures checkboxes look the same everywhere. + */ + +var Checkbox = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Checkbox, _React$Component); + + function Checkbox() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Checkbox); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Checkbox)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "getId", function () { + return _this.props.id || _this.generatedId; + }); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (event) { + var _this$props = _this.props, + checked = _this$props.checked, + indeterminate = _this$props.indeterminate, + onChange = _this$props.onChange; + + if (typeof onChange === 'function') { + // `target.checked` is present twice to maintain backwards compatibility. Please remove first parameter `value` on the next breaking change or when `forms/checkbox` is removed. + if (_this.props.oldEventParameterOrder) { + onChange(event.target.checked, event, { + checked: indeterminate ? true : !checked, + indeterminate: false + }); + } else { + // NEW API + onChange(event, { + checked: indeterminate ? true : !checked, + indeterminate: false + }); + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) { + if (event.keyCode) { + if (event.keyCode === _keyCode.default.ENTER || event.keyCode === _keyCode.default.SPACE) { + _event.default.trapImmediate(event); + + _this.handleChange(event); + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "renderButtonGroupVariant", function (props, assistiveText, labels) { + return _react.default.createElement("span", { + className: "slds-button slds-checkbox_button" + }, _react.default.createElement("input", { + "aria-controls": _this.props['aria-controls'], + "aria-describedby": _this.props['aria-describedby'], + "aria-owns": _this.props['aria-owns'], + "aria-required": _this.props['aria-required'], + disabled: props.disabled, + checked: props.checked, + defaultChecked: props.defaultChecked, + id: _this.getId(), + name: props.name, + onBlur: props.onBlur, + onChange: _this.handleChange, + onFocus: props.onFocus, + onKeyDown: props.onKeyDown, + onKeyPress: props.onKeyPress, + onKeyUp: props.onKeyUp, + ref: function ref(component) { + _this.input = component; + }, + role: props.role, + required: props.required, + type: "checkbox" + }), _react.default.createElement("label", { + className: "slds-checkbox_button__label", + htmlFor: _this.getId() + }, _react.default.createElement("span", { + className: "slds-checkbox_faux" + }, labels.label), assistiveText.label ? _react.default.createElement("span", { + className: "slds-assistive-text" + }, assistiveText.label) : null)); + }); + + _defineProperty(_assertThisInitialized(_this), "renderBaseVariant", function (props, assistiveText, labels) { + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-form-element', { + 'is-required': props.required, + 'slds-has-error': props.errorText + }, props.className) + }, _react.default.createElement("div", { + className: "slds-form-element__control" + }, _react.default.createElement("span", { + className: "slds-checkbox" + }, props.required ? _react.default.createElement("abbr", { + className: "slds-required", + title: "required" + }, "*") : null, _react.default.createElement("input", { + "aria-controls": _this.props['aria-controls'], + "aria-describedby": _this.props['aria-describedby'], + "aria-owns": _this.props['aria-owns'], + "aria-required": _this.props['aria-required'], + disabled: props.disabled, + checked: props.checked, + defaultChecked: props.defaultChecked, + id: _this.getId(), + name: props.name, + onBlur: props.onBlur, + onChange: _this.handleChange, + onFocus: props.onFocus, + onKeyDown: props.onKeyDown, + onKeyPress: props.onKeyPress, + onKeyUp: props.onKeyUp, + ref: function ref(component) { + if (component) { + component.indeterminate = props.indeterminate; + } + + _this.input = component; + }, + role: props.role, + required: props.required, + type: "checkbox" + }), _react.default.createElement("label", { + className: "slds-checkbox__label", + htmlFor: _this.getId() + }, _react.default.createElement("span", { + className: "slds-checkbox_faux" + }), labels.label ? _react.default.createElement("span", { + className: "slds-form-element__label" + }, labels.label) : null, assistiveText.label ? _react.default.createElement("span", { + className: "slds-assistive-text" + }, assistiveText.label) : null))), props.errorText ? _react.default.createElement("div", { + className: "slds-form-element__help" + }, props.errorText) : null); + }); + + _defineProperty(_assertThisInitialized(_this), "renderToggleVariant", function (props, assistiveText, labels) { + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-form-element', { + 'is-required': props.required, + 'slds-has-error': props.errorText + }, props.className) + }, _react.default.createElement("label", { + className: "slds-checkbox_toggle slds-grid", + htmlFor: _this.getId() + }, props.required ? _react.default.createElement("abbr", { + className: "slds-required", + title: "required" + }, "*") : null, labels.label ? _react.default.createElement("span", { + className: "slds-form-element__label slds-m-bottom_none" + }, labels.label) : null, assistiveText.label ? _react.default.createElement("span", { + className: "slds-assistive-text" + }, assistiveText.label) : null, _react.default.createElement("input", { + "aria-controls": _this.props['aria-controls'], + "aria-describedby": "".concat(_this.getId(), "-desc"), + "aria-owns": _this.props['aria-owns'], + "aria-required": _this.props['aria-required'], + disabled: props.disabled, + id: _this.getId(), + checked: props.checked, + defaultChecked: props.defaultChecked, + name: props.name, + onBlur: props.onBlur, + onChange: _this.handleChange, + onFocus: props.onFocus, + onKeyDown: props.onKeyDown, + onKeyPress: props.onKeyPress, + onKeyUp: props.onKeyUp, + ref: function ref(component) { + _this.input = component; + }, + role: props.role, + required: props.required, + type: "checkbox" + }), _react.default.createElement("span", { + id: "".concat(_this.getId(), "-desc"), + className: "slds-checkbox_faux_container", + "aria-live": "assertive" + }, _react.default.createElement("span", { + className: "slds-checkbox_faux" + }), _react.default.createElement("span", { + className: "slds-checkbox_on" + }, labels.toggleEnabled), _react.default.createElement("span", { + className: "slds-checkbox_off" + }, labels.toggleDisabled))), props.errorText ? _react.default.createElement("div", { + className: "slds-form-element__help" + }, props.errorText) : null); + }); + + return _this; + } + + _createClass(Checkbox, [{ + key: "componentWillMount", + value: function componentWillMount() { + (0, _checkProps.default)(_constants.CHECKBOX, this.props, _docs.default); + this.generatedId = _shortid.default.generate(); + } + }, { + key: "render", + value: function render() { + var assistiveText = _objectSpread({}, defaultProps.assistiveText, typeof this.props.assistiveText === 'string' ? { + label: this.props.assistiveText + } : {}, _typeof(this.props.assistiveText) === 'object' ? this.props.assistiveText : {}); + + var labels = _objectSpread({}, defaultProps.labels, this.props.label ? { + label: this.props.label + } : {}, this.props.labels); + + var subRenders = { + base: this.renderBaseVariant, + 'button-group': this.renderButtonGroupVariant, + toggle: this.renderToggleVariant + }; + var variantExists = subRenders[this.props.variant]; + return variantExists ? subRenders[this.props.variant](this.props, assistiveText, labels) : subRenders.base(this.props, assistiveText, labels); + } + }]); + + return Checkbox; +}(_react.default.Component); + +Checkbox.displayName = _constants.CHECKBOX; +Checkbox.propTypes = propTypes; +Checkbox.defaultProps = defaultProps; +var _default = Checkbox; +exports.default = _default; \ No newline at end of file diff --git a/components/color-picker/__docs__/__snapshots__/storybook-stories.storyshot b/components/color-picker/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..7a5197b44b --- /dev/null +++ b/components/color-picker/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,2322 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSColorPicker Color Picker Disabled 1`] = ` +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker ColorPicker Menu Open 1`] = ` +
    +
    +
    + +
    + + +
    +
    +
    + +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker Custom Only 1`] = ` +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker Custom Tab Selected 1`] = ` +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker Custom Validator 1`] = ` +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker Default 1`] = ` +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker Doc site Default 1`] = ` +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker Hidden Input 1`] = ` +
    +
    +
    + +
    + +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker Outer Input in Error State 1`] = ` +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +

    + Hex is invalid. Please correct this field. +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker Predefined Colors 1`] = ` +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker Predefined Colors Only 1`] = ` +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker Swatch Only 1`] = ` +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSColorPicker Working Color Input in Error State 1`] = ` +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    +
    +`; diff --git a/components/color-picker/__docs__/site-stories.js b/components/color-picker/__docs__/site-stories.js new file mode 100644 index 0000000000..d39c07770c --- /dev/null +++ b/components/color-picker/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. Keep in mind, some components like `forms/checkbox` will be changed to `forms-checkbox`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/color-picker/__examples__/default.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/color-picker/__docs__/storybook-stories.js b/components/color-picker/__docs__/storybook-stories.js new file mode 100644 index 0000000000..8eedad8974 --- /dev/null +++ b/components/color-picker/__docs__/storybook-stories.js @@ -0,0 +1,184 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _colorPicker = _interopRequireDefault(require("../../color-picker")); + +var _constants = require("../../../utilities/constants"); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +var HEX_REGEX_6_DIGITS = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i; + +var handleChange = function handleChange(event, data) { + var dataAsArray = Object.keys(data).map(function (key) { + return data[key]; + }); + (0, _addonActions.action)('onChange').apply(void 0, [event, data].concat(_toConsumableArray(dataAsArray))); +}; + +var customOuterInputValidator = function customOuterInputValidator(hex) { + return !hex || HEX_REGEX_6_DIGITS.test(hex); +}; + +(0, _react2.storiesOf)(_constants.COLOR_PICKER, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Default', function () { + return _react.default.createElement(_colorPicker.default, { + className: "test_class_name", + events: { + onChange: handleChange + }, + labels: { + label: 'Choose Color' + }, + id: "default-color-picker" + }); +}).add('Custom Only', function () { + return _react.default.createElement(_colorPicker.default, { + events: { + onChange: handleChange + }, + id: "custom-only-color-picker", + labels: { + label: 'Choose Color' + }, + variant: "custom" + }); +}).add('Swatch Only', function () { + return _react.default.createElement(_colorPicker.default, { + events: { + onChange: handleChange + }, + id: "swatch-only-color-picker", + labels: { + label: 'Choose Color' + }, + variant: "swatches" + }); +}).add('Predefined Colors', function () { + return _react.default.createElement(_colorPicker.default, { + events: { + onChange: handleChange + }, + id: "predefined-color-picker", + labels: { + label: 'Choose Color' + }, + swatchColors: ['#000000', '#ff0000', '#00ff00', '#0000ff', '#ffff00', '#ff00ff', '#00ffff', '#ffffff', ''], + value: "#000000" + }); +}).add('Predefined Colors Only', function () { + return _react.default.createElement(_colorPicker.default, { + value: "#000000", + events: { + onChange: handleChange + }, + id: "predefined-only-color-picker", + labels: { + label: 'Choose Color' + }, + swatchColors: ['#000000', '#ff0000', '#00ff00', '#0000ff', '#ffff00', '#ff00ff', '#00ffff', '#ffffff', ''], + variant: "swatches" + }); +}).add('Hidden Input', function () { + return _react.default.createElement(_colorPicker.default, { + events: { + onChange: handleChange + }, + hideInput: true, + id: "hidden-input-color-picker", + labels: { + label: 'Choose Color' + } + }); +}).add('Custom Tab Selected', function () { + return _react.default.createElement(_colorPicker.default, { + defaultSelectedTab: "custom", + events: { + onChange: handleChange + }, + id: "Custom-tab-default-color-picker", + labels: { + label: 'Choose Color' + } + }); +}).add('Outer Input in Error State', function () { + return _react.default.createElement(_colorPicker.default, { + events: { + onChange: handleChange + }, + errorText: "Hex is invalid. Please correct this field.", + id: "outer-input-error-state-color-picker", + labels: { + label: 'Choose Color' + }, + value: "#invalid" + }); +}).add('Working Color Input in Error State', function () { + return _react.default.createElement(_colorPicker.default, { + events: { + onChange: handleChange + }, + errorTextWorkingColor: "Hex is invalid. Please correct this field.", + id: "working-color-error-state-color-picker", + labels: { + label: 'Choose Color' + }, + valueWorking: "#f", + variant: "custom" + }); +}).add('Custom Validator', function () { + return (// Example of a custom validator that support hex color with strictly 6 digits. + _react.default.createElement(_colorPicker.default, { + events: { + onChange: handleChange, + onValidateColor: customOuterInputValidator, + onValidateWorkingColor: customOuterInputValidator + }, + id: "custom-validator-color-picker", + labels: { + label: 'Choose Color' + } + }) + ); +}).add('Color Picker Disabled', function () { + return _react.default.createElement(_colorPicker.default, { + id: "color-picker", + disabled: true, + labels: { + label: 'Choose Color' + } + }); +}).add('ColorPicker Menu Open', function () { + return _react.default.createElement(_colorPicker.default, { + id: "color-picker", + classNameMenu: "test_class_name_menu", + isOpen: true, + labels: { + label: 'Choose Color' + } + }); +}).add('Doc site Default', function () { + return _react.default.createElement(_default.default, null); +}); \ No newline at end of file diff --git a/components/color-picker/__examples__/default.js b/components/color-picker/__examples__/default.js new file mode 100644 index 0000000000..a690b4d95e --- /dev/null +++ b/components/color-picker/__examples__/default.js @@ -0,0 +1,68 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _colorPicker = _interopRequireDefault(require("../../../../components/color-picker")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_colorPicker.default, { + labels: { + label: 'Choose Color' + }, + id: "default-color-picker" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'DatepickerExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/color-picker/check-props.js b/components/color-picker/check-props.js new file mode 100644 index 0000000000..9cc27bf07b --- /dev/null +++ b/components/color-picker/check-props.js @@ -0,0 +1,35 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _componentIsPrototype = _interopRequireDefault(require("../../utilities/warning/component-is-prototype")); + +var _onlyOneOfProperties = _interopRequireDefault(require("../../utilities/warning/only-one-of-properties")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + (0, _componentIsPrototype.default)(COMPONENT); + (0, _onlyOneOfProperties.default)(COMPONENT, { + 'assistiveText.label': props.assistiveText && props.assistiveText.label, + label: props.labels.label + }, createDocUrl('assistiveText')); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/color-picker/docs.json b/components/color-picker/docs.json new file mode 100644 index 0000000000..9a4d26af97 --- /dev/null +++ b/components/color-picker/docs.json @@ -0,0 +1,7 @@ +{ + "component": "color-picker", + "status": "prod", + "display-name": "Color Pickers", + "SLDS-component-path": "/components/color-picker", + "url-slug": "color-picker" +} diff --git a/components/color-picker/index.js b/components/color-picker/index.js new file mode 100644 index 0000000000..751e4f546b --- /dev/null +++ b/components/color-picker/index.js @@ -0,0 +1,629 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _classnames = _interopRequireDefault(require("classnames")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _react = _interopRequireDefault(require("react")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _customColor = _interopRequireDefault(require("./private/custom-color")); + +var _swatch = _interopRequireDefault(require("./private/swatch")); + +var _swatchPicker = _interopRequireDefault(require("./private/swatch-picker")); + +var _button = _interopRequireDefault(require("../button")); + +var _input = _interopRequireDefault(require("../input")); + +var _tabs = _interopRequireDefault(require("../tabs")); + +var _panel = _interopRequireDefault(require("../tabs/panel")); + +var _popover = _interopRequireDefault(require("../popover")); + +var _color = _interopRequireDefault(require("../../utilities/color")); + +var _constants = require("../../utilities/constants"); + +var _docs = _interopRequireDefault(require("./docs.json")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * **Assistive text for accessibility** + * * `label`: Visually hidden label but read out loud by screen readers. + * * `hueSlider`: Instructions for hue selection input + * * `saturationValueGrid`: Instructions for using the grid for saturation + * and value selection + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string, + hueSlider: _propTypes.default.string, + saturationValueGrid: _propTypes.default.string + }), + + /** + * CSS classes to be added to tag with `.slds-color-picker`. Uses `classNames` [API](https://github.com/JedWatson/classnames). _Tested with snapshot testing._ + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * CSS classes to be added to tag with `.slds-popover`. Uses `classNames` [API](https://github.com/JedWatson/classnames). _Tested with snapshot testing._ + */ + classNameMenu: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Unique ID for component. + */ + id: _propTypes.default.string, + + /** + * Disables the input and button. + */ + disabled: _propTypes.default.bool, + + /** + * Message to display when the outer input is in an error state. When this is present, also visually highlights the component as in error. + */ + errorText: _propTypes.default.string, + + /** + * Message to display when the custom tab input is in an error state. When this is present, also visually highlights the component as in error. + */ + errorTextWorkingColor: _propTypes.default.string, + + /** + * Event Callbacks + * * `onChange`: This function is triggered when done is clicked. This function returns `{event, { color: [string] }}`, which is a hex representation of the color. + * * `onClose`: This function is triggered when the menu is closed. This function returns `{event, { trigger, componentWillUnmount }}`. Trigger can have the values `cancel`, `clickOutside`, or `newPopover`. + * * `onOpen`: This function is triggered when the color-picker menu is mounted and added to the DOM. The parameters are `event, { portal: }`. `portal` can be used as a React tree root node. + * * `onRequestClose`: This function is triggered when the user clicks outside the menu or clicks the close button. You will want to define this if color-picker is to be a controlled component. Most of the time you will want to set `isOpen` to `false` when this is triggered unless you need to validate something. + * This function returns `{event, {trigger: [string]}}` where `trigger` is either `cancel` or `clickOutside`. + * * `onRequestOpen`: Function called when the color-picker menu would like show. + * * `onValidateColor`: Function that overwrites default color validator and called when validating HEX color on outer input change. If callback returns false, errorText is shown if set. + * * `onValidateWorkingColor`: Function that overwrites default color validator and called when validating HEX color on custom tab inner input change. If callback returns false, errorTextWorkingColor is shown if set. + * * `onWorkingColorChange`: This function is triggered when working color changes (color inside the custom tab). This function returns `{event, { color: [string] }}`, which is a hex representation of the color. + * _Tested with Mocha framework._ + */ + events: _propTypes.default.shape({ + onChange: _propTypes.default.func, + onClose: _propTypes.default.func, + onOpen: _propTypes.default.func, + onRequestClose: _propTypes.default.func, + onRequestOpen: _propTypes.default.func, + onValidateColor: _propTypes.default.func, + onValidateWorkingColor: _propTypes.default.func, + onWorkingColorChange: _propTypes.default.func + }), + + /** + * By default, dialogs will flip their alignment (such as bottom to top) if they extend beyond a boundary element such as a scrolling parent or a window/viewpoint. `hasStaticAlignment` disables this behavior and allows this component to extend beyond boundary elements. _Not tested._ + */ + hasStaticAlignment: _propTypes.default.bool, + + /** + * Hides the text input + */ + hideInput: _propTypes.default.bool, + + /** + * Popover open state + */ + isOpen: _propTypes.default.bool, + + /** + * **Text labels for internationalization** + * * `blueAbbreviated`: One letter abbreviation of blue color component + * * `cancelButton`: Text for cancel button on popover + * * `customTab`: Text for custom tab of popover + * * `customTabActiveWorkingColorSwatch`: Label for custom tab active working color swatch + * * `customTabTransparentSwatch`: Label for custom tab active transparent swatch + * * `greenAbbreviated`: One letter abbreviation of green color component + * * `hexLabel`: Label for input of hexadecimal color + * * `invalidColor`: Error message when hex color input is invalid + * * `invalidComponent`: Error message when a component input is invalid + * * `label`: An `input` label as for a `form` + * * `redAbbreviated`: One letter abbreviation of red color component + * * `swatchTab`: Label for swatch tab of popover + * * `submitButton`: Text for submit/done button of popover + */ + labels: _propTypes.default.shape({ + blueAbbreviated: _propTypes.default.string, + cancelButton: _propTypes.default.string, + customTab: _propTypes.default.string, + customTabActiveWorkingColorSwatch: _propTypes.default.string, + customTabTransparentSwatch: _propTypes.default.string, + greenAbbreviated: _propTypes.default.string, + hexLabel: _propTypes.default.string, + invalidColor: _propTypes.default.string, + invalidComponent: _propTypes.default.string, + label: _propTypes.default.string, + redAbbreviated: _propTypes.default.string, + swatchTab: _propTypes.default.string, + swatchTabTransparentSwatch: _propTypes.default.string, + submitButton: _propTypes.default.string + }), + + /** + * Please select one of the following: + * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog. + * * `overflowBoundaryElement` - The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree. + * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing. + */ + menuPosition: _propTypes.default.oneOf(['absolute', 'overflowBoundaryElement', 'relative']), + + /** + * An array of hex color values which is used to set the options of the + * swatch tab of the colorpicker popover. + * To specify transparent, use empty string as a value. + */ + swatchColors: _propTypes.default.arrayOf(_propTypes.default.string), + + /** + * Determines which tab is visible when dialog opens. Use this prop with `base` variant only. + * Defaults to `swatch` tab. + */ + defaultSelectedTab: _propTypes.default.oneOf(['swatches', 'custom']), + + /** + * Selects which tabs are present for the colorpicker. + * * `base`: both swatches and custom tabs are present + * * `swatches`: only swatch tab is present + * * `custom`: only custom tab is present + * _Tested with snapshot testing._ + */ + variant: _propTypes.default.oneOf(['base', 'swatches', 'custom']), + + /** + * Current color in hexadecimal string, including # sign (eg: "#000000") + */ + value: _propTypes.default.string, + + /** + * Current working color in hexadecimal string, including # sign (eg: "#000000") + */ + valueWorking: _propTypes.default.string +}; +var defaultProps = { + assistiveText: { + saturationValueGrid: 'Use arrow keys to select a saturation and brightness, on an x and y axis.', + hueSlider: 'Select Hue' + }, + events: {}, + labels: { + blueAbbreviated: 'B', + cancelButton: 'Cancel', + customTab: 'Custom', + customTabActiveWorkingColorSwatch: 'Working Color', + customTabTransparentSwatch: 'Transparent Swatch', + greenAbbreviated: 'G', + hexLabel: 'Hex', + invalidColor: 'The color entered is invalid', + invalidComponent: 'The value needs to be an integer from 0-255', + redAbbreviated: 'R', + submitButton: 'Done', + swatchTab: 'Default', + swatchTabTransparentSwatch: 'Transparent Swatch' + }, + menuPosition: 'absolute', + swatchColors: ['#e3abec', '#c2dbf7', '#9fd6ff', '#9de7da', '#9df0c0', '#fff099', '#fed49a', '#d073e0', '#86baf3', '#5ebbff', '#44d8be', '#3be282', '#ffe654', '#ffb758', '#bd35bd', '#5779c1', '#5679c0', '#00aea9', '#3cba4c', '#f5bc25', '#f99221', '#580d8c', '#001970', '#0a2399', '#0b7477', '#0b6b50', '#b67e11', '#b85d0d', ''], + defaultSelectedTab: 'swatches', + variant: 'base' +}; +/** + * The Unified Color Picker component allows for a fully accessible and configurable color picker, allowing the user to pick from a set of predefined colors (swatches), or to pick a custom color using a HSB selection interface. It can be configured to show one or both of those color selection interfaces. View [component blueprint guidelines](https://lightningdesignsystem.com/components/color-picker/). + */ + +var ColorPicker = +/*#__PURE__*/ +function (_React$Component) { + _inherits(ColorPicker, _React$Component); + + function ColorPicker(props) { + var _this; + + _classCallCheck(this, ColorPicker); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(ColorPicker).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "handleSwatchChange", function (event) { + _this.setWorkingColor(event, { + hex: event.target.value + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleOnRequestClose", function (event, _ref) { + var trigger = _ref.trigger; + + if (trigger === 'clickOutside' || trigger === 'cancel') { + _this.handleCancelState(); + } + + if (_this.props.onRequestClose) { + _this.props.onRequestClose(event, { + trigger: trigger + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleClickOutside", function (event) { + _this.handleCancelButtonClick(event); + }); + + _defineProperty(_assertThisInitialized(_this), "handleCancel", function (event) { + _this.handleCancelState(); + + if (_this.props.onRequestClose) { + _this.props.onRequestClose(event, { + trigger: 'cancel' + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleCancelState", function () { + var workingColor = _color.default.getNewColor({ + hex: _this.state.currentColor + }, _this.props.events.onValidateWorkingColor); + + _this.setState({ + isOpen: false, + workingColor: workingColor, + previousWorkingColor: workingColor + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleHexInputChange", function (event, _ref2) { + var labels = _ref2.labels; + var currentColor = event.target.value; + var isValid = _this.props.events.onValidateColor ? _this.props.events.onValidateColor(event.target.value) : _color.default.isValidHex(event.target.value); + + _this.setState({ + currentColor: currentColor, + workingColor: _color.default.getNewColor({ + hex: currentColor + }, _this.props.events.onValidateWorkingColor), + colorErrorMessage: isValid ? '' : labels.invalidColor + }); + + if (_this.props.events.onChange) { + _this.props.events.onChange(event, { + color: currentColor, + isValid: isValid + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleSaturationValueChange", function (event, _ref3) { + var saturation = _ref3.saturation, + value = _ref3.value; + + _this.setWorkingColor(event, { + saturation: saturation, + value: value + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleSubmitButtonClick", function (event) { + _this.setState({ + isOpen: false, + currentColor: _this.state.workingColor.hex, + colorErrorMessage: '' + }); + + if (_this.props.events.onChange) { + _this.props.events.onChange(event, { + color: _this.state.workingColor.hex, + isValid: true + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleSwatchButtonClick", function () { + var workingColor = _color.default.getNewColor({ + hex: _this.state.workingColor.hex + }, _this.props.events.onValidateWorkingColor); + + _this.setState({ + isOpen: !_this.state.isOpen, + workingColor: workingColor, + previousWorkingColor: _this.state.previousWorkingColor + }); + + if (_this.props.onRequestOpen) { + _this.props.onRequestOpen(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleSwatchSelect", function (event, _ref4) { + var hex = _ref4.hex; + + _this.setWorkingColor(event, { + hex: hex + }); + }); + + _this.generatedId = _this.props.id || _shortid.default.generate(); + + var _workingColor = _color.default.getNewColor({ + hex: _this.props.valueWorking || _this.props.value + }, _this.props.events.onValidateWorkingColor); + + _this.state = { + currentColor: _this.props.value != null ? _this.props.value : '', + disabled: _this.props.disabled, + isOpen: _this.props.isOpen, + workingColor: _workingColor, + previousWorkingColor: _workingColor, + colorErrorMessage: _this.props.errorText + }; + return _this; + } + + _createClass(ColorPicker, [{ + key: "componentWillMount", + value: function componentWillMount() { + (0, _checkProps.default)(_constants.COLOR_PICKER, this.props, _docs.default); + } // use getDerivedStateFromProps when available + + }, { + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + var nextState = {}; + + if (nextProps.value) { + nextState.currentColor = nextProps.value; + } + + if (nextProps.valueWorking) { + nextState.workingColor = _color.default.getNewColor({ + hex: nextProps.valueWorking + }, this.props.events.onValidateWorkingColor); + } + + if (nextProps.disabled !== undefined) { + nextState.disabled = nextProps.disabled; + } + + this.setState(nextState); + } + }, { + key: "getInput", + value: function getInput(_ref5) { + var _this2 = this; + + var labels = _ref5.labels; + return this.props.hideInput ? null : _react.default.createElement(_input.default, { + "aria-describedby": "color-picker-summary-error-".concat(this.generatedId), + className: (0, _classnames.default)('slds-color-picker__summary-input', 'slds-align-top', { + 'slds-has-error': !!this.state.colorErrorMessage + }), + disabled: this.props.disabled, + id: "color-picker-summary-input-".concat(this.generatedId), + onChange: function onChange(event) { + _this2.handleHexInputChange(event, { + labels: labels + }); + }, + value: this.state.currentColor + }); + } + }, { + key: "getDefaultTab", + value: function getDefaultTab(_ref6) { + var labels = _ref6.labels; + return (this.props.variant === 'base' || this.props.variant === 'swatches') && _react.default.createElement(_panel.default, { + label: labels.swatchTab + }, _react.default.createElement(_swatchPicker.default, { + color: this.state.workingColor, + labels: labels, + onSelect: this.handleSwatchSelect, + swatchColors: this.props.swatchColors + })); + } + }, { + key: "getCustomTab", + value: function getCustomTab(_ref7) { + var labels = _ref7.labels; + return (this.props.variant === 'base' || this.props.variant === 'custom') && _react.default.createElement(_panel.default, { + label: labels.customTab + }, _react.default.createElement(_customColor.default, { + assistiveText: this.props.assistiveText, + id: this.generatedId, + color: this.state.workingColor, + errorTextWorkingColor: this.props.errorTextWorkingColor, + previousColor: this.state.previousWorkingColor, + labels: labels, + onBlueChange: this.handleColorChange('blue'), + onGreenChange: this.handleColorChange('green'), + onHexChange: this.handleColorChange('hex'), + onHueChange: this.handleColorChange('hue'), + onRedChange: this.handleColorChange('red'), + onSwatchChange: this.handleSwatchChange, + onSaturationValueChange: this.handleSaturationValueChange, + onSaturationNavigate: this.handleNavigate('saturation'), + onValueNavigate: this.handleNavigate('value') + })); + } + }, { + key: "getPopover", + value: function getPopover(_ref8) { + var labels = _ref8.labels; + + var popoverBody = _react.default.createElement(_tabs.default, { + id: "color-picker-tabs-".concat(this.generatedId), + defaultSelectedIndex: this.props.defaultSelectedTab === 'custom' ? 1 : 0 + }, this.getDefaultTab({ + labels: labels + }), this.getCustomTab({ + labels: labels + })); + + var popoverFooter = _react.default.createElement("div", { + className: "slds-color-picker__selector-footer" + }, _react.default.createElement(_button.default, { + className: "slds-color-picker__selector-cancel", + id: "color-picker-footer-cancel-".concat(this.generatedId), + label: labels.cancelButton, + onClick: this.handleCancel, + variant: "neutral" + }), _react.default.createElement(_button.default, { + className: "slds-color-picker__selector-submit", + disabled: Object.keys(this.state.workingColor.errors || {}).length > 0, + id: "color-picker-footer-submit-".concat(this.generatedId), + label: labels.submitButton, + onClick: this.handleSubmitButtonClick, + variant: "brand" + })); + + return _react.default.createElement(_popover.default, { + ariaLabelledby: "color-picker-label-".concat(this.generatedId), + align: "bottom left", + body: popoverBody, + className: (0, _classnames.default)('slds-color-picker__selector', this.props.classNameMenu), + footer: popoverFooter, + hasStaticAlignment: this.props.hasStaticAlignment, + id: "slds-color-picker__selector-".concat(this.generatedId), + isOpen: this.state.isOpen, + onClose: this.props.onClose, + onOpen: this.props.onOpen, + onRequestClose: this.handleOnRequestClose, + position: this.props.menuPosition + }, _react.default.createElement(_button.default, { + className: "slds-color-picker__summary-button", + disabled: this.props.disabled, + iconClassName: "slds-m-left_xx-small", + iconPosition: "right", + iconVariant: "more", + id: "slds-color-picker__summary-button-".concat(this.generatedId), + label: _react.default.createElement(_swatch.default, { + color: this.state.currentColor, + labels: labels + }), + onClick: this.handleSwatchButtonClick, + variant: "icon" + })); + } + }, { + key: "setWorkingColor", + value: function setWorkingColor(event, color) { + var newColor = _color.default.getNewColor(color, this.props.events.onValidateWorkingColor, this.state.workingColor); + + this.setState({ + workingColor: newColor, + previousWorkingColor: this.state.workingColor + }); + + if (this.props.events.onWorkingColorChange) { + this.props.events.onWorkingColorChange(event, { + color: newColor + }); + } + } + }, { + key: "handleColorChange", + value: function handleColorChange(property) { + var _this3 = this; + + return function (event) { + var colorProperties = {}; + colorProperties[property] = event.target.value; + + _this3.setWorkingColor(event, colorProperties); + }; + } + }, { + key: "handleNavigate", + value: function handleNavigate(property) { + var _this4 = this; + + return function (event, _ref9) { + var delta = _ref9.delta; + var colorProperties = {}; + colorProperties[property] = delta; + + var newColor = _color.default.getDeltaColor(colorProperties, _this4.props.events.onValidateWorkingColor, _this4.state.workingColor); + + _this4.setState({ + workingColor: newColor, + previousWorkingColor: _this4.state.workingColor + }); + + if (_this4.props.events.onWorkingColorChange) { + _this4.props.events.onWorkingColorChange(event, { + color: newColor + }); + } + }; + } + }, { + key: "render", + value: function render() { + var _this5 = this; + + var labels = (0, _lodash.default)({}, defaultProps.labels, this.props.labels); + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-color-picker', this.props.className), + ref: function ref(node) { + _this5.wrapper = node; + } + }, _react.default.createElement("div", { + className: "slds-color-picker__summary" + }, _react.default.createElement("label", { + className: (0, _classnames.default)('slds-color-picker__summary-label', this.props.assistiveText.label ? 'slds-assistive-text' : ''), + htmlFor: "color-picker-summary-input-".concat(this.generatedId), + id: "color-picker-label-".concat(this.generatedId) + }, this.props.assistiveText.label ? this.props.assistiveText.label : labels.label), this.getPopover({ + labels: labels + }), this.getInput({ + labels: labels + }), !this.state.isOpen && this.state.colorErrorMessage ? _react.default.createElement("p", { + className: "slds-form-error", + id: "color-picker-summary-error-".concat(this.generatedId) + }, this.state.colorErrorMessage) : '')); + } + }]); + + return ColorPicker; +}(_react.default.Component); + +_defineProperty(ColorPicker, "displayName", _constants.COLOR_PICKER); + +_defineProperty(ColorPicker, "propTypes", propTypes); + +_defineProperty(ColorPicker, "defaultProps", defaultProps); + +var _default = ColorPicker; +exports.default = _default; \ No newline at end of file diff --git a/components/color-picker/private/custom-color-form.js b/components/color-picker/private/custom-color-form.js new file mode 100644 index 0000000000..57f1cb5707 --- /dev/null +++ b/components/color-picker/private/custom-color-form.js @@ -0,0 +1,102 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _input = _interopRequireDefault(require("../../input")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var CustomColorForm = +/*#__PURE__*/ +function (_React$Component) { + _inherits(CustomColorForm, _React$Component); + + function CustomColorForm() { + _classCallCheck(this, CustomColorForm); + + return _possibleConstructorReturn(this, _getPrototypeOf(CustomColorForm).apply(this, arguments)); + } + + _createClass(CustomColorForm, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + className: "slds-color-picker__custom-inputs" + }, _react.default.createElement(_input.default, { + "aria-describedby": "color-picker-custom-error-".concat(this.props.id), + className: (0, _classnames.default)('slds-color-picker__input-custom-hex', { + 'slds-has-error': this.props.color.errors && this.props.color.errors.hex + }), + id: "color-picker-input-hex-".concat(this.props.id), + label: this.props.labels.hexLabel, + maxLength: "7", + onChange: this.props.onHexChange, + value: this.props.color.hex + }), _react.default.createElement(_input.default, { + "aria-describedby": "color-picker-custom-error-".concat(this.props.id), + className: (0, _classnames.default)('slds-color-picker__input-custom-r', { + 'slds-has-error': this.props.color.errors && this.props.color.errors.red + }), + id: "color-picker-input-r-".concat(this.props.id), + label: this.props.labels.redAbbreviated, + onChange: this.props.onRedChange, + maxLength: "3", + value: String(this.props.color.rgb.red) + }), _react.default.createElement(_input.default, { + "aria-describedby": "color-picker-custom-error-".concat(this.props.id), + className: (0, _classnames.default)('slds-color-picker__input-custom-g', { + 'slds-has-error': this.props.color.errors && this.props.color.errors.green + }), + id: "color-picker-input-g-".concat(this.props.id), + label: this.props.labels.greenAbbreviated, + onChange: this.props.onGreenChange, + maxLength: "3", + value: String(this.props.color.rgb.green) + }), _react.default.createElement(_input.default, { + "aria-describedby": "color-picker-custom-error-".concat(this.props.id), + className: (0, _classnames.default)('slds-color-picker__input-custom-b', { + 'slds-has-error': this.props.color.errors && this.props.color.errors.blue + }), + id: "color-picker-input-b-".concat(this.props.id), + label: this.props.labels.blueAbbreviated, + onChange: this.props.onBlueChange, + maxLength: "3", + value: String(this.props.color.rgb.blue) + })); + } + }]); + + return CustomColorForm; +}(_react.default.Component); + +_defineProperty(CustomColorForm, "displayName", 'SLDSCustomColorForm'); + +var _default = CustomColorForm; +exports.default = _default; \ No newline at end of file diff --git a/components/color-picker/private/custom-color.js b/components/color-picker/private/custom-color.js new file mode 100644 index 0000000000..f556b783c8 --- /dev/null +++ b/components/color-picker/private/custom-color.js @@ -0,0 +1,97 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _customColorForm = _interopRequireDefault(require("./custom-color-form")); + +var _hsvColor = _interopRequireDefault(require("./hsv-color")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// using state to manage everything in here because multiple HSV coordinates +// can map to a single RGB coordinate and we lose that if we're always passing +// in a hex color +var CustomColor = +/*#__PURE__*/ +function (_React$Component) { + _inherits(CustomColor, _React$Component); + + function CustomColor() { + _classCallCheck(this, CustomColor); + + return _possibleConstructorReturn(this, _getPrototypeOf(CustomColor).apply(this, arguments)); + } + + _createClass(CustomColor, [{ + key: "render", + value: function render() { + var errorText; + + if (this.props.errorTextWorkingColor) { + errorText = this.props.errorTextWorkingColor; + } else if (this.props.color.errors && this.props.color.errors.hex) { + errorText = this.props.labels.invalidColor; + } else { + errorText = this.props.labels.invalidComponent; + } + + return _react.default.createElement("div", { + className: "slds-color-picker__custom" + }, _react.default.createElement(_hsvColor.default, { + assistiveText: this.props.assistiveText, + color: this.props.color, + id: this.props.id, + labels: this.props.labels, + onHueChange: this.props.onHueChange, + onSaturationValueChange: this.props.onSaturationValueChange, + onSaturationNavigate: this.props.onSaturationNavigate, + onValueNavigate: this.props.onValueNavigate, + onSwatchChange: this.props.onSwatchChange, + previousColor: this.props.previousColor + }), _react.default.createElement(_customColorForm.default, { + color: this.props.color, + id: this.props.id, + labels: this.props.labels, + onBlueChange: this.props.onBlueChange, + onGreenChange: this.props.onGreenChange, + onHexChange: this.props.onHexChange, + onRedChange: this.props.onRedChange + }), this.props.errorTextWorkingColor || this.props.color.errors ? _react.default.createElement("p", { + className: "slds-form-error slds-color-picker__input-custom-error", + id: "color-picker-custom-error-".concat(this.props.id) + }, errorText) : ''); + } + }]); + + return CustomColor; +}(_react.default.Component); + +_defineProperty(CustomColor, "displayName", 'SLDSCustomColor'); + +var _default = CustomColor; +exports.default = _default; \ No newline at end of file diff --git a/components/color-picker/private/hsv-color.js b/components/color-picker/private/hsv-color.js new file mode 100644 index 0000000000..ad3a472454 --- /dev/null +++ b/components/color-picker/private/hsv-color.js @@ -0,0 +1,220 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _keyCode = _interopRequireDefault(require("../../../utilities/key-code")); + +var _radioButtonGroup = _interopRequireDefault(require("../../../components/radio-button-group")); + +var _radio = _interopRequireDefault(require("../../../components/radio-button-group/radio")); + +var _color = _interopRequireDefault(require("../../../utilities/color")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var handleClick = function handleClick(event, rangeIndicator, _ref) { + var onSaturationValueChange = _ref.onSaturationValueChange; + var rect = event.currentTarget.getBoundingClientRect(); + rangeIndicator.focus(); + onSaturationValueChange(event, { + saturation: Math.round((event.clientX - rect.left) / rect.width * 100), + value: Math.round((rect.bottom - event.clientY) / rect.height * 100) + }); +}; + +var handleKeyDown = function handleKeyDown(event, _ref2) { + var _keyDownCallbacks; + + var onSaturationNavigate = _ref2.onSaturationNavigate, + onValueNavigate = _ref2.onValueNavigate; + var keyDownCallbacks = (_keyDownCallbacks = {}, _defineProperty(_keyDownCallbacks, _keyCode.default.LEFT, function (multiplier) { + onSaturationNavigate(event, { + delta: multiplier * -1 + }); + }), _defineProperty(_keyDownCallbacks, _keyCode.default.RIGHT, function (multiplier) { + onSaturationNavigate(event, { + delta: multiplier + }); + }), _defineProperty(_keyDownCallbacks, _keyCode.default.UP, function (multiplier) { + onValueNavigate(event, { + delta: multiplier + }); + }), _defineProperty(_keyDownCallbacks, _keyCode.default.DOWN, function (multiplier) { + onValueNavigate(event, { + delta: multiplier * -1 + }); + }), _keyDownCallbacks); + + if (keyDownCallbacks[event.keyCode]) { + event.preventDefault(); + keyDownCallbacks[event.keyCode](event.shiftKey ? 10 : 1); + } +}; + +var selectedStyle = { + border: '1px solid #9e9e9e', + boxShadow: 'rgb(117, 112, 112) 1px 1px 1px', + marginRight: '2px' +}; +var unselectedStyle = { + border: '1px solid #9e9e9e', + marginRight: '2px' +}; + +var HsvColor = +/*#__PURE__*/ +function (_React$Component) { + _inherits(HsvColor, _React$Component); + + function HsvColor() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, HsvColor); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(HsvColor)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "handleSwatchChange", function (event) { + _this.setState({ + isTransparentSelected: event.target.value === '' + }); + + _this.props.onSwatchChange(event); + }); + + _defineProperty(_assertThisInitialized(_this), "isTransparent", function () { + return _this.props.color.hex === ''; + }); + + return _this; + } + + _createClass(HsvColor, [{ + key: "render", + value: function render() { + var _this2 = this; + + var style = { + border: 'none', + borderRadius: 'unset' + }; + var swatchStyle = this.isTransparent() ? _objectSpread({}, unselectedStyle) : _objectSpread({}, selectedStyle); + var transparentSwatchStyle = this.isTransparent() ? _objectSpread({}, selectedStyle) : _objectSpread({}, unselectedStyle); // when working color is transparent: either use the previous color or default to black + + var fallbackWorkingColor = this.props.previousColor.hex ? this.props.previousColor : _color.default.getNewColor({ + hex: '#000000' + }); + var workingColor = this.isTransparent() ? fallbackWorkingColor : this.props.color; + return _react.default.createElement("div", null, _react.default.createElement("p", { + className: "slds-assistive-text", + id: "color-picker-instructions-".concat(this.props.id) + }, this.props.assistiveText.saturationValueGrid), _react.default.createElement("div", { + className: "slds-color-picker__custom-range", + style: { + background: "hsl(".concat(workingColor.hsv.hue, ", 100%, 50%)") + }, + onClick: function onClick(event) { + handleClick(event, _this2.rangeIndicator, { + onSaturationValueChange: _this2.props.onSaturationValueChange + }); + }, + role: "presentation" + }, _react.default.createElement("a", { + "aria-atomic": "true", + "aria-describedby": "color-picker-instructions-".concat(this.props.id), + "aria-live": "assertive", + className: "slds-color-picker__range-indicator", + onKeyDown: function onKeyDown(event) { + handleKeyDown(event, _objectSpread({}, _this2.props)); + }, + ref: function ref(rangeIndicator) { + _this2.rangeIndicator = rangeIndicator; + }, + role: "button", + style: { + bottom: "".concat(workingColor.hsv.value, "%"), + left: "".concat(workingColor.hsv.saturation, "%") + }, + tabIndex: 0 + }, _react.default.createElement("span", { + className: "slds-assistive-text" + }, "Saturation ".concat(workingColor.hsv.saturation, "% Brightness: ").concat(workingColor.hsv.value, "%")))), _react.default.createElement("div", { + className: "slds-color-picker__hue-and-preview" + }, _react.default.createElement("label", { + className: "slds-assistive-text", + htmlFor: "color-picker-input-range-".concat(this.props.id) + }, this.props.assistiveText.hueSlider), _react.default.createElement("input", { + type: "range", + min: "0", + max: "360", + className: "slds-color-picker__hue-slider", + id: "color-picker-input-range-".concat(this.props.id), + value: workingColor.hsv.hue, + onChange: this.props.onHueChange + }), _react.default.createElement(_radioButtonGroup.default, { + name: "".concat(this.props.id, "-color-picker-swatch-toggle-button-group"), + assistiveText: { + label: 'Toggle Transparency' + }, + style: style, + onChange: this.handleSwatchChange + }, _react.default.createElement(_radio.default, { + checked: !this.isTransparent(), + id: "color-picker-active-working-color-swatch-".concat(this.props.id), + key: "working-color", + label: this.props.labels.customTabActiveWorkingColorSwatch, + style: swatchStyle, + value: workingColor.hex, + variant: "swatch" + }), _react.default.createElement(_radio.default, { + checked: this.isTransparent(), + id: "color-picker-transparent-swatch-".concat(this.props.id), + key: "transparent", + label: this.props.labels.customTabTransparentSwatch, + style: transparentSwatchStyle, + value: "" // transparent + , + variant: "swatch" + })))); + } + }]); + + return HsvColor; +}(_react.default.Component); + +_defineProperty(HsvColor, "displayName", 'SLDSHsvColor'); + +var _default = HsvColor; +exports.default = _default; \ No newline at end of file diff --git a/components/color-picker/private/swatch-option.js b/components/color-picker/private/swatch-option.js new file mode 100644 index 0000000000..705b5f9533 --- /dev/null +++ b/components/color-picker/private/swatch-option.js @@ -0,0 +1,94 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _swatch = _interopRequireDefault(require("./swatch")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var handleClick = function handleClick(event, _ref) { + var hex = _ref.hex, + onSelect = _ref.onSelect; + event.preventDefault(); + onSelect(event, { + hex: hex + }); +}; + +var selectedStyle = { + border: '1px solid #9e9e9e', + boxShadow: 'rgb(117, 112, 112) 1px 1px 1px', + margin: '3px' +}; + +var SwatchOption = +/*#__PURE__*/ +function (_React$Component) { + _inherits(SwatchOption, _React$Component); + + function SwatchOption() { + _classCallCheck(this, SwatchOption); + + return _possibleConstructorReturn(this, _getPrototypeOf(SwatchOption).apply(this, arguments)); + } + + _createClass(SwatchOption, [{ + key: "render", + value: function render() { + var _this = this; + + return _react.default.createElement("li", { + className: "slds-color-picker__swatch", + style: this.props.workingColor && this.props.workingColor.hex === this.props.color ? selectedStyle : {}, + role: "presentation" + }, _react.default.createElement("a", { + "aria-selected": this.props.workingColor && this.props.workingColor.hex === this.props.color, + className: "slds-color-picker__swatch-trigger", + onClick: function onClick(event) { + handleClick(event, { + hex: _this.props.color, + onSelect: _this.props.onSelect + }); + }, + ref: this.props.swatchOptionRef, + role: "option", + tabIndex: this.props.tabIndex + }, _react.default.createElement(_swatch.default, { + color: this.props.color, + labels: this.props.labels + }))); + } + }]); + + return SwatchOption; +}(_react.default.Component); + +_defineProperty(SwatchOption, "displayName", 'SLDSSwatchOption'); + +var _default = SwatchOption; +exports.default = _default; \ No newline at end of file diff --git a/components/color-picker/private/swatch-picker.js b/components/color-picker/private/swatch-picker.js new file mode 100644 index 0000000000..0ab6c1ebfb --- /dev/null +++ b/components/color-picker/private/swatch-picker.js @@ -0,0 +1,153 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _lodash = _interopRequireDefault(require("lodash.findindex")); + +var _swatchOption = _interopRequireDefault(require("./swatch-option")); + +var _keyCode = _interopRequireDefault(require("../../../utilities/key-code")); + +var _event = _interopRequireDefault(require("../../../utilities/event")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var SwatchPicker = +/*#__PURE__*/ +function (_React$Component) { + _inherits(SwatchPicker, _React$Component); + + function SwatchPicker(_props) { + var _this; + + _classCallCheck(this, SwatchPicker); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(SwatchPicker).call(this, _props)); + + _defineProperty(_assertThisInitialized(_this), "selectPreviousColor", function (event, props) { + var index = (0, _lodash.default)(props.swatchColors, function (item) { + return item === props.color.hex; + }); + var nextIndex = index === -1 || index === props.swatchColors.length - 1 ? 0 : index + 1; + var prevColor = props.swatchColors[nextIndex]; + props.onSelect(event, { + hex: prevColor + }); + + _this.swatchColorRefs[prevColor].focus(); + }); + + _defineProperty(_assertThisInitialized(_this), "selectNextColor", function (event, props) { + var index = (0, _lodash.default)(props.swatchColors, function (item) { + return item === props.color.hex; + }); + var prevIndex; + + if (index === 0) { + prevIndex = props.swatchColors.length - 1; + } else if (index === -1) { + prevIndex = 0; + } else { + prevIndex = index - 1; + } + + var nextColor = props.swatchColors[prevIndex]; + props.onSelect(event, { + hex: nextColor + }); + + _this.swatchColorRefs[nextColor].focus(); + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event, props) { + var _keyDownCallbacks; + + var keyDownCallbacks = (_keyDownCallbacks = {}, _defineProperty(_keyDownCallbacks, _keyCode.default.RIGHT, function () { + _this.selectPreviousColor(event, props); + }), _defineProperty(_keyDownCallbacks, _keyCode.default.DOWN, function () { + _this.selectPreviousColor(event, props); + }), _defineProperty(_keyDownCallbacks, _keyCode.default.LEFT, function () { + _this.selectNextColor(event, props); + }), _defineProperty(_keyDownCallbacks, _keyCode.default.UP, function () { + _this.selectNextColor(event, props); + }), _keyDownCallbacks); + + if (event.keyCode) { + if (keyDownCallbacks[event.keyCode]) { + _event.default.trapEvent(event); + + keyDownCallbacks[event.keyCode](); + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "addRef", function (color) { + return function (el) { + _this.swatchColorRefs[color] = el; + }; + }); + + _this.swatchColorRefs = {}; + return _this; + } + + _createClass(SwatchPicker, [{ + key: "render", + value: function render() { + var _this2 = this; + + var isSelectedColorInSwatch = this.props.swatchColors.includes(this.props.color.hex); + return _react.default.createElement("ul", { + className: "slds-color-picker__swatches", + role: "listbox", + onKeyDown: function onKeyDown(event) { + _this2.handleKeyDown(event, _objectSpread({}, _this2.props)); + } + }, this.props.swatchColors.map(function (color, index) { + return _react.default.createElement(_swatchOption.default, { + color: color, + key: color, + labels: _this2.props.labels, + onSelect: _this2.props.onSelect, + swatchOptionRef: _this2.addRef(color), + workingColor: _this2.props.color, + tabIndex: _this2.props.color && _this2.props.color.hex === color || index === 0 && !isSelectedColorInSwatch ? 0 : -1 + }); + })); + } + }]); + + return SwatchPicker; +}(_react.default.Component); + +_defineProperty(SwatchPicker, "displayName", 'SLDSSwatchPicker'); + +var _default = SwatchPicker; +exports.default = _default; \ No newline at end of file diff --git a/components/color-picker/private/swatch.js b/components/color-picker/private/swatch.js new file mode 100644 index 0000000000..550ed3cc61 --- /dev/null +++ b/components/color-picker/private/swatch.js @@ -0,0 +1,50 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Swatch = function Swatch(_ref) { + var color = _ref.color, + style = _ref.style, + label = _ref.label, + labels = _ref.labels; + + var innerStyle = _objectSpread({ + backgroundColor: color, + border: '1px solid #cccccc' + }, style); + + var assistiveText; // falsey values output a transparent swatch + + if (!color) { + innerStyle.backgroundImage = 'linear-gradient(-45deg, white 47%, #870500 0, #870500 53%, white 0)'; + assistiveText = labels && labels.swatchTabTransparentSwatch; + } else { + assistiveText = label || color; + } + + return _react.default.createElement("span", { + className: "slds-swatch", + style: innerStyle + }, _react.default.createElement("span", { + className: "slds-assistive-text" + }, assistiveText)); +}; + +Swatch.propTypes = { + color: _propTypes.default.string.isRequired +}; +var _default = Swatch; +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__docs__/__snapshots__/storybook-stories.storyshot b/components/combobox/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..92b92dc830 --- /dev/null +++ b/components/combobox/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,6120 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSCombobox Base 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
      +
    • + + + + + + Account + + + + + Acme + + + + + + + , Press delete or backspace to remove + + + +
    • +
    • + + + + + + Account + + + + + Salesforce.com, Inc. + + + + + + + , Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Base Custom Menu Item 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Base Custom Menu Item Disabled 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Base Inherit Menu Width 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Base Inline Help 1`] = ` +
    +
    +

    + Field Level Help Tooltip +

    +
    + +
    + + +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
      +
    • + + + + + + Account + + + + + Acme + + + + + + + , Press delete or backspace to remove + + + +
    • +
    • + + + + + + Account + + + + + Salesforce.com, Inc. + + + + + + + , Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Base Menu Item Disabled 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
      +
    • + + + + + + Account + + + + + Acme + + + + + + + , Press delete or backspace to remove + + + +
    • +
    • + + + + + + Account + + + + + Salesforce.com, Inc. + + + + + + + , Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Base Menu Item Disabled With Tooltip 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
      +
    • + + + + + + Account + + + + + Acme + + + + + + + , Press delete or backspace to remove + + + +
    • +
    • + + + + + + Account + + + + + Salesforce.com, Inc. + + + + + + + , Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Base Menu Item Disabled With Tooltip Open 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
      +
    • + + + + + + Account + + + + + + Paddy's Pub + + + Account • Boston, MA + + + +
    • +
    • +
      + + + + + + Account + + + + + + Tyrell Corp + + + Account • San Francisco, CA + + + + +
      +
    • +
    • + + + + + + Account + + + + + + Paper St. Soap Company + + + Account • Beloit, WI + + + +
    • +
    • +
      + + + + + + Account + + + + + + Nakatomi Investments + + + Account • Chicago, IL + + + + +
      +
    • +
    • + + + + + + Account + + + + + + Acme Landscaping + + +   + + + +
    • +
    • + + + + + + Account + + + + + + Acme Construction + + + Account • Grand Marais, MN + + + +
    • +
    +
    +
    +
    +
    +
      +
    • + + + + + + Account + + + + + Acme + + + + + + + , Press delete or backspace to remove + + + +
    • +
    • + + + + + + Account + + + + + Salesforce.com, Inc. + + + + + + + , Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Base Menu Separator 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Base Menu Sub Headers 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Base Pre-defined Options Only 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
      +
    • + + + + + + Account + + + + + Acme + + + + + + + , Press delete or backspace to remove + + + +
    • +
    • + + + + + + Account + + + + + Salesforce.com, Inc. + + + + + + + , Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Dialog 1`] = ` +
    +
    + +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Inline Multiple Selection 1`] = ` +
    +
    + +
    +
    +
    +
      +
    • + + + + + + Account + + + + + Acme + + + + + + + , Press delete or backspace to remove + + + +
    • +
    • + + + + + + Account + + + + + Salesforce.com, Inc. + + + + + + + , Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Inline Single Selection 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Input Component as a Prop 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
      +
    • + + + + + + Account + + + + + Acme + + + + + + + , Press delete or backspace to remove + + + +
    • +
    • + + + + + + Account + + + + + Salesforce.com, Inc. + + + + + + + , Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Readonly Multiple Selection 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Readonly Single Menu Item Disabled 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Readonly Single Selection 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Readonly Single Selection Custom Menu Item 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Readonly Single Selection Disabled 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Required Input in Error State 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    + This field is required +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Base Custom Menu Item Open 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
      +
    • + + + + Acme + + + Account • San Francisco + + + +
    • +
    • + + + + Salesforce.com, Inc. + + + Account • San Francisco + + + +
    • +
    • + + + + Paddy's Pub + + + Account • Boston, MA + + + +
    • +
    • + + + + Tyrell Corp + + + Account • San Francisco, CA + + + +
    • +
    • + + + + Paper St. Soap Company + + + Account • Beloit, WI + + + +
    • +
    • + + + + Nakatomi Investments + + + Account • Chicago, IL + + + +
    • +
    • + + + + Acme Landscaping + + +   + + + +
    • +
    • + + + + Acme Construction + + + Account • Grand Marais, MN + + + +
    • +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Base Label Required 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    + This field is required +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Base Open 1`] = ` +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
      +
    • + + + + + + Account + + + + + + Acme + + + Account • San Francisco + + + +
    • +
    • + + + + + + Account + + + + + + Salesforce.com, Inc. + + + Account • San Francisco + + + +
    • +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Base Open Menu Sub Header Separator 1`] = ` +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
      +
    • + + Accounts + +
    • +
    • + + + + Salesforce.com, Inc. + + + Account • San Francisco + + + +
    • +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Base Open Menu inheritWidthOf prop 1`] = ` +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
      +
    • + + Accounts + +
    • +
    • + + + + Salesforce.com, Inc. + + + Account • San Francisco + + + +
    • +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Base Selected 1`] = ` +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
      +
    • + + + + + + Account + + + + + Salesforce.com, Inc. + + + + + + + , Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Dialog Open 1`] = ` +
    +
    + +
    +
    +
    +
    +
    + + + + +
    + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Inline Multiple Selection 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Inline Multiple Selection Selected 1`] = ` +
    +
    + +
    +
    +
    +
      +
    • + + + + + + Account + + + + + Acme + + + + + + + , Press delete or backspace to remove + + + +
    • +
    • + + + + + + Account + + + + + Salesforce.com, Inc. + + + + + + + , Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Inline Single Selection 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Inline Single Selection Selected 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + Account + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Readonly Multiple Selection 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Readonly Multiple Selection Multiple Items Selected 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    +
      +
    • + + + Acme + + + + + + + , Press delete or backspace to remove + + + +
    • +
    • + + + Salesforce.com, Inc. + + + + + + + , Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Readonly Multiple Selection Single Item Selected 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Readonly Single Selection 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Readonly Single Selection Custom Menu Item 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
      +
    • + + + + + + + + + + + + + + Account + + + + + + + Acme + + + + + +
    • +
    • + + + + + + + + + + + + + + Account + + + + + + + Salesforce.com, Inc. + + + + + +
    • +
    • + + + + + + + + + + + + + + Account + + + + + + + Paddy's Pub + + + + + +
    • +
    • + + + + + + + + + + + + + + Account + + + + + + + Tyrell Corp + + + + + +
    • +
    • + + + + + + + + + + + + + + Account + + + + + + + Paper St. Soap Company + + + + + +
    • +
    • + + + + + + + + + + + + + + Account + + + + + + + Nakatomi Investments + + + + + +
    • +
    • + + + + + + + + + + + + + + Account + + + + + + + Acme Landscaping + + + + + +
    • +
    • + + + + + + + + + + + + + + Account + + + + + + + Acme Construction + + + + + +
    • +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Readonly Single Selection Disabled 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Readonly Single Selection Selected 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSCombobox Snapshot Readonly Single Selection Selected Open 1`] = ` +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    +
      +
    • + + + + + + + + + + + Current Selection: + + + Acme + + + +
    • +
    • + + + + + + + + + + + Salesforce.com, Inc. + + + +
    • +
    • + + + + + + + + + + + Paddy's Pub + + + +
    • +
    • + + + + + + + + + + + Tyrell Corp + + + +
    • +
    • + + + + + + + + + + + Paper St. Soap Company + + + +
    • +
    • + + + + + + + + + + + Nakatomi Investments + + + +
    • +
    • + + + + + + + + + + + Acme Landscaping + + + +
    • +
    • + + + + + + + + + + + Acme Construction + + + +
    • +
    +
    +
    +
    +
    +
    +
    +`; diff --git a/components/combobox/__docs__/site-stories.js b/components/combobox/__docs__/site-stories.js new file mode 100644 index 0000000000..1feba5d846 --- /dev/null +++ b/components/combobox/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/combobox/__examples__/base.jsx'), require('raw-loader!@salesforce/design-system-react/components/combobox/__examples__/base-menu-subheader.jsx'), require('raw-loader!@salesforce/design-system-react/components/combobox/__examples__/base-inherit-menu-width.jsx'), require('raw-loader!@salesforce/design-system-react/components/combobox/__examples__/base-predefined-options-only.jsx'), require('raw-loader!@salesforce/design-system-react/components/combobox/__examples__/dialog.jsx'), require('raw-loader!@salesforce/design-system-react/components/combobox/__examples__/inline-multiple.jsx'), require('raw-loader!@salesforce/design-system-react/components/combobox/__examples__/inline-single.jsx'), require('raw-loader!@salesforce/design-system-react/components/combobox/__examples__/readonly-single.jsx'), require('raw-loader!@salesforce/design-system-react/components/combobox/__examples__/readonly-multiple.jsx'), require('raw-loader!@salesforce/design-system-react/components/combobox/__examples__/required-input-error-state.jsx'), require('raw-loader!@salesforce/design-system-react/components/combobox/__examples__/dialog.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/combobox/__docs__/storybook-stories.js b/components/combobox/__docs__/storybook-stories.js new file mode 100644 index 0000000000..63e9246349 --- /dev/null +++ b/components/combobox/__docs__/storybook-stories.js @@ -0,0 +1,259 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _constants = require("../../../utilities/constants"); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +var _baseInlineHelpTooltip = _interopRequireDefault(require("../__examples__/base-inline-help-tooltip")); + +var _baseMenuSubheader = _interopRequireDefault(require("../__examples__/base-menu-subheader")); + +var _baseMenuSeparator = _interopRequireDefault(require("../__examples__/base-menu-separator")); + +var _baseMenuItemDisabled = _interopRequireDefault(require("../__examples__/base-menu-item-disabled")); + +var _baseMenuItemDisabledTooltipOpen = _interopRequireDefault(require("../__examples__/base-menu-item-disabled-tooltip-open")); + +var _baseMenuItemDisabledTooltip = _interopRequireDefault(require("../__examples__/base-menu-item-disabled-tooltip")); + +var _baseInheritMenuWidth = _interopRequireDefault(require("../__examples__/base-inherit-menu-width.jsx")); + +var _dialog = _interopRequireDefault(require("../__examples__/dialog.jsx")); + +var _requiredInputErrorState = _interopRequireDefault(require("../__examples__/required-input-error-state")); + +var _basePredefinedOptionsOnly = _interopRequireDefault(require("../__examples__/base-predefined-options-only")); + +var _inlineSingle = _interopRequireDefault(require("../__examples__/inline-single")); + +var _inlineMultiple = _interopRequireDefault(require("../__examples__/inline-multiple")); + +var _baseCustomMenuItem = _interopRequireDefault(require("../__examples__/base-custom-menu-item")); + +var _baseCustomMenuItemDisabled = _interopRequireDefault(require("../__examples__/base-custom-menu-item-disabled")); + +var _readonlySingle = _interopRequireDefault(require("../__examples__/readonly-single")); + +var _readonlySingleDisabled = _interopRequireDefault(require("../__examples__/readonly-single-disabled")); + +var _readonlyMenuItemDisabled = _interopRequireDefault(require("../__examples__/readonly-menu-item-disabled")); + +var _readonlySingleSelectionCustomMenuItem = _interopRequireDefault(require("../__examples__/readonly-single-selection-custom-menu-item")); + +var _readonlyMultiple = _interopRequireDefault(require("../__examples__/readonly-multiple")); + +var _inputProp = _interopRequireDefault(require("../__examples__/input-prop")); + +var _baseOpen = _interopRequireDefault(require("../__examples__/snapshot/base-open")); + +var _baseOpenMenuSubHeader = _interopRequireDefault(require("../__examples__/snapshot/base-open-menu-sub-header")); + +var _baseOpenMenuInheritWidthOf = _interopRequireDefault(require("../__examples__/snapshot/base-open-menu-inheritWidthOf")); + +var _baseCustomMenuItemOpen = _interopRequireDefault(require("../__examples__/snapshot/base-custom-menu-item-open")); + +var _baseSelected = _interopRequireDefault(require("../__examples__/snapshot/base-selected")); + +var _dialogOpen = _interopRequireDefault(require("../__examples__/snapshot/dialog-open")); + +var _inlineSingleSelection = _interopRequireDefault(require("../__examples__/snapshot/inline-single-selection")); + +var _inlineSingleSelectionSelected = _interopRequireDefault(require("../__examples__/snapshot/inline-single-selection-selected")); + +var _inlineMultipleSelection = _interopRequireDefault(require("../__examples__/snapshot/inline-multiple-selection")); + +var _inlineMultipleSelectionSelected = _interopRequireDefault(require("../__examples__/snapshot/inline-multiple-selection-selected")); + +var _readonlySingleSelection = _interopRequireDefault(require("../__examples__/snapshot/readonly-single-selection")); + +var _readonlySingleSelectionDisabled = _interopRequireDefault(require("../__examples__/snapshot/readonly-single-selection-disabled")); + +var _readonlySingleSelectionSelected = _interopRequireDefault(require("../__examples__/snapshot/readonly-single-selection-selected")); + +var _readonlySingleSelectionSelectedOpen = _interopRequireDefault(require("../__examples__/snapshot/readonly-single-selection-selected-open")); + +var _readonlyMultipleSelection = _interopRequireDefault(require("../__examples__/snapshot/readonly-multiple-selection")); + +var _readonlyMultipleSelectionSingleItemSelected = _interopRequireDefault(require("../__examples__/snapshot/readonly-multiple-selection-single-item-selected")); + +var _readonlyMultipleSelectionMultipleItemsSelected = _interopRequireDefault(require("../__examples__/snapshot/readonly-multiple-selection-multiple-items-selected")); + +var _readonlySingleSelectionCustomMenuItem2 = _interopRequireDefault(require("../__examples__/snapshot/readonly-single-selection-custom-menu-item")); + +var _baseLabelRequired = _interopRequireDefault(require("../__examples__/snapshot/base-label-required")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.COMBOBOX, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base', function () { + return _react.default.createElement(_base.default, { + action: _addonActions.action + }); +}).add('Base Pre-defined Options Only', function () { + return _react.default.createElement(_basePredefinedOptionsOnly.default, { + action: _addonActions.action + }); +}).add('Base Inline Help', function () { + return _react.default.createElement("section", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Field Level Help Tooltip"), _react.default.createElement(_baseInlineHelpTooltip.default, { + action: _addonActions.action + })); +}).add('Base Menu Item Disabled', function () { + return _react.default.createElement(_baseMenuItemDisabled.default, { + action: _addonActions.action + }); +}).add('Base Menu Item Disabled With Tooltip', function () { + return _react.default.createElement(_baseMenuItemDisabledTooltip.default, { + action: _addonActions.action + }); +}).add('Base Menu Item Disabled With Tooltip Open', function () { + return _react.default.createElement(_baseMenuItemDisabledTooltipOpen.default, { + action: _addonActions.action + }); +}).add('Inline Single Selection', function () { + return _react.default.createElement(_inlineSingle.default, { + action: _addonActions.action + }); +}).add('Inline Multiple Selection', function () { + return _react.default.createElement(_inlineMultiple.default, { + action: _addonActions.action + }); +}).add('Base Custom Menu Item', function () { + return _react.default.createElement(_baseCustomMenuItem.default, { + action: _addonActions.action + }); +}).add('Base Custom Menu Item Disabled', function () { + return _react.default.createElement(_baseCustomMenuItemDisabled.default, { + action: _addonActions.action + }); +}).add('Base Menu Sub Headers', function () { + return _react.default.createElement(_baseMenuSubheader.default, { + action: _addonActions.action + }); +}).add('Base Menu Separator', function () { + return _react.default.createElement(_baseMenuSeparator.default, { + action: _addonActions.action + }); +}).add('Base Inherit Menu Width', function () { + return _react.default.createElement(_baseInheritMenuWidth.default, { + action: _addonActions.action + }); +}).add('Dialog', function () { + return _react.default.createElement(_dialog.default, { + action: _addonActions.action + }); +}).add('Readonly Single Selection', function () { + return _react.default.createElement(_readonlySingle.default, { + action: _addonActions.action + }); +}).add('Readonly Single Selection Disabled', function () { + return _react.default.createElement(_readonlySingleDisabled.default, { + action: _addonActions.action + }); +}).add('Readonly Single Menu Item Disabled', function () { + return _react.default.createElement(_readonlyMenuItemDisabled.default, { + action: _addonActions.action + }); +}).add('Readonly Multiple Selection', function () { + return _react.default.createElement(_readonlyMultiple.default, { + action: _addonActions.action + }); +}).add('Readonly Single Selection Custom Menu Item', function () { + return _react.default.createElement(_readonlySingleSelectionCustomMenuItem.default, { + action: _addonActions.action + }); +}).add('Required Input in Error State', function () { + return _react.default.createElement(_requiredInputErrorState.default, { + action: _addonActions.action + }); +}).add('Input Component as a Prop', function () { + return _react.default.createElement(_inputProp.default, { + action: _addonActions.action + }); +}).add('Snapshot Base Open', function () { + return _react.default.createElement(_baseOpen.default, { + action: _addonActions.action + }); +}).add('Snapshot Base Custom Menu Item Open', function () { + return _react.default.createElement(_baseCustomMenuItemOpen.default, { + action: _addonActions.action + }); +}).add('Snapshot Base Selected', function () { + return _react.default.createElement(_baseSelected.default, { + action: _addonActions.action + }); +}).add('Snapshot Base Label Required', function () { + return _react.default.createElement(_baseLabelRequired.default, { + action: _addonActions.action + }); +}).add('Snapshot Base Open Menu Sub Header Separator', function () { + return _react.default.createElement(_baseOpenMenuSubHeader.default, { + action: _addonActions.action + }); +}).add('Snapshot Base Open Menu inheritWidthOf prop', function () { + return _react.default.createElement(_baseOpenMenuInheritWidthOf.default, { + action: _addonActions.action + }); +}).add('Snapshot Dialog Open', function () { + return _react.default.createElement(_dialogOpen.default, { + action: _addonActions.action + }); +}).add('Snapshot Inline Single Selection', function () { + return _react.default.createElement(_inlineSingleSelection.default, { + action: _addonActions.action + }); +}).add('Snapshot Inline Single Selection Selected', function () { + return _react.default.createElement(_inlineSingleSelectionSelected.default, { + action: _addonActions.action + }); +}).add('Snapshot Inline Multiple Selection', function () { + return _react.default.createElement(_inlineMultipleSelection.default, { + action: _addonActions.action + }); +}).add('Snapshot Inline Multiple Selection Selected', function () { + return _react.default.createElement(_inlineMultipleSelectionSelected.default, { + action: _addonActions.action + }); +}).add('Snapshot Readonly Single Selection', function () { + return _react.default.createElement(_readonlySingleSelection.default, { + action: _addonActions.action + }); +}).add('Snapshot Readonly Single Selection Disabled', function () { + return _react.default.createElement(_readonlySingleSelectionDisabled.default, { + action: _addonActions.action + }); +}).add('Snapshot Readonly Single Selection Selected', function () { + return _react.default.createElement(_readonlySingleSelectionSelected.default, { + action: _addonActions.action + }); +}).add('Snapshot Readonly Single Selection Selected Open', function () { + return _react.default.createElement(_readonlySingleSelectionSelectedOpen.default, { + action: _addonActions.action + }); +}).add('Snapshot Readonly Multiple Selection', function () { + return _react.default.createElement(_readonlyMultipleSelection.default, { + action: _addonActions.action + }); +}).add('Snapshot Readonly Multiple Selection Single Item Selected', function () { + return _react.default.createElement(_readonlyMultipleSelectionSingleItemSelected.default, { + action: _addonActions.action + }); +}).add('Snapshot Readonly Multiple Selection Multiple Items Selected', function () { + return _react.default.createElement(_readonlyMultipleSelectionMultipleItemsSelected.default, { + action: _addonActions.action + }); +}).add('Snapshot Readonly Single Selection Custom Menu Item', function () { + return _react.default.createElement(_readonlySingleSelectionCustomMenuItem2.default, { + action: _addonActions.action + }); +}); \ No newline at end of file diff --git a/components/combobox/__examples__/base-custom-menu-item-disabled.js b/components/combobox/__examples__/base-custom-menu-item-disabled.js new file mode 100644 index 0000000000..30dd1f8fb4 --- /dev/null +++ b/components/combobox/__examples__/base-custom-menu-item-disabled.js @@ -0,0 +1,215 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _classnames = _interopRequireDefault(require("classnames")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account', + disabled: true +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account', + disabled: true +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + size: "x-small", + name: elem.type + }) + }); +}); + +var CustomMenuItem = function CustomMenuItem(props) { + var disabledRule = { + 'slds-disabled-text': props.option.disabled + }; + return _react.default.createElement("span", null, _react.default.createElement("span", { + className: (0, _classnames.default)('slds-listbox__option-text', 'slds-listbox__option-text_entity', disabledRule) + }, props.option.label), _react.default.createElement("span", { + className: (0, _classnames.default)('slds-listbox__option-meta', 'slds-listbox__option-meta_entity', disabledRule) + }, props.option.subTitle || "\xA0")); +}; + +CustomMenuItem.displayName = 'CustomMenuItem'; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, _extends({ + id: "combobox-unique-id", + disabled: this.props.disabled, + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: "Account", + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + onRenderMenuItem: CustomMenuItem, + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.inputValue + }, this.props))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/base-custom-menu-item.js b/components/combobox/__examples__/base-custom-menu-item.js new file mode 100644 index 0000000000..f6cf6e0cc8 --- /dev/null +++ b/components/combobox/__examples__/base-custom-menu-item.js @@ -0,0 +1,224 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + size: "x-small", + name: elem.type + }) + }); +}); + +var CustomMenuItem = function CustomMenuItem(props) { + return _react.default.createElement("span", null, _react.default.createElement("span", { + className: "slds-listbox__option-text slds-listbox__option-text_entity" + }, props.option.label), _react.default.createElement("span", { + className: "slds-listbox__option-meta slds-listbox__option-meta_entity" + }, props.option.subTitle || "\xA0")); +}; + +CustomMenuItem.displayName = 'CustomMenuItem'; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, _extends({ + id: "combobox-base-custom-menu-item", + disabled: this.props.disabled, + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + onRenderMenuItem: CustomMenuItem, + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.inputValue + }, this.props))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/base-inherit-menu-width.js b/components/combobox/__examples__/base-inherit-menu-width.js new file mode 100644 index 0000000000..fe9a524b8a --- /dev/null +++ b/components/combobox/__examples__/base-inherit-menu-width.js @@ -0,0 +1,209 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'A very very very very very very very very very very very long title to show how menu width will behave', + subTitle: 'Account • San Francisco ', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Opportunities', + subTitle: 'Opportunity • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Nakatomi Investments', + subTitle: 'Opportunity • Chicago, IL', + type: 'opportunity' +}, { + id: '6', + label: 'Acme Landscaping', + subTitle: "\xA0", + type: 'account' +}, { + id: '7', + label: 'Acme Construction', + subTitle: 'Opportunity • Grand Marais, MN', + type: 'opportunity' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-base-inherit-menu-width", + disabled: this.props.disabled, + inheritWidthOf: "menu", + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuMaxWidth: "500px", + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + limit: 10, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/base-inline-help-tooltip.js b/components/combobox/__examples__/base-inline-help-tooltip.js new file mode 100644 index 0000000000..5db58943d7 --- /dev/null +++ b/components/combobox/__examples__/base-inline-help-tooltip.js @@ -0,0 +1,219 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _tooltip = _interopRequireDefault(require("../../tooltip")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + subTitle: "\xA0", + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accountsWithIcon[0], accountsWithIcon[1]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-base-inline-help", + disabled: this.props.disabled, + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + fieldLevelHelpTooltip: _react.default.createElement(_tooltip.default, { + align: "top left", + content: "Type to search Salesforce objects...", + id: "field-level-help-tooltip" + }), + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + limit: 10, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/base-menu-item-disabled-tooltip-open.js b/components/combobox/__examples__/base-menu-item-disabled-tooltip-open.js new file mode 100644 index 0000000000..9727b9ff4b --- /dev/null +++ b/components/combobox/__examples__/base-menu-item-disabled-tooltip-open.js @@ -0,0 +1,223 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _tooltip = _interopRequireDefault(require("../../../../components/tooltip")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account', + disabled: true, + tooltipContent: 'This account has been removed from the system.' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account', + disabled: true, + tooltipContent: "You don't have permission to access this account." +}, { + id: '7', + label: 'Acme Landscaping', + subTitle: "\xA0", + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type, + style: elem.disabled ? { + backgroundColor: '#dddbda' + } : {} + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accountsWithIcon[0], accountsWithIcon[1]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-base", + disabled: this.props.disabled, + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: "Account", + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + isOpen: true, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + limit: 10, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + tooltipMenuItemDisabled: _react.default.createElement(_tooltip.default, { + isOpen: true + }), + value: this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/base-menu-item-disabled-tooltip.js b/components/combobox/__examples__/base-menu-item-disabled-tooltip.js new file mode 100644 index 0000000000..afe30bcfc4 --- /dev/null +++ b/components/combobox/__examples__/base-menu-item-disabled-tooltip.js @@ -0,0 +1,220 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _tooltip = _interopRequireDefault(require("../../../../components/tooltip")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account', + disabled: true, + tooltipContent: 'This account has been removed from the system.' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account', + disabled: true, + tooltipContent: "You don't have permission to access this account." +}, { + id: '7', + label: 'Acme Landscaping', + subTitle: "\xA0", + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type, + style: elem.disabled ? { + backgroundColor: '#dddbda' + } : {} + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accountsWithIcon[0], accountsWithIcon[1]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-base", + disabled: this.props.disabled, + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: "Account", + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + limit: 10, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + tooltipMenuItemDisabled: _react.default.createElement(_tooltip.default, null), + value: this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/base-menu-item-disabled.js b/components/combobox/__examples__/base-menu-item-disabled.js new file mode 100644 index 0000000000..afd5737fdc --- /dev/null +++ b/components/combobox/__examples__/base-menu-item-disabled.js @@ -0,0 +1,215 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account', + disabled: true +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account', + disabled: true +}, { + id: '7', + label: 'Acme Landscaping', + subTitle: "\xA0", + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type, + style: elem.disabled ? { + backgroundColor: '#dddbda' + } : {} + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accountsWithIcon[0], accountsWithIcon[1]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-base", + disabled: this.props.disabled, + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: "Account", + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + limit: 10, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/base-menu-separator.js b/components/combobox/__examples__/base-menu-separator.js new file mode 100644 index 0000000000..559f7b3418 --- /dev/null +++ b/components/combobox/__examples__/base-menu-separator.js @@ -0,0 +1,213 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + type: 'separator' +}, { + id: '4', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '5', + label: 'Opportunities', + subTitle: 'Opportunity • San Francisco, CA', + type: 'account' +}, { + id: '6', + type: 'separator' +}, { + id: '7', + label: 'Nakatomi Investments', + subTitle: 'Opportunity • Chicago, IL', + type: 'opportunity' +}, { + id: '8', + label: 'Acme Landscaping', + subTitle: "\xA0", + type: 'account' +}, { + id: '9', + label: 'Acme Construction', + subTitle: 'Opportunity • Grand Marais, MN', + type: 'opportunity' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-base-menu-separator", + disabled: this.props.disabled, + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + limit: 10, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/base-menu-subheader.js b/components/combobox/__examples__/base-menu-subheader.js new file mode 100644 index 0000000000..fd581285c3 --- /dev/null +++ b/components/combobox/__examples__/base-menu-subheader.js @@ -0,0 +1,221 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _addSubheadings = _interopRequireDefault(require("../../../../components/combobox/add-subheadings")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var subheadings = [{ + id: 'account', + label: 'Accounts', + type: 'separator' +}, { + id: 'opportunity', + label: 'Opportunities', + type: 'separator' +}]; +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Vandelay Industries', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Opportunity • Chicago, IL', + type: 'opportunity' +}, { + id: '7', + label: 'Acme Landscaping', + subTitle: "\xA0", + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Opportunity • Grand Marais, MN', + type: 'opportunity' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-base-menu-subheader", + disabled: this.props.disabled, + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + multiple: true, + options: (0, _addSubheadings.default)({ + subheadings: subheadings, + filteredOptions: (0, _filter.default)({ + inputValue: this.state.inputValue, + limit: 10, + options: accountsWithIcon, + selection: this.state.selection + }) + }), + selection: this.state.selection, + value: this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/base-predefined-options-only.js b/components/combobox/__examples__/base-predefined-options-only.js new file mode 100644 index 0000000000..40330e9c92 --- /dev/null +++ b/components/combobox/__examples__/base-predefined-options-only.js @@ -0,0 +1,189 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accountsWithIcon[0], accountsWithIcon[1]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-base-predefined-options", + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + options: accountsWithIcon, + selection: this.state.selection + }), + predefinedOptionsOnly: true, + selection: this.state.selection, + value: this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/base.js b/components/combobox/__examples__/base.js new file mode 100644 index 0000000000..ca03f1f8f7 --- /dev/null +++ b/components/combobox/__examples__/base.js @@ -0,0 +1,212 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + subTitle: "\xA0", + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accountsWithIcon[0], accountsWithIcon[1]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-base", + disabled: this.props.disabled, + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + limit: 10, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/dialog.js b/components/combobox/__examples__/dialog.js new file mode 100644 index 0000000000..1525c8bec6 --- /dev/null +++ b/components/combobox/__examples__/dialog.js @@ -0,0 +1,173 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _checkbox = _interopRequireDefault(require("../../../../components/checkbox")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _popover = _interopRequireDefault(require("../../../../components/popover")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var languages = ['English', 'German', 'Tobagonian Creole English', 'Spanish']; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "getInputString", function (options) { + var inputValue = ''; + if (options.length === 0) inputValue = 'Select an option';else if (options.length === 1) inputValue = "".concat(options[0].label);else inputValue = "".concat(options.length, " options selected"); + return inputValue; + }); + + _this.state = { + inputValue: 'Select an option', + selection: [], + checked: [] + }; + _this.handleClose = _this.handleClose.bind(_assertThisInitialized(_this)); + return _this; + } + + _createClass(Example, [{ + key: "getIsChecked", + value: function getIsChecked(label) { + var isChecked = false; + var checkedIndex = this.state.checked.findIndex(function (el) { + return el.label === label; + }); + if (checkedIndex > -1) isChecked = true; + return isChecked; + } + }, { + key: "handleCheckboxChange", + value: function handleCheckboxChange(target, value) { + var checked = this.state.checked; + + if (target.checked) { + checked.push({ + id: target.id, + label: value + }); + } else { + var valueIndex = checked.findIndex(function (el) { + return el.label === value; + }); + checked.splice(valueIndex, 1); + } + + var inputValue = this.getInputString(checked); + this.setState({ + inputValue: inputValue, + checked: checked + }); + } + }, { + key: "handleClose", + value: function handleClose(e, _ref) { + var trigger = _ref.trigger; + + if (trigger === 'cancel') { + var inputValue = this.getInputString(this.state.selection); + var selection = this.state.selection.length > 0 ? this.state.selection.slice(0) : []; + this.setState({ + checked: selection, + inputValue: inputValue + }); + } else { + var checked = this.state.checked.length > 0 ? this.state.checked.slice(0) : []; + this.setState({ + selection: checked + }); + } + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + assistiveText: { + popoverLabel: 'Language Options' + }, + id: "combobox-dialog", + errorText: this.state.selection.length > 2 || this.state.checked.length > 2 ? 'Only select 2 options.' : null, + labels: { + label: 'Languages', + placeholder: this.state.inputValue + }, + popover: _react.default.createElement(_popover.default, { + body: _react.default.createElement("div", null, _react.default.createElement("fieldset", { + className: "slds-form-element" + }, _react.default.createElement("legend", { + className: "slds-form-element__legend slds-form-element__label" + }, "Select up to 2"), _react.default.createElement("div", { + className: "slds-form-element__control" + }, languages.map(function (language, i) { + return _react.default.createElement(_checkbox.default, { + checked: _this2.getIsChecked(language), + id: "checkbox-".concat(i), + key: "checkbox-".concat(i + 1), + labels: { + label: language + }, + onChange: function onChange(e) { + _this2.handleCheckboxChange(e.target, language); + } + }); + })))), + onClose: this.handleClose + }), + selection: this.state.selection, + value: this.state.inputValue, + variant: "popover" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/inline-multiple.js b/components/combobox/__examples__/inline-multiple.js new file mode 100644 index 0000000000..953a3d1c5b --- /dev/null +++ b/components/combobox/__examples__/inline-multiple.js @@ -0,0 +1,206 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accountsWithIcon[0], accountsWithIcon[1]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-inline-multiple", + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + _this2.props.action('onChange')(event, value); + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.inputValue, + variant: "inline-listbox" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/inline-single.js b/components/combobox/__examples__/inline-single.js new file mode 100644 index 0000000000..1f10b8eb5c --- /dev/null +++ b/components/combobox/__examples__/inline-single.js @@ -0,0 +1,209 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-inline-single", + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.selectedOption ? this.state.selectedOption.label : this.state.inputValue, + variant: "inline-listbox" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/input-prop.js b/components/combobox/__examples__/input-prop.js new file mode 100644 index 0000000000..093062e275 --- /dev/null +++ b/components/combobox/__examples__/input-prop.js @@ -0,0 +1,220 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _input = _interopRequireDefault(require("../../../../components/input")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + subTitle: "\xA0", + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accountsWithIcon[0], accountsWithIcon[1]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + // example of passing in an SLDSInput component to a SLDSCombobox + var inputElement = _react.default.createElement(_input.default, { + autoComplete: "test", + id: "id_from_input_prop", + placeholder: "My overridden placeholder" + }); + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-input-prop-example", + input: inputElement, + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + limit: 10, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/readonly-menu-item-disabled.js b/components/combobox/__examples__/readonly-menu-item-disabled.js new file mode 100644 index 0000000000..d5abf087b2 --- /dev/null +++ b/components/combobox/__examples__/readonly-menu-item-disabled.js @@ -0,0 +1,143 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + disabled: true +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + disabled: true +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + disabled: true +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL' +}, { + id: '7', + label: 'Acme Landscaping' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-readonly-single", + events: { + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + options: accounts, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/readonly-multiple.js b/components/combobox/__examples__/readonly-multiple.js new file mode 100644 index 0000000000..4d51c3c44a --- /dev/null +++ b/components/combobox/__examples__/readonly-multiple.js @@ -0,0 +1,145 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL' +}, { + id: '7', + label: 'Acme Landscaping' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-readonly-multiple", + events: { + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + multiple: true, + options: accounts, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/readonly-single-disabled.js b/components/combobox/__examples__/readonly-single-disabled.js new file mode 100644 index 0000000000..7751b4b964 --- /dev/null +++ b/components/combobox/__examples__/readonly-single-disabled.js @@ -0,0 +1,149 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + events: { + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + options: accounts, + singleInputDisabled: true, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/readonly-single-selection-custom-menu-item.js b/components/combobox/__examples__/readonly-single-selection-custom-menu-item.js new file mode 100644 index 0000000000..34e3fd4298 --- /dev/null +++ b/components/combobox/__examples__/readonly-single-selection-custom-menu-item.js @@ -0,0 +1,184 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + size: "x-small", + name: elem.type + }) + }); +}); + +var CustomMenuItem = function CustomMenuItem(props) { + return _react.default.createElement("span", { + className: "slds-media" + }, _react.default.createElement("span", { + className: "slds-m-left_x-small slds-m-right_x-small" + }, props.option.icon), _react.default.createElement("span", { + className: "slds-media__body" + }, _react.default.createElement("span", { + className: "slds-truncate", + title: props.option.label + }, props.selected ? _react.default.createElement("span", { + className: "slds-assistive-text" + }, props.assistiveText.optionSelectedInMenu) : null, ' ', props.option.label))); +}; + +CustomMenuItem.displayName = 'CustomMenuItem'; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, _extends({ + id: "combobox-readonly-single-custom-item", + events: { + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholderReadOnly: 'Select company' + }, + onRenderMenuItem: CustomMenuItem, + options: accountsWithIcon, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + }, this.props))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/readonly-single.js b/components/combobox/__examples__/readonly-single.js new file mode 100644 index 0000000000..b6a4ed9a84 --- /dev/null +++ b/components/combobox/__examples__/readonly-single.js @@ -0,0 +1,140 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL' +}, { + id: '7', + label: 'Acme Landscaping' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-readonly-single", + events: { + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + options: accounts, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/required-input-error-state.js b/components/combobox/__examples__/required-input-error-state.js new file mode 100644 index 0000000000..cf2dc6ef96 --- /dev/null +++ b/components/combobox/__examples__/required-input-error-state.js @@ -0,0 +1,215 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + subTitle: "\xA0", + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + "aria-describedby": "description-unique-id", + id: "combobox-required-error-state", + disabled: this.props.disabled, + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + + if (_this2.props.action) { + _this2.props.action('onChange')(event, value); + } else if (console) { + console.log('onChange', event, value); + } + + _this2.setState({ + inputValue: 'input not found', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + if (_this2.props.action) { + _this2.props.action('onSelect').apply(void 0, [event].concat(_toConsumableArray(Object.keys(data).map(function (key) { + return data[key]; + })))); + } else if (console) { + console.log('onSelect', event, data); + } + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + errorText: "This field is required", + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + limit: 10, + options: accountsWithIcon, + selection: this.state.selection + }), + required: true, + selection: this.state.selection, + value: this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/base-custom-menu-item-open.js b/components/combobox/__examples__/snapshot/base-custom-menu-item-open.js new file mode 100644 index 0000000000..bebd274902 --- /dev/null +++ b/components/combobox/__examples__/snapshot/base-custom-menu-item-open.js @@ -0,0 +1,59 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _baseCustomMenuItem = _interopRequireDefault(require("../base-custom-menu-item")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_baseCustomMenuItem.default, { + menuPosition: "relative", + isOpen: true + }); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/base-label-required.js b/components/combobox/__examples__/snapshot/base-label-required.js new file mode 100644 index 0000000000..2364ba0b6a --- /dev/null +++ b/components/combobox/__examples__/snapshot/base-label-required.js @@ -0,0 +1,56 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _requiredInputErrorState = _interopRequireDefault(require("../required-input-error-state")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_requiredInputErrorState.default, null); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/base-open-class-name.js b/components/combobox/__examples__/snapshot/base-open-class-name.js new file mode 100644 index 0000000000..b8034bb7a9 --- /dev/null +++ b/components/combobox/__examples__/snapshot/base-open-class-name.js @@ -0,0 +1,154 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '0', + label: 'Accounts', + type: 'separator' +}, { + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + className: "this-is-the-input", + classNameContainer: "this-is-the-container", + classNameMenu: "this-is-the-menu", + classNameMenuSubHeader: "this-is-the-menu-sub-header", + id: "combobox-unique-id", + isOpen: true, + labels: { + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + onChange: function onChange(event, _ref) { + var value = _ref.value; + console.log('onChange', value); + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: [] + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + console.log('onSubmit', value); + + _this2.setState({ + selection: [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }] + }); + }, + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + selection: data.selection + }); + }, + options: accountsWithIcon, + selection: this.state.selection, + value: this.state.selectedOption ? this.state.selectedOption.label : this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/base-open-menu-inheritWidthOf.js b/components/combobox/__examples__/snapshot/base-open-menu-inheritWidthOf.js new file mode 100644 index 0000000000..a4c43ea06e --- /dev/null +++ b/components/combobox/__examples__/snapshot/base-open-menu-inheritWidthOf.js @@ -0,0 +1,136 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Accounts', + type: 'separator' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + isOpen: true, + labels: { + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + console.log('onChange', value); + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: [] + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + console.log('onSubmit', value); + + _this2.setState({ + selection: [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }] + }); + }, + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + selection: data.selection + }); + } + }, + inheritWidthOf: "menu", + menuMaxWidth: "500px", + options: accounts, + selection: this.state.selection, + value: this.state.selectedOption ? this.state.selectedOption.label : this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/base-open-menu-sub-header.js b/components/combobox/__examples__/snapshot/base-open-menu-sub-header.js new file mode 100644 index 0000000000..61e29b330b --- /dev/null +++ b/components/combobox/__examples__/snapshot/base-open-menu-sub-header.js @@ -0,0 +1,134 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Accounts', + type: 'separator' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + isOpen: true, + labels: { + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + console.log('onChange', value); + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: [] + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + console.log('onSubmit', value); + + _this2.setState({ + selection: [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }] + }); + }, + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + selection: data.selection + }); + } + }, + options: accounts, + selection: this.state.selection, + value: this.state.selectedOption ? this.state.selectedOption.label : this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/base-open.js b/components/combobox/__examples__/snapshot/base-open.js new file mode 100644 index 0000000000..3517b08d3f --- /dev/null +++ b/components/combobox/__examples__/snapshot/base-open.js @@ -0,0 +1,146 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + isOpen: true, + labels: { + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + onChange: function onChange(event, _ref) { + var value = _ref.value; + console.log('onChange', value); + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: [] + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + console.log('onSubmit', value); + + _this2.setState({ + selection: [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }] + }); + }, + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + selection: data.selection + }); + }, + options: accountsWithIcon, + selection: this.state.selection, + value: this.state.selectedOption ? this.state.selectedOption.label : this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/base-selected.js b/components/combobox/__examples__/snapshot/base-selected.js new file mode 100644 index 0000000000..9706b70725 --- /dev/null +++ b/components/combobox/__examples__/snapshot/base-selected.js @@ -0,0 +1,105 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accountsWithIcon[1]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + labels: { + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + options: accountsWithIcon, + selection: this.state.selection, + value: this.state.selectedOption ? this.state.selectedOption.label : this.state.inputValue + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/dialog-open.js b/components/combobox/__examples__/snapshot/dialog-open.js new file mode 100644 index 0000000000..189c028a92 --- /dev/null +++ b/components/combobox/__examples__/snapshot/dialog-open.js @@ -0,0 +1,79 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _popover = _interopRequireDefault(require("../../../../../components/popover")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + assistiveText: { + popoverLabel: 'Language Options' + }, + id: "combobox-unique-id", + isOpen: true, + labels: { + label: 'Languages', + placeholder: 'Select an option' + }, + popover: _react.default.createElement(_popover.default, { + body: _react.default.createElement("div", null, "Any content can go here.") + }), + value: "Select an option", + variant: "popover" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/inline-multiple-selection-selected.js b/components/combobox/__examples__/snapshot/inline-multiple-selection-selected.js new file mode 100644 index 0000000000..17bf63da34 --- /dev/null +++ b/components/combobox/__examples__/snapshot/inline-multiple-selection-selected.js @@ -0,0 +1,195 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accountsWithIcon[0], accountsWithIcon[1]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + console.log('onChange', value); + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + console.log('onSubmit', value); + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.inputValue, + variant: "inline-listbox" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/inline-multiple-selection.js b/components/combobox/__examples__/snapshot/inline-multiple-selection.js new file mode 100644 index 0000000000..30e819966b --- /dev/null +++ b/components/combobox/__examples__/snapshot/inline-multiple-selection.js @@ -0,0 +1,195 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + console.log('onChange', value); + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + console.log('onSubmit', value); + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + multiple: true, + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.inputValue, + variant: "inline-listbox" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/inline-single-selection-selected.js b/components/combobox/__examples__/snapshot/inline-single-selection-selected.js new file mode 100644 index 0000000000..ab5885b253 --- /dev/null +++ b/components/combobox/__examples__/snapshot/inline-single-selection-selected.js @@ -0,0 +1,194 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accountsWithIcon[0]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + console.log('onChange', value); + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + console.log('onSubmit', value); + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.selectedOption ? this.state.selectedOption.label : this.state.inputValue, + variant: "inline-listbox" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/inline-single-selection.js b/components/combobox/__examples__/snapshot/inline-single-selection.js new file mode 100644 index 0000000000..83501f926d --- /dev/null +++ b/components/combobox/__examples__/snapshot/inline-single-selection.js @@ -0,0 +1,194 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _filter = _interopRequireDefault(require("../../../../../components/combobox/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; +var accountsWithIcon = accounts.map(function (elem) { + return _objectSpread({}, elem, { + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: elem.type + }) + }); +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + events: { + onChange: function onChange(event, _ref) { + var value = _ref.value; + console.log('onChange', value); + + _this2.setState({ + inputValue: value + }); + }, + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSubmit: function onSubmit(event, _ref2) { + var value = _ref2.value; + console.log('onSubmit', value); + + _this2.setState({ + inputValue: '', + selection: [].concat(_toConsumableArray(_this2.state.selection), [{ + label: value, + icon: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account" + }) + }]) + }); + }, + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + options: (0, _filter.default)({ + inputValue: this.state.inputValue, + options: accountsWithIcon, + selection: this.state.selection + }), + selection: this.state.selection, + value: this.state.selectedOption ? this.state.selectedOption.label : this.state.inputValue, + variant: "inline-listbox" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/readonly-multiple-selection-multiple-items-selected.js b/components/combobox/__examples__/snapshot/readonly-multiple-selection-multiple-items-selected.js new file mode 100644 index 0000000000..4fcd8c3b61 --- /dev/null +++ b/components/combobox/__examples__/snapshot/readonly-multiple-selection-multiple-items-selected.js @@ -0,0 +1,142 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accounts[0], accounts[1]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + events: { + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + multiple: true, + options: accounts, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/readonly-multiple-selection-single-item-selected.js b/components/combobox/__examples__/snapshot/readonly-multiple-selection-single-item-selected.js new file mode 100644 index 0000000000..3131852a5d --- /dev/null +++ b/components/combobox/__examples__/snapshot/readonly-multiple-selection-single-item-selected.js @@ -0,0 +1,138 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accounts[0]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + events: { + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + multiple: true, + options: accounts, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/readonly-multiple-selection.js b/components/combobox/__examples__/snapshot/readonly-multiple-selection.js new file mode 100644 index 0000000000..c3e23f9229 --- /dev/null +++ b/components/combobox/__examples__/snapshot/readonly-multiple-selection.js @@ -0,0 +1,142 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + events: { + onRequestRemoveSelectedOption: function onRequestRemoveSelectedOption(event, data) { + _this2.setState({ + inputValue: '', + selection: data.selection + }); + }, + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + multiple: true, + options: accounts, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/readonly-single-selection-custom-menu-item.js b/components/combobox/__examples__/snapshot/readonly-single-selection-custom-menu-item.js new file mode 100644 index 0000000000..be4fda6d17 --- /dev/null +++ b/components/combobox/__examples__/snapshot/readonly-single-selection-custom-menu-item.js @@ -0,0 +1,59 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _readonlySingleSelectionCustomMenuItem = _interopRequireDefault(require("../readonly-single-selection-custom-menu-item")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_readonlySingleSelectionCustomMenuItem.default, { + menuPosition: "relative", + isOpen: true + }); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/readonly-single-selection-disabled.js b/components/combobox/__examples__/snapshot/readonly-single-selection-disabled.js new file mode 100644 index 0000000000..6470d6003f --- /dev/null +++ b/components/combobox/__examples__/snapshot/readonly-single-selection-disabled.js @@ -0,0 +1,136 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + events: { + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + options: accounts, + singleInputDisabled: true, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/readonly-single-selection-selected-open.js b/components/combobox/__examples__/snapshot/readonly-single-selection-selected-open.js new file mode 100644 index 0000000000..1c84775e77 --- /dev/null +++ b/components/combobox/__examples__/snapshot/readonly-single-selection-selected-open.js @@ -0,0 +1,132 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accounts[0]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + isOpen: true, + events: { + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + options: accounts, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/readonly-single-selection-selected.js b/components/combobox/__examples__/snapshot/readonly-single-selection-selected.js new file mode 100644 index 0000000000..a94273b12b --- /dev/null +++ b/components/combobox/__examples__/snapshot/readonly-single-selection-selected.js @@ -0,0 +1,133 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _icon = _interopRequireDefault(require("../../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [accounts[0]] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + events: { + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + options: accounts, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/__examples__/snapshot/readonly-single-selection.js b/components/combobox/__examples__/snapshot/readonly-single-selection.js new file mode 100644 index 0000000000..91d07721b7 --- /dev/null +++ b/components/combobox/__examples__/snapshot/readonly-single-selection.js @@ -0,0 +1,131 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../../components/combobox")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var accounts = [{ + id: '1', + label: 'Acme', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '2', + label: 'Salesforce.com, Inc.', + subTitle: 'Account • San Francisco', + type: 'account' +}, { + id: '3', + label: "Paddy's Pub", + subTitle: 'Account • Boston, MA', + type: 'account' +}, { + id: '4', + label: 'Tyrell Corp', + subTitle: 'Account • San Francisco, CA', + type: 'account' +}, { + id: '5', + label: 'Paper St. Soap Company', + subTitle: 'Account • Beloit, WI', + type: 'account' +}, { + id: '6', + label: 'Nakatomi Investments', + subTitle: 'Account • Chicago, IL', + type: 'account' +}, { + id: '7', + label: 'Acme Landscaping', + type: 'account' +}, { + id: '8', + label: 'Acme Construction', + subTitle: 'Account • Grand Marais, MN', + type: 'account' +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + inputValue: '', + selection: [] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_combobox.default, { + id: "combobox-unique-id", + events: { + onSelect: function onSelect(event, data) { + console.log('onSelect', data); + + _this2.setState({ + inputValue: '', + selection: data.selection + }); + } + }, + labels: { + label: 'Search', + placeholder: 'Search Salesforce' + }, + menuPosition: "relative", + options: accounts, + selection: this.state.selection, + value: this.state.inputValue, + variant: "readonly" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ComboboxExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/add-subheadings.js b/components/combobox/add-subheadings.js new file mode 100644 index 0000000000..6826a1a071 --- /dev/null +++ b/components/combobox/add-subheadings.js @@ -0,0 +1,64 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/** + * This is a UX pattern recommendation for auto-complete search results that can contain multiple subheadings within the results. It inserts a subheading object based on `option.type === subheading.id` directly before a found option object and only inserts the subheading at the first occurence of that type of option. + */ +var addSubheadings = function addSubheadings(_ref) { + var _ref2; + + var subheadings = _ref.subheadings, + filteredOptions = _ref.filteredOptions; + + // Let's not mutate things we don't own. + var subheadingsNotPresent = _toConsumableArray(subheadings); + + var filteredOptionsWithSubheadings = filteredOptions.map(function (option) { + var subheadingRelatedToFilteredOption; // Remove subheadings that have been found from + // `subheadingsNotPresent` and flag if they are + // found. + + subheadingsNotPresent = subheadingsNotPresent.filter(function (subheading) { + var subheadingNotPresentInFilteredOptions = true; + + if (option.type === subheading.id) { + subheadingRelatedToFilteredOption = subheading; + subheadingNotPresentInFilteredOptions = false; + } + + return subheadingNotPresentInFilteredOptions; + }); // So that they can be inserted into the current filtered + // options in a child array with the first related option + // OUTPUT + // Array [ + // 0: Array [ + // 0: {id: "account", label: "Accounts", type: "separator"} + // 1: {id: "1", label: "Acme", type: "account"} + // ] + // ] + + return subheadingRelatedToFilteredOption ? [subheadingRelatedToFilteredOption, option] : [option]; + }); // flatten and remove child arrays, so that we have one array + // `...` operates on each array item, not the array + + return (_ref2 = []).concat.apply(_ref2, _toConsumableArray(filteredOptionsWithSubheadings)); +}; + +var _default = addSubheadings; +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/check-props.js b/components/combobox/check-props.js new file mode 100644 index 0000000000..0be11cb1f0 --- /dev/null +++ b/components/combobox/check-props.js @@ -0,0 +1,45 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _deprecatedProperty = _interopRequireDefault(require("../../utilities/warning/deprecated-property")); + +var _oneOfRequiredProperty = _interopRequireDefault(require("../../utilities/warning/one-of-required-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + /* eslint-disable max-len */ + + (0, _deprecatedProperty.default)(COMPONENT, props.isInline, 'isInline', 'menuPosition="relative"', createDocUrl('menuPosition')); + (0, _deprecatedProperty.default)(COMPONENT, props.menuItem, 'menuItem', 'onRenderMenuItem', createDocUrl('onRenderItem')); + /* eslint-enable max-len */ + + if (props.variant !== 'popover') { + (0, _oneOfRequiredProperty.default)(COMPONENT, { + options: props.options + }, createDocUrl('options')); + } else { + (0, _oneOfRequiredProperty.default)(COMPONENT, { + "assistiveText['popoverLabel']": props.assistiveText.popoverLabel + }, createDocUrl('assistiveText')); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/combobox.js b/components/combobox/combobox.js new file mode 100644 index 0000000000..fbcd24ee87 --- /dev/null +++ b/components/combobox/combobox.js @@ -0,0 +1,1597 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _lodash2 = _interopRequireDefault(require("lodash.find")); + +var _lodash3 = _interopRequireDefault(require("lodash.reject")); + +var _lodash4 = _interopRequireDefault(require("lodash.isequal")); + +var _lodash5 = _interopRequireDefault(require("lodash.findindex")); + +var _lodash6 = _interopRequireDefault(require("lodash.isfunction")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _button = _interopRequireDefault(require("../button")); + +var _dialog = _interopRequireDefault(require("../utilities/dialog")); + +var _innerInput = _interopRequireDefault(require("../../components/input/private/inner-input")); + +var _inputIcon = _interopRequireDefault(require("../icon/input-icon")); + +var _menu = _interopRequireDefault(require("./private/menu")); + +var _label = _interopRequireDefault(require("../forms/private/label")); + +var _popover = _interopRequireDefault(require("../popover")); + +var _selectedListbox = _interopRequireDefault(require("../pill-container/private/selected-listbox")); + +var _fieldLevelHelpTooltip = _interopRequireDefault(require("../tooltip/private/field-level-help-tooltip")); + +var _keyCode = _interopRequireDefault(require("../../utilities/key-code")); + +var _keyBuffer = _interopRequireDefault(require("../../utilities/key-buffer")); + +var _keyLetterMenuItemSelect = _interopRequireDefault(require("../../utilities/key-letter-menu-item-select")); + +var _keyCallbacks = _interopRequireDefault(require("../../utilities/key-callbacks")); + +var _menuItemSelectScroll = _interopRequireDefault(require("../../utilities/menu-item-select-scroll")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _constants = require("../../utilities/constants"); + +var _docs = _interopRequireDefault(require("./docs.json")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var currentOpenDropdown; +var documentDefined = typeof document !== 'undefined'; +var propTypes = { + /** + * **Assistive text for accessibility** + * This object is merged with the default props object on every render. + * * `label`: This is used as a visually hidden label if, no `labels.label` is provided. + * * `optionSelectedInMenu`: Added before selected menu items in Read-only variants (Picklists). The default is `Current Selection:`. + * * `popoverLabel`: Used by popover variant, assistive text for the Popover aria-label. + * * `removeSingleSelectedOption`: Used by inline-listbox, single-select variant to remove the selected item (pill). This is a button with focus. The default is `Remove selected option`. + * * `removePill`: Used by multiple selection Comboboxes to remove a selected item (pill). Focus is on the pill. This is not a button. The default is `, Press delete or backspace to remove`. + * * `selectedListboxLabel`: This is a label for the selected listbox. The grouping of pills for multiple selection Comboboxes. The default is `Selected Options:`. + * _Tested with snapshot testing._ + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string, + optionSelectedInMenu: _propTypes.default.string, + popoverLabel: _propTypes.default.string, + removeSingleSelectedOption: _propTypes.default.string, + removePill: _propTypes.default.string, + selectedListboxLabel: _propTypes.default.string + }), + + /** + * The `aria-describedby` attribute is used to indicate the IDs of the elements that describe the object. It is used to establish a relationship between widgets or groups and text that described them. + * This is very similar to aria-labelledby: a label describes the essence of an object, while a description provides more information that the user might need. _Tested with snapshot testing._ + */ + 'aria-describedby': _propTypes.default.string, + + /** + * CSS classes to be added to tag with `.slds-combobox`. Uses `classNames` [API](https://github.com/JedWatson/classnames). _Tested with snapshot testing._ + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * CSS classes to be added to top level tag with `.slds-form-element` and not on `.slds-combobox_container`. Uses `classNames` [API](https://github.com/JedWatson/classnames). _Tested with snapshot testing._ + */ + classNameContainer: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * CSS classes to be added to tag with `.slds-dropdown`. Uses `classNames` [API](https://github.com/JedWatson/classnames). Autocomplete/bass variant menu height should not scroll and should be determined by number items which should be no more than 10. _Tested with snapshot testing._ + */ + classNameMenu: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * CSS classes to be added to tag with `.slds-dropdown__header`. Uses `classNames` [API](https://github.com/JedWatson/classnames). + */ + classNameMenuSubHeader: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Event Callbacks + * * `onBlur`: Called when `input` removes focus. + * * `onChange`: Called when keyboard events occur within `input` + * * `onClose`: Triggered when the menu has closed. + * * `onFocus`: Called when `input` receives focus. + * * `onOpen`: Triggered when the menu has opened. + * * `onRequestClose`: Function called when the menu would like to hide. Please use with `isOpen`. + * * `onRequestOpen`: Function called when the menu would like to show. Please use with `isOpen`. + * * `onRequestRemoveSelectedOption`: Function called when a single selection option is to be removed. + * * `onSelect`: Function called when a menu item is selected + * * `onSubmit`: Function called when user presses enter or submits the `input` + * _Tested with Mocha testing._ + */ + events: _propTypes.default.shape({ + onBlur: _propTypes.default.func, + onChange: _propTypes.default.func, + onClose: _propTypes.default.func, + onFocus: _propTypes.default.func, + onOpen: _propTypes.default.func, + onRequestClose: _propTypes.default.func, + onRequestOpen: _propTypes.default.func, + onRequestRemoveSelectedOption: _propTypes.default.func, + onSelect: _propTypes.default.func, + onSubmit: _propTypes.default.func + }), + + /** + * Message to display when the input is in an error state. When this is present, also visually highlights the component as in error. _Tested with snapshot testing._ + */ + errorText: _propTypes.default.string, + + /** + * A [Tooltip](https://react.lightningdesignsystem.com/components/tooltips/) component that is displayed next to the `labels.label`. The props from the component will be merged and override any default props. + */ + fieldLevelHelpTooltip: _propTypes.default.node, + + /** + * By default, dialogs will flip their alignment (such as bottom to top) if they extend beyond a boundary element such as a scrolling parent or a window/viewpoint. `hasStaticAlignment` disables this behavior and allows this component to extend beyond boundary elements. _Not tested._ + */ + hasStaticAlignment: _propTypes.default.bool, + + /** + * HTML id for component. _Tested with snapshot testing._ + */ + id: _propTypes.default.string, + + /** + * An [Input](https://react.lightningdesignsystem.com/components/inputs) component. + * The props from this component will override any default props. + */ + input: _propTypes.default.node, + + /** + * **Text labels for internationalization** + * This object is merged with the default props object on every render. + * * `label`: This label appears above the input. + * * `cancelButton`: This label is only used by the dialog variant for the cancel button in the footer of the dialog. The default is `Cancel` + * * `doneButton`: This label is only used by the dialog variant for the done button in the footer of the dialog. The default is `Done` + * * `multipleOptionsSelected`: This label is used by the readonly variant when multiple options are selected. The default is `${props.selection.length} options selected`. This will override the entire string. + * * `noOptionsFound`: Custom message that renders when no matches found. The default empty state is just text that says, 'No matches found.'. + * * `placeholder`: Input placeholder + * * `placeholderReadOnly`: Placeholder for Picklist-like Combobox + * * `removePillTitle`: Title on `X` icon + * _Tested with snapshot testing._ + */ + labels: _propTypes.default.shape({ + label: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + multipleOptionsSelected: _propTypes.default.string, + noOptionsFound: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + placeholder: _propTypes.default.string, + placeholderReadOnly: _propTypes.default.string, + removePillTitle: _propTypes.default.string + }), + + /** + * Forces the dropdown to be open or closed. See controlled/uncontrolled callback/prop pattern for more on suggested use view [Concepts and Best Practices](https://github.com/salesforce-ux/design-system-react/blob/master/CONTRIBUTING.md#concepts-and-best-practices) _Tested with snapshot testing._ + */ + isOpen: _propTypes.default.bool, + + /** + * Sets the dialog width to the width of one of the following: + * * `target`: Sets the dialog width to the width of the target. (Menus attached to `input` typically follow this UX pattern), + * * `menu`: Consider setting a `menuMaxWidth` if using this value. If not, width will be set to width of largest menu item. + * * `none`: Does not set a width on the dialog. _Tested with snapshot testing._ + */ + inheritWidthOf: _propTypes.default.oneOf(['target', 'menu', 'none']), + + /** + * Accepts a custom menu item rendering function that becomes a custom component. It should return a React node. The checkmark is still rendered in readonly variants. This function is passed the following props: + * * `assistiveText`: Object, `assistiveText` prop that is passed into Combobox + * * `option`: Object, option data for item being rendered that is passed into Combobox + * * `selected`: Boolean, allows rendering of `assistiveText.optionSelectedInMenu` in Readonly Combobox + * + * _Tested with snapshot testing._ + */ + onRenderMenuItem: _propTypes.default.func, + + /** + * Please select one of the following: + * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog. + * * `overflowBoundaryElement` - The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree. + * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing. + */ + menuPosition: _propTypes.default.oneOf(['absolute', 'overflowBoundaryElement', 'relative']), + + /** + * Sets a maximum width that the menu will be used if `inheritWidthOf` is set to `menu`. (Example: 500px) _Tested with snapshot testing._ + * + */ + menuMaxWidth: _propTypes.default.string, + + /** + * Allows multiple selections _Tested with mocha testing._ + */ + multiple: _propTypes.default.bool, + + /** + * **Array of item objects in the dropdown menu.** + * Each object can contain: + * * `icon`: An `Icon` component. (not used in read-only variant) + * * `id`: A unique identifier string. + * * `label`: A primary string of text for a menu item or group separator. + * * `subTitle`: A secondary string of text added for clarity. (optional) + * * `type`: 'separator' is the only type currently used + * * `disabled`: Set to true to disable this menu item. + * * `tooltipContent`: Content that is displayed in tooltip when item is disabled + * ``` + * { + * id: '2', + * label: 'Salesforce.com, Inc.', + * subTitle: 'Account • San Francisco', + * type: 'account', + * disabled: true, + * tooltipContent: "You don't have permission to select this item." + * }, + * ``` + * Note: At the moment, Combobox does not support two consecutive separators. _Tested with snapshot testing._ + */ + options: _propTypes.default.arrayOf(_propTypes.default.PropTypes.shape({ + id: _propTypes.default.string.isRequired, + icon: _propTypes.default.node, + label: _propTypes.default.string, + subTitle: _propTypes.default.string, + type: _propTypes.default.string, + disabled: _propTypes.default.boolean, + tooltipContent: _propTypes.default.node + })), + + /** + * Determines the height of the menu based on SLDS CSS classes. This only applies to the readonly variant. This is a `number`. + */ + readOnlyMenuItemVisibleLength: _propTypes.default.oneOf([5, 7, 10]), + + /** + * Limits auto-complete input submission to one of the provided options. _Tested with mocha testing._ + */ + predefinedOptionsOnly: _propTypes.default.bool, + + /** + * A `Popover` component. The props from this popover will be merged and override any default props. This also allows a Combobox's Popover dialog to be a controlled component. _Tested with snapshot testing._ + */ + popover: _propTypes.default.node, + + /** + * Applies label styling for a required form element. _Tested with snapshot testing._ + */ + required: _propTypes.default.bool, + + /** + * Accepts an array of item objects. For single selection, pass in an array of one object. For item object keys, see `options` prop. _Tested with snapshot testing._ + */ + selection: _propTypes.default.arrayOf(_propTypes.default.PropTypes.shape({ + id: _propTypes.default.string.isRequired, + icon: _propTypes.default.node, + label: _propTypes.default.string, + subTitle: _propTypes.default.string, + type: _propTypes.default.string + })).isRequired, + + /** + * This callback exposes the selected listbox reference / DOM node to parent components. + */ + selectedListboxRef: _propTypes.default.func, + + /** + * Disables the input and prevents editing the contents. This only applies for single readonly and inline-listbox variants. + */ + singleInputDisabled: _propTypes.default.bool, + + /** + * Accepts a tooltip that is displayed when hovering on disabled menu items. + */ + tooltipMenuItemDisabled: _propTypes.default.element, + + /** + * Value of input. _This is a controlled component,_ so you will need to control the input value by passing the `value` from `onChange` to a parent component or state manager, and then pass it back into the componet with this prop. Please see examples for more clarification. _Tested with snapshot testing._ + */ + value: _propTypes.default.string, + + /** + * Changes styles of the input and menu. Currently `entity` is not supported. + * The options are: + * * `base`: An autocomplete Combobox also allows a user to select an option from a list, but that list can be affected by what the user types into the input of the Combobox. The SLDS website used to call the autocomplete Combobox its `base` variant. + * * `inline-listbox`: An Entity Autocomplete Combobox or Lookup, is used to search for and select Salesforce Entities. + * * `popover`: A dialog Combobox is best used when a listbox, tree, grid, or tree-grid is not the best solution. This variant allows custom content. + * * `readonly`: A readonly text input that allows a user to select an option from a pre-defined list of options. It does not allow free form user input, nor does it allow the user to modify the selected value. + * + * _Tested with snapshot testing._ + */ + variant: _propTypes.default.oneOf(['base', 'inline-listbox', 'popover', 'readonly']) +}; +var defaultProps = { + assistiveText: { + optionSelectedInMenu: 'Current Selection:', + removeSingleSelectedOption: 'Remove selected option', + removePill: ', Press delete or backspace to remove', + selectedListboxLabel: 'Selected Options:' + }, + events: {}, + labels: { + cancelButton: 'Cancel', + doneButton: "Done", + noOptionsFound: 'No matches found.', + optionDisabledTooltipLabel: 'This option is disabled.', + placeholderReadOnly: 'Select an Option', + removePillTitle: 'Remove' + }, + inheritWidthOf: 'target', + menuPosition: 'absolute', + readOnlyMenuItemVisibleLength: 5, + required: false, + selection: [], + singleInputDisabled: false, + variant: 'base' +}; +/** + * A widget that provides a user with an input field that is either an autocomplete or readonly, accompanied with a listbox of pre-definfined options. + */ + +var Combobox = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Combobox, _React$Component); + + function Combobox(_props) { + var _this; + + _classCallCheck(this, Combobox); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Combobox).call(this, _props)); + + _defineProperty(_assertThisInitialized(_this), "getCustomPopoverProps", function (body, _ref) { + var assistiveText = _ref.assistiveText, + labels = _ref.labels; + + /* + * Generate the popover props based on passed in popover props. Using the default behavior if not provided by passed in popover + */ + var popoverBody = _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-assistive-text", + id: "".concat(_this.getId(), "-label") + }, assistiveText.popoverLabel), body); + + var popoverFooter = _react.default.createElement("div", null, _react.default.createElement(_button.default, { + label: labels.cancelButton, + onClick: function onClick(e) { + _this.handleClose(e, { + trigger: 'cancel' + }); + } + }), _react.default.createElement(_button.default, { + label: labels.doneButton, + variant: "brand", + onClick: _this.handleClose + })); + + var defaultPopoverProps = { + ariaLabelledby: "".concat(_this.getId(), "-label"), + align: 'bottom', + body: popoverBody, + className: 'slds-popover_full-width', + footer: popoverFooter, + footerClassName: 'slds-popover__footer_form', + hasNoNubbin: true, + id: "".concat(_this.getId()), + isOpen: _this.state.isOpen, + hasNoTriggerStyles: true, + onOpen: _this.handleOpen, + onClose: _this.handleClose, + onRequestClose: _this.handleClose + }; + /* Merge in passed popover's props if there is any to override the default popover props */ + + var popoverProps = (0, _lodash.default)(defaultPopoverProps, _this.props.popover ? _this.props.popover.props : {}); + popoverProps.body = popoverBody; + delete popoverProps.children; + return popoverProps; + }); + + _defineProperty(_assertThisInitialized(_this), "getId", function () { + return _this.props.id || _this.generatedId; + }); + + _defineProperty(_assertThisInitialized(_this), "getIsActiveOption", function () { + return _this.state.activeOption && _this.state.activeOptionIndex !== -1; + }); + + _defineProperty(_assertThisInitialized(_this), "getIsOpen", function () { + return !!(typeof _this.props.isOpen === 'boolean' ? _this.props.isOpen : _this.state.isOpen); + }); + + _defineProperty(_assertThisInitialized(_this), "getNewActiveOptionIndex", function (_ref2) { + var activeOptionIndex = _ref2.activeOptionIndex, + offset = _ref2.offset, + options = _ref2.options; + // used by menu listbox and selected options listbox + var nextIndex = activeOptionIndex + offset; + var skipIndex = options.length > nextIndex && nextIndex >= 0 && options[nextIndex].type === 'separator'; + var newIndex = skipIndex ? nextIndex + offset : nextIndex; + var hasNewIndex = options.length > nextIndex && nextIndex >= 0; + return hasNewIndex ? newIndex : activeOptionIndex; + }); + + _defineProperty(_assertThisInitialized(_this), "getTargetElement", function () { + return _this.inputRef; + }); + + _defineProperty(_assertThisInitialized(_this), "setInputRef", function (component) { + _this.inputRef = component; // yes, this is a render triggered by a render. + // Dialog/Popper.js cannot place the menu until + // the trigger/target DOM node is mounted. This + // way `findDOMNode` is not called and parent + // DOM nodes are not queried. + + if (!_this.state.inputRendered) { + _this.setState({ + inputRendered: true + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "setSelectedListboxRef", function (ref) { + _this.selectedListboxRef = ref; + + if (_this.props.selectedListboxRef) { + _this.props.selectedListboxRef(ref); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleBlurPill", function () { + _this.setState({ + listboxHasFocus: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClickOutside", function (event) { + _this.handleRequestClose(event, {}); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClose", function (event) { + var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + trigger = _ref3.trigger; + + var isOpen = _this.getIsOpen(); + + if (isOpen) { + if (currentOpenDropdown === _assertThisInitialized(_this)) { + currentOpenDropdown = undefined; + } + + _this.setState({ + activeOption: undefined, + activeOptionIndex: -1, + isOpen: false + }); + + if (_this.props.variant === 'popover' && trigger === 'cancel') { + if (_this.props.popover.props.onClose) { + _this.props.popover.props.onClose(event, { + trigger: trigger + }); + } + } + + if (_this.props.events.onClose) { + _this.props.events.onClose(event, {}); + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleInputBlur", function (event) { + // If menu is open when the input's onBlur event fires, it will close before the onClick of the menu item can fire. + setTimeout(function () { + var activeElement = documentDefined ? document.activeElement : false; // detect if the scrollbar of the combobox-autocomplete/lookup menu is clicked in IE11. If it is, return focus to input, and do not close menu. + + if (activeElement && activeElement.tagName === 'DIV' && activeElement.id === "".concat(_this.getId(), "-listbox")) { + if (_this.inputRef) { + _this.inputRef.focus(); + } + } else if (!_this.props.popover) { + _this.handleClose(event); + } + }, 200); + + if (_this.props.events.onBlur) { + _this.props.events.onBlur(event); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event) { + _this.requestOpenMenu(); + + if (_this.props.events && _this.props.events.onChange) { + _this.props.events.onChange(event, { + value: event.target.value + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleInputFocus", function (event) { + if (_this.props.events.onFocus) { + _this.props.events.onFocus(event, {}); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleInputSubmit", function (event) { + if (_this.state.activeOption && _this.state.activeOption.disabled) { + return; + } // use menu options + + + if (_this.getIsActiveOption()) { + _this.handleSelect(event, { + option: _this.state.activeOption, + selection: _this.props.selection + }); // use input value, if not limited to predefined options (in the menu) + + } else if (!_this.props.predefinedOptionsOnly && event.target.value !== '' && _this.props.events.onSubmit) { + _this.props.events.onSubmit(event, { + value: event.target.value + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) { + var _callbacks; + + var callbacks = (_callbacks = {}, _defineProperty(_callbacks, _keyCode.default.DOWN, { + callback: _this.handleKeyDownDown + }), _defineProperty(_callbacks, _keyCode.default.ENTER, { + callback: _this.handleInputSubmit + }), _defineProperty(_callbacks, _keyCode.default.ESCAPE, { + callback: _this.handleClose + }), _defineProperty(_callbacks, _keyCode.default.UP, { + callback: _this.handleKeyDownUp + }), _callbacks); + + if (_this.props.variant === 'readonly') { + if (_this.props.selection.length > 2) { + callbacks[_keyCode.default.TAB] = { + callback: _this.handleKeyDownTab + }; + } else { + callbacks[_keyCode.default.TAB] = undefined; + } + + callbacks.other = { + callback: _this.handleKeyDownOther, + stopPropagation: false + }; + } // Helper function that takes an object literal of callbacks that are triggered with a key event + + + (0, _keyCallbacks.default)(event, { + callbacks: callbacks + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDownDown", function (event) { + // Don't open if user is selecting text + if (!event.shiftKey) { + _this.openDialog(); + } + + if (_this.props.variant !== 'popover') { + _this.handleNavigateListboxMenu(event, { + direction: 'next' + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDownTab", function () { + if (_this.selectedListboxRef) { + _this.setState({ + listboxHasFocus: true + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDownUp", function (event) { + // Don't open if user is selecting text + if (!event.shiftKey && _this.state.isOpen) { + _this.handleNavigateListboxMenu(event, { + direction: 'previous' + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDownOther", function (event) { + var activeOptionIndex = (0, _keyLetterMenuItemSelect.default)({ + key: event.key, + keyBuffer: _this.menuKeyBuffer, + keyCode: event.keyCode, + options: _this.props.options + }); + + if (activeOptionIndex !== undefined) { + if (_this.state.isOpen) { + (0, _menuItemSelectScroll.default)({ + container: _this.menuRef, + focusedIndex: activeOptionIndex + }); + } + + _this.setState({ + activeOption: _this.props.options[activeOptionIndex], + activeOptionIndex: activeOptionIndex + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleNavigateListboxMenu", function (event, _ref4) { + var direction = _ref4.direction; + var offsets = { + next: 1, + previous: -1 + }; // takes current/previous state and returns an object with the new state + + _this.setState(function (prevState) { + var newIndex = _this.getNewActiveOptionIndex({ + activeOptionIndex: prevState.activeOptionIndex, + offset: offsets[direction], + options: _this.props.options + }); + + if (_this.state.isOpen) { + (0, _menuItemSelectScroll.default)({ + container: _this.menuRef, + focusedIndex: newIndex + }); + } + + return { + activeOption: _this.props.options[newIndex], + activeOptionIndex: newIndex + }; + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleNavigateSelectedListbox", function (event, _ref5) { + var direction = _ref5.direction; + var offsets = { + next: 1, + previous: -1 + }; + + _this.setState(function (prevState) { + var isLastOptionAndRightIsPressed = prevState.activeSelectedOptionIndex + 1 === _this.props.selection.length && direction === 'next'; + var isFirstOptionAndLeftIsPressed = prevState.activeSelectedOptionIndex === 0 && direction === 'previous'; + var newState; + + if (isLastOptionAndRightIsPressed) { + newState = { + activeSelectedOption: _this.props.selection[0], + activeSelectedOptionIndex: 0, + listboxHasFocus: true + }; + } else if (isFirstOptionAndLeftIsPressed) { + newState = { + activeSelectedOption: _this.props.selection[_this.props.selection.length - 1], + activeSelectedOptionIndex: _this.props.selection.length - 1, + listboxHasFocus: true + }; + } else { + var newIndex = _this.getNewActiveOptionIndex({ + activeOptionIndex: prevState.activeSelectedOptionIndex, + offset: offsets[direction], + options: _this.props.selection + }); + + newState = { + activeSelectedOption: _this.props.selection[newIndex], + activeSelectedOptionIndex: newIndex, + listboxHasFocus: true + }; + } + + return newState; + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleOpen", function (event, data) { + var isOpen = _this.getIsOpen(); + + if (!isOpen) { + if (currentOpenDropdown && (0, _lodash6.default)(currentOpenDropdown.handleClose)) { + currentOpenDropdown.handleClose(); + } + } else { + currentOpenDropdown = _assertThisInitialized(_this); + + _this.setState({ + isOpen: true + }); + + if (_this.props.events.onOpen) { + _this.props.events.onOpen(event, data); + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "handlePillClickSelectedListbox", function (event, _ref6) { + var option = _ref6.option, + index = _ref6.index; + + // this is clicking the span, not the remove button + _this.setState({ + activeSelectedOption: option, + activeSelectedOptionIndex: index, + listboxHasFocus: true + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handlePillFocus", function () { + if (!_this.state.listboxHasFocus) { + _this.setState({ + listboxHasFocus: true + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleRemoveSelectedOption", function (event, _ref7) { + var option = _ref7.option, + index = _ref7.index; + event.preventDefault(); + var onlyOnePillAndInputExists = _this.props.selection.length === 1; + var isReadOnlyAndTwoPillsExists = _this.props.selection.length === 2 && _this.props.variant === 'readonly' && _this.props.multiple; + var lastPillWasRemoved = index + 1 === _this.props.selection.length; + + if ((onlyOnePillAndInputExists || isReadOnlyAndTwoPillsExists) && _this.inputRef) { + _this.inputRef.focus(); + } else if (lastPillWasRemoved) { + // set focus to previous option and index + _this.setState({ + activeSelectedOption: _this.props.selection[index - 1], + activeSelectedOptionIndex: index - 1, + listboxHasFocus: true + }); + } else { + // set focus to next option, but same index + _this.setState({ + activeSelectedOption: _this.props.selection[index + 1], + activeSelectedOptionIndex: index, + listboxHasFocus: true + }); + } + + if (_this.props.events.onRequestRemoveSelectedOption) { + _this.props.events.onRequestRemoveSelectedOption(event, { + selection: (0, _lodash3.default)(_this.props.selection, option) + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleRequestClose", function (event, data) { + if (_this.props.events.onRequestClose) { + _this.props.events.onRequestClose(event, data); + } + + if (_this.getIsOpen()) { + _this.setState({ + isOpen: false + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleRequestFocusSelectedListbox", function (event, _ref8) { + var ref = _ref8.ref; + + if (ref) { + _this.activeSelectedOptionRef = ref; + + _this.activeSelectedOptionRef.focus(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleSelect", function (event, _ref9) { + var selection = _ref9.selection, + option = _ref9.option; + var newSelection; + + var isSelected = _this.isSelected({ + selection: selection, + option: option + }); + + var singleSelectAndSelectedWasNotClicked = !_this.props.multiple && !isSelected; + var multiSelectAndSelectedWasNotClicked = _this.props.multiple && !isSelected; + + if (singleSelectAndSelectedWasNotClicked) { + newSelection = [option]; + } else if (multiSelectAndSelectedWasNotClicked) { + newSelection = [].concat(_toConsumableArray(_this.props.selection), [option]); + } else { + newSelection = (0, _lodash3.default)(_this.props.selection, option); + } + + if (_this.props.events.onSelect) { + _this.props.events.onSelect(event, { + selection: newSelection + }); + } + + _this.handleClose(); // if (this.inputRef) { + // this.inputRef.focus(); + // } + + }); + + _defineProperty(_assertThisInitialized(_this), "isSelected", function (_ref10) { + var selection = _ref10.selection, + option = _ref10.option; + return !!(0, _lodash2.default)(selection, option); + }); + + _defineProperty(_assertThisInitialized(_this), "openDialog", function () { + if (_this.props.events.onRequestOpen) { + _this.props.events.onRequestOpen(); + } else { + _this.setState({ + isOpen: true + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "requestOpenMenu", function () { + var isInlineSingleSelectionAndIsNotSelected = !_this.props.multiple && _this.props.selection.length === 0 && _this.props.variant === 'inline-listbox'; + + if (isInlineSingleSelectionAndIsNotSelected || _this.props.multiple || _this.props.variant === 'readonly') { + _this.openDialog(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "renderBase", function (_ref11) { + var assistiveText = _ref11.assistiveText, + labels = _ref11.labels, + props = _ref11.props, + userDefinedProps = _ref11.userDefinedProps; + return _react.default.createElement("div", { + className: "slds-form-element__control" + }, _react.default.createElement("div", { + className: "slds-combobox_container" + }, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-combobox', 'slds-dropdown-trigger', 'slds-dropdown-trigger_click', 'ignore-react-onclickoutside', { + 'slds-is-open': _this.getIsOpen() + }, { + 'slds-has-error': props.errorText + }, props.className), + "aria-expanded": _this.getIsOpen(), + "aria-haspopup": "listbox" // eslint-disable-line jsx-a11y/aria-proptypes + // used on menu's listbox + , + "aria-owns": "".concat(_this.getId(), "-listbox") // eslint-disable-line jsx-a11y/aria-proptypes + , + role: "combobox" + }, _react.default.createElement(_innerInput.default, _extends({ + "aria-autocomplete": "list", + "aria-controls": "".concat(_this.getId(), "-listbox"), + "aria-activedescendant": _this.state.activeOption ? "".concat(_this.getId(), "-listbox-option-").concat(_this.state.activeOption.id) : null, + "aria-describedby": _this.getErrorId(), + autoComplete: "off", + className: "slds-combobox__input", + containerProps: { + className: 'slds-combobox__form-element', + role: 'none' + }, + iconRight: _react.default.createElement(_inputIcon.default, { + category: "utility", + name: "search", + title: labels.inputIconTitle + }), + id: _this.getId(), + onFocus: _this.handleInputFocus, + onBlur: _this.handleInputBlur, + onKeyDown: _this.handleKeyDown, + inputRef: _this.setInputRef, + onClick: function onClick() { + _this.openDialog(); + }, + onChange: _this.handleInputChange, + placeholder: labels.placeholder, + readOnly: !!(props.predefinedOptionsOnly && _this.state.activeOption), + required: props.required, + role: "textbox", + value: props.predefinedOptionsOnly ? _this.state.activeOption && _this.state.activeOption.label || props.value : props.value + }, userDefinedProps.input)), _this.getDialog({ + menuRenderer: _this.renderMenu({ + assistiveText: assistiveText, + labels: labels + }) + }))), _react.default.createElement(_selectedListbox.default, { + activeOption: _this.state.activeSelectedOption, + activeOptionIndex: _this.state.activeSelectedOptionIndex, + assistiveText: assistiveText, + events: { + onBlurPill: _this.handleBlurPill, + onClickPill: _this.handlePillClickSelectedListbox, + onPillFocus: _this.handlePillFocus, + onRequestFocus: _this.handleRequestFocusSelectedListbox, + onRequestFocusOnNextPill: _this.handleNavigateSelectedListbox, + onRequestFocusOnPreviousPill: _this.handleNavigateSelectedListbox, + onRequestRemove: _this.handleRemoveSelectedOption + }, + id: "".concat(_this.getId(), "-selected-listbox"), + labels: labels, + selectedListboxRef: _this.setSelectedListboxRef, + selection: props.selection, + listboxHasFocus: _this.state.listboxHasFocus + }), props.errorText && _react.default.createElement("div", { + className: "slds-has-error" + }, _react.default.createElement("div", { + id: _this.getErrorId(), + className: "slds-form-element__help slds-has-error" + }, props.errorText))); + }); + + _defineProperty(_assertThisInitialized(_this), "renderInlineMultiple", function (_ref12) { + var assistiveText = _ref12.assistiveText, + labels = _ref12.labels, + props = _ref12.props, + userDefinedProps = _ref12.userDefinedProps; + return _react.default.createElement("div", { + className: "slds-form-element__control" + }, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-combobox_container', { + 'slds-has-inline-listbox': props.selection.length + }) + }, props.selection.length ? _react.default.createElement(_selectedListbox.default, { + activeOption: _this.state.activeSelectedOption, + activeOptionIndex: _this.state.activeSelectedOptionIndex, + assistiveText: assistiveText, + events: { + onBlurPill: _this.handleBlurPill, + onClickPill: _this.handlePillClickSelectedListbox, + onPillFocus: _this.handlePillFocus, + onRequestFocus: _this.handleRequestFocusSelectedListbox, + onRequestFocusOnNextPill: _this.handleNavigateSelectedListbox, + onRequestFocusOnPreviousPill: _this.handleNavigateSelectedListbox, + onRequestRemove: _this.handleRemoveSelectedOption + }, + id: "".concat(_this.getId(), "-selected-listbox"), + labels: labels, + selectedListboxRef: _this.setSelectedListboxRef, + selection: props.selection, + listboxHasFocus: _this.state.listboxHasFocus + }) : null, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-combobox', 'slds-dropdown-trigger', 'slds-dropdown-trigger_click', 'ignore-react-onclickoutside', { + 'slds-is-open': _this.getIsOpen() + }, { + 'slds-has-error': props.errorText + }, props.className), + "aria-expanded": _this.getIsOpen(), + "aria-haspopup": "listbox" // eslint-disable-line jsx-a11y/aria-proptypes + , + role: "combobox" + }, _react.default.createElement(_innerInput.default, _extends({ + "aria-autocomplete": "list", + "aria-controls": "".concat(_this.getId(), "-listbox"), + "aria-activedescendant": _this.state.activeOption ? "".concat(_this.getId(), "-listbox-option-").concat(_this.state.activeOption.id) : null, + "aria-describedby": _this.getErrorId(), + autoComplete: "off", + className: "slds-combobox__input", + containerProps: { + 'aria-expanded': _this.getIsOpen(), + 'aria-haspopup': 'listbox', + className: 'slds-combobox__form-element', + role: 'none' + }, + iconRight: _react.default.createElement(_inputIcon.default, { + category: "utility", + name: "search", + title: labels.inputIconTitle + }), + id: _this.getId(), + onFocus: _this.handleInputFocus, + onBlur: _this.handleInputBlur, + onKeyDown: _this.handleKeyDown, + inputRef: _this.setInputRef, + onClick: function onClick() { + _this.openDialog(); + }, + onChange: _this.handleInputChange, + placeholder: labels.placeholder, + readOnly: !!(props.predefinedOptionsOnly && _this.state.activeOption), + required: props.required, + role: "textbox", + value: props.predefinedOptionsOnly ? _this.state.activeOption && _this.state.activeOption.label || props.value : props.value + }, userDefinedProps.input)), _this.getDialog({ + menuRenderer: _this.renderMenu({ + assistiveText: assistiveText, + labels: labels + }) + }), props.errorText && _react.default.createElement("div", { + id: _this.getErrorId(), + className: "slds-form-element__help" + }, props.errorText)))); + }); + + _defineProperty(_assertThisInitialized(_this), "renderInlineSingle", function (_ref13) { + var assistiveText = _ref13.assistiveText, + labels = _ref13.labels, + props = _ref13.props, + userDefinedProps = _ref13.userDefinedProps; + var iconLeft = props.selection[0] && props.selection[0].icon ? _react.default.cloneElement(props.selection[0].icon, { + containerClassName: 'slds-combobox__input-entity-icon' + }) : null; + var value = props.selection[0] && props.selection[0].label ? props.selection[0].label : props.value; + /* eslint-disable jsx-a11y/role-supports-aria-props */ + + return _react.default.createElement("div", { + className: "slds-form-element__control" + }, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-combobox_container', { + 'slds-has-inline-listbox': props.selection.length + }) + }, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-combobox', 'slds-dropdown-trigger', 'slds-dropdown-trigger_click', 'ignore-react-onclickoutside', { + 'slds-is-open': _this.getIsOpen() + }, { + 'slds-has-error': props.errorText + }, props.className), + "aria-expanded": _this.getIsOpen(), + "aria-haspopup": "listbox" // eslint-disable-line jsx-a11y/aria-proptypes + , + role: "combobox" + }, _react.default.createElement(_innerInput.default, _extends({ + "aria-autocomplete": "list", + "aria-controls": "".concat(_this.getId(), "-listbox"), + "aria-activedescendant": _this.state.activeOption ? "".concat(_this.getId(), "-listbox-option-").concat(_this.state.activeOption.id) : null, + "aria-describedby": _this.getErrorId(), + autoComplete: "off", + className: "slds-combobox__input", + containerProps: { + className: 'slds-combobox__form-element', + role: 'none' + }, + disabled: _this.props.singleInputDisabled, + iconRight: props.selection.length ? _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: assistiveText.removeSingleSelectedOption + }, + buttonRef: function buttonRef(component) { + _this.buttonRef = component; + }, + category: "utility", + iconPosition: "right", + name: "close", + onClick: function onClick(event) { + _this.handleRemoveSelectedOption(event, { + option: props.selection[0] + }); + } + }) : _react.default.createElement(_inputIcon.default, { + category: "utility", + name: "search" + }), + iconLeft: iconLeft, + id: _this.getId(), + onFocus: _this.handleInputFocus, + onBlur: _this.handleInputBlur, + onKeyDown: _this.handleKeyDown, + inputRef: _this.setInputRef, + onClick: function onClick() { + _this.requestOpenMenu(); + }, + onChange: function onChange(event) { + if (!props.selection.length) { + _this.handleInputChange(event); + } + }, + placeholder: labels.placeholder, + readOnly: !!(props.predefinedOptionsOnly && _this.state.activeOption) || !!props.selection.length, + required: props.required, + role: "textbox", + value: props.predefinedOptionsOnly ? _this.state.activeOption && _this.state.activeOption.label || props.value : value + }, userDefinedProps.input)), _this.getDialog({ + menuRenderer: _this.renderMenu({ + assistiveText: assistiveText, + labels: labels + }) + }), props.errorText && _react.default.createElement("div", { + id: _this.getErrorId(), + className: "slds-form-element__help" + }, props.errorText)))); + }); + + _defineProperty(_assertThisInitialized(_this), "renderMenu", function (_ref14) { + var assistiveText = _ref14.assistiveText, + labels = _ref14.labels; + var menuVariant = { + base: 'icon-title-subtitle', + 'inline-listbox': 'icon-title-subtitle', + readonly: 'checkbox' + }; + return _react.default.createElement(_menu.default, { + assistiveText: assistiveText, + activeOption: _this.state.activeOption, + activeOptionIndex: _this.state.activeOptionIndex, + classNameMenu: _this.props.classNameMenu, + classNameMenuSubHeader: _this.props.classNameMenuSubHeader, + tooltipMenuItemDisabled: _this.props.tooltipMenuItemDisabled, + inheritWidthOf: _this.props.inheritWidthOf, + inputId: _this.getId(), + inputValue: _this.props.value, + isSelected: _this.isSelected, + itemVisibleLength: _this.props.variant === 'readonly' ? _this.props.readOnlyMenuItemVisibleLength : null, + labels: labels // For backward compatibility, 'menuItem' prop will be deprecated soon + , + onRenderMenuItem: _this.props.onRenderMenuItem ? _this.props.onRenderMenuItem : _this.props.menuItem, + menuPosition: _this.props.menuPosition, + menuRef: function menuRef(ref) { + _this.menuRef = ref; + }, + maxWidth: _this.props.menuMaxWidth, + options: _this.props.options, + onSelect: _this.handleSelect, + clearActiveOption: _this.clearActiveOption, + selection: _this.props.selection, + variant: menuVariant[_this.props.variant] + }); + }); + + _defineProperty(_assertThisInitialized(_this), "renderPopover", function (_ref15) { + var assistiveText = _ref15.assistiveText, + labels = _ref15.labels, + props = _ref15.props; + + var popoverProps = _this.getCustomPopoverProps(_this.props.popover.props.body, { + assistiveText: assistiveText, + labels: labels + }); + + return _react.default.createElement("div", { + className: "slds-form-element__control" + }, _react.default.createElement("div", { + className: "slds-combobox_container" + }, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-combobox', 'slds-dropdown-trigger', 'slds-dropdown-trigger_click', 'ignore-react-onclickoutside', { + 'slds-is-open': _this.getIsOpen() + }, { + 'slds-has-error': props.errorText + }, props.className), + "aria-expanded": _this.getIsOpen(), + "aria-haspopup": "dialog" // eslint-disable-line jsx-a11y/aria-proptypes + , + "aria-owns": "".concat(_this.getId()) // eslint-disable-line jsx-a11y/aria-proptypes + , + role: "combobox" + }, _react.default.createElement(_popover.default, popoverProps, _react.default.createElement(_innerInput.default, { + "aria-autocomplete": "none", + "aria-controls": "".concat(_this.getId()), + "aria-describedby": _this.getErrorId(), + autoComplete: "off", + className: "slds-combobox__input", + containerProps: { + className: 'slds-combobox__form-element', + role: 'none' + }, + iconRight: _react.default.createElement(_inputIcon.default, { + category: "utility", + name: "down" + }), + id: _this.getId(), + onFocus: _this.handleInputFocus, + onBlur: _this.handleInputBlur, + onKeyDown: _this.handleKeyDown, + inputRef: _this.setInputRef, + onClick: function onClick() { + _this.openDialog(); + }, + onChange: _this.handleInputChange, + placeholder: labels.placeholder, + readOnly: true, + required: props.required, + role: "textbox", + value: props.value + })))), props.errorText && _react.default.createElement("div", { + className: "slds-has-error" + }, _react.default.createElement("div", { + id: _this.getErrorId(), + className: "slds-form-element__help slds-has-error" + }, props.errorText))); + }); + + _defineProperty(_assertThisInitialized(_this), "renderReadOnlyMultiple", function (_ref16) { + var assistiveText = _ref16.assistiveText, + labels = _ref16.labels, + props = _ref16.props, + userDefinedProps = _ref16.userDefinedProps; + var value = props.selection.length > 1 ? labels.multipleOptionsSelected || "".concat(props.selection.length, " options selected") : props.selection[0] && props.selection[0].label || ''; + /* eslint-disable jsx-a11y/role-supports-aria-props */ + + return _react.default.createElement("div", { + className: "slds-form-element__control" + }, _react.default.createElement("div", { + className: "slds-combobox_container" + }, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-combobox', 'slds-dropdown-trigger', 'slds-dropdown-trigger_click', 'ignore-react-onclickoutside', { + 'slds-is-open': _this.getIsOpen() + }, { + 'slds-has-error': props.errorText + }, props.className), + "aria-expanded": _this.getIsOpen(), + "aria-haspopup": "listbox" // eslint-disable-line jsx-a11y/aria-proptypes + , + role: "combobox" + }, _react.default.createElement(_innerInput.default, _extends({ + "aria-autocomplete": "list", + "aria-controls": "".concat(_this.getId(), "-listbox"), + "aria-activedescendant": _this.state.activeOption ? "".concat(_this.getId(), "-listbox-option-").concat(_this.state.activeOption.id) : null, + "aria-describedby": _this.getErrorId(), + autoComplete: "off", + className: "slds-combobox__input", + containerProps: { + 'aria-expanded': _this.getIsOpen(), + 'aria-haspopup': 'listbox', + className: 'slds-combobox__form-element', + role: 'none' + }, + iconRight: _react.default.createElement(_inputIcon.default, { + category: "utility", + name: "down", + variant: "combobox" + }), + id: _this.getId(), + onFocus: _this.handleInputFocus, + onBlur: _this.handleInputBlur, + onKeyDown: _this.handleKeyDown, + inputRef: _this.setInputRef, + onClick: function onClick() { + _this.requestOpenMenu(); + }, + onChange: function onChange(event) { + if (!props.selection.length) { + _this.handleInputChange(event); + } + }, + placeholder: labels.placeholderReadOnly, + readOnly: true, + required: props.required, + role: "textbox", + value: value + }, userDefinedProps.input)), _this.getDialog({ + menuRenderer: _this.renderMenu({ + assistiveText: assistiveText, + labels: labels + }) + }))), _react.default.createElement(_selectedListbox.default, { + activeOption: _this.state.activeSelectedOption, + activeOptionIndex: _this.state.activeSelectedOptionIndex, + assistiveText: assistiveText, + events: { + onBlurPill: _this.handleBlurPill, + onClickPill: _this.handlePillClickSelectedListbox, + onPillFocus: _this.handlePillFocus, + onRequestFocus: _this.handleRequestFocusSelectedListbox, + onRequestFocusOnNextPill: _this.handleNavigateSelectedListbox, + onRequestFocusOnPreviousPill: _this.handleNavigateSelectedListbox, + onRequestRemove: _this.handleRemoveSelectedOption + }, + id: "".concat(_this.getId(), "-selected-listbox"), + labels: labels, + selectedListboxRef: _this.setSelectedListboxRef, + selection: props.selection, + listboxHasFocus: _this.state.listboxHasFocus, + variant: _this.props.variant, + renderAtSelectionLength: 2 + }), props.errorText && _react.default.createElement("div", { + className: "slds-has-error" + }, _react.default.createElement("div", { + id: _this.getErrorId(), + className: "slds-form-element__help slds-has-error" + }, props.errorText))); + }); + + _defineProperty(_assertThisInitialized(_this), "renderReadOnlySingle", function (_ref17) { + var assistiveText = _ref17.assistiveText, + labels = _ref17.labels, + props = _ref17.props, + userDefinedProps = _ref17.userDefinedProps; + var value = props.selection[0] && props.selection[0].label || ''; + /* eslint-disable jsx-a11y/role-supports-aria-props */ + + return _react.default.createElement("div", { + className: "slds-form-element__control" + }, _react.default.createElement("div", { + className: "slds-combobox_container" + }, _react.default.createElement("div", { + // aria attributes have been moved to the `div` wrapping `input` to comply with ARIA 1.1. + className: (0, _classnames.default)('slds-combobox', 'slds-dropdown-trigger', 'slds-dropdown-trigger_click', 'ignore-react-onclickoutside', { + 'slds-is-open': _this.getIsOpen() + }, { + 'slds-has-error': props.errorText + }, props.className), + "aria-expanded": _this.getIsOpen(), + "aria-haspopup": "listbox" // eslint-disable-line jsx-a11y/aria-proptypes + , + role: "combobox" + }, _react.default.createElement(_innerInput.default, _extends({ + "aria-autocomplete": "list", + "aria-controls": "".concat(_this.getId(), "-listbox"), + "aria-activedescendant": _this.state.activeOption ? "".concat(_this.getId(), "-listbox-option-").concat(_this.state.activeOption.id) : null, + "aria-describedby": _this.getErrorId(), + autoComplete: "off", + className: "slds-combobox__input", + containerProps: { + 'aria-expanded': _this.getIsOpen(), + 'aria-haspopup': 'listbox', + className: 'slds-combobox__form-element', + role: 'none' + }, + disabled: _this.props.singleInputDisabled, + iconRight: _react.default.createElement(_inputIcon.default, { + category: "utility", + name: "down", + variant: "combobox" + }), + id: _this.getId(), + onFocus: _this.handleInputFocus, + onBlur: _this.handleInputBlur, + onKeyDown: _this.handleKeyDown, + inputRef: _this.setInputRef, + onClick: function onClick() { + _this.requestOpenMenu(); + }, + onChange: function onChange(event) { + if (!props.selection.length) { + _this.handleInputChange(event); + } + }, + placeholder: labels.placeholderReadOnly, + readOnly: true, + required: props.required, + role: "textbox", + value: _this.state.activeOption && _this.state.activeOption.label || value + }, userDefinedProps.input)), _this.getDialog({ + menuRenderer: _this.renderMenu({ + assistiveText: assistiveText, + labels: labels + }) + }), props.errorText && _react.default.createElement("div", { + id: _this.getErrorId(), + className: "slds-form-element__help" + }, props.errorText)))); + }); + + _this.state = { + activeOption: undefined, + activeOptionIndex: -1, + // seeding initial state with this.props.selection[0] + activeSelectedOption: _this.props.selection && _this.props.selection[0] || undefined, + activeSelectedOptionIndex: 0, + listboxHasFocus: false, + isOpen: false + }; + _this.menuKeyBuffer = new _keyBuffer.default(); + _this.menuRef = undefined; + _this.selectedListboxRef = null; + return _this; + } + /** + * Lifecycle methods + */ + + + _createClass(Combobox, [{ + key: "componentWillMount", + value: function componentWillMount() { + // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + (0, _checkProps.default)(_constants.COMBOBOX, this.props, _docs.default); + this.generatedId = _shortid.default.generate(); + this.generatedErrorId = _shortid.default.generate(); + + if (this.props.isOpen) { + this.setState({ + isOpen: this.props.isOpen + }); + } + } + }, { + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + var _this2 = this; + + // This logic will maintain the active highlight even when the + // option order changes. One example would be the server pushes + // data out as the user has the menu open. This logic clears + // `activeOption` if the active option is no longer in the options + // list. If it's in the options list, then find the new index and + // set `activeOptionIndex` + if (!(0, _lodash4.default)(this.props.options, nextProps.options)) { + var index = (0, _lodash5.default)(nextProps.options, function (item) { + return (0, _lodash4.default)(item, _this2.state.activeOption); + }); + + if (index !== -1) { + this.setState({ + activeOptionIndex: index + }); + } else { + this.setState({ + activeOption: undefined, + activeOptionIndex: -1 + }); + } + } else if (this.props.isOpen !== nextProps.isOpen) { + this.setState({ + isOpen: nextProps.isOpen + }); + } // there may be issues with tabindex/focus if the app removes an item + // from selection while the user is using the listbox + + + var selectedOptionsRenderIsInitialRender = this.props.selection && this.props.selection.length === 0 && nextProps.selection.length > 0; + + if (selectedOptionsRenderIsInitialRender) { + this.setState({ + activeSelectedOption: nextProps.selection[0], + activeSelectedOptionIndex: 0 + }); + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + if (currentOpenDropdown === this) { + currentOpenDropdown = undefined; + } + } + }, { + key: "getDialog", + value: function getDialog(_ref18) { + var menuRenderer = _ref18.menuRenderer; + // FOR BACKWARDS COMPATIBILITY + var menuPosition = this.props.isInline ? 'relative' : this.props.menuPosition; // eslint-disable-line react/prop-types + + return !this.props.disabled && this.getIsOpen() ? _react.default.createElement(_dialog.default, { + align: "bottom left", + context: this.context, + hasStaticAlignment: this.props.hasStaticAlignment, + inheritWidthOf: this.props.inheritWidthOf, + onClose: this.handleClose, + onMouseDown: function onMouseDown(event) { + // prevent onBlur + event.preventDefault(); + }, + onOpen: this.handleOpen, + onRequestTargetElement: this.getTargetElement, + position: menuPosition, + containerProps: { + id: "".concat(this.getId(), "-listbox"), + role: 'listbox' + } + }, menuRenderer) : null; + } + }, { + key: "getErrorId", + value: function getErrorId() { + return this.props['aria-describedby'] || this.props.errorText && this.generatedErrorId; + } + /** + * Shared class property getter methods + */ + + }, { + key: "render", + value: function render() { + var props = this.props; // Merge objects of strings with their default object + + var assistiveText = (0, _lodash.default)({}, defaultProps.assistiveText, props.assistiveText); + var labels = (0, _lodash.default)({}, defaultProps.labels, this.props.labels); + var hasRenderedLabel = labels.label || assistiveText && assistiveText.label; // declare user defined props + + var userDefinedProps = {}; + + if (props.input) { + // at the moment we only support overriding the input props + userDefinedProps.input = props.input.props; + } + + var subRenderParameters = { + assistiveText: assistiveText, + labels: labels, + props: this.props, + userDefinedProps: userDefinedProps + }; + var multipleOrSingle = this.props.multiple ? 'multiple' : 'single'; + var subRenders = { + base: { + multiple: this.renderBase, + // same + single: this.renderBase + }, + 'inline-listbox': { + multiple: this.renderInlineMultiple, + single: this.renderInlineSingle + }, + popover: { + multiple: this.renderPopover, + // same + single: this.renderPopover + }, + readonly: { + multiple: this.renderReadOnlyMultiple, + single: this.renderReadOnlySingle + } + }; + var variantExists = subRenders[this.props.variant][multipleOrSingle]; + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-form-element', props.classNameContainer) + }, _react.default.createElement(_label.default, { + assistiveText: this.props.assistiveText, + htmlFor: this.getId(), + label: labels.label, + required: props.required + }), this.props.fieldLevelHelpTooltip && hasRenderedLabel ? _react.default.createElement(_fieldLevelHelpTooltip.default, { + fieldLevelHelpTooltip: this.props.fieldLevelHelpTooltip + }) : null, variantExists ? subRenders[this.props.variant][multipleOrSingle](subRenderParameters) : subRenders.base.multiple(subRenderParameters)); + } + }]); + + return Combobox; +}(_react.default.Component); +/* eslint-enable jsx-a11y/role-supports-aria-props */ + + +Combobox.contextTypes = { + iconPath: _propTypes.default.string +}; +Combobox.displayName = _constants.COMBOBOX; +Combobox.propTypes = propTypes; +Combobox.defaultProps = defaultProps; +var _default = Combobox; +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/docs.json b/components/combobox/docs.json new file mode 100644 index 0000000000..dc8617c43e --- /dev/null +++ b/components/combobox/docs.json @@ -0,0 +1,11 @@ +{ + "component": "combobox", + "status": "prod", + "display-name": "Comboboxes", + "last-accessibility-review": { + "date-iso-8601": "2017/08/21", + "commit-sha": "295a4766f712a5f93743c4ecd3ba62d91c1fc153" + }, + "SLDS-component-path": "/components/combobox", + "url-slug": "comboboxes" +} \ No newline at end of file diff --git a/components/combobox/filter.js b/components/combobox/filter.js new file mode 100644 index 0000000000..5f648cf2df --- /dev/null +++ b/components/combobox/filter.js @@ -0,0 +1,37 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/** + * SLDS recommends auto-complete/search inputs menus have a limit of 10 items. + */ +var filter = function filter(_ref) { + var inputValue = _ref.inputValue, + _ref$limit = _ref.limit, + limit = _ref$limit === void 0 ? 10 : _ref$limit, + options = _ref.options, + selection = _ref.selection; + var inputValueRegExp = new RegExp((0, _lodash.default)(inputValue), 'ig'); + return options.filter(function (option) { + var searchTermFound = option.label ? option.label.match(inputValueRegExp) : false; + var isSeparator = option.type === 'separator'; + var notAlreadySelected = !selection.some(function (sel) { + return sel.id === option.id; + }); + return (!inputValue || isSeparator || searchTermFound) && notAlreadySelected; + }).splice(0, limit); +}; + +var _default = filter; +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/index.js b/components/combobox/index.js new file mode 100644 index 0000000000..8c797aa4e1 --- /dev/null +++ b/components/combobox/index.js @@ -0,0 +1,23 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _reactOnclickoutside = _interopRequireDefault(require("react-onclickoutside")); + +var _combobox = _interopRequireDefault(require("./combobox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// ### onClickOutside +// Listen for clicks that occur somewhere in the document, outside of the element itself +var _default = (0, _reactOnclickoutside.default)(_combobox.default, { + excludeScrollbar: true +}); + +exports.default = _default; \ No newline at end of file diff --git a/components/combobox/private/menu.js b/components/combobox/private/menu.js new file mode 100644 index 0000000000..3ee085e334 --- /dev/null +++ b/components/combobox/private/menu.js @@ -0,0 +1,309 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.isequal")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _icon = _interopRequireDefault(require("../../icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +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; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +var propTypes = { + /* + * Active descendant in menu + */ + activeOption: _propTypes.default.object, + + /* + * Index of active descendant in menu + */ + activeOptionIndex: _propTypes.default.number, + + /** + * CSS classes to be added to container `div` tag. Uses `classNames` [API](https://github.com/JedWatson/classnames). + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * CSS classes to be added to tag with `.slds-dropdown`. Uses `classNames` [API](https://github.com/JedWatson/classnames). + */ + classNameMenu: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * CSS classes to be added to menu sub header `span` tag. Uses `classNames` [API](https://github.com/JedWatson/classnames). + */ + classNameMenuSubHeader: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Sets the dialog width to the width of one of the following: + * `target`: (Menus attached to `input` typically follow this UX pattern), + * `menu`: Consider setting a menuMaxWidth if using this value. If not, width will be set to width of largest menu item. + * 'none' + */ + inheritWidthOf: _propTypes.default.oneOf(['target', 'menu', 'none']), + + /* + * Id used for assistive technology + */ + inputId: _propTypes.default.string, + + /** + * Determines the height of the menu based on SLDS CSS classes. + */ + itemVisibleLength: _propTypes.default.oneOf([5, 7, 10]), + + /** + * **Text labels for internationalization** + * This object is merged with the default props object on every render. + * * `noOptionsFound`: Custom message that renders when no matches found. The default empty state is just text that says, 'No matches found.'. + */ + labels: _propTypes.default.shape({ + noOptionsFound: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]).isRequired + }), + + /** + * Accepts a custom menu item rendering function that becomes a custom component and is passed in the following props: + * * `assistiveText`: Object, `assistiveText` prop that is passed into Combobox + * * `option`: Object, option data for item being rendered that is passed into Combobox + * * `selected`: Boolean, allows rendering of `assistiveText.optionSelectedInMenu` in Readonly Combobox + * + * _Tested with snapshot testing._ + */ + onRenderMenuItem: _propTypes.default.func, + + /** + * Accepts a ref function or object (React.createRef() or otherwise) to store the menu DOM reference once available + */ + menuRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]), + + /* + * Sets a maximum width that the menu will be if `inheritWidthOf` is menu. + */ + maxWidth: _propTypes.default.string, + + /* + * Callback when option is selected with keyboard or mouse + */ + onSelect: _propTypes.default.func, + + /* + * Menu options + */ + options: _propTypes.default.array, + + /* + * Callback to remove active descendent + */ + resetActiveOption: _propTypes.default.func, + + /* + * Selected options + */ + selection: _propTypes.default.array, + + /** + * Acepts a tooltip that is displayed when hovering on disabled menu items. + */ + tooltipMenuItemDisabled: _propTypes.default.element, + + /** + * Changes styles of the menu option + */ + variant: _propTypes.default.oneOf(['icon-title-subtitle', 'checkbox']), + isSelected: _propTypes.default.func, + assistiveText: _propTypes.default.object +}; +var defaultProps = { + menuRef: function menuRef() {} +}; + +var Menu = function Menu(props) { + var maxWidth = props.inheritWidthOf === 'menu' ? 'inherit' : undefined; + maxWidth = props.inheritWidthOf === 'menu' && props.maxWidth ? props.maxWidth : maxWidth; // .slds-dropdown sets the menu to absolute positioning, since it has a relative parent. Absolute positioning removes clientHeight and clientWidth which Popper.js needs to absolute position the menu's wrapping div. Absolute positioning an already absolute positioned element doesn't work. Setting the menu's position to relative allows PopperJS to work it's magic. + + var menuOptions = props.options.map(function (optionData, index) { + var active = index === props.activeOptionIndex && (0, _lodash.default)(optionData, props.activeOption); + var selected = props.isSelected({ + selection: props.selection, + option: optionData + }); + var MenuItem = props.onRenderMenuItem; + + if (optionData.type === 'separator') { + return optionData.label ? _react.default.createElement("li", { + className: "slds-dropdown__header slds-truncate", + title: optionData.label, + role: "separator", + key: "menu-separator-".concat(optionData.id) + }, _react.default.createElement("span", { + className: (0, _classnames.default)('slds-listbox__option-header', props.classNameMenuSubHeader) + }, optionData.label)) : _react.default.createElement("li", { + className: "slds-has-divider_top-space", + role: "separator", + key: "menu-separator-".concat(optionData.id) + }); + } + + var disabledProps = {}; + var tooltipId = "".concat(props.inputId, "-listbox-option-help-").concat(optionData.id); + + if (optionData.disabled && props.tooltipMenuItemDisabled && active) { + disabledProps['aria-describedby'] = tooltipId; + } + + if (optionData.disabled) { + disabledProps['aria-disabled'] = !!optionData.disabled; + disabledProps.style = { + cursor: 'default' + }; // Replace this with a css class name once SLDS has it. + } + + var menuItem = { + 'icon-title-subtitle': _react.default.createElement("span", _extends({ + "aria-selected": active + }, disabledProps, { + id: "".concat(props.inputId, "-listbox-option-").concat(optionData.id), + className: (0, _classnames.default)('slds-media slds-listbox__option', 'slds-listbox__option_entity slds-listbox__option_has-meta', { + 'slds-has-focus': active + }), + onClick: optionData.disabled ? null : function (event) { + props.onSelect(event, { + option: optionData + }); + }, + role: "option" + }), optionData.icon && !props.onRenderMenuItem ? _react.default.createElement("span", { + className: "slds-media__figure" + }, optionData.icon) : null, props.onRenderMenuItem ? _react.default.createElement(MenuItem, { + assistiveText: props.assistiveText, + selected: selected, + option: optionData + }) : _react.default.createElement("span", { + className: "slds-media__body" + }, _react.default.createElement("span", { + className: (0, _classnames.default)('slds-listbox__option-text', 'slds-listbox__option-text_entity', { + 'slds-disabled-text': optionData.disabled + }) + }, optionData.label), _react.default.createElement("span", { + className: (0, _classnames.default)('slds-listbox__option-meta slds-listbox__option-meta_entity', { + 'slds-disabled-text': optionData.disabled + }) + }, optionData.subTitle))), + checkbox: _react.default.createElement("span", _extends({ + // eslint-disable-line jsx-a11y/no-static-element-interactions + "aria-selected": active + }, disabledProps, { + id: "".concat(props.inputId, "-listbox-option-").concat(optionData.id), + className: (0, _classnames.default)('slds-media slds-listbox__option', ' slds-listbox__option_plain slds-media_small slds-media_center', { + 'slds-has-focus': active, + 'slds-is-selected': selected + }), + onClick: optionData.disabled ? null : function (event) { + props.onSelect(event, { + selection: props.selection, + option: optionData + }); + }, + role: "option" + }), _react.default.createElement("span", { + className: "slds-media__figure" + }, _react.default.createElement(_icon.default, { + className: "slds-listbox__icon-selected", + category: "utility", + name: "check", + size: "x-small" + })), _react.default.createElement("span", { + className: "slds-media__body" + }, props.onRenderMenuItem ? _react.default.createElement(MenuItem, { + assistiveText: props.assistiveText, + selected: selected, + option: optionData + }) : _react.default.createElement("span", { + className: (0, _classnames.default)('slds-truncate', { + 'slds-disabled-text': optionData.disabled + }), + title: optionData.label + }, selected ? _react.default.createElement("span", { + className: "slds-assistive-text" + }, props.assistiveText.optionSelectedInMenu) : null, ' ', optionData.label))) + }; + var item; + + if (optionData.disabled && props.tooltipMenuItemDisabled) { + var _props$tooltipMenuIte = props.tooltipMenuItemDisabled.props, + content = _props$tooltipMenuIte.content, + userDefinedTooltipProps = _objectWithoutProperties(_props$tooltipMenuIte, ["content"]); + + var tooltipProps = _objectSpread({ + align: 'top', + content: optionData.tooltipContent || content, + // either use specific content defined on option or content defined on tooltip component. + id: tooltipId, + position: 'absolute', + triggerStyle: { + width: '100%' + } + }, userDefinedTooltipProps); + + if (active) { + // allows showing the tooltip on keyboard navigation to disabled menu item + tooltipProps.isOpen = true; + } + + item = _react.default.cloneElement(props.tooltipMenuItemDisabled, tooltipProps, menuItem[props.variant]); + } else { + item = menuItem[props.variant]; + } + + return _react.default.createElement("li", { + className: "slds-listbox__item", + key: "menu-option-".concat(optionData.id), + role: "presentation" + }, item); + }); + return _react.default.createElement("ul", { + className: (0, _classnames.default)('slds-listbox slds-listbox_vertical slds-dropdown slds-dropdown_fluid', { + 'slds-dropdown_length-with-icon-5': props.itemVisibleLength === 5, + 'slds-dropdown_length-with-icon-7': props.itemVisibleLength === 7, + 'slds-dropdown_length-with-icon-10': props.itemVisibleLength === 10 + }, props.classNameMenu), + ref: props.menuRef, + role: "presentation", + style: { + width: props.inheritWidthOf === 'menu' ? 'auto' : undefined, + maxWidth: maxWidth, + position: props.menuPosition !== 'relative' ? 'relative' : undefined + } + }, menuOptions.length ? menuOptions : _react.default.createElement("li", { + className: "slds-listbox__item slds-listbox__status", + role: "status", + "aria-live": "polite" + }, _react.default.createElement("span", { + className: "slds-m-left_x-large slds-p-vertical_medium" + }, props.labels.noOptionsFound))); +}; + +Menu.displayName = 'Menu'; +Menu.propTypes = propTypes; +Menu.defaultProps = defaultProps; +var _default = Menu; +exports.default = _default; \ No newline at end of file diff --git a/components/component-docs.json b/components/component-docs.json new file mode 100644 index 0000000000..0db917ef98 --- /dev/null +++ b/components/component-docs.json @@ -0,0 +1,14551 @@ +{ + "accordion": { + "description": "An accordion allows a user to toggle the display of sections of content.\nThe accordion component wraps accordion panels that can be selected and expanded. It accepts children to define the content displayed within.", + "methods": [], + "props": { + "className": { + "type": { + "name": "union", + "value": [ + { + "name": "array" + }, + { + "name": "object" + }, + { + "name": "string" + } + ] + }, + "required": false, + "description": "CSS class names to be added to the accordion component. _Tested with snapshot testing._" + }, + "id": { + "type": { + "name": "union", + "value": [ + { + "name": "number" + }, + { + "name": "string" + } + ] + }, + "required": false, + "description": "HTML id for accordion component. _Tested with snapshot testing._" + }, + "children": { + "type": { + "name": "node" + }, + "required": true, + "description": "The panel content for the Accordion component. Accordion panels should be added as . Event handler for the accordion panels should be added to ``. Optional `panelContentActions` component may be passed as prop. _Tested with Mocha framework and snapshot testing._\n\nExample:\n```\n\n \n \n \n\n```" + } + }, + "route": "accordions", + "display-name": "Accordions", + "SLDS-component-path": "/components/accordion", + "dependencies": [ + { + "panel": { + "description": "The panel content for the Accordion component.", + "methods": [], + "props": { + "children": { + "type": { + "name": "node" + }, + "required": false, + "description": "The panel content for the Accordion component. Accordion panels should be added as . Event handler for the accordion panels should be added to ``. Optional `panelContentActions` component may be passed as prop. _Tested with Mocha framework and snapshot testing._" + }, + "expanded": { + "type": { + "name": "bool" + }, + "required": true, + "description": "Indicates whether item is expanded or not, which should be handled by `onTogglePanel`. _Tested with Mocha framework and snapshot testing._" + }, + "id": { + "type": { + "name": "union", + "value": [ + { + "name": "number" + }, + { + "name": "string" + } + ] + }, + "required": true, + "description": "Id of the item belonging to this panel. _Tested with snapshot testing._" + }, + "panelContentActions": { + "type": { + "name": "node" + }, + "required": false, + "description": "Component that can be passed as prop to ``. As an example, a menu dropdown could be used here to handle additional actions for each accordion panel. _Tested with Mocha framework._" + }, + "onTogglePanel": { + "type": { + "name": "func" + }, + "required": true, + "description": "Callback that will run whenever a panel is toggled. Function should handle state to toggle `expanded` prop. _Tested with Mocha framework._" + }, + "summary": { + "type": { + "name": "union", + "value": [ + { + "name": "string" + }, + { + "name": "node" + } + ] + }, + "required": true, + "description": "Summary in the span element in the header of this panel. The summary is truncated and so the title element should contain the full text so that it is accessible on hover. _Tested with snapshot testing._" + }, + "title": { + "type": { + "name": "string" + }, + "required": false, + "description": "HTML title attribute. _Tested with snapshot testing._" + } + }, + "name": "panel", + "source": "/components/accordion/panel.jsx" + } + } + ] + }, + "alert": { + "description": "Alert banners communicate a state that affects the entire system, not just a feature or page. It persists over a session and appears without the user initiating the action. View [banner guidelines](https://www.lightningdesignsystem.com/guidelines/messaging/components/banners/).", + "methods": [ + { + "name": "saveButtonRef", + "docblock": null, + "modifiers": [], + "params": [ + { + "name": "component", + "type": null + } + ], + "returns": null + } + ], + "props": { + "assistiveText": { + "type": { + "name": "shape", + "value": { + "closeButton": { + "name": "union", + "value": [ + { + "name": "string" + }, + { + "name": "node" + } + ], + "required": false + } + } + }, + "required": false, + "description": "**Assistive text for accessibility**\nThis object is merged with the default props object on every render.\n* `closeButton`: This is a visually hidden label for the close button.\n_Tested with snapshot testing._", + "defaultValue": { + "value": "{\n closeButton: 'Close',\n}", + "computed": false + } + }, + "className": { + "type": { + "name": "union", + "value": [ + { + "name": "array" + }, + { + "name": "object" + }, + { + "name": "string" + } + ] + }, + "required": false, + "description": "CSS classes to be added to tag with `.slds-notify_alert`. Uses `classNames` [API](https://github.com/JedWatson/classnames).\n_Tested with snapshot testing._" + }, + "dismissible": { + "type": { + "name": "bool" + }, + "required": false, + "description": "Allows user to click a close button. Banners should be dismissible only if they communicate future impact to the system,\n_Tested with snapshot testing._" + }, + "icon": { + "type": { + "name": "node" + }, + "required": false, + "description": "Icon of type `~/components/icon`. This icon will be cloned and additional props appended. The default icons are:\n* info variant: `utility:info`\n* error variant: `utility:error`\n* offline variant: `utility:offline`\n* warning variant: `utility:warning`\n\n_Tested with snapshot testing._" + }, + "labels": { + "type": { + "name": "shape", + "value": { + "heading": { + "name": "union", + "value": [ + { + "name": "string" + }, + { + "name": "node" + } + ], + "required": false + }, + "headingLink": { + "name": "union", + "value": [ + { + "name": "string" + }, + { + "name": "node" + } + ], + "required": false + } + } + }, + "required": false, + "description": "**Text labels for internationalization**\nThis object is merged with the default props object on every render.\n* `heading`: text within heading tag\n* `headingLink`: Text of link that triggers `onClickHeadingLink`. Inline links should pass a keyed array of React components into `labels.heading`.\n\n_Tested with snapshot testing._", + "defaultValue": { + "value": "{}", + "computed": false + } + }, + "onClickHeadingLink": { + "type": { + "name": "func" + }, + "required": false, + "description": "Triggered by link. _Tested with Mocha testing._" + }, + "onRequestClose": { + "type": { + "name": "func" + }, + "required": false, + "description": "Triggered by close button. This is a controlled component. _Tested with Mocha testing._" + }, + "style": { + "type": { + "name": "object" + }, + "required": false, + "description": "Custom styles to be passed to the component. _Tested with Mocha testing._" + }, + "variant": { + "type": { + "name": "enum", + "value": [ + { + "value": "'error'", + "computed": false + }, + { + "value": "'info'", + "computed": false + }, + { + "value": "'offline'", + "computed": false + }, + { + "value": "'warning'", + "computed": false + } + ] + }, + "required": false, + "description": "The type of alert. _Tested with snapshot testing._", + "defaultValue": { + "value": "'info'", + "computed": false + } + } + }, + "route": "alerts", + "display-name": "Alerts", + "SLDS-component-path": "/components/alert", + "dependencies": [ + { + "container": { + "description": "A fixed container for alert banners.", + "methods": [], + "props": { + "className": { + "type": { + "name": "union", + "value": [ + { + "name": "array" + }, + { + "name": "object" + }, + { + "name": "string" + } + ] + }, + "required": false, + "description": "CSS classes to be added to tag with `.slds-notify_alert`. Uses `classNames` [API](https://github.com/JedWatson/classnames)." + }, + "children": { + "type": { + "name": "node" + }, + "required": false, + "description": "Alert components" + } + }, + "name": "container", + "source": "/components/alert/container.jsx" + } + } + ] + }, + "app-launcher": { + "description": "The App Launcher allows the user to quickly access all the apps and functionality with their organization.\nThe App Launcher should generally only be used as a sub-component of the [Global Navigation Bar](/components/global-navigation-bar)\n\nUSAGE EXAMPLE:\n```\n\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n```\n\nBy default, `Modal`, a child component of App Launcher, will add `aria-hidden=true` to the `body` tag, but this disables some assistive technologies. To prevent this you can add the following to your application with `#mount` being the root node of your application that you would like to hide from assistive technologies when the `Modal` is open.\n```\nimport settings from 'design-system-react/components/settings';\nsettings.setAppElement('#mount');\n```", + "methods": [ + { + "name": "openAppLauncher", + "docblock": null, + "modifiers": [], + "params": [ + { + "name": "event", + "type": null + } + ], + "returns": null + }, + { + "name": "closeAppLauncher", + "docblock": null, + "modifiers": [], + "params": [ + { + "name": "event", + "type": null + } + ], + "returns": null + }, + { + "name": "renderSearch", + "docblock": null, + "modifiers": [], + "params": [], + "returns": null + } + ], + "props": { + "assistiveText": { + "type": { + "name": "shape", + "value": { + "trigger": { + "name": "string", + "required": false + } + } + }, + "required": false, + "description": "**Assistive text for accessibility.**\nThis object is merged with the default props object on every render.\n* `trigger`: This is a visually hidden label for the app launcher icon.", + "defaultValue": { + "value": "{\n trigger: 'Open App Launcher',\n}", + "computed": false + } + }, + "ariaHideApp": { + "type": { + "name": "bool" + }, + "required": false, + "description": "Boolean indicating if the appElement should be hidden.", + "defaultValue": { + "value": "true", + "computed": false + } + }, + "children": { + "type": { + "name": "node" + }, + "required": true, + "description": "One or more ``s each containing one or more ``s" + }, + "isOpen": { + "type": { + "name": "bool" + }, + "required": false, + "description": "Control the open/close state of the App Launcher" + }, + "modalClassName": { + "type": { + "name": "union", + "value": [ + { + "name": "array" + }, + { + "name": "object" + }, + { + "name": "string" + } + ] + }, + "required": false, + "description": "CSS classes to be added to App Launcher Modal." + }, + "modalHeaderButton": { + "type": { + "name": "node" + }, + "required": false, + "description": "Button that exists in the upper right hand corner of the App Launcher modal" + }, + "noTruncate": { + "type": { + "name": "bool" + }, + "required": false, + "description": "Allows longer application names without truncating them." + }, + "onClose": { + "type": { + "name": "func" + }, + "required": false, + "description": "Callback when the App Launcher Modal is closed" + }, + "search": { + "type": { + "name": "node" + }, + "required": false, + "description": "Search bar for the Modal's header. Will typically be an instance of `design-system-react/input/search`" + }, + "title": { + "type": { + "name": "string" + }, + "required": false, + "description": "Set the App Launcher's title text (for localization)", + "defaultValue": { + "value": "'App Launcher'", + "computed": false + } + }, + "triggerName": { + "type": { + "name": "node" + }, + "required": false, + "description": "This is typically the name of the cloud or application" + }, + "triggerOnClick": { + "type": { + "name": "func" + }, + "required": false, + "description": "Callback when the App Launcher icon is clicked" + } + }, + "route": "app-launcher", + "display-name": "App Launcher", + "SLDS-component-path": "/components/app-launcher/#flavor-default", + "dependencies": [ + { + "section": { + "description": "App Launcher Sections allow users to categorize App Tiles as well as toggle their display", + "methods": [ + { + "name": "toggleOpen", + "docblock": null, + "modifiers": [], + "params": [ + { + "name": "event", + "type": null + } + ], + "returns": null + } + ], + "props": { + "assistiveText": { + "type": { + "name": "shape", + "value": { + "collapseSection": { + "name": "string", + "required": false + } + } + }, + "required": false, + "description": "**Assistive text for accessibility.**\nThis object is merged with the default props object on every render.\n* `collapseSection`: The assistive text for the section collapse icons.", + "defaultValue": { + "value": "{\n collapseSection: 'Toggle visibility of section',\n}", + "computed": false + } + }, + "title": { + "type": { + "name": "string" + }, + "required": true, + "description": "The title for this section of apps" + }, + "toggleable": { + "type": { + "name": "bool" + }, + "required": false, + "description": "Allows the user to show/hide the section" + }, + "children": { + "type": { + "name": "node" + }, + "required": true, + "description": "An array of applications to display" + }, + "isOpen": { + "type": { + "name": "bool" + }, + "required": false, + "description": "Controls the open/closed state of the section" + }, + "onToggleClick": { + "type": { + "name": "func" + }, + "required": false, + "description": "Callback for when section is toggled. Passes \"isOpen\" bool. Forces `toggleable` to true" + } + }, + "name": "section", + "source": "/components/app-launcher/section.jsx" + } + }, + { + "tile": { + "description": "App Launcher Tiles provide information and links to a user's apps", + "methods": [], + "props": { + "title": { + "type": { + "name": "string" + }, + "required": true, + "description": "App name for the tile's title." + }, + "size": { + "type": { + "name": "enum", + "value": [ + { + "value": "'default'", + "computed": false + }, + { + "value": "'small'", + "computed": false + } + ] + }, + "required": false, + "description": "Size of the rendered tile.", + "defaultValue": { + "value": "'default'", + "computed": false + } + }, + "description": { + "type": { + "name": "string" + }, + "required": false, + "description": "The description of the app. Not visible on small tiles." + }, + "descriptionHeading": { + "type": { + "name": "string" + }, + "required": false, + "description": "Heading for app description" + }, + "href": { + "type": { + "name": "string" + }, + "required": false, + "description": "The `href` attribute of the tile. Please pass in bookmarkable URLs from your routing library. If the `onClick` callback is specified this URL will be prevented from changing the browser's location.", + "defaultValue": { + "value": "'javascript:void(0);'", + "computed": false + } + }, + "isOpenTooltip": { + "type": { + "name": "bool" + }, + "required": false, + "description": "Open the More Tooltip" + }, + "moreLabel": { + "type": { + "name": "string" + }, + "required": false, + "description": "The localized text for the \"More information\" tooltip.", + "defaultValue": { + "value": "' More'", + "computed": false + } + }, + "className": { + "type": { + "name": "union", + "value": [ + { + "name": "array" + }, + { + "name": "object" + }, + { + "name": "string" + } + ] + }, + "required": false, + "description": "Class names to be added to the tile." + }, + "onClick": { + "type": { + "name": "func" + }, + "required": false, + "description": "Function that will be executed when clicking on a tile" + }, + "iconNode": { + "type": { + "name": "node" + }, + "required": false, + "description": "Icon node for app tile. Takes priority over `iconText`" + }, + "iconText": { + "type": { + "name": "string" + }, + "required": false, + "description": "Text to be used as an icon. Only renders if iconNode is undefined" + }, + "search": { + "type": { + "name": "string" + }, + "required": false, + "description": "Text used to highlight content in app tiles" + } + }, + "name": "tile", + "source": "/components/app-launcher/tile.jsx" + } + } + ] + }, + "avatar": { + "description": "The avatar component represents an object or entity. An image is the preferred format for an avatar.\n If the `imgSrc` prop is undefined, and if a `label` or `initials` prop is available, the fallback avatar will render with initials. If initals are passed in directly in the `initials` prop, this will render in the fallback avatar. If `initals` prop is unavailable but a `label` prop is available, the fallback avatar will render with built initials of the user name or entity name.\n\n Intials built from the `label` prop will apply the following logic: If the label name contains two words, like first and last name, the first letter of each will be capitalized and returned. For labels that only have a single word name, the first two letters of that word, using one capital and one lower case letter, will be returned. For labels that contain three or more words, the first character of the first and last words will be capitalized and returned.\n\n If `initials` or `label` are not available, the fallback avatar will render a standard icon. If `variant='user'`, a user icon will\n render. If `variant='entity'`, an account icon will render.", + "methods": [ + { + "name": "buildInitials", + "docblock": null, + "modifiers": [], + "params": [], + "returns": null + }, + { + "name": "handleImageError", + "docblock": null, + "modifiers": [], + "params": [], + "returns": null + }, + { + "name": "renderBaseAvatar", + "docblock": null, + "modifiers": [], + "params": [], + "returns": null + }, + { + "name": "renderIconAvatar", + "docblock": null, + "modifiers": [], + "params": [], + "returns": null + }, + { + "name": "renderInitialsAvatar", + "docblock": null, + "modifiers": [], + "params": [], + "returns": null + } + ], + "props": { + "assistiveText": { + "type": { + "name": "shape", + "value": { + "icon": { + "name": "string", + "required": false + } + } + }, + "required": false, + "description": "**Assistive text for accessibility.**\nThis object is merged with the default props object on every render.\n* `icon`: Assistive text for accessibility that labels the icon.", + "defaultValue": { + "value": "{\n icon: 'User or Account Icon',\n}", + "computed": false + } + }, + "imgAlt": { + "type": { + "name": "string" + }, + "required": false, + "description": "Alt attribute to be applied to image (base case) element.", + "defaultValue": { + "value": "''", + "computed": false + } + }, + "imgSrc": { + "type": { + "name": "string" + }, + "required": false, + "description": "Source attribute to be applied to image (base case) element." + }, + "initials": { + "type": { + "name": "string" + }, + "required": false, + "description": "Initials attribute to optionally pass in initials directly in case of \"initials\" fallback case." + }, + "inverse": { + "type": { + "name": "bool" + }, + "required": false, + "description": "Avatar with initials that are dark text on light background" + }, + "label": { + "type": { + "name": "string" + }, + "required": false, + "description": "Label attibute to display inside \"initials\" fallback case. Will be passed as title prop in `abbr` element to provide more specificity." + }, + "variant": { + "type": { + "name": "enum", + "value": [ + { + "value": "'entity'", + "computed": false + }, + { + "value": "'user'", + "computed": false + } + ] + }, + "required": false, + "description": "Avatar variants to apply relevant styling (circle: user, square: entity) and icon rendering if applicable.", + "defaultValue": { + "value": "'user'", + "computed": false + } + }, + "size": { + "type": { + "name": "enum", + "value": [ + { + "value": "'x-small'", + "computed": false + }, + { + "value": "'small'", + "computed": false + }, + { + "value": "'medium'", + "computed": false + }, + { + "value": "'large'", + "computed": false + } + ] + }, + "required": false, + "description": "Size of the icon in \"icon\" fallback case.", + "defaultValue": { + "value": "'medium'", + "computed": false + } + }, + "title": { + "type": { + "name": "string" + }, + "required": false, + "description": "Title attribute for the avatar container.", + "defaultValue": { + "value": "'user avatar'", + "computed": false + } + } + }, + "route": "avatars", + "display-name": "Avatars", + "SLDS-component-path": "/components/avatar", + "dependencies": [] + }, + "brand-band": { + "description": "The brand band provides theming capability that adds personality and improves information density and contrast.\n\nNOTE: you may find that themes other than 'default' fail to load the appropriate styling in your application.\nIf this occurs the cause is very likely to be CSP settings on the server hosting your application protecting against style injections.\nChanging these settings is not recommended. Instead, add the following styles to any stylesheet provided by the server itself (such as an external stylesheet):\n\nWhen using 'lightning-theme':\n.slds-brand-band.dsr-brand-band_lightning-blue:before {\n background-image: url(/assets/images/themes/oneSalesforce/banner-brand-default.png), linear-gradient(to top, rgba(175, 197, 222, 0) 0, #1B5F9E);\n}\n.slds-brand-band.dsr-brand-band_lightning-blue:after {\n background-image: linear-gradient(to bottom, rgba(175, 197, 222, 0) 60%, #AFC5DE);\n}\n\nFor more information on the problem, [see this Stack Overflow question](https://stackoverflow.com/questions/17766817/refused-to-apply-inline-style-because-it-violates-the-following-content-security)", + "methods": [ + { + "name": "injectLightningBlueStyles", + "docblock": null, + "modifiers": [ + "static" + ], + "params": [], + "returns": null + }, + { + "name": "getId", + "docblock": null, + "modifiers": [], + "params": [], + "returns": null + } + ], + "props": { + "children": { + "type": { + "name": "node" + }, + "required": false, + "description": "Primary application grid layout or a white background component such as a `Card` should be passed into this component." + }, + "className": { + "type": { + "name": "union", + "value": [ + { + "name": "array" + }, + { + "name": "object" + }, + { + "name": "string" + } + ] + }, + "required": false, + "description": "CSS classes that are applied to the component" + }, + "id": { + "type": { + "name": "string" + }, + "required": false, + "description": "Id of component, if desired. If not provided an id is automatically generated" + }, + "image": { + "type": { + "name": "enum", + "value": [ + { + "value": "'default'", + "computed": false + }, + { + "value": "'none'", + "computed": false + } + ] + }, + "required": false, + "description": "Image of the brand band", + "defaultValue": { + "value": "'default'", + "computed": false + } + }, + "backgroundSize": { + "type": { + "name": "enum", + "value": [ + { + "value": "'contain'", + "computed": false + }, + { + "value": "'cover'", + "computed": false + } + ] + }, + "required": false, + "description": "Background size of the brand band. Default is 'contain'", + "defaultValue": { + "value": "'contain'", + "computed": false + } + }, + "size": { + "type": { + "name": "enum", + "value": [ + { + "value": "'small'", + "computed": false + }, + { + "value": "'medium'", + "computed": false + }, + { + "value": "'large'", + "computed": false + } + ] + }, + "required": false, + "description": "Size of the brand band. Default is 'medium'", + "defaultValue": { + "value": "'medium'", + "computed": false + } + }, + "style": { + "type": { + "name": "object" + }, + "required": false, + "description": "Custom styles to be passed to the component" + }, + "styleContainer": { + "type": { + "name": "object" + }, + "required": false, + "description": "Custom styles to be passed to the component container" + }, + "theme": { + "type": { + "name": "enum", + "value": [ + { + "value": "'default'", + "computed": false + }, + { + "value": "'lightning-blue'", + "computed": false + } + ] + }, + "required": false, + "description": "Different brand band styling.\nNOTE: using 'lightning-blue' may result in incorrect styling depending on server CSP settings. See opening component documentation above for details.", + "defaultValue": { + "value": "'default'", + "computed": false + } + } + }, + "route": "brand-band", + "display-name": "BrandBand", + "SLDS-component-path": "/components/brand-band", + "dependencies": [] + }, + "breadcrumb": { + "description": "Use breadcrumbs to note the path of a record and help the user to navigate back to the parent.Breadcrumb based on SLDS 2.1.0-dev", + "methods": [], + "props": { + "assistiveText": { + "type": { + "name": "shape", + "value": { + "label": { + "name": "string", + "required": false + } + } + }, + "required": false, + "description": "**Assistive text for accessibility.**\nThis object is merged with the default props object on every render.\n* `label`: The assistive text for the breadcrumb trail.", + "defaultValue": { + "value": "{\n label: 'Breadcrumbs',\n}", + "computed": false + } + }, + "trail": { + "type": { + "name": "array" + }, + "required": false, + "description": "An array of react elements presumably anchor elements." + } + }, + "route": "breadcrumbs", + "display-name": "Breadcrumbs", + "SLDS-component-path": "/components/breadcrumbs", + "dependencies": [] + }, + "button": { + "description": "The Button component is the Lightning Design System Button component. The Button should be used for label buttons, icon buttons, or buttons that have both labels and icons.\nEither a label or assistiveText.icon is required; see the Prop Details table below. For buttons that maintain selected/unselected states, use the ButtonStateful component.\nAlthough not listed in the prop table, all `aria-*` props will be added to the `button` element if passed in.", + "methods": [ + { + "name": "getClassName", + "docblock": null, + "modifiers": [], + "params": [], + "returns": null + }, + { + "name": "handleClick", + "docblock": null, + "modifiers": [], + "params": [ + { + "name": "event", + "type": null + } + ], + "returns": null + }, + { + "name": "renderIcon", + "docblock": null, + "modifiers": [], + "params": [ + { + "name": "name", + "type": null + } + ], + "returns": null + }, + { + "name": "renderLabel", + "docblock": null, + "modifiers": [], + "params": [], + "returns": null + }, + { + "name": "renderButton", + "docblock": null, + "modifiers": [], + "params": [], + "returns": null + }, + { + "name": "renderTooltip", + "docblock": null, + "modifiers": [], + "params": [], + "returns": null + } + ], + "props": { + "assistiveText": { + "type": { + "name": "shape", + "value": { + "icon": { + "name": "string", + "required": false + } + } + }, + "required": false, + "description": "**Assistive text for accessibility.**\nThis object is merged with the default props object on every render.\n* `icon`: Text that is visually hidden but read aloud by screenreaders to tell the user what the icon means. If the button has an icon and a visible label, you can omit the assistiveText.icon prop and use the label prop.", + "defaultValue": { + "value": "{ icon: '' }", + "computed": false + } + }, + "buttonRef": { + "type": { + "name": "func" + }, + "required": false, + "description": "Callback that passes in the DOM reference of the ` + +
    + +
    + + +`; diff --git a/components/dynamic-icon/__docs__/site-stories.js b/components/dynamic-icon/__docs__/site-stories.js new file mode 100644 index 0000000000..3d6d6401e1 --- /dev/null +++ b/components/dynamic-icon/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/dynamic-icon/__examples__/ellie.jsx'), require('raw-loader!@salesforce/design-system-react/components/dynamic-icon/__examples__/eq.jsx'), require('raw-loader!@salesforce/design-system-react/components/dynamic-icon/__examples__/score.jsx'), require('raw-loader!@salesforce/design-system-react/components/dynamic-icon/__examples__/strength.jsx'), require('raw-loader!@salesforce/design-system-react/components/dynamic-icon/__examples__/trend.jsx'), require('raw-loader!@salesforce/design-system-react/components/dynamic-icon/__examples__/typing.jsx'), require('raw-loader!@salesforce/design-system-react/components/dynamic-icon/__examples__/waffle.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/dynamic-icon/__docs__/storybook-stories.js b/components/dynamic-icon/__docs__/storybook-stories.js new file mode 100644 index 0000000000..a1597805a9 --- /dev/null +++ b/components/dynamic-icon/__docs__/storybook-stories.js @@ -0,0 +1,43 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _ellie = _interopRequireDefault(require("../__examples__/ellie")); + +var _eq = _interopRequireDefault(require("../__examples__/eq")); + +var _score = _interopRequireDefault(require("../__examples__/score")); + +var _strength = _interopRequireDefault(require("../__examples__/strength")); + +var _trend = _interopRequireDefault(require("../__examples__/trend")); + +var _typing = _interopRequireDefault(require("../__examples__/typing")); + +var _waffle = _interopRequireDefault(require("../__examples__/waffle")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.DYNAMIC_ICON, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Ellie', function () { + return _react.default.createElement(_ellie.default, null); +}).add('Eq', function () { + return _react.default.createElement(_eq.default, null); +}).add('Score', function () { + return _react.default.createElement(_score.default, null); +}).add('Strength', function () { + return _react.default.createElement(_strength.default, null); +}).add('Trend', function () { + return _react.default.createElement(_trend.default, null); +}).add('Typing', function () { + return _react.default.createElement(_typing.default, null); +}).add('Waffle', function () { + return _react.default.createElement(_waffle.default, null); +}); \ No newline at end of file diff --git a/components/dynamic-icon/__examples__/ellie.js b/components/dynamic-icon/__examples__/ellie.js new file mode 100644 index 0000000000..f629e68625 --- /dev/null +++ b/components/dynamic-icon/__examples__/ellie.js @@ -0,0 +1,80 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _dynamicIcon = _interopRequireDefault(require("../../../../components/dynamic-icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + title: "Ellie icon title", + variant: "ellie" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + title: "Ellie icon title", + isPaused: true, + variant: "ellie" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + className: "ellie-icon-example-custom-class", + title: "Ellie icon title", + isStatic: true, + variant: "ellie" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'EllieExample'; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/dynamic-icon/__examples__/eq.js b/components/dynamic-icon/__examples__/eq.js new file mode 100644 index 0000000000..db7920da10 --- /dev/null +++ b/components/dynamic-icon/__examples__/eq.js @@ -0,0 +1,73 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _dynamicIcon = _interopRequireDefault(require("../../../../components/dynamic-icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + title: "Eq icon title", + variant: "eq" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + title: "Eq icon title", + isStatic: true, + variant: "eq" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'EqExample'; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/dynamic-icon/__examples__/score.js b/components/dynamic-icon/__examples__/score.js new file mode 100644 index 0000000000..f3c862ab02 --- /dev/null +++ b/components/dynamic-icon/__examples__/score.js @@ -0,0 +1,73 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _dynamicIcon = _interopRequireDefault(require("../../../../components/dynamic-icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + title: "Score icon title", + variant: "score" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + scorePolarity: "negative", + title: "Score icon title", + variant: "score" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ScoreExample'; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/dynamic-icon/__examples__/strength.js b/components/dynamic-icon/__examples__/strength.js new file mode 100644 index 0000000000..5bcc999f08 --- /dev/null +++ b/components/dynamic-icon/__examples__/strength.js @@ -0,0 +1,127 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _dynamicIcon = _interopRequireDefault(require("../../../../components/dynamic-icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + title: "Strength icon title", + variant: "strength" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isStatic: true, + strengthLevel: 1, + title: "Strength icon title", + variant: "strength" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isStatic: true, + strengthLevel: 2, + title: "Strength icon title", + variant: "strength" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isStatic: true, + strengthLevel: 3, + title: "Strength icon title", + variant: "strength" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isStatic: true, + strengthLevel: "-1", + title: "Strength icon title", + variant: "strength" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isStatic: true, + strengthLevel: "-2", + title: "Strength icon title", + variant: "strength" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isStatic: true, + strengthLevel: "-3", + title: "Strength icon title", + variant: "strength" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + strengthLevel: "3", + title: "Strength icon title", + variant: "strength" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + strengthLevel: "-3", + title: "Strength icon title", + variant: "strength" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isPaused: true, + title: "Strength icon title", + variant: "strength" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'StrengthExample'; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/dynamic-icon/__examples__/trend.js b/components/dynamic-icon/__examples__/trend.js new file mode 100644 index 0000000000..4b9ba78705 --- /dev/null +++ b/components/dynamic-icon/__examples__/trend.js @@ -0,0 +1,93 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _dynamicIcon = _interopRequireDefault(require("../../../../components/dynamic-icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + title: "Trend icon title", + variant: "trend" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + title: "Trend icon title", + trendDirection: "down", + variant: "trend" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + title: "Trend icon title", + trendDirection: "up", + variant: "trend" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isStatic: true, + title: "Trend icon title", + trendDirection: "up", + variant: "trend" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isPaused: true, + title: "Trend icon title", + trendDirection: "up", + variant: "trend" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'TrendExample'; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/dynamic-icon/__examples__/typing.js b/components/dynamic-icon/__examples__/typing.js new file mode 100644 index 0000000000..aade874f70 --- /dev/null +++ b/components/dynamic-icon/__examples__/typing.js @@ -0,0 +1,79 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _dynamicIcon = _interopRequireDefault(require("../../../../components/dynamic-icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + title: "User is typing", + variant: "typing" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isPaused: true, + title: "User is typing", + variant: "typing" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isStatic: true, + title: "User is typing", + variant: "typing" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'TypingExample'; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/dynamic-icon/__examples__/waffle.js b/components/dynamic-icon/__examples__/waffle.js new file mode 100644 index 0000000000..ee43b91451 --- /dev/null +++ b/components/dynamic-icon/__examples__/waffle.js @@ -0,0 +1,73 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _dynamicIcon = _interopRequireDefault(require("../../../../components/dynamic-icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + title: "Open App Launcher", + variant: "waffle" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_dynamicIcon.default, { + isPaused: true, + title: "Open App Launcher", + variant: "waffle" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'WaffleExample'; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/dynamic-icon/docs.json b/components/dynamic-icon/docs.json new file mode 100644 index 0000000000..9f9951f690 --- /dev/null +++ b/components/dynamic-icon/docs.json @@ -0,0 +1,7 @@ +{ + "component": "dynamic-icon", + "status": "prod", + "display-name": "Dynamic Icon", + "SLDS-component-path": "/components/dynamic-icon", + "url-slug": "dynamic-icon" +} diff --git a/components/dynamic-icon/index.js b/components/dynamic-icon/index.js new file mode 100644 index 0000000000..8eb641fbb1 --- /dev/null +++ b/components/dynamic-icon/index.js @@ -0,0 +1,430 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classNames = _interopRequireDefault(require("../../utilities/class-names")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// PropTypes for the component +var propTypes = { + /** + * **Assistive text for accessibility** + * * `label`: Used as a visually hidden label to describe the dynamic icon. + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string + }), + + /** + * CSS class names to be added to the icon. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Pauses the icon animation if the value is true. + */ + isPaused: _propTypes.default.bool, + + /** + * Disables icon animation if set to true + */ + isStatic: _propTypes.default.bool, + + /** + * Polarity values for the 'score' variant. Defaults to 'positive' + */ + scorePolarity: _propTypes.default.oneOf(['positive', 'negative']), + + /** + * Range of strength values for the 'strength' variant. Defaults to '0'. + */ + strengthLevel: _propTypes.default.oneOf(['-3', '-2', '-1', '0', '1', '2', '3', -3, -2, -1, 0, 1, 2, 3]), + + /** + * HTML title attribute. + */ + title: _propTypes.default.string.isRequired, + + /** + * Signals direction for the 'trend' variant. The default value 'neutral' points to the east. + */ + trendDirection: _propTypes.default.oneOf(['down', 'up', 'neutral']), + + /** + * Different types of dynamic icons. Possible variants: + * + * `ellie` - Displays a pulsing blue circle, which pulses and stops after one animation cycle. + * `eq` - Displays an animated graph with three bars that rise and fall randomly. + * `score` - Displays a green filled circle or a red unfilled circle. + * `strength` - Displays three animated horizontal circles that are colored green or red. + * `trend` - Displays animated arrows that point up, down, or straight. + * `waffle` - Displays a 3x3 grid of dots that animates on hover. + */ + variant: _propTypes.default.oneOf(['ellie', 'eq', 'score', 'strength', 'trend', 'typing', 'waffle']).isRequired +}; +/** + * A set of delightful animated icons. + */ + +var DynamicIcon = +/*#__PURE__*/ +function (_React$Component) { + _inherits(DynamicIcon, _React$Component); + + function DynamicIcon() { + _classCallCheck(this, DynamicIcon); + + return _possibleConstructorReturn(this, _getPrototypeOf(DynamicIcon).apply(this, arguments)); + } + + _createClass(DynamicIcon, [{ + key: "getIconChildren", + value: function getIconChildren() { + var children = []; + var defaultAssistiveText = this.props.title ? this.props.title : "".concat(this.props.variant.charAt(0).toUpperCase()).concat(this.props.variant.slice(1)); + + if (this.props.variant === 'ellie') { + children = [_react.default.createElement("svg", { + viewBox: "0 0 280 14", + "aria-hidden": "true" + }, _react.default.createElement("circle", { + cx: "7", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "7", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "21", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "21", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "35", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "35", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "49", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "49", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "63", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "63", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "77", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "77", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "91", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "91", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "105", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "105", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "119", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "119", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "133", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "133", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "147", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "147", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "161", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "161", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "175", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "175", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "189", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "189", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "203", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "203", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "217", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "217", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "231", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "231", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "245", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "245", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "259", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "259", + cy: "7", + r: "3" + }), _react.default.createElement("circle", { + cx: "273", + cy: "7", + r: "4" + }), _react.default.createElement("circle", { + cx: "273", + cy: "7", + r: "3" + }))]; + } else if (this.props.variant === 'eq') { + children = [_react.default.createElement("div", { + className: "slds-icon-eq__bar" + }), _react.default.createElement("div", { + className: "slds-icon-eq__bar" + }), _react.default.createElement("div", { + className: "slds-icon-eq__bar" + })]; + } else if (this.props.variant === 'score') { + children = [_react.default.createElement("svg", { + viewBox: "0 0 5 5", + className: "slds-icon-score__positive", + "aria-hidden": "true" + }, _react.default.createElement("circle", { + cx: "50%", + cy: "50%", + r: "1.875" + })), _react.default.createElement("svg", { + viewBox: "0 0 5 5", + className: "slds-icon-score__negative", + "aria-hidden": "true" + }, _react.default.createElement("circle", { + cx: "50%", + cy: "50%", + r: "1.875" + }))]; + } else if (this.props.variant === 'strength') { + children = [_react.default.createElement("svg", { + viewBox: "0 0 27 7", + "aria-hidden": "true" + }, _react.default.createElement("circle", { + r: "3.025", + cx: "3.5", + cy: "3.5" + }), _react.default.createElement("circle", { + r: "3.025", + cx: "13.5", + cy: "3.5" + }), _react.default.createElement("circle", { + r: "3.025", + cx: "23.5", + cy: "3.5" + }))]; + } else if (this.props.variant === 'trend') { + children = [_react.default.createElement("svg", { + viewBox: "0 0 16 16", + "aria-hidden": "true" + }, _react.default.createElement("path", { + className: "slds-icon-trend__arrow", + d: "M.75 8H11M8 4.5L11.5 8 8 11.5" + }), _react.default.createElement("circle", { + className: "slds-icon-trend__circle", + cy: "8", + cx: "8", + r: "7.375", + transform: "rotate(-28 8 8) scale(-1 1) translate(-16 0)" + }))]; + } else if (this.props.variant === 'typing') { + children = [_react.default.createElement("span", { + className: "slds-icon-typing__dot" + }), _react.default.createElement("span", { + className: "slds-icon-typing__dot" + }), _react.default.createElement("span", { + className: "slds-icon-typing__dot" + })]; + + if (!this.props.title) { + defaultAssistiveText = 'User is typing'; + } + } else if (this.props.variant === 'waffle') { + children = [_react.default.createElement("span", { + className: "slds-icon-waffle" + }, _react.default.createElement("span", { + className: "slds-r1" + }), _react.default.createElement("span", { + className: "slds-r2" + }), _react.default.createElement("span", { + className: "slds-r3" + }), _react.default.createElement("span", { + className: "slds-r4" + }), _react.default.createElement("span", { + className: "slds-r5" + }), _react.default.createElement("span", { + className: "slds-r6" + }), _react.default.createElement("span", { + className: "slds-r7" + }), _react.default.createElement("span", { + className: "slds-r8" + }), _react.default.createElement("span", { + className: "slds-r9" + }))]; + + if (!this.props.title) { + defaultAssistiveText = 'Open App Launcher'; + } + } + + children.push(_react.default.createElement("span", { + className: "slds-assistive-text" + }, this.props.assistiveText && this.props.assistiveText.label ? this.props.assistiveText.label : defaultAssistiveText)); + return children; + } + }, { + key: "render", + value: function render() { + var children = this.getIconChildren(); + var classes = [{ + 'slds-is-animated': !this.props.isStatic, + 'slds-is-paused': this.props.isPaused + }]; + var iconProps = { + title: this.props.title + }; + var element = 'span'; + + if (this.props.variant === 'waffle') { + classes.unshift('slds-button', 'slds-icon-waffle_container'); + element = 'button'; + } else { + classes.unshift("slds-icon-".concat(this.props.variant)); + + if (this.props.variant === 'eq') { + element = 'div'; + } else if (this.props.variant === 'score') { + iconProps['data-slds-state'] = this.props.scorePolarity ? this.props.scorePolarity : 'positive'; + } else if (this.props.variant === 'strength') { + iconProps['data-slds-strength'] = this.props.strengthLevel !== undefined ? "".concat(this.props.strengthLevel) : '0'; + } else if (this.props.variant === 'trend') { + iconProps['data-slds-trend'] = this.props.trendDirection ? this.props.trendDirection : 'neutral'; + } + } + + iconProps.className = (0, _classNames.default)(classes, this.props.className); + return _react.default.createElement.apply(_react.default, [element, iconProps].concat(_toConsumableArray(children))); + } + }]); + + return DynamicIcon; +}(_react.default.Component); + +DynamicIcon.displayName = _constants.DYNAMIC_ICON; +DynamicIcon.propTypes = propTypes; +var _default = DynamicIcon; +exports.default = _default; \ No newline at end of file diff --git a/components/filter/__docs__/__snapshots__/storybook-stories.storyshot b/components/filter/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..a38ad68496 --- /dev/null +++ b/components/filter/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,480 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSFilter AssistiveTextFilter 1`] = ` +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSFilter ErrorFilter 1`] = ` +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSFilter Filter 1`] = ` +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSFilter Filter Align Right 1`] = ` +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSFilter Locked Filter 1`] = ` +
    +
    +
    +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSFilter New Filter 1`] = ` +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSFilter Permanant Filter 1`] = ` +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +`; diff --git a/components/filter/__docs__/site-stories.js b/components/filter/__docs__/site-stories.js new file mode 100644 index 0000000000..7f2a1fd74b --- /dev/null +++ b/components/filter/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/filter/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/filter/__examples__/new.jsx'), require('raw-loader!@salesforce/design-system-react/components/filter/__examples__/error.jsx'), require('raw-loader!@salesforce/design-system-react/components/filter/__examples__/locked.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/filter/__docs__/storybook-stories.js b/components/filter/__docs__/storybook-stories.js new file mode 100644 index 0000000000..2471cb9cab --- /dev/null +++ b/components/filter/__docs__/storybook-stories.js @@ -0,0 +1,68 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _new = _interopRequireDefault(require("../__examples__/new")); + +var _locked = _interopRequireDefault(require("../__examples__/locked")); + +var _permanant = _interopRequireDefault(require("../__examples__/permanant")); + +var _error = _interopRequireDefault(require("../__examples__/error")); + +var _assistiveText = _interopRequireDefault(require("../__examples__/assistive-text")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* eslint-disable react/display-name */ + +/* eslint-disable react/prop-types */ +var CustomAlignment = function CustomAlignment(_ref) { + var children = _ref.children, + align = _ref.align; + return _react.default.createElement("div", { + className: "slds-grid slds-m-around_xx-large" + }, _react.default.createElement("div", { + className: "slds-col_bump-".concat(align), + style: { + width: '420px' + } + }, children)); +}; + +CustomAlignment.defaultProps = { + align: 'left' +}; +(0, _react2.storiesOf)(_constants.FILTER, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Filter', function () { + return _react.default.createElement(CustomAlignment, null, _react.default.createElement(_default.default, null)); +}).add('New Filter', function () { + return _react.default.createElement(CustomAlignment, null, _react.default.createElement(_new.default, null)); +}).add('Locked Filter', function () { + return _react.default.createElement(CustomAlignment, null, _react.default.createElement(_locked.default, null)); +}).add('Permanant Filter', function () { + return _react.default.createElement(CustomAlignment, null, _react.default.createElement(_permanant.default, null)); +}).add('Filter Align Right', function () { + return _react.default.createElement(CustomAlignment, { + align: "right" + }, _react.default.createElement(_default.default, { + align: "right" + })); +}).add('AssistiveTextFilter', function () { + return _react.default.createElement(CustomAlignment, null, _react.default.createElement(_assistiveText.default, null)); +}).add('ErrorFilter', function () { + return _react.default.createElement(CustomAlignment, null, _react.default.createElement(_error.default, null)); +}); \ No newline at end of file diff --git a/components/filter/__examples__/assistive-text.js b/components/filter/__examples__/assistive-text.js new file mode 100644 index 0000000000..d087de04ff --- /dev/null +++ b/components/filter/__examples__/assistive-text.js @@ -0,0 +1,158 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _filter = _interopRequireDefault(require("../../../../components/filter")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var options = { + 'show-me': [{ + id: 1, + label: 'All Products', + value: 'all-products' + }, { + id: 2, + label: 'All Wackamoles', + value: 'all-Wackamoles' + }] +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + 'show-me': { + selectedItem: options['show-me'][0], + isActive: true, + comboboxSelection: [options['show-me'][0]] + } + }); + + _defineProperty(_assertThisInitialized(_this), "onChangePredicate", function (event, _ref) { + var id = _ref.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + selectedItem: _this.state[idSuffix].comboboxSelection[0] + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemove", function (event, _ref2) { + var id = _ref2.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + isActive: false + }))); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return this.state['show-me'].isActive && _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_filter.default, _extends({ + assistiveText: { + editFilter: 'editFilter-TEST', + editFilterHeading: 'editFilterHeading-TEST', + removeFilter: 'removeFilter-TEST' + }, + align: this.props.align, + id: "sample-panel-filtering-show-me", + onChange: this.onChangePredicate, + onRemove: this.onRemove, + property: "Show Me", + predicate: this.state['show-me'].selectedItem.label + }, this.props), _react.default.createElement(_combobox.default, { + events: { + onSelect: function onSelect(event, data) { + _this2.setState({ + 'show-me': _objectSpread({}, _this2.state['show-me'], { + comboboxSelection: data.selection + }) + }); + } + }, + labels: { + label: 'Show Me', + placeholder: 'Select record type' + }, + menuPosition: "relative", + options: options['show-me'], + selection: this.state['show-me'].comboboxSelection, + variant: "readonly" + }))); + } + }], [{ + key: "propTypes", + value: function propTypes() { + return { + align: _propTypes.default.string + }; + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'FilterExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/filter/__examples__/default.js b/components/filter/__examples__/default.js new file mode 100644 index 0000000000..f7bbd8767a --- /dev/null +++ b/components/filter/__examples__/default.js @@ -0,0 +1,153 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _filter = _interopRequireDefault(require("../../../../components/filter")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var options = { + 'show-me': [{ + id: 1, + label: 'All Products', + value: 'all-products' + }, { + id: 2, + label: 'All Wackamoles', + value: 'all-Wackamoles' + }] +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + 'show-me': { + selectedItem: options['show-me'][0], + isActive: true, + comboboxSelection: [options['show-me'][0]] + } + }); + + _defineProperty(_assertThisInitialized(_this), "onChangePredicate", function (event, _ref) { + var id = _ref.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + selectedItem: _this.state[idSuffix].comboboxSelection[0] + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemove", function (event, _ref2) { + var id = _ref2.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + isActive: false + }))); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return this.state['show-me'].isActive && _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_filter.default, _extends({ + align: this.props.align, + id: "sample-panel-filtering-show-me", + onChange: this.onChangePredicate, + onRemove: this.onRemove, + property: "Show Me", + predicate: this.state['show-me'].selectedItem.label + }, this.props), _react.default.createElement(_combobox.default, { + events: { + onSelect: function onSelect(event, data) { + _this2.setState({ + 'show-me': _objectSpread({}, _this2.state['show-me'], { + comboboxSelection: data.selection + }) + }); + } + }, + labels: { + label: 'Show Me', + placeholder: 'Select record type' + }, + menuPosition: "relative", + options: options['show-me'], + selection: this.state['show-me'].comboboxSelection, + variant: "readonly" + }))); + } + }], [{ + key: "propTypes", + value: function propTypes() { + return { + align: _propTypes.default.string + }; + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'FilterExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/filter/__examples__/error.js b/components/filter/__examples__/error.js new file mode 100644 index 0000000000..842d427a45 --- /dev/null +++ b/components/filter/__examples__/error.js @@ -0,0 +1,154 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _filter = _interopRequireDefault(require("../../../../components/filter")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _menuPicklist = _interopRequireDefault(require("../../../../components/menu-picklist")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var options = { + 'show-me': [{ + id: 1, + label: 'All Products', + value: 'all-products' + }, { + id: 2, + label: 'All Wackamoles', + value: 'all-Wackamoles' + }] +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + 'show-me': { + comboboxSelection: [options['show-me'][0]], + selectedItem: options['show-me'][0], + isActive: true + } + }); + + _defineProperty(_assertThisInitialized(_this), "onChangePredicate", function (event, _ref) { + var id = _ref.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + selectedItem: _this.state[idSuffix].comboboxSelection + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemove", function (event, _ref2) { + var id = _ref2.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + isActive: false + }))); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return this.state['show-me'].isActive && _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_filter.default, { + align: this.props.align, + id: "sample-panel-filtering-show-me", + isError: true, + onChange: this.onChangePredicate, + onRemove: this.onRemove, + property: "Show Me", + predicate: this.state['show-me'].selectedItem.label + }, _react.default.createElement(_combobox.default, { + events: { + onSelect: function onSelect(event, data) { + _this2.setState({ + 'show-me': _objectSpread({}, _this2.state['show-me'], { + comboboxSelection: data.selection + }) + }); + } + }, + labels: { + label: 'Show Me', + placeholder: 'Select record type' + }, + menuPosition: "relative", + options: options['show-me'], + selection: this.state['show-me'].comboboxSelection, + variant: "readonly" + }))); + } + }], [{ + key: "propTypes", + value: function propTypes() { + return { + align: _propTypes.default.string + }; + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'FilterExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/filter/__examples__/locked.js b/components/filter/__examples__/locked.js new file mode 100644 index 0000000000..ba824caf92 --- /dev/null +++ b/components/filter/__examples__/locked.js @@ -0,0 +1,152 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _filter = _interopRequireDefault(require("../../../../components/filter")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var options = { + 'show-me': [{ + id: 1, + label: 'All Products', + value: 'all-products' + }, { + id: 2, + label: 'All Wackamoles', + value: 'all-Wackamoles' + }] +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + 'show-me': { + comboboxSelection: [options['show-me'][0]], + selectedItem: options['show-me'][0], + isActive: true + } + }); + + _defineProperty(_assertThisInitialized(_this), "onChangePredicate", function (event, _ref) { + var id = _ref.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + selectedItem: _this.state[idSuffix].comboboxSelection + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemove", function (event, _ref2) { + var id = _ref2.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + isActive: false + }))); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return this.state['show-me'].isActive && _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_filter.default, { + align: this.props.align, + id: "sample-panel-filtering-show-me", + isLocked: true, + onChange: this.onChangePredicate, + onRemove: this.onRemove, + property: "Show Me", + predicate: this.state['show-me'].selectedItem.label + }, _react.default.createElement(_combobox.default, { + events: { + onSelect: function onSelect(event, data) { + _this2.setState({ + 'show-me': _objectSpread({}, _this2.state['show-me'], { + comboboxSelection: data.selection + }) + }); + } + }, + labels: { + label: 'Show Me', + placeholder: 'Select record type' + }, + menuPosition: "relative", + options: options['show-me'], + selection: this.state['show-me'].comboboxSelection, + variant: "readonly" + }))); + } + }], [{ + key: "propTypes", + value: function propTypes() { + return { + align: _propTypes.default.string + }; + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'FilterExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/filter/__examples__/new.js b/components/filter/__examples__/new.js new file mode 100644 index 0000000000..56af9c15fe --- /dev/null +++ b/components/filter/__examples__/new.js @@ -0,0 +1,152 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _filter = _interopRequireDefault(require("../../../../components/filter")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var options = { + 'show-me': [{ + id: 1, + label: 'All Products', + value: 'all-products' + }, { + id: 2, + label: 'All Wackamoles', + value: 'all-Wackamoles' + }] +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + 'show-me': { + comboboxSelection: [options['show-me'][0]], + selectedItem: options['show-me'][0], + isActive: true + } + }); + + _defineProperty(_assertThisInitialized(_this), "onChangePredicate", function (event, _ref) { + var id = _ref.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + selectedItem: _this.state[idSuffix].comboboxSelection + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemove", function (event, _ref2) { + var id = _ref2.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + isActive: false + }))); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return this.state['show-me'].isActive && _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_filter.default, { + align: this.props.align, + id: "sample-panel-filtering-show-me", + isNew: true, + onChange: this.onChangePredicate, + onRemove: this.onRemove, + property: "Show Me", + predicate: this.state['show-me'].selectedItem.label + }, _react.default.createElement(_combobox.default, { + events: { + onSelect: function onSelect(event, data) { + _this2.setState({ + 'show-me': _objectSpread({}, _this2.state['show-me'], { + comboboxSelection: data.selection + }) + }); + } + }, + labels: { + label: 'Show Me', + placeholder: 'Select record type' + }, + menuPosition: "relative", + options: options['show-me'], + selection: this.state['show-me'].comboboxSelection, + variant: "readonly" + }))); + } + }], [{ + key: "propTypes", + value: function propTypes() { + return { + align: _propTypes.default.string + }; + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'FilterExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/filter/__examples__/permanant.js b/components/filter/__examples__/permanant.js new file mode 100644 index 0000000000..e949557856 --- /dev/null +++ b/components/filter/__examples__/permanant.js @@ -0,0 +1,152 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _filter = _interopRequireDefault(require("../../../../components/filter")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var options = { + 'show-me': [{ + id: 1, + label: 'All Products', + value: 'all-products' + }, { + id: 2, + label: 'All Wackamoles', + value: 'all-Wackamoles' + }] +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + 'show-me': { + comboboxSelection: [options['show-me'][0]], + selectedItem: options['show-me'][0], + isActive: true + } + }); + + _defineProperty(_assertThisInitialized(_this), "onChangePredicate", function (event, _ref) { + var id = _ref.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + selectedItem: _this.state[idSuffix].comboboxSelection + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemove", function (event, _ref2) { + var id = _ref2.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + isActive: false + }))); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return this.state['show-me'].isActive && _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_filter.default, { + align: this.props.align, + id: "sample-panel-filtering-show-me", + isPermanent: true, + onChange: this.onChangePredicate, + onRemove: this.onRemove, + property: "Show Me", + predicate: this.state['show-me'].selectedItem.label + }, _react.default.createElement(_combobox.default, { + events: { + onSelect: function onSelect(event, data) { + _this2.setState({ + 'show-me': _objectSpread({}, _this2.state['show-me'], { + comboboxSelection: data.selection + }) + }); + } + }, + labels: { + label: 'Show Me', + placeholder: 'Select record type' + }, + menuPosition: "relative", + options: options['show-me'], + selection: this.state['show-me'].comboboxSelection, + variant: "readonly" + }))); + } + }], [{ + key: "propTypes", + value: function propTypes() { + return { + align: _propTypes.default.string + }; + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'FilterExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/filter/check-props.js b/components/filter/check-props.js new file mode 100644 index 0000000000..0ca6ef9db4 --- /dev/null +++ b/components/filter/check-props.js @@ -0,0 +1,29 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _componentIsPrototype = _interopRequireDefault(require("../../utilities/warning/component-is-prototype")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + (0, _componentIsPrototype.default)(COMPONENT, createDocUrl()); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/filter/docs.json b/components/filter/docs.json new file mode 100644 index 0000000000..bc41912ddb --- /dev/null +++ b/components/filter/docs.json @@ -0,0 +1,7 @@ +{ + "component": "filter", + "status": "prototype", + "display-name": "Filters", + "SLDS-component-path": "/components/filter", + "url-slug": "filters" +} \ No newline at end of file diff --git a/components/filter/index.js b/components/filter/index.js new file mode 100644 index 0000000000..5622752fbf --- /dev/null +++ b/components/filter/index.js @@ -0,0 +1,315 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _button = _interopRequireDefault(require("../button")); + +var _popover = _interopRequireDefault(require("../popover")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * A Filter is a popover with custom trigger. It can be used by [Panel Filtering](/components/panels/). Menus within a Filter Popover will need to not have "portal mounts" and be inline. + */ +var Filter = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Filter, _React$Component); + + function Filter() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Filter); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Filter)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + popoverIsOpen: _this.props.popover ? _this.props.popover.props.isOpen : false + }); + + _defineProperty(_assertThisInitialized(_this), "getId", function () { + return _this.props.id || _this.generatedId; + }); + + _defineProperty(_assertThisInitialized(_this), "getCustomPopoverProps", function (_ref) { + var assistiveText = _ref.assistiveText; + + /* + * Generate the popover props based on passed in popover props. Using the default behavior if not provided by passed in popover + */ + var popoverBody = _react.default.createElement("div", null, _react.default.createElement("h4", { + className: "slds-assistive-text", + id: "".concat(_this.getId(), "-popover-heading") + }, assistiveText.editFilterHeading), _this.props.children, _react.default.createElement("div", { + className: "slds-m-top_small slds-text-align_right" + }, _react.default.createElement(_button.default, { + className: "slds-col_bump-left", + label: "Done", + onClick: _this.handleChange + }))); + + var defaultPopoverProps = { + ariaLabelledby: "".concat(_this.getId(), "-popover-heading"), + align: _this.props.align, + body: popoverBody, + heading: '', + id: _this.getId(), + isOpen: _this.state.popoverIsOpen, + // MAGIC NUMBERS - REMOVE/REDESIGN WHEN DESIGN FOR RIGHT-ALIGNED FILTERS ARE ADDED TO SLDS + offset: _this.props.align === 'right' ? '0px -35px' : undefined, + onClose: _this.handleClose, + onRequestClose: _this.handleClose, + position: 'overflowBoundaryElement', + triggerClassName: 'slds-grow' + }; + /* Mixin passed popover's props if there is any to override the default popover props */ + + var popoverProps = (0, _lodash.default)(defaultPopoverProps, _this.props.popover ? _this.props.popover.props : {}); + delete popoverProps.children; + return popoverProps; + }); + + _defineProperty(_assertThisInitialized(_this), "handleFilterClick", function () { + _this.setState({ + popoverIsOpen: true + }); + + if (_this.props.onClick) { + _this.props.onClick(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleClose", function () { + _this.setState({ + popoverIsOpen: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (event) { + _this.setState({ + popoverIsOpen: false + }); + + if (_this.props.onChange) { + _this.props.onChange(event, { + id: _this.getId() + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleRemove", function (event) { + if (_this.props.onRemove) { + _this.props.onRemove(event, { + id: _this.getId() + }); + } + }); + + return _this; + } + + _createClass(Filter, [{ + key: "componentWillMount", + value: function componentWillMount() { + this.generatedId = _shortid.default.generate(); + (0, _checkProps.default)(_constants.FILTER, _docs.default); + } + }, { + key: "render", + value: function render() { + /* Remove at next breaking change */ + var assistiveText = { + editFilter: this.props.assistiveTextEditFilter || // eslint-disable-line react/prop-types + this.props.assistiveText.editFilter, + editFilterHeading: this.props.assistiveTextEditFilterHeading || // eslint-disable-line react/prop-types + this.props.assistiveText.editFilterHeading, + removeFilter: this.props.assistiveTextRemoveFilter || // eslint-disable-line react/prop-types + this.props.assistiveText.removeFilter || "Remove Filter: ".concat(this.props.property, " ").concat(this.props.predicate) + }; + /* TODO: Button wrapper for property and predictate should be transitioned to `Button` component. `Button` needs to take custom children first though. */ + + var popoverProps = this.getCustomPopoverProps({ + assistiveText: assistiveText + }); + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-filters__item', 'slds-grid', 'slds-grid_vertical-align-center', { + 'slds-is-locked': this.props.isLocked, + 'slds-is-new': this.props.isNew, + 'slds-has-error': this.props.isError + }, this.props.className) + }, !this.props.isLocked && (this.props.children || this.props.popover) ? _react.default.createElement(_popover.default, popoverProps, _react.default.createElement("button", { + className: "slds-button_reset slds-grow slds-has-blur-focus", + onClick: this.handleFilterClick, + "aria-describedby": this.props.isError ? "".concat(this.getId(), "-error") : undefined + }, _react.default.createElement("span", { + className: "slds-assistive-text" + }, assistiveText.editFilter), this.props.property ? _react.default.createElement("p", { + className: "slds-text-body_small" + }, this.props.property) : null, _react.default.createElement("p", null, this.props.predicate))) : _react.default.createElement("button", { + "aria-describedby": this.props.isError ? "".concat(this.getId(), "-error") : undefined, + className: "slds-button_reset slds-grow slds-has-blur-focus", + disabled: true + }, _react.default.createElement("p", { + className: "slds-text-body_small" + }, this.props.property), _react.default.createElement("p", null, this.props.predicate)), // Remove button + !this.props.isPermanent && !this.props.isLocked ? _react.default.createElement(_button.default, { + assistiveText: { + icon: assistiveText.removeFilter + }, + hint: true, + iconCategory: "utility", + iconName: "close", + iconSize: "small", + iconVariant: "bare", + onClick: this.handleRemove, + title: assistiveText.removeFilter, + variant: "icon" + }) : null); + } + }]); + + return Filter; +}(_react.default.Component); + +_defineProperty(Filter, "displayName", _constants.FILTER); + +_defineProperty(Filter, "propTypes", { + /** + * Aligns the popover with the respective side of the trigger. That is `left` will place the `Popover` to the left of the Filter. + */ + align: _propTypes.default.oneOf(['left', 'right']), + + /** + * **Assistive text for accessibility** + * * `removeFilter`: Assistive text for removing a filter. The default is `Remove Filter: this.props.property this.props.predicate`. + * * `editFilter`: Assistive text for changing a filter. + * * `editFilterHeading`: Assistive text for Popover heading. + */ + assistiveText: _propTypes.default.shape({ + editFilter: _propTypes.default.string, + editFilterHeading: _propTypes.default.string, + removeFilter: _propTypes.default.string + }), + + /** + * Contents of popover. That is the dropdowns and inputs that set the filter criteria. + */ + children: _propTypes.default.node, + + /** + * Custom CSS classes for `slds-filters__item` node. Uses `classNames` [API](https://github.com/JedWatson/classnames). + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Applies error state styling. Per filter error messages are outside this components. + */ + isError: _propTypes.default.bool, + + /** + * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the dropdown to the triggering button. An `id` will be generated if none is supplied. + */ + id: _propTypes.default.string, + + /** + * If true, the filter will not display an editing popover when clicked. + */ + isLocked: _propTypes.default.bool, + + /** + * Applies new filter styling. + */ + isNew: _propTypes.default.bool, + + /** + * If true, the filter will not include a remove button. + */ + isPermanent: _propTypes.default.bool, + + /** + * Will be triggered when Done within the Popover is clicked. This is the place to update the filter props displayed. Callback will recieve parameters: `clickEvent, { id }`. An index into your store may be a good setting for `id`, so that it will be passed back here. + */ + onChange: _propTypes.default.func, + + /** + * Will be triggered when "Remove Filter" button is clicked. Callback will recieve parameters: `clickEvent, { id }`. An index into your store may be a good setting for `id`, so that it will be passed back here. + */ + onRemove: _propTypes.default.func, + + /** + * Will be triggered when Filter is clicked. This is the place to close/open popover if a custom popover is passed in + */ + onClick: _propTypes.default.func, + + /** + * A `Popover` component. The props from this popover will be merged and override any default props. This also allows a Filter's Popover dialog to be a controlled component. _Tested with Mocha framework._ + */ + popover: _propTypes.default.node, + + /** + * The criteria you are filtering for. For instance, if "Hair Color is PURPLE" is your filter, "is PURPLE" is your filter predicate. + */ + predicate: _propTypes.default.node, + + /** + * The property you are filtering. For instance, if "Hair Color is PURPLE" is your filter, "Hair Color" is your filter property. + */ + property: _propTypes.default.node +}); + +_defineProperty(Filter, "defaultProps", { + align: 'left', + assistiveText: { + editFilter: 'Edit filter:', + editFilterHeading: 'Choose filter criteria' + }, + predicate: 'New Filter' +}); + +var _default = Filter; +exports.default = _default; \ No newline at end of file diff --git a/components/forms/checkbox/index.js b/components/forms/checkbox/index.js new file mode 100644 index 0000000000..62091674e3 --- /dev/null +++ b/components/forms/checkbox/index.js @@ -0,0 +1,23 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _checkbox = _interopRequireDefault(require("../../checkbox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +var OldCheckbox = function OldCheckbox(props) { + return _react.default.createElement(_checkbox.default, _extends({ + oldEventParameterOrder: true + }, props)); +}; + +var _default = OldCheckbox; +exports.default = _default; \ No newline at end of file diff --git a/components/forms/input/__docs__/inline/storybook-stories.js b/components/forms/input/__docs__/inline/storybook-stories.js new file mode 100644 index 0000000000..a45fe81bfd --- /dev/null +++ b/components/forms/input/__docs__/inline/storybook-stories.js @@ -0,0 +1,118 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +var _constants = require("../../../../../utilities/constants"); + +var _inline = _interopRequireDefault(require("../../inline")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var DemoInlineEdit = +/*#__PURE__*/ +function (_React$Component) { + _inherits(DemoInlineEdit, _React$Component); + + function DemoInlineEdit() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, DemoInlineEdit); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DemoInlineEdit)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + value: 'Edit me inline' + }); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (eventProps) { + for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + rest[_key2 - 1] = arguments[_key2]; + } + + (0, _addonActions.action)('change')(rest); + + if (eventProps.value === '') { + _this.setState({ + value: 'Edit me inline' + }); + } else { + _this.setState({ + value: eventProps.value + }); + } + }); + + return _this; + } + + _createClass(DemoInlineEdit, [{ + key: "render", + value: function render() { + return _react.default.createElement(_inline.default, _extends({}, this.props, { + value: this.state.value, + onChange: this.handleChange + })); + } + }]); + + return DemoInlineEdit; +}(_react.default.Component); + +_defineProperty(DemoInlineEdit, "displayName", 'DemoInlineEdit'); + +(0, _react2.storiesOf)(_constants.FORMS_INLINE_EDIT, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base', function () { + return _react.default.createElement("section", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Base Inline Edit Input"), _react.default.createElement(DemoInlineEdit, { + name: "inline-edit-standard", + id: "inline-edit-standard" + })); +}).add('Disabled', function () { + return _react.default.createElement("section", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Disabled Inline Edit Input"), _react.default.createElement(DemoInlineEdit, { + name: "inline-edit-disabled", + id: "inline-edit-disabled", + disabled: true + })); +}); \ No newline at end of file diff --git a/components/forms/input/__examples__/inline-default.js b/components/forms/input/__examples__/inline-default.js new file mode 100644 index 0000000000..5c3821f733 --- /dev/null +++ b/components/forms/input/__examples__/inline-default.js @@ -0,0 +1,103 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../../components/icon-settings")); + +var _inline = _interopRequireDefault(require("../../../../../components/forms/input/inline")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + value: 'Edit me inline' + }); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (eventProps) { + _this.setState({ + value: eventProps.value + }); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("section", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Base Input with visible label"), _react.default.createElement(_inline.default, { + id: "inline-edit-example-1", + value: this.state.value, + onChange: this.handleChange + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Disabled Base Input"), _react.default.createElement(_inline.default, { + disabled: true, + id: "inline-edit-example-2", + value: this.state.value, + onChange: this.handleChange + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'InlineEditExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/forms/input/index.js b/components/forms/input/index.js new file mode 100644 index 0000000000..1456bf1beb --- /dev/null +++ b/components/forms/input/index.js @@ -0,0 +1,25 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _input = _interopRequireDefault(require("../../input")); + +var _componentHasMoved = _interopRequireDefault(require("../../../utilities/warning/component-has-moved")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// Alias +(0, _componentHasMoved.default)(_constants.INPUT, { + oldFileLocation: 'components/forms/input', + newFileLocation: 'components/input' +}); +var _default = _input.default; +exports.default = _default; \ No newline at end of file diff --git a/components/forms/input/inline-check-props.js b/components/forms/input/inline-check-props.js new file mode 100644 index 0000000000..4373fa182b --- /dev/null +++ b/components/forms/input/inline-check-props.js @@ -0,0 +1,28 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _componentIsDeprecated = _interopRequireDefault(require("../../../utilities/warning/component-is-deprecated")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ + +/* eslint-disable max-len */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT) { + (0, _componentIsDeprecated.default)(COMPONENT, 'For a multiple input form, please use the pattern located at https://www.lightningdesignsystem.com/components/form-element/#Record-Detail that swaps out a read-only `Input` with a base `Input`. For a single input, please use a `Popover` paired with ` +
    + +
    + + + +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + +
    +
  • + + + + + +`; + +exports[`DOM snapshots SLDSGlobalHeader Fewer Elements 1`] = ` +
    +
    +
    +
    +
    +
    +
    +
      +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSGlobalHeader Search + Navigation 1`] = ` +
    +
    + + Skip to Navigation + + + Skip to Main Content + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +
    +
      +
    • +
      +
      + +
      + +
      +
      +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + + +
      +
    • +
    • +
      + +
      +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSGlobalHeader With custom 1`] = ` +
    +
    + + Skip to Navigation + + + Skip to Main Content + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +
    +
      +
    • +
      +
      + +
      + +
      +
      +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + + +
      +
    • +
    • +
      + +
      +
    • +
    +
    +
    +
    +
    +`; diff --git a/components/global-header/__docs__/site-stories.js b/components/global-header/__docs__/site-stories.js new file mode 100644 index 0000000000..a4600c9f8b --- /dev/null +++ b/components/global-header/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/global-header/__examples__/default.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/global-header/__docs__/storybook-stories.js b/components/global-header/__docs__/storybook-stories.js new file mode 100644 index 0000000000..3fbefee532 --- /dev/null +++ b/components/global-header/__docs__/storybook-stories.js @@ -0,0 +1,314 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _avatar = _interopRequireDefault(require("../../avatar")); + +var _combobox = _interopRequireDefault(require("../../combobox")); + +var _menuDropdown = _interopRequireDefault(require("../../menu-dropdown")); + +var _globalHeader = _interopRequireDefault(require("../../global-header")); + +var _favorites = _interopRequireDefault(require("../../global-header/favorites")); + +var _help = _interopRequireDefault(require("../../global-header/help")); + +var _notifications = _interopRequireDefault(require("../../global-header/notifications")); + +var _profile = _interopRequireDefault(require("../../global-header/profile")); + +var _search = _interopRequireDefault(require("../../global-header/search")); + +var _setup = _interopRequireDefault(require("../../global-header/setup")); + +var _task = _interopRequireDefault(require("../../global-header/task")); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _popover = _interopRequireDefault(require("../../popover")); + +var _constants = require("../../../utilities/constants"); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +/* eslint-disable max-len */ + +/* eslint-disable no-script-url */ + +/* eslint-disable react/prop-types */ +var ipsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec bibendum fermentum eros, vel porta metus dignissim vitae. Fusce finibus sed magna vitae tempus. Suspendisse condimentum, arcu eu viverra vulputate, mauris odio dictum velit, in dictum lorem augue id augue. Proin nec leo convallis, aliquet mi ut, interdum nunc.'; // Notifications content is currently the contents of a generic `Popover` with markup copied from https://www.lightningdesignsystem.com/components/global-header/#Notifications. This allows content to have tab stops and focus trapping. If you need a more specific/explicit `GlobalHeaderNotification` content, please create an issue. + +var HeaderNotificationsCustomContent = function HeaderNotificationsCustomContent(props) { + return _react.default.createElement("ul", { + id: "header-notifications-custom-popover-content" + }, props.items.map(function (item) { + return _react.default.createElement("li", { + className: "slds-global-header__notification ".concat(item.unread ? 'slds-global-header__notification_unread' : ''), + key: "notification-item-".concat(item.id) + }, _react.default.createElement("div", { + className: "slds-media slds-has-flexi-truncate slds-p-around_x-small" + }, _react.default.createElement("div", { + className: "slds-media__figure" + }, _react.default.createElement("span", { + className: "slds-avatar slds-avatar_small" + }, _react.default.createElement("img", { + alt: item.name, + src: "/assets/images/".concat(item.avatar, ".jpg"), + title: "".concat(item.name, " avatar\"") + }))), _react.default.createElement("div", { + className: "slds-media__body" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_align-spread" + }, _react.default.createElement("a", { + href: "javascript:void(0);", + className: "slds-text-link_reset slds-has-flexi-truncate" + }, _react.default.createElement("h3", { + className: "slds-truncate", + title: "".concat(item.name, " ").concat(item.action) + }, _react.default.createElement("strong", null, "".concat(item.name, " ").concat(item.action))), _react.default.createElement("p", { + className: "slds-truncate", + title: item.comment + }, item.comment), _react.default.createElement("p", { + className: "slds-m-top_x-small slds-text-color_weak" + }, item.timePosted, ' ', item.unread ? _react.default.createElement("abbr", { + className: "slds-text-link slds-m-horizontal_xxx-small", + title: "unread" + }, "\u25CF") : null)))))); + })); +}; + +HeaderNotificationsCustomContent.displayName = 'HeaderNotificationsCustomContent'; // Profile content is currently the contents of a generic `Popover` with markup copied from https://www.lightningdesignsystem.com/components/global-header/. This allows content to have tab stops and focus trapping. If you need a more specific/explicit `GlobalHeaderProfile` content, please create an issue. + +var HeaderProfileCustomContent = function HeaderProfileCustomContent(props) { + return _react.default.createElement("div", { + id: "header-profile-custom-popover-content" + }, _react.default.createElement("div", { + className: "slds-m-around_medium" + }, _react.default.createElement("div", { + className: "slds-tile slds-tile_board slds-m-horizontal_small" + }, _react.default.createElement("p", { + className: "tile__title slds-text-heading_small" + }, "Art Vandelay"), _react.default.createElement("div", { + className: "slds-tile__detail" + }, _react.default.createElement("p", { + className: "slds-truncate" + }, _react.default.createElement("a", { + className: "slds-m-right_medium", + href: "javascript:void(0)", + onClick: props.onClick + }, "Settings"), _react.default.createElement("a", { + href: "javascript:void(0)", + onClick: props.onClick + }, "Log Out")))))); +}; + +HeaderProfileCustomContent.displayName = 'HeaderProfileCustomContent'; + +var GlobalHeaderDemo = +/*#__PURE__*/ +function (_React$Component) { + _inherits(GlobalHeaderDemo, _React$Component); + + function GlobalHeaderDemo(props) { + var _this; + + _classCallCheck(this, GlobalHeaderDemo); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(GlobalHeaderDemo).call(this, props)); + _this.state = { + favoritesActionSelected: false + }; + return _this; + } + + _createClass(GlobalHeaderDemo, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_globalHeader.default, { + onSkipToContent: (0, _addonActions.action)('Skip to Main Content'), + onSkipToNav: (0, _addonActions.action)('Skip to Navigation') // Add back for visual review with navigation present. + // The presence of React Modal in App Launcher in Global Navigation prevents Jest (node) testing. + // navigation={globalNavigationBar(props)} + , + assistiveText: { + skipToContent: 'Skip to Main Content', + skipToNavAssistiveText: 'Skip to Navigation' + } + }, _react.default.createElement(_search.default, { + combobox: _react.default.createElement(_combobox.default, { + events: { + onSelect: (0, _addonActions.action)('Search Selected') + }, + id: "header-search-custom-id", + labels: { + placeholder: 'Search Salesforce' + }, + options: [{ + id: 'email', + label: 'Email' + }, { + id: 'mobile', + label: 'Mobile' + }] + }) + }), _react.default.createElement(_favorites.default, { + actionSelected: this.state.favoritesActionSelected, + onToggleActionSelected: function onToggleActionSelected(event, data) { + _this2.setState({ + favoritesActionSelected: !data.actionSelected + }); + }, + popover: _react.default.createElement(_popover.default, { + ariaLabelledby: "favorites-heading", + body: _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_small", + id: "favorites-heading" + }, "Favorites"), ipsum), + id: "header-favorites-popover-id" + }) + }), _react.default.createElement(_task.default, { + dropdown: _react.default.createElement(_menuDropdown.default, { + id: "header-task-dropdown-id", + options: [{ + id: 'taskOptionOne', + label: 'Task Option One' + }, { + id: 'taskOptionTwo', + label: 'Task Option Two' + }] + }) + }), _react.default.createElement(_help.default, { + popover: _react.default.createElement(_popover.default, { + ariaLabelledby: "help-heading", + body: _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_small", + id: "help-heading" + }, "Help and Training"), ipsum), + id: "header-help-popover-id" + }) + }), _react.default.createElement(_setup.default, { + dropdown: _react.default.createElement(_menuDropdown.default, { + id: "header-setup-dropdown-id", + options: [{ + id: 'setupOptionOne', + label: 'Setup Option One' + }, { + id: 'setupOptionTwo', + label: 'Setup Option Two' + }] + }) + }), _react.default.createElement(_notifications.default, { + notificationCount: 5, + popover: _react.default.createElement(_popover.default, { + ariaLabelledby: "header-notifications-custom-popover-content", + body: _react.default.createElement(HeaderNotificationsCustomContent, { + items: [{ + action: 'mentioned you', + avatar: 'avatar2', + comment: '@jrogers Could I please have a review on my presentation deck', + id: 1, + name: 'Val Handerly', + timePosted: '10 hours ago', + unread: true + }, { + action: 'commented on your post', + avatar: 'avatar3', + comment: 'I totally agree with your sentiment', + id: 2, + name: 'Jon Rogers', + timePosted: '13 hours ago', + unread: true + }, { + action: 'mentioned you', + avatar: 'avatar2', + comment: "@jrogers Here's the conversation I mentioned to you", + id: 3, + name: 'Rebecca Stone', + timePosted: '1 day ago' + }] + }), + id: "header-notifications-popover-id" + }) + }), _react.default.createElement(_profile.default, { + avatar: this.props.avatar, + buttonClassName: "custom-button-class", + className: "custom-popover-class", + popover: _react.default.createElement(_popover.default, { + body: _react.default.createElement(HeaderProfileCustomContent, null), + id: "header-profile-popover-id" + }), + userName: "Art Vandelay" + })); + } + }]); + + return GlobalHeaderDemo; +}(_react.default.Component); + +GlobalHeaderDemo.displayName = 'GlobalHeaderDemo'; +(0, _react2.storiesOf)(_constants.GLOBAL_HEADER, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Search + Navigation', function () { + return _react.default.createElement(GlobalHeaderDemo, null); +}).add('Fewer Elements', function () { + return _react.default.createElement(_globalHeader.default, { + logoSrc: "/assets/images/global-header/logo.svg" + }, _react.default.createElement(_setup.default, { + dropdown: _react.default.createElement(_menuDropdown.default, { + id: "header-setup-dropdown-id", + options: [{ + id: 'setupOptionOne', + label: 'Setup Option One' + }, { + id: 'setupOptionTwo', + label: 'Setup Option Two' + }] + }) + }), _react.default.createElement(_profile.default, { + popover: _react.default.createElement(_popover.default, { + body: _react.default.createElement(HeaderProfileCustomContent, null), + id: "header-profile-popover-id" + }), + userName: "Art Vandelay" + })); +}).add('With custom ', function () { + return _react.default.createElement(GlobalHeaderDemo, { + avatar: _react.default.createElement(_avatar.default, { + variant: "user", + label: "Art Vandelay" + }) + }); +}).add('Doc site Default', function () { + return _react.default.createElement(_default.default, null); +}); \ No newline at end of file diff --git a/components/global-header/__examples__/default.js b/components/global-header/__examples__/default.js new file mode 100644 index 0000000000..15f77c2dfe --- /dev/null +++ b/components/global-header/__examples__/default.js @@ -0,0 +1,276 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _combobox = _interopRequireDefault(require("../../../../components/combobox")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +var _globalHeader = _interopRequireDefault(require("../../../../components/global-header")); + +var _favorites = _interopRequireDefault(require("../../../../components/global-header/favorites")); + +var _help = _interopRequireDefault(require("../../../../components/global-header/help")); + +var _notifications = _interopRequireDefault(require("../../../../components/global-header/notifications")); + +var _profile = _interopRequireDefault(require("../../../../components/global-header/profile")); + +var _search = _interopRequireDefault(require("../../../../components/global-header/search")); + +var _setup = _interopRequireDefault(require("../../../../components/global-header/setup")); + +var _task = _interopRequireDefault(require("../../../../components/global-header/task")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _popover = _interopRequireDefault(require("../../../../components/popover")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable max-len */ + +/* eslint-disable no-script-url */ + +/* eslint-disable react/prop-types */ +var ipsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec bibendum fermentum eros, vel porta metus dignissim vitae. Fusce finibus sed magna vitae tempus. Suspendisse condimentum, arcu eu viverra vulputate, mauris odio dictum velit, in dictum lorem augue id augue. Proin nec leo convallis, aliquet mi ut, interdum nunc.'; // Notifications content is currently the contents of a generic `Popover` with markup copied from https://www.lightningdesignsystem.com/components/global-header/#Notifications. This allows content to have tab stops and focus trapping. If you need a more specific/explicit `GlobalHeaderNotification` content, please create an issue. + +var HeaderNotificationsCustomContent = function HeaderNotificationsCustomContent(props) { + return _react.default.createElement("ul", { + id: "header-notifications-custom-popover-content" + }, props.items.map(function (item) { + return _react.default.createElement("li", { + className: "slds-global-header__notification ".concat(item.unread ? 'slds-global-header__notification_unread' : ''), + key: "notification-item-".concat(item.id) + }, _react.default.createElement("div", { + className: "slds-media slds-has-flexi-truncate slds-p-around_x-small" + }, _react.default.createElement("div", { + className: "slds-media__figure" + }, _react.default.createElement("span", { + className: "slds-avatar slds-avatar_small" + }, _react.default.createElement("img", { + alt: item.name, + src: "/assets/images/".concat(item.avatar, ".jpg"), + title: "".concat(item.name, " avatar\"") + }))), _react.default.createElement("div", { + className: "slds-media__body" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_align-spread" + }, _react.default.createElement("a", { + href: "javascript:void(0);", + className: "slds-text-link_reset slds-has-flexi-truncate" + }, _react.default.createElement("h3", { + className: "slds-truncate", + title: "".concat(item.name, " ").concat(item.action) + }, _react.default.createElement("strong", null, "".concat(item.name, " ").concat(item.action))), _react.default.createElement("p", { + className: "slds-truncate", + title: item.comment + }, item.comment), _react.default.createElement("p", { + className: "slds-m-top_x-small slds-text-color_weak" + }, item.timePosted, ' ', item.unread ? _react.default.createElement("abbr", { + className: "slds-text-link slds-m-horizontal_xxx-small", + title: "unread" + }, "\u25CF") : null)))))); + })); +}; + +HeaderNotificationsCustomContent.displayName = 'HeaderNotificationsCustomContent'; // Profile content is currently the contents of a generic `Popover` with markup copied from https://www.lightningdesignsystem.com/components/global-header/. This allows content to have tab stops and focus trapping. If you need a more specific/explicit `GlobalHeaderProfile` content, please create an issue. + +var HeaderProfileCustomContent = function HeaderProfileCustomContent(props) { + return _react.default.createElement("div", { + id: "header-profile-custom-popover-content" + }, _react.default.createElement("div", { + className: "slds-m-around_medium" + }, _react.default.createElement("div", { + className: "slds-tile slds-tile_board slds-m-horizontal_small" + }, _react.default.createElement("p", { + className: "tile__title slds-text-heading_small" + }, "Art Vandelay"), _react.default.createElement("div", { + className: "slds-tile__detail" + }, _react.default.createElement("p", { + className: "slds-truncate" + }, _react.default.createElement("a", { + className: "slds-m-right_medium", + href: "javascript:void(0)", + onClick: props.onClick + }, "Settings"), _react.default.createElement("a", { + href: "javascript:void(0)", + onClick: props.onClick + }, "Log Out")))))); +}; + +HeaderProfileCustomContent.displayName = 'HeaderProfileCustomContent'; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + favoritesActionSelected: false + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_globalHeader.default, { + logoSrc: "/assets/images/logo.svg", + onSkipToContent: function onSkipToContent() { + console.log('>>> Skip to Content Clicked'); + }, + onSkipToNav: function onSkipToNav() { + console.log('>>> Skip to Nav Clicked'); + } + }, _react.default.createElement(_search.default, { + combobox: _react.default.createElement(_combobox.default, { + events: { + onSelect: function onSelect() { + console.log('>>> onSelect'); + } + }, + id: "header-search-custom-id", + labels: { + placeholder: 'Search Salesforce' + }, + options: [{ + id: 'email', + label: 'Email' + }, { + id: 'mobile', + label: 'Mobile' + }] + }) + }), _react.default.createElement(_favorites.default, { + actionSelected: this.state.favoritesActionSelected, + onToggleActionSelected: function onToggleActionSelected(event, data) { + _this2.setState({ + favoritesActionSelected: !data.actionSelected + }); + }, + popover: _react.default.createElement(_popover.default, { + ariaLabelledby: "favorites-heading", + body: _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_small", + id: "favorites-heading" + }, "Favorites"), ipsum), + id: "header-favorites-popover-id" + }) + }), _react.default.createElement(_task.default, { + dropdown: _react.default.createElement(_menuDropdown.default, { + id: "header-task-dropdown-id", + options: [{ + id: 'taskOptionOne', + label: 'Task Option One' + }, { + id: 'taskOptionTwo', + label: 'Task Option Two' + }] + }) + }), _react.default.createElement(_help.default, { + popover: _react.default.createElement(_popover.default, { + ariaLabelledby: "help-heading", + body: _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_small", + id: "help-heading" + }, "Help and Training"), ipsum), + id: "header-help-popover-id" + }) + }), _react.default.createElement(_setup.default, { + dropdown: _react.default.createElement(_menuDropdown.default, { + id: "header-setup-dropdown-id", + options: [{ + id: 'setupOptionOne', + label: 'Setup Option One' + }, { + id: 'setupOptionTwo', + label: 'Setup Option Two' + }] + }) + }), _react.default.createElement(_notifications.default, { + notificationCount: 5, + popover: _react.default.createElement(_popover.default, { + ariaLabelledby: "header-notifications-custom-popover-content", + body: _react.default.createElement(HeaderNotificationsCustomContent, { + items: [{ + action: 'mentioned you', + avatar: 'avatar2', + comment: '@jrogers Could I please have a review on my presentation deck', + id: 1, + name: 'Val Handerly', + timePosted: '10 hours ago', + unread: true + }, { + action: 'commented on your post', + avatar: 'avatar3', + comment: 'I totally agree with your sentiment', + id: 2, + name: 'Jon Rogers', + timePosted: '13 hours ago', + unread: true + }, { + action: 'mentioned you', + avatar: 'avatar2', + comment: "@jrogers Here's the conversation I mentioned to you", + id: 3, + name: 'Rebecca Stone', + timePosted: '1 day ago' + }] + }), + id: "header-notifications-popover-id" + }) + }), _react.default.createElement(_profile.default, { + popover: _react.default.createElement(_popover.default, { + body: _react.default.createElement(HeaderProfileCustomContent, null), + id: "header-profile-popover-id" + }), + userName: "Art Vandelay" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'GlobalHeaderExample'); + +Example.displayName = 'GlobalHeaderExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/button.js b/components/global-header/button.js new file mode 100644 index 0000000000..53814072ee --- /dev/null +++ b/components/global-header/button.js @@ -0,0 +1,43 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _button = _interopRequireDefault(require("../button")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +/** + * A helper component that renders a Button in the tools area of the Global Header. Currently defaults to a bare icon, but this can be overriden if text-based buttons are required. + */ +var GlobalHeaderButton = function GlobalHeaderButton(props) { + (0, _checkProps.default)(_constants.GLOBAL_HEADER_BUTTON, props); + + var buttonVariant = props.buttonVariant, + rest = _objectWithoutProperties(props, ["buttonVariant"]); + + var btn = _react.default.createElement(_button.default, _extends({ + iconVariant: "global-header", + variant: "icon" + }, rest)); + + return buttonVariant === 'dropdown' ? btn : _react.default.createElement("li", null, btn); +}; + +GlobalHeaderButton.displayName = _constants.GLOBAL_HEADER_TOOL; +var _default = GlobalHeaderButton; +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/check-props.js b/components/global-header/check-props.js new file mode 100644 index 0000000000..faf4268170 --- /dev/null +++ b/components/global-header/check-props.js @@ -0,0 +1,51 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _componentIsDeprecated = _interopRequireDefault(require("../../utilities/warning/component-is-deprecated")); + +var _deprecatedProperty = _interopRequireDefault(require("../../utilities/warning/deprecated-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +// ## Constants +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + if (COMPONENT === _constants.GLOBAL_HEADER_BUTTON || COMPONENT === _constants.GLOBAL_HEADER_DROPDOWN) { + (0, _componentIsDeprecated.default)(COMPONENT, "".concat(COMPONENT, " has been deprecated in favor of more-specific global header subcomponents. Please see docs for updated examples.")); + } + + if (COMPONENT === _constants.GLOBAL_HEADER_PROFILE) { + var popoverExtraMessage = 'Use the `popover` attribute to provide a `Popover` component with content inside the `body` prop instead.'; + (0, _sunsetProperty.default)(COMPONENT, props.align, 'align'); + (0, _sunsetProperty.default)(COMPONENT, props.children, 'children', popoverExtraMessage); + (0, _sunsetProperty.default)(COMPONENT, props.nubbinPosition, 'nubbinPosition'); + (0, _sunsetProperty.default)(COMPONENT, props.offset, 'offset'); + (0, _sunsetProperty.default)(COMPONENT, props.onSelect, 'onSelect'); + (0, _sunsetProperty.default)(COMPONENT, props.options, 'options', popoverExtraMessage); + } + + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + (0, _deprecatedProperty.default)(COMPONENT, props.skipToContentAssistiveText, 'skipToContentAssistiveText', "assistiveText['skipToContent']", createDocUrl('assistiveText')); + (0, _deprecatedProperty.default)(COMPONENT, props.skipToNavAssistiveText, 'skipToNavAssistiveText', "assistiveText['skipToNav']", createDocUrl('assistiveText')); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/docs.json b/components/global-header/docs.json new file mode 100644 index 0000000000..513976f75b --- /dev/null +++ b/components/global-header/docs.json @@ -0,0 +1,30 @@ +{ + "component": "global-header", + "status": "prod", + "display-name": "Global Header", + "SLDS-component-path": "/components/global-header#flavor-base", + "dependencies": [ + { + "component": "favorites" + }, + { + "component": "help" + }, + { + "component": "notifications" + }, + { + "component": "profile" + }, + { + "component": "search" + }, + { + "component": "setup" + }, + { + "component": "task" + } + ], + "url-slug": "global-headers" +} diff --git a/components/global-header/dropdown.js b/components/global-header/dropdown.js new file mode 100644 index 0000000000..51cca48518 --- /dev/null +++ b/components/global-header/dropdown.js @@ -0,0 +1,122 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _menuDropdown = _interopRequireDefault(require("../menu-dropdown")); + +var _dropdownTrigger = _interopRequireDefault(require("./private/dropdown-trigger")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +/** + * This component is an implementation of `MenuDropdown` with a custom trigger. All the properties listed below are provided to the `MenuDropdown` component. Any additional properties are provided to the Custom Trigger (that is the `Button` or `li` tag). + */ +var GlobalHeaderDropdown = function GlobalHeaderDropdown(props) { + (0, _checkProps.default)(_constants.GLOBAL_HEADER_DROPDOWN, props); + + var globalAction = props.globalAction, + iconVariant = props.iconVariant, + rest = _objectWithoutProperties(props, ["globalAction", "iconVariant"]); + + var iconVariantOverride; + + if (globalAction) { + iconVariantOverride = 'container'; + } + + return _react.default.createElement(_menuDropdown.default, _extends({ + nubbinPosition: "top right" + }, rest), _react.default.createElement(_dropdownTrigger.default, { + globalAction: globalAction, + iconSize: globalAction && 'small', + iconVariant: iconVariantOverride || iconVariant + })); +}; // ### Display Name +// Always use the canonical component name (set in the core) as the React +// display name. + + +GlobalHeaderDropdown.displayName = _constants.GLOBAL_HEADER_TOOL; // ### Prop Types + +GlobalHeaderDropdown.propTypes = { + /** + * Aligns the right or left side of the menu with the respective side of the trigger. This is not intended for use with `nubbinPosition`. + */ + align: _propTypes.default.oneOf(['left', 'right']), + + /** + * Extra classnames to apply to the dropdown menu. + */ + className: _propTypes.default.string, + + /** + * CSS classes to be added to `li` element. + */ + buttonClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Name of the icon. Visit Lightning Design System Icons to reference icon names. + */ + iconName: _propTypes.default.string, + + /** + * For icon variants, please reference Lightning Design System Icons. + */ + iconVariant: _propTypes.default.oneOf(['bare', 'container', 'border', 'border-filled', 'more', 'global-header']), + + /** + * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the dropdown to the triggering button. + */ + id: _propTypes.default.string, + + /** + * Adds custom styling such as inverse fill and special sizing/spacing + */ + globalAction: _propTypes.default.bool, + + /** + * Positions dropdown menu with a nubbin--that is the arrow notch. The placement options correspond to the placement of the nubbin. This is implemeted with CSS classes and is best used with a `Button` with "icon container" styling. Dropdown menus will still be contained to the closest scrolling parent. + */ + nubbinPosition: _propTypes.default.oneOf(['top left', 'top', 'top right', 'bottom left', 'bottom', 'bottom right']), + + /** + * Offset adds pixels to the absolutely positioned dropdown menu in the format: ([vertical]px [horizontal]px). + */ + offset: _propTypes.default.string, + + /** + * Triggered when an item in the menu is clicked. + */ + onSelect: _propTypes.default.func, + + /** + * An array of menu item. + */ + options: _propTypes.default.array.isRequired +}; // ### Default Props + +GlobalHeaderDropdown.defaultProps = { + align: 'right', + buttonVariant: 'icon', + iconVariant: 'global-header', + nubbinPosition: 'top right' +}; +var _default = GlobalHeaderDropdown; +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/favorites.js b/components/global-header/favorites.js new file mode 100644 index 0000000000..1153456504 --- /dev/null +++ b/components/global-header/favorites.js @@ -0,0 +1,190 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _button = _interopRequireDefault(require("../button")); + +var _event = _interopRequireDefault(require("../../utilities/event")); + +var _keyCode = _interopRequireDefault(require("../../utilities/key-code")); + +var _popover = _interopRequireDefault(require("../popover")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * **Assistive text for accessibility** + * * `action`: Description of star button. Default is "Toggle Favorite." + * * `more`: Description of dropdown menu. Default is "View Favorites." + */ + assistiveText: _propTypes.default.shape({ + action: _propTypes.default.string, + more: _propTypes.default.string + }), + + /** + * Disables the favorites action (star) button and not the related Popover." + */ + actionDisabled: _propTypes.default.bool, + + /** + * Controls whether the favorites action (star) button is selected or not + */ + actionSelected: _propTypes.default.bool, + + /** + * This event fires when the favorites action (star) button is toggled. Passes in `event, { actionSelected }`. + */ + onToggleActionSelected: _propTypes.default.func, + + /** + * A `Popover` component applied to the favorites more button. The props from this popover will be merged and override any default props. The `children` prop will be ignored. + */ + popover: _propTypes.default.node +}; +/** + * A GlobalHeaderFavorites component. The favorites action is used to "favorite" a commonly used page within a user's experience. When a user "favorites" a page by pressing the favorites action, the button icon changes color with a small animation to confirm your selection. + */ + +var GlobalHeaderFavorites = +/*#__PURE__*/ +function (_React$Component) { + _inherits(GlobalHeaderFavorites, _React$Component); + + function GlobalHeaderFavorites() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, GlobalHeaderFavorites); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(GlobalHeaderFavorites)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "toggleActionSelected", function (event) { + if (_this.props.onToggleActionSelected) { + _this.props.onToggleActionSelected(event, { + actionSelected: _this.props.actionSelected || false + }); + } + }); + + return _this; + } + + _createClass(GlobalHeaderFavorites, [{ + key: "render", + value: function render() { + var _this2 = this; + + var actionAriaProps = {}; + var popoverProps = (0, _lodash.default)({ + align: 'bottom', + body: _react.default.createElement("span", null), + triggerClassName: 'slds-dropdown-trigger slds-dropdown-trigger_click' + }, this.props.popover ? this.props.popover.props : {}); + delete popoverProps.children; + + if (this.props.actionSelected) { + actionAriaProps['aria-pressed'] = true; + } + + return _react.default.createElement("div", { + className: "slds-global-actions__favorites slds-dropdown-trigger slds-dropdown-trigger_click" + }, _react.default.createElement("div", { + className: "slds-button-group" + }, _react.default.createElement(_button.default, _extends({ + assistiveText: { + icon: this.props.assistiveText.action + }, + className: (0, _classnames.default)('slds-button_icon slds-global-actions__favorites-action', { + 'slds-is-disabled': this.props.actionDisabled, + 'slds-is-selected': this.props.actionSelected + }), + disabled: this.props.actionDisabled, + iconCategory: "utility", + iconName: "favorite", + iconSize: "small", + iconVariant: "border", + onClick: this.toggleActionSelected, + onKeyDown: function onKeyDown(event) { + if (event.keyCode === _keyCode.default.ENTER) { + _event.default.trapImmediate(event); + + _this2.toggleActionSelected(event); + } + }, + title: this.props.assistiveText.action, + variant: "icon" + }, actionAriaProps)), _react.default.createElement(_popover.default, popoverProps, _react.default.createElement(_button.default, { + assistiveText: { + icon: this.props.assistiveText.more + }, + className: "slds-button_icon slds-global-actions__favorites-more", + iconCategory: "utility", + iconName: "down", + iconSize: "small", + iconVariant: "border", + style: { + // this is needed because the popover trigger wrapper janks up the default styles + borderLeft: '0', + borderRadius: '0 .25rem .25rem 0' + }, + title: this.props.assistiveText.more, + variant: "icon" + })))); + } + }]); + + return GlobalHeaderFavorites; +}(_react.default.Component); + +GlobalHeaderFavorites.displayName = _constants.GLOBAL_HEADER_FAVORITES; +GlobalHeaderFavorites.defaultProps = { + assistiveText: { + action: 'Toggle Favorite', + more: 'View Favorites' + } +}; +GlobalHeaderFavorites.propTypes = propTypes; +var _default = GlobalHeaderFavorites; +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/help.js b/components/global-header/help.js new file mode 100644 index 0000000000..c34b87586f --- /dev/null +++ b/components/global-header/help.js @@ -0,0 +1,110 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _button = _interopRequireDefault(require("../button")); + +var _popover = _interopRequireDefault(require("../popover")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * **Assistive text for accessibility** + * * `triggerButton`: Assistive text for the GlobalHeaderHelp trigger button. The default is `Help and Training`. + */ + assistiveText: _propTypes.default.shape({ + triggerButton: _propTypes.default.string + }), + + /** + * A `Popover` component. The props from this popover will be merged and override any default props. The `children` prop will be ignored. + */ + popover: _propTypes.default.node +}; +/** + * A GlobalHeaderHelp component. + */ + +var GlobalHeaderHelp = +/*#__PURE__*/ +function (_React$Component) { + _inherits(GlobalHeaderHelp, _React$Component); + + function GlobalHeaderHelp() { + _classCallCheck(this, GlobalHeaderHelp); + + return _possibleConstructorReturn(this, _getPrototypeOf(GlobalHeaderHelp).apply(this, arguments)); + } + + _createClass(GlobalHeaderHelp, [{ + key: "render", + value: function render() { + var buttonAriaProps = { + 'aria-haspopup': true + }; + var popoverProps = (0, _lodash.default)({ + align: 'bottom', + body: _react.default.createElement("span", null), + triggerClassName: 'slds-dropdown-trigger slds-dropdown-trigger_click' + }, this.props.popover ? this.props.popover.props : {}); + delete popoverProps.children; + return _react.default.createElement(_popover.default, popoverProps, _react.default.createElement(_button.default, _extends({ + assistiveText: { + icon: this.props.assistiveText.triggerButton + }, + className: "slds-button_icon slds-global-actions__help slds-global-actions__item-action", + iconCategory: "utility", + iconClassName: "slds-global-header__icon", + iconName: "question", + iconSize: "small", + iconVariant: "container", + title: this.props.assistiveText.triggerButton, + variant: "icon" + }, buttonAriaProps))); + } + }]); + + return GlobalHeaderHelp; +}(_react.default.Component); + +GlobalHeaderHelp.displayName = _constants.GLOBAL_HEADER_HELP; +GlobalHeaderHelp.defaultProps = { + assistiveText: { + triggerButton: 'Help and Training' + } +}; +GlobalHeaderHelp.propTypes = propTypes; +var _default = GlobalHeaderHelp; +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/index.js b/components/global-header/index.js new file mode 100644 index 0000000000..04bb426301 --- /dev/null +++ b/components/global-header/index.js @@ -0,0 +1,209 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _event = _interopRequireDefault(require("../../utilities/event")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var defaultProps = { + assistiveText: { + skipToNav: 'Skip to Navigation', + skipToContent: 'Skip to Main Content' + }, + logoSrc: '/assets/images/logo-noname.svg' +}; +/** + * The global header is the anchor for the Salesforce platform and spans all other parts of the UI. It accepts children to define the items displayed within. + * + * Example: + * ``` + * + * + * + * + * + * + * + * ``` + */ + +var GlobalHeader = +/*#__PURE__*/ +function (_React$Component) { + _inherits(GlobalHeader, _React$Component); + + function GlobalHeader() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, GlobalHeader); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(GlobalHeader)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "handleSkipToContent", function (e) { + _event.default.trap(e); + + _this.props.onSkipToContent(e); + }); + + _defineProperty(_assertThisInitialized(_this), "handleSkipToNav", function (e) { + _event.default.trap(e); + + _this.props.onSkipToNav(e); + }); + + return _this; + } + + _createClass(GlobalHeader, [{ + key: "componentWillMount", + value: function componentWillMount() { + (0, _checkProps.default)(_constants.GLOBAL_HEADER, this.props, _docs.default); + } + }, { + key: "render", + value: function render() { + var _actions; + + var assistiveText = _objectSpread({}, defaultProps.assistiveText, this.props.assistiveText); + + var actions = (_actions = {}, _defineProperty(_actions, _constants.GLOBAL_HEADER_FAVORITES, []), _defineProperty(_actions, _constants.GLOBAL_HEADER_HELP, []), _defineProperty(_actions, _constants.GLOBAL_HEADER_NOTIFICATIONS, []), _defineProperty(_actions, _constants.GLOBAL_HEADER_PROFILE, []), _defineProperty(_actions, _constants.GLOBAL_HEADER_SETUP, []), _defineProperty(_actions, _constants.GLOBAL_HEADER_TASK, []), _defineProperty(_actions, _constants.GLOBAL_HEADER_TOOL, []), _actions); + var search; + + _react.default.Children.forEach(this.props.children, function (child) { + if (child) { + if (child.type.displayName === _constants.GLOBAL_HEADER_SEARCH) { + search = child; + } else if (actions[child.type.displayName]) { + actions[child.type.displayName].push(child); + } + } + }); + + actions = [].concat(actions[_constants.GLOBAL_HEADER_FAVORITES], actions[_constants.GLOBAL_HEADER_TASK], actions[_constants.GLOBAL_HEADER_HELP], actions[_constants.GLOBAL_HEADER_SETUP], actions[_constants.GLOBAL_HEADER_NOTIFICATIONS], actions[_constants.GLOBAL_HEADER_TOOL], // support for deprecated GlobalHeaderButton and GlobalHeaderDropdown + actions[_constants.GLOBAL_HEADER_PROFILE]); + /* eslint-disable max-len, no-script-url */ + + return _react.default.createElement("header", { + className: "slds-global-header_container" + }, this.props.onSkipToNav ? _react.default.createElement("a", { + href: "javascript:void(0);", + className: "slds-assistive-text slds-assistive-text_focus", + onClick: this.handleSkipToNav + }, this.props.skipToNavAssistiveText || assistiveText.skipToNav) : null, this.props.onSkipToContent ? _react.default.createElement("a", { + href: "javascript:void(0);", + className: "slds-assistive-text slds-assistive-text_focus", + onClick: this.handleSkipToContent + }, this.props.skipToContentAssistiveText || assistiveText.skipToContent) : null, _react.default.createElement("div", { + className: "slds-global-header slds-grid slds-grid_align-spread" + }, _react.default.createElement("div", { + className: "slds-global-header__item" + }, _react.default.createElement("div", { + className: "slds-global-header__logo", + style: { + backgroundImage: "url(".concat(this.props.logoSrc, ")") + } + })), search, _react.default.createElement("div", { + className: "slds-global-header__item" + }, _react.default.createElement("ul", { + className: "slds-global-actions" + }, actions.map(function (actionItem, index) { + return _react.default.createElement("li", { + className: "slds-global-actions__item", + key: "actions-item-".concat(index) + /* eslint-disable-line react/no-array-index-key */ + + }, actionItem); + })))), this.props.navigation); + /* eslint-enable max-len, no-script-url */ + } + }]); + + return GlobalHeader; +}(_react.default.Component); + +_defineProperty(GlobalHeader, "displayName", _constants.GLOBAL_HEADER); + +_defineProperty(GlobalHeader, "propTypes", { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `skipToNav`: The localized text that will be read back for the "Skip to Navigation" accessibility link. + * * `skipToContent`: The localized text that will be read back for the "Skip to Main Content" accessibility link. + */ + assistiveText: _propTypes.default.shape({ + skipToNav: _propTypes.default.string, + skipToContent: _propTypes.default.string + }), + + /** + * See the component description, this accepts some combination of `SLDSGlobalHeaderSearch`, `SLDSGlobalHeaderButton`, `SLDSGlobalHeaderDropdown`, and `SLDSGlobalHeaderProfile` components. + */ + children: _propTypes.default.node, + + /** + * The Salesforce logo to display in the header. + */ + logoSrc: _propTypes.default.string, + + /** + * Pass in the Global Navigation Bar component + */ + navigation: _propTypes.default.node, + + /** + * Required for accessibility. Should jump the user to the primary content area. + */ + onSkipToContent: _propTypes.default.func, + + /** + * Required for accessibility. Should jump the user to the primary navigation. + */ + onSkipToNav: _propTypes.default.func +}); + +_defineProperty(GlobalHeader, "defaultProps", defaultProps); + +var _default = GlobalHeader; +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/notifications.js b/components/global-header/notifications.js new file mode 100644 index 0000000000..86dd845b53 --- /dev/null +++ b/components/global-header/notifications.js @@ -0,0 +1,137 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _button = _interopRequireDefault(require("../button")); + +var _popover = _interopRequireDefault(require("../popover")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * **Assistive text for accessibility** + * * `newNotificationsAfter`: Assistive text for when there are new notifications, after the notificationCount. The default is ' new notifications'. + * * `newNotificationsBefore`: Assistive text for when there are new notifications, before the notificationCount. The default is ''. + * * `noNotifications`: Assistive text for when there are no new notifications. + */ + assistiveText: _propTypes.default.shape({ + newNotificationsAfter: _propTypes.default.string, + newNotificationsBefore: _propTypes.default.string, + noNotifications: _propTypes.default.string + }), + + /** + * Dictates the number of notifications shown in the new notifications badge. + */ + notificationCount: _propTypes.default.number, + + /** + * A `Popover` component. The props from this popover will be merged and override any default props. The `children` prop will be ignored. + */ + popover: _propTypes.default.node +}; +/** + * A GlobalHeaderNotifications component. Notifications are a way to notify a user about a global change within the application. + */ + +var GlobalHeaderNotifications = +/*#__PURE__*/ +function (_React$Component) { + _inherits(GlobalHeaderNotifications, _React$Component); + + function GlobalHeaderNotifications() { + _classCallCheck(this, GlobalHeaderNotifications); + + return _possibleConstructorReturn(this, _getPrototypeOf(GlobalHeaderNotifications).apply(this, arguments)); + } + + _createClass(GlobalHeaderNotifications, [{ + key: "render", + value: function render() { + var buttonAriaProps = { + 'aria-live': 'assertive' + }; + var notificationCount = this.props.notificationCount; + var popoverProps = (0, _lodash.default)({ + align: 'bottom right', + body: _react.default.createElement("span", null), + triggerClassName: 'slds-dropdown-trigger slds-dropdown-trigger_click' + }, this.props.popover ? this.props.popover.props : {}); + var notificationsAssistiveText = this.props.assistiveText.noNotifications; + delete popoverProps.children; + + if (notificationCount > 0) { + notificationsAssistiveText = "".concat(this.props.assistiveText.newNotificationsBefore).concat(notificationCount).concat(this.props.assistiveText.newNotificationsAfter); + } else { + buttonAriaProps['aria-atomic'] = true; + } + + return _react.default.createElement(_popover.default, popoverProps, _react.default.createElement(_button.default, _extends({ + assistiveText: { + icon: notificationsAssistiveText + }, + className: "slds-button_icon slds-global-actions__notifications slds-global-actions__item-action", + iconCategory: "utility", + iconClassName: "slds-global-header__icon", + iconName: "notification", + iconSize: "small", + iconVariant: "container", + title: notificationsAssistiveText, + variant: "icon" + }, buttonAriaProps)), notificationCount > 0 ? _react.default.createElement("span", { + "aria-hidden": "true", + className: "slds-notification-badge slds-incoming-notification slds-show-notification" + }, notificationCount) : _react.default.createElement("span", { + "aria-hidden": "true", + className: "slds-notification-badge" + })); + } + }]); + + return GlobalHeaderNotifications; +}(_react.default.Component); + +GlobalHeaderNotifications.displayName = _constants.GLOBAL_HEADER_NOTIFICATIONS; +GlobalHeaderNotifications.defaultProps = { + assistiveText: { + newNotificationsAfter: ' new notifications', + newNotificationsBefore: '', + noNotifications: 'No new notifications' + }, + notificationCount: 0 +}; +GlobalHeaderNotifications.propTypes = propTypes; +var _default = GlobalHeaderNotifications; +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/private/dropdown-trigger.js b/components/global-header/private/dropdown-trigger.js new file mode 100644 index 0000000000..4799ad1f5c --- /dev/null +++ b/components/global-header/private/dropdown-trigger.js @@ -0,0 +1,225 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _button = _interopRequireDefault(require("../button")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * The Dropdown Button Trigger renders the default trigger button for the dropdown menu. If this component has children, it does not render itself to the DOM. Instead, it renders its child element, `Button`, and all that child's properties. This component may be used as a template to create custom triggers that do not use `Button`. + */ +var GlobalHeaderDropdownTrigger = +/*#__PURE__*/ +function (_React$Component) { + _inherits(GlobalHeaderDropdownTrigger, _React$Component); + + function GlobalHeaderDropdownTrigger() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, GlobalHeaderDropdownTrigger); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(GlobalHeaderDropdownTrigger)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "renderAvatar", function () { + var avatar = _this.props.avatar; + + if (typeof avatar === 'string') { + return _react.default.createElement("span", { + className: "slds-avatar slds-avatar_circle slds-avatar_medium" + }, _react.default.createElement("img", { + src: avatar, + alt: "" + })); + } + + return avatar || null; + }); + + return _this; + } + + _createClass(GlobalHeaderDropdownTrigger, [{ + key: "render", + // ### Render + value: function render() { + // The following props are provided to the `li`, all others are passed into the `Button` + var _this$props = this.props, + className = _this$props.className, + id = _this$props.id, + isOpen = _this$props.isOpen, + globalAction = _this$props.globalAction, + menu = _this$props.menu, + onBlur = _this$props.onBlur, + onClick = _this$props.onClick, + onFocus = _this$props.onFocus, + onKeyDown = _this$props.onKeyDown, + onMouseDown = _this$props.onMouseDown, + onMouseEnter = _this$props.onMouseEnter, + onMouseLeave = _this$props.onMouseLeave, + triggerRef = _this$props.triggerRef, + rest = _objectWithoutProperties(_this$props, ["className", "id", "isOpen", "globalAction", "menu", "onBlur", "onClick", "onFocus", "onKeyDown", "onMouseDown", "onMouseEnter", "onMouseLeave", "triggerRef"]); + + return ( + /* eslint-disable jsx-a11y/no-static-element-interactions */ + _react.default.createElement("li", { + "aria-haspopup": "true", + className: (0, _classnames.default)('slds-dropdown-trigger slds-dropdown-trigger_click', { + 'slds-is-open': isOpen, + 'slds-p-around_xx-small': globalAction + }, className), + id: id, + onBlur: onBlur, + onClick: onClick, + onFocus: onFocus, + onKeyDown: onKeyDown, + onMouseDown: onMouseDown, + onMouseEnter: onMouseEnter, + onMouseLeave: onMouseLeave, + ref: triggerRef + }, _react.default.createElement(_button.default, _extends({ + className: (0, _classnames.default)({ + 'slds-global-header__button_icon-actions': globalAction + }), + iconClassName: (0, _classnames.default)({ + 'slds-global-header__icon-actions': globalAction + }), + "aria-haspopup": "true", + buttonVariant: "dropdown" + }, rest), this.renderAvatar()), menu) + ); + } + }]); + + return GlobalHeaderDropdownTrigger; +}(_react.default.Component); + +_defineProperty(GlobalHeaderDropdownTrigger, "displayName", _constants.MENU_DROPDOWN_TRIGGER); + +_defineProperty(GlobalHeaderDropdownTrigger, "propTypes", { + /** + * An image URL or avatar node to display for the user profile. + */ + avatar: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]), + + /** + * CSS classes to be added to `li` element. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the dropdown to the triggering button. + */ + id: _propTypes.default.string, + + /** + * Informs the trigger on the open/close state of the dropdown menu + */ + isOpen: _propTypes.default.bool, + + /** + * Adds custom styling such as inverse fill and special sizing/spacing + */ + globalAction: _propTypes.default.bool, + + /** + * The dropdown menu. + */ + menu: _propTypes.default.node, + + /** + * Is only called when `openOn` is set to `hover` and when the triggering li loses focus. + */ + onBlur: _propTypes.default.func, + + /** + * This prop is passed onto the triggering `li`. Triggered when the trigger li is clicked. + */ + onClick: _propTypes.default.func, + + /** + * Is only called when `openOn` is set to `hover` and when the triggering li gains focus. + */ + onFocus: _propTypes.default.func, + + /** + * Called when a key pressed. + */ + onKeyDown: _propTypes.default.func, + + /** + * Called when mouse clicks down on the trigger li. + */ + onMouseDown: _propTypes.default.func, + + /** + * Called when mouse hovers over the trigger `li`. + */ + onMouseEnter: _propTypes.default.func, + + /** + * Called when mouse leaves trigger `li` or the menu. + */ + onMouseLeave: _propTypes.default.func, + + /** + * Determines if mouse hover or click opens the dropdown menu. The default of `click` is highly recommended to comply with accessibility standards. If you are planning on using hover, please pause a moment and reconsider. + */ + openOn: _propTypes.default.oneOf(['hover', 'click', 'hybrid']), + + /** + * Set to true if menu is inline and relatively positioned with CSS. This is the typical use case for menus with nubbins. + */ + positioned: _propTypes.default.bool, + + /** + * The ref of the actual triggering button. + */ + triggerRef: _propTypes.default.func +}); + +var _default = GlobalHeaderDropdownTrigger; +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/profile.js b/components/global-header/profile.js new file mode 100644 index 0000000000..4fe65e0079 --- /dev/null +++ b/components/global-header/profile.js @@ -0,0 +1,142 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _button = _interopRequireDefault(require("../button")); + +var _popover = _interopRequireDefault(require("../popover")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +/** + * This component is an `Avatar` component that opens a `Popover` component when clicked. + */ +var GlobalHeaderProfile = +/*#__PURE__*/ +function (_React$Component) { + _inherits(GlobalHeaderProfile, _React$Component); + + function GlobalHeaderProfile(props) { + var _this; + + _classCallCheck(this, GlobalHeaderProfile); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(GlobalHeaderProfile).call(this, props)); + (0, _checkProps.default)(_constants.GLOBAL_HEADER_PROFILE, props); + return _this; + } + + _createClass(GlobalHeaderProfile, [{ + key: "render", + value: function render() { + var buttonAriaProps = { + 'aria-haspopup': true + }; + var popoverProps = (0, _lodash.default)({ + align: 'bottom right', + body: _react.default.createElement("span", null), + className: this.props.className, + heading: this.props.userName, + id: this.props.id, + triggerClassName: 'slds-dropdown-trigger slds-dropdown-trigger_click' + }, this.props.popover ? this.props.popover.props : {}); // Note: the default avatar is done this way to prevent documentation from showing this giant string + + /* eslint-disable max-len */ + + var avatar = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAwaADAAQAAAABAAAAwQAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgAwQDBAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAQEBAQEBAgEBAgMCAgIDBAMDAwMEBQQEBAQEBQYFBQUFBQUGBgYGBgYGBgcHBwcHBwgICAgICQkJCQkJCQkJCf/bAEMBAQEBAgICBAICBAkGBQYJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCf/dAAQADf/aAAwDAQACEQMRAD8A+oKKKK/oA/DwooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9D6gooor+gD8PCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/0fqCiiiv6APw8KKKKACiiigAooooAKKKKACijOOtdhoPw8+IHiqPzvDGh3+op/etreSQf+OqamU1HVsqMW3ZHH0V2GvfDz4geFY/O8T6Hf6cn965t5Ix/wCPKK4/OelEZqWqYSi07MKKKKokKKKKACiiigAooooAKKKKACiiigD/0vqCiiiv6APw8KKKKACiiigAooooAK6Lwn4T8R+OvEdp4R8JWj32o30gjhhjGSzH+QHUk8AVzpOOa/ff/gmL+zjZeFPA5+OXia2zqushksd45itQcbh6GQ85/u4ry84zOOEouq9+nqellWXSxNZU1t19Drf2ZP8AgnF8OvhpYWvij4swx6/r7KHaGQbrW3brhUP3yP7zd+gr9JrHTNN0uBbbTbeO3jQYVY1CgAdgABV6ivx/GY+tiJc9WVz9UwmCpUI8lJWKN9pmm6pA1tqVvHcRuMMsihgQexBBr82f2m/+CcXw6+Jdhc+J/hNDHoGvqpdYYxttbhuuGQfcJ/vL36iv00oowePrYeXPSlYMXgqVePJVVz+MnxZ4T8R+BfEd34R8W2j2Oo2MhjmhkGCrD+YPUEcEVztfvv8A8FOv2cbLxX4HHxy8M22NV0bal9sHMtqTjc3qYzzn+7mvwIBzzX7Bk+ZxxdFVVv19T8rzXLpYas6b26egUUUV6h5oUUUUAFFFFABRRRQAUUUUAf/T+oKKKK/oA/DwooooAKKKKACiiigDX8P6RN4g1+x0G3/1l7cRwL9ZGC/1r+xnwR4csfCHg7S/C2mrst9PtYreNfRY1AFfyI/CO5gsvit4ZvLn/Vxapas2fQSqTX9iULK8KOvQgEflX57xxN3px6an3XBsFapLrp+pJRRRXwJ9sFFFFAHL+NvDtj4u8H6p4X1Jd9vqFrLbyL6rIhU/zr+ObxBpE3h/X77Qbj/WWVxJA31jYr/Sv7PZmVIXdugBJr+O34uXMF78VvE15bf6uXVLplx6GViK++4Gm71I9ND4njKCtTl11/Q89ooor9CPhQooooAKKKKACiiigAooooA//9T6gooor+gD8PCiiigAooooAKKKKAHxTS28qXEBIeNg6kdQVORX9dH7OfxMsfi58FvD/jizlEj3NpGs+P4Z4xtkU/Rga/kUr9Lf+CeX7WVp8F/E8nwx8eXAi8O6zKGjnf7trcnjJPZH4B9Dg+tfMcVZZLEUOaC1jr8up9Hw1mKoVuWe0v6R/RXRUNvcQXcCXVq6yRyAMrKchgeQQR1BqavyY/TQooqG4uILSB7q6dY44wWZmOAoHJJJ6AUAeMftGfEyx+EXwX8QeObyURvbWkiwZ/inkG2NR9WIr+ReWaW4le4nJLyMXYnqSxya/Sv/AIKG/tZ2nxo8Tx/DHwHcCXw7o0paSdPu3VyMjIPdE5A9Tk+lfmjX6zwrlksPQ5prWX5dD8y4lzFV63LDaP8ATCiiivpz5wKKKKACiiigAooooAKKKKAP/9X6gooor+gD8PCiiigAooooAKKKkhhmuZltrZGkkc4VEBLEnsAOTQBHQQCMGv0D+Bf/AATm+N/xaWHWPFEY8MaTJhvMu1JndT/ch4P/AH1iv0ztP+CXf7OUHgt/D1yL2bUnX/kJGUiVW/2UH7vbnsQfrXgYzibCUZcjld+Wp7eE4exVaPMlZeeh+Xn7Nn7f3xV+A1vB4Y1kf8JD4eiG1bad8Swr/wBMpcE4H905Hpiv1S8Jf8FPP2ZdetFm125vNGlx8yXEDPg98GLdkV+ZHxk/4JsfHr4c3M154NhTxRpiklHtvluAvbdEeSf90mviPXfhz8QvDE7WviPQr+ykT7yzW8ikfmK46uVZdjX7SD18n+n/AADrp5lj8GvZzWi7r9T+hPxb/wAFPP2ZdBtGm0K5vNZlx8qW8DJk9smXbgV+V37Sf7f3xV+PFvP4X0Yf8I94elG1raB8yzL/ANNZMA4P90YHrmvj3Q/h18QfE062vh3Qr+9kf7qw28jE/kK+1vg//wAE2vj/APEa4hu/FkCeGNNYgvJdfNOV77YQc5/3iKKWVZdgv3k3r5v9P+AFTM8fjF7OC0fZfr/wT89wABgUV/RNd/8ABLH9n6XwWug2txfQ6oq/8hHzMsz+8eNm3PYYPvX5ofHL/gnd8dPhEs2raDAPE2kx5PnWanzlUd3h5b/vkkV24PiXCV5ckZWfnoceL4fxVGPM43XlqfBFFSSxS28rW9wjRyIcMrAgg+hB6VHXvHihRRRQAUUUUAFFFFABRRRQB//W+oKKKK/oA/DwooooAKKK2/DPh7VPF3iKw8K6InmXmozx28K+ryMFH86UpJK7Gk27I9N+BvwF+IP7QXjBPCPgO2LYwbi6cEQ26f3nb+Q6mv6Iv2cP2IfhH+z/AGUOo/Zl1nxAAPM1C5UMVbv5KHIQe/X3r1f9nX4E+Fv2ffhrZeCPD0S+eED3lxgb55yPnZj6Z4A7Cvd6/KM94kqYiTp0naH5+v8AkfpmTZBToRU6ivL8gooor5c+jCoJLW2mOZY1Y+4BqeigCCO1toTmKNVPsAKnoooAKCM8GiigD4t/aO/Yd+EXx+tJtTS2XRfEBBMeoWyhdzdvOQYDj1P3vev54Pjl8BviF+z94wfwh49tthOWt7lMmG4T+8jY/MHkV/XjXhH7RXwI8LftBfDW98E+IYl88oz2dxgb4JwPkZT6Z4I7ivqMi4kqYeSp1XeH5eh85nOQU68XOmrS/M/keorb8TeHdU8I+I7/AMK62nl3mnTyW8y+jxsVP4cViV+rxkmro/M2mnZhRRRTEFFFFABRRRQB/9f6gooor+gD8PCiiigAr62/YTsLbUv2sfB1tdqGQXEsmD6pC7L+RFfJNe6fszfEWw+E/wAePDPj7VeLSxuwJz/djlUxs3/AQ2a5MfCUqE4x3af5HVgZxjWhKWya/M/rkoqjpupWGs6fDqulzLPbXCCSKRDlWVhkEEVer8LaP2ZMKKKKQBRRRQAUUUUAFFFFABRRVLUtSsNH0+bVdUmW3trdDJJI5wqqoySSaaQNn8tf7dun22m/tY+Mba0UIhuIpMD1eFGP5k18kV7p+0z8RbH4sfHjxN4+0o5tb67Igb+9HEojRv8AgQXNeF1+6YCEo0IRlukvyPxnHTjKtOUdm3+YUUUV1nKFFFFABRRRQB//0PqCiiiv6APw8KKKKACiiigD6v8Agv8Atp/H34F6WugeE9TS602P/V2l8nnRx/7nIZR7A49q9/8A+Hq37SX/AD5aL/4Dy/8Ax2vzRorza2T4WpLnnTTZ6FLNcTCPLCbSP0u/4erftJf8+Wi/+A8v/wAdo/4erftJf8+Wi/8AgPL/APHa/NGisv7Bwf8Az7Rp/bWL/wCfjP0u/wCHq37SX/Plov8A4Dy//HaP+Hq37SX/AD5aL/4Dy/8Ax2vzRoo/sHB/8+0H9tYv/n4z9Lv+Hq37SX/Plov/AIDy/wDx2j/h6t+0l/z5aL/4Dy//AB2vzRoo/sHB/wDPtB/bWL/5+M/S7/h6t+0l/wA+Wi/+A8v/AMdo/wCHq37SX/Plov8A4Dy//Ha/NGij+wcH/wA+0H9tYv8A5+M/S7/h6t+0l/z5aL/4Dy//AB2vAPjR+2n8ffjppbaB4s1NLXTZP9ZaWKeTHJ/v8lmHsTj2r5QorWjk+Fpy54U0mZ1c1xM48s5toKKKK9I88KKKKACiiigAooooA//R+oKKKK/oA/DwooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9L6gooor+gD8PCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/0/qCiiiv6APw8KKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//Z'; + /* eslint-enable max-len */ + + delete popoverProps.children; + avatar = this.props.avatar ? this.props.avatar : avatar; + return _react.default.createElement(_popover.default, popoverProps, _react.default.createElement(_button.default, _extends({ + className: (0, _classnames.default)('slds-global-actions__avatar slds-global-actions__item-action', this.props.buttonClassName), + title: this.props.userName, + variant: "icon" + }, buttonAriaProps), typeof avatar === 'string' ? _react.default.createElement("span", { + className: "slds-avatar slds-avatar_circle slds-avatar_medium" + }, _react.default.createElement("img", { + alt: this.props.userName, + src: avatar, + title: "User avatar" + })) : avatar || null)); + } + }]); + + return GlobalHeaderProfile; +}(_react.default.Component); // ### Display Name + + +GlobalHeaderProfile.displayName = _constants.GLOBAL_HEADER_PROFILE; // ### Prop Types + +GlobalHeaderProfile.propTypes = { + /** + * Extra classnames to apply to the popover. + */ + className: _propTypes.default.string, + + /** + * An image URL or avatar node to display for the user profile. Defaults to a base64 encoded generic user avatar image string + */ + avatar: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]), + + /** + * CSS classes to be added to the `button` element. + */ + buttonClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the popover to the triggering button. If an id is not provided, it will be automatically generated. + */ + id: _propTypes.default.string, + + /** + * A `Popover` component. The props from this popover will be merged and override any default props. + */ + popover: _propTypes.default.node, + + /** + * The user name of the profile. Defaults to "User Name" + */ + userName: _propTypes.default.string +}; // ### Default Props + +GlobalHeaderProfile.defaultProps = { + userName: 'User Name' +}; +var _default = GlobalHeaderProfile; +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/search.js b/components/global-header/search.js new file mode 100644 index 0000000000..878a8311ec --- /dev/null +++ b/components/global-header/search.js @@ -0,0 +1,41 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// # Global Header Search Component +// ## Dependencies +// ### React +// ## Constants + +/** + * The GlobalHeaderSearch component is used for application wide search. The form element is implemented as a `Combobox`. + */ +var GlobalHeaderSearch = function GlobalHeaderSearch(props) { + return _react.default.createElement("div", { + className: "slds-global-header__item slds-global-header__item_search" + }, props.combobox); +}; + +GlobalHeaderSearch.displayName = _constants.GLOBAL_HEADER_SEARCH; +GlobalHeaderSearch.propTypes = { + /** + * A required `Combobox` component. The props from this combobox will be merged and override any default props. + */ + combobox: _propTypes.default.node.isRequired +}; +var _default = GlobalHeaderSearch; +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/setup.js b/components/global-header/setup.js new file mode 100644 index 0000000000..28914d22ac --- /dev/null +++ b/components/global-header/setup.js @@ -0,0 +1,112 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _button = _interopRequireDefault(require("../button")); + +var _menuDropdown = _interopRequireDefault(require("../menu-dropdown")); + +var _buttonTrigger = _interopRequireDefault(require("../menu-dropdown/button-trigger")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * **Assistive text for accessibility** + * * `triggerButton`: Assistive text for the GlobalHeaderSetup trigger button. The default is `Setup`. + */ + assistiveText: _propTypes.default.shape({ + triggerButton: _propTypes.default.string + }), + + /** + * A `Dropdown` component. The props from this dropdown will be merged and override any default props. This also allows custom content to be passed as children and rendered in the dropdown. + */ + dropdown: _propTypes.default.node +}; +/** + * A GlobalHeaderSetup component. + */ + +var GlobalHeaderSetup = +/*#__PURE__*/ +function (_React$Component) { + _inherits(GlobalHeaderSetup, _React$Component); + + function GlobalHeaderSetup() { + _classCallCheck(this, GlobalHeaderSetup); + + return _possibleConstructorReturn(this, _getPrototypeOf(GlobalHeaderSetup).apply(this, arguments)); + } + + _createClass(GlobalHeaderSetup, [{ + key: "render", + value: function render() { + var buttonAriaProps = { + 'aria-haspopup': true + }; + var dropdownProps = (0, _lodash.default)({ + align: 'right', + nubbinPosition: 'top right' + }, this.props.dropdown ? this.props.dropdown.props : {}); + var dropdownChildren = dropdownProps.children || null; + delete dropdownProps.children; + return _react.default.createElement(_menuDropdown.default, dropdownProps, _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, _extends({ + assistiveText: { + icon: this.props.assistiveText.triggerButton + }, + className: "slds-button_icon slds-global-actions__setup slds-global-actions__item-action", + iconCategory: "utility", + iconClassName: "slds-global-header__icon", + iconName: "setup", + iconSize: "small", + iconVariant: "container", + title: this.props.assistiveText.triggerButton, + variant: "icon" + }, buttonAriaProps))), dropdownChildren); + } + }]); + + return GlobalHeaderSetup; +}(_react.default.Component); + +GlobalHeaderSetup.displayName = _constants.GLOBAL_HEADER_SETUP; +GlobalHeaderSetup.defaultProps = { + assistiveText: { + triggerButton: 'Setup' + } +}; +GlobalHeaderSetup.propTypes = propTypes; +var _default = GlobalHeaderSetup; +exports.default = _default; \ No newline at end of file diff --git a/components/global-header/task.js b/components/global-header/task.js new file mode 100644 index 0000000000..86324cad94 --- /dev/null +++ b/components/global-header/task.js @@ -0,0 +1,111 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _button = _interopRequireDefault(require("../button")); + +var _menuDropdown = _interopRequireDefault(require("../menu-dropdown")); + +var _buttonTrigger = _interopRequireDefault(require("../menu-dropdown/button-trigger")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * **Assistive text for accessibility** + * * `triggerButton`: Assistive text for the GlobalHeaderTask trigger button. The default is `Global Actions`. + */ + assistiveText: _propTypes.default.shape({ + triggerButton: _propTypes.default.string + }), + + /** + * A `Dropdown` component. The props from this dropdown will be merged and override any default props. This also allows custom content to be passed as children and rendered in the dropdown. + */ + dropdown: _propTypes.default.node +}; +/** + * A GlobalHeaderTask component. + */ + +var GlobalHeaderTask = +/*#__PURE__*/ +function (_React$Component) { + _inherits(GlobalHeaderTask, _React$Component); + + function GlobalHeaderTask() { + _classCallCheck(this, GlobalHeaderTask); + + return _possibleConstructorReturn(this, _getPrototypeOf(GlobalHeaderTask).apply(this, arguments)); + } + + _createClass(GlobalHeaderTask, [{ + key: "render", + value: function render() { + var buttonAriaProps = { + 'aria-haspopup': true + }; + var dropdownProps = (0, _lodash.default)({ + align: 'right', + nubbinPosition: 'top right' + }, this.props.dropdown ? this.props.dropdown.props : {}); + var dropdownChildren = dropdownProps.children || null; + delete dropdownProps.children; + return _react.default.createElement(_menuDropdown.default, dropdownProps, _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, _extends({ + assistiveText: { + icon: this.props.assistiveText.triggerButton + }, + className: "slds-button_icon slds-global-actions__task slds-global-actions__item-action", + iconCategory: "utility", + iconName: "add", + iconSize: "small", + iconVariant: "container", + title: this.props.assistiveText.triggerButton, + variant: "icon" + }, buttonAriaProps))), dropdownChildren); + } + }]); + + return GlobalHeaderTask; +}(_react.default.Component); + +GlobalHeaderTask.displayName = _constants.GLOBAL_HEADER_TASK; +GlobalHeaderTask.defaultProps = { + assistiveText: { + triggerButton: 'Global Actions' + } +}; +GlobalHeaderTask.propTypes = propTypes; +var _default = GlobalHeaderTask; +exports.default = _default; \ No newline at end of file diff --git a/components/global-navigation-bar/__docs__/site-stories.js b/components/global-navigation-bar/__docs__/site-stories.js new file mode 100644 index 0000000000..9c6f7db9c1 --- /dev/null +++ b/components/global-navigation-bar/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/global-navigation-bar/__examples__/default.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/global-navigation-bar/__docs__/storybook-stories.js b/components/global-navigation-bar/__docs__/storybook-stories.js new file mode 100644 index 0000000000..9057062f18 --- /dev/null +++ b/components/global-navigation-bar/__docs__/storybook-stories.js @@ -0,0 +1,306 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _globalNavigationBar = require("../../../utilities/sample-data/global-navigation-bar"); + +var _globalNavigationBar2 = _interopRequireDefault(require("../../global-navigation-bar")); + +var _region = _interopRequireDefault(require("../../global-navigation-bar/region")); + +var _dropdown = _interopRequireDefault(require("../../global-navigation-bar/dropdown")); + +var _link = _interopRequireDefault(require("../../global-navigation-bar/link")); + +var _label = _interopRequireDefault(require("../../global-navigation-bar/label")); + +var _button = _interopRequireDefault(require("../../global-navigation-bar/button")); + +var _appLauncher = _interopRequireDefault(require("../../app-launcher")); + +var _section = _interopRequireDefault(require("../../app-launcher/section")); + +var _tile = _interopRequireDefault(require("../../app-launcher/tile")); + +var _default2 = _interopRequireDefault(require("../__examples__/default")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +// aliased to allow copy and paste from component tests +var buttonClicked = _addonActions.action; +var dropdownItemClicked = _addonActions.action; +var linkClicked = _addonActions.action; +var searchClicked = _addonActions.action; +var dropdownCollection = [{ + label: 'Main action', + value: '0', + iconCategory: 'utility', + iconName: 'table', + href: 'http://www.google.com' +}, { + label: 'Menu Header', + type: 'header', + divider: 'top' +}, { + label: 'Menu Item One', + value: '1', + iconCategory: 'utility', + iconName: 'kanban', + href: 'http://www.google.com' +}, { + label: 'Menu Item Two', + value: '2', + iconCategory: 'utility', + iconName: 'kanban', + href: 'http://www.google.com' +}, { + label: 'Menu Item Three', + value: '3', + iconCategory: 'utility', + iconName: 'side_list', + href: 'http://www.google.com' +}, { + label: 'Menu Item Four', + value: '4', + iconCategory: 'utility', + iconName: 'side_list', + href: 'http://www.google.com' +}, { + type: 'divider' +}, { + label: 'Menu Item Five', + value: '5', + iconCategory: 'utility', + iconName: 'side_list', + href: 'http://www.google.com' +}]; +/* eslint-disable react/display-name */ + +var getGlobalNavigationBar = function getGlobalNavigationBar(props, primaryRegionProps) { + return _react.default.createElement(_globalNavigationBar2.default, props, _react.default.createElement(_region.default, _extends({ + region: "primary" + }, primaryRegionProps), _react.default.createElement(_appLauncher.default, { + onSearch: searchClicked('App Launcher searched'), + assistiveText: { + trigger: 'Open App Launcher' + }, + id: "app-launcher-trigger", + triggerName: "App Name" + }, _react.default.createElement(_section.default, { + title: "All Items" + }, _react.default.createElement(_tile.default, { + title: "Marketing Cloud", + iconText: "MC", + description: "Send emails, track emails, read emails! Emails!", + onClick: (0, _addonActions.action)('Tile clicked!') + })))), _react.default.createElement(_region.default, { + region: "secondary", + navigation: true + }, _react.default.createElement(_link.default, { + href: "https://www.lightningdesignsystem.com/", + label: "Home", + id: "home-link", + onClick: linkClicked('Home link clicked. Actual href should be ignored'), + onKeyDown: function onKeyDown(e) { + console.log(e.target); + } + }), _react.default.createElement(_dropdown.default, { + assistiveText: { + icon: 'Open Menu Item 1' + }, + id: "primaryDropdown", + label: "Menu Item", + openOn: props.openOn || undefined, + onSelect: dropdownItemClicked('Dropdown Menu Item clicked'), + options: dropdownCollection + }), _react.default.createElement(_link.default // will actually go to website + , { + active: true, + href: "https://www.lightningdesignsystem.com/", + label: "Menu Item" + })), _react.default.createElement(_region.default, { + region: "tertiary" + }, _react.default.createElement(_button.default, { + label: "Button", + onClick: buttonClicked('Button clicked') + }), _react.default.createElement(_link.default, { + label: "Actions", + onClick: buttonClicked('Link clicked') + }), _react.default.createElement(_label.default, { + dividerPosition: "left", + label: "Vandelay Enterprises" + }))); +}; + +var getGlobalNavigationBarCustomCloud = function getGlobalNavigationBarCustomCloud(props, primaryRegionProps) { + return _react.default.createElement(_globalNavigationBar2.default, props, _react.default.createElement(_region.default, _extends({ + region: "primary" + }, primaryRegionProps), _react.default.createElement(_appLauncher.default, _extends({ + onSearch: searchClicked('App Launcher searched') + }, primaryRegionProps.appLauncher), _react.default.createElement(_section.default, { + title: "All Items" + }, _react.default.createElement(_tile.default, { + title: "Marketing Cloud", + iconText: "MC", + description: "Send emails, track emails, read emails! Emails!", + onClick: (0, _addonActions.action)('Tile clicked!') + })))), _react.default.createElement(_region.default, { + region: "secondary", + navigation: true + }, _react.default.createElement(_link.default, { + label: "Overview", + id: "overview-link", + onClick: linkClicked('Overview link clicked') + }), _react.default.createElement(_dropdown.default, { + id: "contentDropdown", + label: "Content", + onSelect: dropdownItemClicked('Content Menu Item clicked'), + options: dropdownCollection + }), _react.default.createElement(_dropdown.default, { + id: "subscribersDropdown", + label: "Subscribers", + onSelect: dropdownItemClicked('Subscribers Menu Item clicked'), + options: dropdownCollection + }), _react.default.createElement(_dropdown.default, { + id: "interactionDropdown", + label: "Interaction", + onSelect: dropdownItemClicked('Interaction Menu Item clicked'), + options: dropdownCollection + }), _react.default.createElement(_link.default, { + label: "A/B Testing", + onClick: linkClicked('A/B Testing Link clicked') + }), _react.default.createElement(_dropdown.default, { + id: "trackingDropdown", + label: "Tracking", + onSelect: dropdownItemClicked('Tracking Menu Item clicked'), + options: dropdownCollection + }), _react.default.createElement(_link.default, { + label: "Admin", + onClick: linkClicked('Admin Link clicked') + }), _react.default.createElement(_link.default, { + label: "Audience Builder", + onClick: linkClicked('Audience Builder Link clicked') + })), _react.default.createElement(_region.default, { + region: "tertiary" + }, _react.default.createElement(_link.default, { + label: "Actions", + onClick: linkClicked('Link clicked') + }))); +}; + +var getGlobalNavigationBarCustomCloudOverviewActive = function getGlobalNavigationBarCustomCloudOverviewActive(props, primaryRegionProps) { + return _react.default.createElement(_globalNavigationBar2.default, props, _react.default.createElement(_region.default, { + region: "primary" + }, _react.default.createElement(_appLauncher.default, _extends({ + onSearch: searchClicked('App Launcher searched') + }, primaryRegionProps.appLauncher), _react.default.createElement(_section.default, { + title: "All Items" + }, _react.default.createElement(_tile.default, { + title: "Marketing Cloud", + iconText: "MC", + description: "Send emails, track emails, read emails! Emails!", + onClick: (0, _addonActions.action)('Tile clicked!') + })))), _react.default.createElement(_region.default, { + region: "secondary", + navigation: true + }, _react.default.createElement(_link.default, { + label: "Overview", + id: "overview-link", + active: true, + activeBackgroundColor: "#ffffff", + onClick: linkClicked('Overview link clicked') + }), _react.default.createElement(_dropdown.default, { + id: "contentDropdown", + label: "Content", + onSelect: dropdownItemClicked('Content Menu Item clicked'), + options: dropdownCollection + }), _react.default.createElement(_dropdown.default, { + id: "subscribersDropdown", + label: "Subscribers", + onSelect: dropdownItemClicked('Subscribers Menu Item clicked'), + options: dropdownCollection + }), _react.default.createElement(_dropdown.default, { + active: true, + activeBackgroundColor: "#ffffff", + id: "interactionDropdown", + label: "Interaction", + onSelect: dropdownItemClicked('Interaction Menu Item clicked'), + options: dropdownCollection + }), _react.default.createElement(_link.default, { + label: "A/B Testing", + onClick: linkClicked('A/B Testing Link clicked') + }), _react.default.createElement(_dropdown.default, { + id: "trackingDropdown", + label: "Tracking", + onSelect: dropdownItemClicked('Tracking Menu Item clicked'), + options: dropdownCollection + }), _react.default.createElement(_link.default, { + label: "Admin", + onClick: linkClicked('Admin Link clicked') + }), _react.default.createElement(_link.default, { + label: "Audience Builder", + onClick: linkClicked('Audience Builder Link clicked') + })), _react.default.createElement(_region.default, { + region: "tertiary" + }, _react.default.createElement(_link.default, { + label: "Actions", + onClick: linkClicked('Link clicked') + }))); +}; + +var getGlobalNavigationBarNoNav = function getGlobalNavigationBarNoNav(props, primaryRegionProps) { + return _react.default.createElement(_globalNavigationBar2.default, props, _react.default.createElement(_region.default, _extends({ + region: "primary" + }, primaryRegionProps), _react.default.createElement(_appLauncher.default, { + onSearch: searchClicked('App Launcher searched'), + assistiveText: { + trigger: 'Open App Launcher' + }, + id: "app-launcher-trigger", + triggerName: "App Name" + }, _react.default.createElement(_section.default, { + title: "All Items" + }, _react.default.createElement(_tile.default, { + title: "Marketing Cloud", + iconText: "MC", + description: "Send emails, track emails, read emails! Emails!", + onClick: (0, _addonActions.action)('Tile clicked!') + }))))); +}; + +(0, _react2.storiesOf)(_constants.GLOBAL_NAVIGATION_BAR, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base', function () { + return getGlobalNavigationBar(_globalNavigationBar.propSets.base.props, _globalNavigationBar.propSets.base.primaryRegionProps); +}).add('Custom Cloud', function () { + return getGlobalNavigationBarCustomCloud(_globalNavigationBar.propSets.customCloud.props, _globalNavigationBar.propSets.customCloud.primaryRegionProps); +}).add('Custom Cloud (Multiple active and white)', function () { + return getGlobalNavigationBarCustomCloudOverviewActive(_globalNavigationBar.propSets.customCloud.props, _globalNavigationBar.propSets.customCloud.primaryRegionProps); +}).add('No Secondary Navigation', function () { + return getGlobalNavigationBarNoNav(_globalNavigationBar.propSets.noNav.props, _globalNavigationBar.propSets.noNav.primaryRegionProps); +}).add('Hybrid Dropdown', function () { + return getGlobalNavigationBar(_globalNavigationBar.propSets.hybrid.props, _globalNavigationBar.propSets.base.primaryRegionProps); +}).add('Doc site Default', function () { + return _react.default.createElement(_default2.default, null); +}); +var _default = getGlobalNavigationBar; +exports.default = _default; \ No newline at end of file diff --git a/components/global-navigation-bar/__examples__/default.js b/components/global-navigation-bar/__examples__/default.js new file mode 100644 index 0000000000..e3de557780 --- /dev/null +++ b/components/global-navigation-bar/__examples__/default.js @@ -0,0 +1,156 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _globalNavigationBar = _interopRequireDefault(require("../../../../components/global-navigation-bar")); + +var _region = _interopRequireDefault(require("../../../../components/global-navigation-bar/region")); + +var _dropdown = _interopRequireDefault(require("../../../../components/global-navigation-bar/dropdown")); + +var _link = _interopRequireDefault(require("../../../../components/global-navigation-bar/link")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _appLauncher = _interopRequireDefault(require("../../../../components/app-launcher")); + +var _section = _interopRequireDefault(require("../../../../components/app-launcher/section")); + +var _tile = _interopRequireDefault(require("../../../../components/app-launcher/tile")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var dropdownCollection = [{ + label: 'Menu Item One', + value: '1', + iconCategory: 'utility', + iconName: 'table', + href: 'http://www.google.com' + }, { + label: 'Menu Item Two', + value: '2', + iconCategory: 'utility', + iconName: 'kanban', + href: 'http://www.google.com' + }, { + label: 'Menu Item Three', + value: '3', + iconCategory: 'utility', + iconName: 'side_list', + href: 'http://www.google.com' + }]; + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_globalNavigationBar.default, null, _react.default.createElement(_region.default, { + region: "primary" + }, _react.default.createElement(_appLauncher.default, { + triggerName: "App Name", + onSearch: function onSearch() { + console.log('Search term:', event.target.value); + }, + modalHeaderButton: _react.default.createElement(_button.default, { + label: "App Exchange" + }) + }, _react.default.createElement(_section.default, { + title: "Tile Section" + }, _react.default.createElement(_tile.default, { + title: "Marketing Cloud", + iconText: "MC", + description: "Send emails, track emails, read emails! Emails!" + }), _react.default.createElement(_tile.default, { + title: "Call Center", + description: "The key to call center and contact center is not to use too many words!", + descriptionHeading: "Call Center", + iconText: "CC" + })), _react.default.createElement(_section.default, { + title: "Small Tile Section" + }, _react.default.createElement(_tile.default, { + title: "Journey Builder", + iconText: "JB", + size: "small" + }), _react.default.createElement(_tile.default, { + title: "Sales Cloud", + iconNode: _react.default.createElement(_icon.default, { + name: "campaign", + category: "standard", + size: "large" + }), + size: "small" + })))), _react.default.createElement(_region.default, { + region: "secondary", + navigation: true + }, _react.default.createElement(_link.default, { + href: "javascript:void(0);", + label: "Home", + id: "home-link" + }), _react.default.createElement(_dropdown.default, { + id: "primaryDropdown", + assistiveText: { + icon: 'Context Menu Item 1' + }, + label: "Context Menu Item", + options: dropdownCollection + }), _react.default.createElement(_link.default, { + href: "javascript:void(0);", + label: "Context Menu Item 2", + active: true + })), _react.default.createElement(_region.default, { + region: "tertiary" + }, _react.default.createElement(_link.default, { + href: "javascript:void(0);", + label: "Actions" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'GlobalNavigationBarExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/global-navigation-bar/button.js b/components/global-navigation-bar/button.js new file mode 100644 index 0000000000..ec9a61ca87 --- /dev/null +++ b/components/global-navigation-bar/button.js @@ -0,0 +1,66 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _button = _interopRequireDefault(require("../button")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +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; } + +/** + * A helper component that renders a Button as an item in the Global Navigation Bar. All props are passed onto `Button` except `active` and `dividerPosition`. + */ +var GlobalNavigationButton = function GlobalNavigationButton(_ref) { + var active = _ref.active, + dividerPosition = _ref.dividerPosition, + props = _objectWithoutProperties(_ref, ["active", "dividerPosition"]); + + return _react.default.createElement("li", { + className: (0, _classnames.default)('slds-context-bar__item', _defineProperty({ + 'slds-is-active': active + }, "slds-context-bar__item_divider-".concat(dividerPosition), dividerPosition)) + }, _react.default.createElement(_button.default, props)); +}; + +GlobalNavigationButton.displayName = _constants.GLOBAL_NAVIGATION_BAR_BUTTON; // ### Prop Types + +GlobalNavigationButton.propTypes = { + /** + * Whether the item is active or not. + */ + active: _propTypes.default.bool, + + /** + * Determines position of separating bar. + */ + dividerPosition: _propTypes.default.oneOf(['left', 'right']) +}; // ### Default Props + +GlobalNavigationButton.defaultProps = { + className: 'slds-context-bar__label-action slds-text-body_regular', + // This is a hack since buttons are not supported by Global Navigation + // Bar and have different `font-size` and `line-height` than links or + // dropdowns. + style: { + lineHeight: 'inherit' + }, + variant: 'base' +}; +var _default = GlobalNavigationButton; +exports.default = _default; \ No newline at end of file diff --git a/components/global-navigation-bar/check-props.js b/components/global-navigation-bar/check-props.js new file mode 100644 index 0000000000..39f009af21 --- /dev/null +++ b/components/global-navigation-bar/check-props.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + + if (typeof props.assistiveText === 'string') { + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', "`assistiveText` as a string has been deprecated and is now an object to allow for multiple uses in the component. Please use `assistiveText.icon` instead. ".concat(createDocUrl('assistiveText'))); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/global-navigation-bar/docs.json b/components/global-navigation-bar/docs.json new file mode 100644 index 0000000000..382bcbd551 --- /dev/null +++ b/components/global-navigation-bar/docs.json @@ -0,0 +1,28 @@ +{ + "component": "global-navigation-bar", + "status": "prototype", + "display-name": "Global Navigation Bar", + "last-accessibility-review": { + "date-iso-8601": "2017/05/02", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/global-navigation", + "dependencies": [ + { + "component": "button" + }, + { + "component": "dropdown" + }, + { + "component": "label" + }, + { + "component": "link" + }, + { + "component": "region" + } + ], + "url-slug": "global-navigation-bar" +} \ No newline at end of file diff --git a/components/global-navigation-bar/dropdown-trigger.js b/components/global-navigation-bar/dropdown-trigger.js new file mode 100644 index 0000000000..01eedb6c20 --- /dev/null +++ b/components/global-navigation-bar/dropdown-trigger.js @@ -0,0 +1,246 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _salesforceSkinCommon = _interopRequireDefault(require("../../utilities/design-tokens/dist/salesforce-skin.common.js")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _button = _interopRequireDefault(require("../button")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * The Dropdown Button Trigger renders the default trigger button for the dropdown menu. If this component has children, it does not render itself to the DOM. Instead, it renders its child element, `Button`, and all that child's properties. This component may be used as a template to create custom triggers that do not use `Button`. + */ +var GlobalNavigationDropdownTrigger = +/*#__PURE__*/ +function (_React$Component) { + _inherits(GlobalNavigationDropdownTrigger, _React$Component); + + function GlobalNavigationDropdownTrigger() { + _classCallCheck(this, GlobalNavigationDropdownTrigger); + + return _possibleConstructorReturn(this, _getPrototypeOf(GlobalNavigationDropdownTrigger).apply(this, arguments)); + } + + _createClass(GlobalNavigationDropdownTrigger, [{ + key: "componentWillMount", + // ### Display Name + // Always use the canonical component name (set in the core) as the React + // display name. + // ### Prop Types + value: function componentWillMount() { + (0, _checkProps.default)(_constants.MENU_DROPDOWN_TRIGGER, this.props, _docs.default); + } // ### Render + + }, { + key: "render", + value: function render() { + var _this$props = this.props, + active = _this$props.active, + activeBackgroundColor = _this$props.activeBackgroundColor, + className = _this$props.className, + dividerPosition = _this$props.dividerPosition, + id = _this$props.id, + isOpen = _this$props.isOpen, + label = _this$props.label, + menu = _this$props.menu, + onBlur = _this$props.onBlur, + onClick = _this$props.onClick, + onFocus = _this$props.onFocus, + onKeyDown = _this$props.onKeyDown, + onMouseDown = _this$props.onMouseDown, + onMouseEnter = _this$props.onMouseEnter, + onMouseLeave = _this$props.onMouseLeave, + triggerRef = _this$props.triggerRef, + rest = _objectWithoutProperties(_this$props, ["active", "activeBackgroundColor", "className", "dividerPosition", "id", "isOpen", "label", "menu", "onBlur", "onClick", "onFocus", "onKeyDown", "onMouseDown", "onMouseEnter", "onMouseLeave", "triggerRef"]); + + var listItemstyle = {}; // Uses design token to get correct color + + var hoverBackgroundColor = _salesforceSkinCommon.default.brandPrimaryTransparent10; + + if (active) { + listItemstyle.backgroundColor = activeBackgroundColor; + listItemstyle.borderBottomColor = activeBackgroundColor; + } // Per SLDS pattern, set trigger style like hover style, so that hover visuals and menu being open and closed are in same state + + + if (isOpen) { + listItemstyle.backgroundColor = hoverBackgroundColor; + } + + return ( + /* eslint-disable jsx-a11y/no-static-element-interactions */ + _react.default.createElement("li", { + "aria-haspopup": "true", + className: (0, _classnames.default)('slds-context-bar__item slds-context-bar__dropdown-trigger slds-dropdown-trigger slds-dropdown-trigger_click', _defineProperty({ + 'slds-is-open': isOpen, + 'slds-is-active': active + }, "slds-context-bar__item_divider-".concat(dividerPosition), dividerPosition), className), + id: id, + onBlur: onBlur, + onClick: onClick, + onFocus: onFocus, + onKeyDown: onKeyDown, + onMouseDown: onMouseDown, + onMouseEnter: onMouseEnter, + onMouseLeave: onMouseLeave, + ref: triggerRef, + style: listItemstyle + }, _react.default.createElement("a", { + className: "slds-context-bar__label-action" + }, label), _react.default.createElement("div", { + className: "slds-context-bar__icon-action slds-p-left_none" + }, _react.default.createElement(_button.default, _extends({ + assistiveText: this.props.assistiveText + }, rest, { + className: "slds-context-bar__button slds-context-bar-action__trigger", + "aria-haspopup": "true", + iconCategory: "utility", + iconName: "chevrondown", + iconVariant: "bare", + iconSize: "x-small", + variant: "icon" + }))), menu) + ); + } + }]); + + return GlobalNavigationDropdownTrigger; +}(_react.default.Component); + +_defineProperty(GlobalNavigationDropdownTrigger, "displayName", _constants.MENU_DROPDOWN_TRIGGER); + +_defineProperty(GlobalNavigationDropdownTrigger, "propTypes", { + /** + * Whether the item is active or not. + */ + active: _propTypes.default.bool, + + /** + * Allows alignment of active item with active application background color. + */ + activeBackgroundColor: _propTypes.default.string, + + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `icon`: Text that is visually hidden but read aloud by screenreaders to tell the user what the icon means. If the button has an icon and a visible label, you can omit the assistiveText.icon prop and use the label prop. + */ + assistiveText: _propTypes.default.shape({ + icon: _propTypes.default.string + }), + + /** + * CSS classes to be added to the 'li'. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Determines position of separating bar. + */ + dividerPosition: _propTypes.default.oneOf(['left', 'right']), + + /** + * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the dropdown to the triggering button. + */ + id: _propTypes.default.string, + + /** + * Allows the dropdown menu to style itself accordingly when open since CSS hover rules cannot take effect if the menu is not inline. + */ + isOpen: _propTypes.default.bool, + + /** + * Visible label on the dropdown menu trigger button. + */ + label: _propTypes.default.string, + + /** + * The dropdown menu. + */ + menu: _propTypes.default.node, + + /** + * Is only called when `openOn` is set to `hover` and when the triggering li loses focus. + */ + onBlur: _propTypes.default.func, + + /** + * This prop is passed onto the triggering `li`. Triggered when the trigger li is clicked. + */ + onClick: _propTypes.default.func, + + /** + * Is only called when `openOn` is set to `hover` and when the triggering li gains focus. + */ + onFocus: _propTypes.default.func, + + /** + * Called when a key pressed. + */ + onKeyDown: _propTypes.default.func, + + /** + * Called when mouse clicks down on the trigger `li`. + */ + onMouseDown: _propTypes.default.func, + + /** + * Called when mouse hovers over the trigger `li`. + */ + onMouseEnter: _propTypes.default.func, + + /** + * Called when mouse leaves trigger `li` or the menu. + */ + onMouseLeave: _propTypes.default.func, + + /** + * The ref of the actual triggering button. + */ + triggerRef: _propTypes.default.func +}); + +var _default = GlobalNavigationDropdownTrigger; +exports.default = _default; \ No newline at end of file diff --git a/components/global-navigation-bar/dropdown.js b/components/global-navigation-bar/dropdown.js new file mode 100644 index 0000000000..5c79c8922c --- /dev/null +++ b/components/global-navigation-bar/dropdown.js @@ -0,0 +1,133 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _menuDropdown = _interopRequireDefault(require("../menu-dropdown")); + +var _dropdownTrigger = _interopRequireDefault(require("./dropdown-trigger")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +/** + * This component is an implementation of `MenuDropdown` with a custom trigger. All the properties listed below are provided to the `MenuDropdown` component. Any additional properties are provided to the Custom Trigger (that is the `Button` or `li` tag). + */ +var GlobalNavigationBarDropdown = function GlobalNavigationBarDropdown(props) { + (0, _checkProps.default)(_constants.GLOBAL_NAVIGATION_BAR_DROPDOWN, props, _docs.default); // Separate props we care about in order to pass others along passively to the dropdown component + + var active = props.active, + activeBackgroundColor = props.activeBackgroundColor, + assistiveText = props.assistiveText, + dividerPosition = props.dividerPosition, + rest = _objectWithoutProperties(props, ["active", "activeBackgroundColor", "assistiveText", "dividerPosition"]); + + return _react.default.createElement(_menuDropdown.default, _extends({ + align: "right", + hasStaticAlignment: true // only need if using hybrid or hover + , + hoverCloseDelay: 400, + length: props.length, + menuPosition: "relative" + }, rest), _react.default.createElement(_dropdownTrigger.default, { + active: active, + assistiveText: assistiveText, + activeBackgroundColor: activeBackgroundColor, + dividerPosition: dividerPosition + })); +}; // ### Display Name +// Always use the canonical component name (set in the core) as the React +// display name. + + +GlobalNavigationBarDropdown.displayName = _constants.GLOBAL_NAVIGATION_BAR_DROPDOWN; // ### Prop Types + +GlobalNavigationBarDropdown.propTypes = { + /** + * Whether the item is active or not. + */ + active: _propTypes.default.bool, + + /** + * Allows alignment of active item with active application background color. + */ + activeBackgroundColor: _propTypes.default.string, + + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `icon`: Text that is visually hidden but read aloud by screenreaders to tell the user what the icon means. If the button has an icon and a visible label, you can omit the assistiveText.icon prop and use the label prop. + */ + assistiveText: _propTypes.default.shape({ + icon: _propTypes.default.string + }), + + /** + * Aligns the right or left side of the menu with the respective side of the trigger. This is not intended for use with `nubbinPosition`. + */ + align: _propTypes.default.oneOf(['left', 'right']), + + /** + * Extra classnames to apply to the dropdown menu. + */ + className: _propTypes.default.string, + + /** + * Determines position of separating bar. + */ + dividerPosition: _propTypes.default.oneOf(['left', 'right']), + + /** + * CSS classes to be added to `li` element. + */ + buttonClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the dropdown to the triggering button. + */ + id: _propTypes.default.string, + + /** + * Provided to List to indicate number of items visible in the List. Pass `null` to display all items, or a string containing one of the numeric option values listed under [Dropdown Height](https://www.lightningdesignsystem.com/components/menus/#flavor-dropdown-height) at the right (eg. '5'). + */ + length: _propTypes.default.oneOf([null, '5', '7', '10']), + + /** + * Offset adds pixels to the absolutely positioned dropdown menu in the format: ([vertical]px [horizontal]px). + */ + offset: _propTypes.default.string, + + /** + * Triggered when an item in the menu is clicked. + */ + onSelect: _propTypes.default.func, + + /** + * An array of menu item. + */ + options: _propTypes.default.array.isRequired +}; // ### Default Props + +GlobalNavigationBarDropdown.defaultProps = { + align: 'right', + length: null +}; +var _default = GlobalNavigationBarDropdown; +exports.default = _default; \ No newline at end of file diff --git a/components/global-navigation-bar/index.js b/components/global-navigation-bar/index.js new file mode 100644 index 0000000000..8cbebdaa38 --- /dev/null +++ b/components/global-navigation-bar/index.js @@ -0,0 +1,89 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var auditChildren = function auditChildren(children) { + var primaryRegion; // there can be multiple secondary navigation regions + + var secondaryRegions = []; + var tertiaryRegion; + + _react.default.Children.forEach(children, function (child) { + if (child && child.type.displayName === _constants.GLOBAL_NAVIGATION_BAR_REGION) { + if (child.props.region === 'primary') { + primaryRegion = child; + } else if (child.props.region === 'secondary') { + secondaryRegions.push(child); + } else if (child.props.region === 'tertiary') { + tertiaryRegion = child; + } + } + }); + + if (primaryRegion && secondaryRegions.length > 0) { + var dividerPosition = primaryRegion.props.dividerPosition === undefined ? 'right' : primaryRegion.props.dividerPosition; + primaryRegion = _react.default.cloneElement(primaryRegion, { + dividerPosition: dividerPosition, + key: 'primary-region' + }); + } + + return [primaryRegion].concat(secondaryRegions, [tertiaryRegion]); +}; +/** + * Global Navigation Bar represents a list of links that either take the user to another page or parts of the page the user is in. + */ + + +var GlobalNavigationBar = function GlobalNavigationBar(props) { + var _classNames; + + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-context-bar', (_classNames = {}, _defineProperty(_classNames, "slds-context-bar_theme-".concat(props.cloud), props.cloud), _defineProperty(_classNames, "slds-context-bar_theme-".concat(props.theme), props.theme), _classNames), props.className) + }, auditChildren(props.children)); +}; // ### Prop Types + + +GlobalNavigationBar.propTypes = { + /** + * The items to be displayed in the Global Navigation Bar. + */ + children: _propTypes.default.node, + + /** + * CSS class names to be added to the container element. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Typically the cloud name (e.g.- "sales" or "marketing"). This primarily changes the background color. + */ + cloud: _propTypes.default.string, + + /** + * Transforms text and interactions (such as hover) to be more visually accessible. + */ + theme: _propTypes.default.oneOf(['light', 'dark']) +}; +GlobalNavigationBar.defaultProps = { + cloud: 'default', + theme: 'dark' +}; +GlobalNavigationBar.displayName = _constants.GLOBAL_NAVIGATION_BAR; +var _default = GlobalNavigationBar; +exports.default = _default; \ No newline at end of file diff --git a/components/global-navigation-bar/label.js b/components/global-navigation-bar/label.js new file mode 100644 index 0000000000..5ef0daeaba --- /dev/null +++ b/components/global-navigation-bar/label.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _salesforceSkinCommon = _interopRequireDefault(require("../../utilities/design-tokens/dist/salesforce-skin.common.js")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Wraps text in the proper markup and removes link styling to support use in the GlobalNavigationBar. + */ +var GlobalNavigationBarLabel = function GlobalNavigationBarLabel(props) { + // Separate props we care about in order to pass others along passively to the `span` tag + var className = props.className, + dividerPosition = props.dividerPosition, + id = props.id, + label = props.label; + return _react.default.createElement("li", { + className: "slds-context-bar__item slds-no-hover" + }, _react.default.createElement("span", { + id: id // inline style override + , + style: { + color: _salesforceSkinCommon.default.colorTextLinkDisabled + }, + className: (0, _classnames.default)('slds-context-bar__label-action', _defineProperty({}, "slds-context-bar__item_divider-".concat(dividerPosition), dividerPosition), className) + }, _react.default.createElement("span", { + className: "slds-truncate" + }, label))); +}; + +GlobalNavigationBarLabel.displayName = _constants.GLOBAL_NAVIGATION_BAR_LABEL; // ### Prop Types + +GlobalNavigationBarLabel.propTypes = { + /** + * Class names to be added to the `span` element + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Determines position of separating bar. + */ + dividerPosition: _propTypes.default.oneOf(['left', 'right']), + + /** + * Id string applied to first inside of
  • + */ + id: _propTypes.default.string, + + /** + * Text to show + */ + label: _propTypes.default.string +}; +var _default = GlobalNavigationBarLabel; +exports.default = _default; \ No newline at end of file diff --git a/components/global-navigation-bar/link.js b/components/global-navigation-bar/link.js new file mode 100644 index 0000000000..d1aa1ae63c --- /dev/null +++ b/components/global-navigation-bar/link.js @@ -0,0 +1,162 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _lodash = _interopRequireDefault(require("lodash.isfunction")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function handleClick(event, href, onClick) { + event.preventDefault(); + onClick(event, { + href: href + }); +} +/** + * Wraps a link in the proper markup to support use in the GlobalNavigationBar. + */ + + +var GlobalNavigationBarLink = function GlobalNavigationBarLink(props) { + // Separate props we care about in order to pass others along passively to the `a` tag + var active = props.active, + activeBackgroundColor = props.activeBackgroundColor, + className = props.className, + dividerPosition = props.dividerPosition, + href = props.href, + id = props.id, + label = props.label, + onBlur = props.onBlur, + onClick = props.onClick, + onFocus = props.onFocus, + onKeyDown = props.onKeyDown, + onKeyPress = props.onKeyPress, + tabIndex = props.tabIndex; + var listItemstyle = active ? { + backgroundColor: activeBackgroundColor, + borderBottomColor: activeBackgroundColor + } : null; + return _react.default.createElement("li", { + className: (0, _classnames.default)('slds-context-bar__item', _defineProperty({ + 'slds-is-active': active + }, "slds-context-bar__item_divider-".concat(dividerPosition), dividerPosition)), + id: id, + style: listItemstyle + }, _react.default.createElement("a", { + href: href, + className: (0, _classnames.default)('slds-context-bar__label-action', className), + onBlur: onBlur, + onClick: (0, _lodash.default)(onClick) ? function (event) { + return handleClick(event, href, onClick); + } : null, + onFocus: onFocus, + onKeyDown: onKeyDown, + onKeyPress: onKeyPress, + tabIndex: tabIndex + }, _react.default.createElement("span", { + className: "slds-truncate" + }, label))); +}; + +GlobalNavigationBarLink.displayName = _constants.GLOBAL_NAVIGATION_BAR_LINK; // ### Prop Types + +GlobalNavigationBarLink.propTypes = { + /** + * Whether the item is active or not. + */ + active: _propTypes.default.bool, + + /** + * Allows alignment of active item with active application background color. If application background is dark, text color may need to be `#fff`. This can be done with the style prop. + */ + activeBackgroundColor: _propTypes.default.string, + + /** + * Class names to be added to the anchor element + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Determines position of separating bar. + */ + dividerPosition: _propTypes.default.oneOf(['left', 'right']), + + /** + * The `href` attribute of the link. Please pass in bookmarkable URLs from your routing library. Use `GlobalNavigationBarButton` if a "real URL" is not desired. If the `onClick` callback is specified this URL will still be prevented from changing the browser's location. + */ + href: _propTypes.default.string, + + /** + * The `id` attribute is applied to the `li` tag. _This was recently changed from being on the anchor tag._ + */ + id: _propTypes.default.string, + + /** + * Text to show for link item. + */ + label: _propTypes.default.string, + + /** + * Triggered when focus is removed. + */ + onBlur: _propTypes.default.func, + + /** + * `function (event, href)` - fires when the link is clicked. If set, the browser location change to the `href` specified will be ignored, but the `href` will be included in an additional parameter passed to the callback. + */ + onClick: _propTypes.default.func, + + /** + * Triggered when component is focused. + */ + onFocus: _propTypes.default.func, + + /** + * Triggered when a key is pressed down + */ + onKeyDown: _propTypes.default.func, + + /** + * Triggered when a key is pressed and released + */ + onKeyPress: _propTypes.default.func, + + /** + * Triggered when a key is released + */ + onKeyUp: _propTypes.default.func, + + /** + * Triggered when a mouse arrow hovers + */ + onMouseEnter: _propTypes.default.func, + + /** + * Triggered when a mouse arrow no longer hovers + */ + onMouseLeave: _propTypes.default.func, + + /** + * Write "-1" if you don't want the user to tab to the button. + */ + tabIndex: _propTypes.default.string +}; +GlobalNavigationBarLink.defaultProps = { + href: 'javascript:void(0);' // eslint-disable-line no-script-url + +}; +var _default = GlobalNavigationBarLink; +exports.default = _default; \ No newline at end of file diff --git a/components/global-navigation-bar/region.js b/components/global-navigation-bar/region.js new file mode 100644 index 0000000000..15ca37588a --- /dev/null +++ b/components/global-navigation-bar/region.js @@ -0,0 +1,156 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.regions = exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// List regions for export +var regions = ['primary', 'secondary', 'tertiary']; +/* eslint-disable react/display-name */ + +exports.regions = regions; + +var renderPrimary = function renderPrimary(dividerClass, className, children) { + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-context-bar__primary', dividerClass, className) + }, children); +}; + +var renderSecondary = function renderSecondary(dividerClass, className, children, navigation) { + var region; + + if (navigation) { + region = _react.default.createElement("nav", { + className: (0, _classnames.default)('slds-context-bar__secondary', dividerClass, className), + role: "navigation" + }, _react.default.createElement("ul", { + className: "slds-grid" + }, children)); + } else { + region = _react.default.createElement("div", { + className: (0, _classnames.default)('slds-context-bar__secondary', dividerClass, className) + }, _react.default.createElement("ul", { + className: "slds-grid" + }, children)); + } + + return region; +}; + +var renderTertiary = function renderTertiary(dividerClass, className, children) { + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-context-bar__tertiary', 'slds-col_bump-left', dividerClass, className) + }, _react.default.createElement("ul", { + className: "slds-grid" + }, children)); +}; +/* eslint-enable react/display-name */ + +/** + * Regions make up a GlobalNavigation Bar and typically contain links and dropdowns. The Primary region contains the AppSwitcher, Application Name, and Object Switcher. The secondary region typically has navigation betweens sections of the application. The tertiary region is aligned to the right side of the screen and contains shortcuts or actions. + */ + + +var Region = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Region, _React$Component); + + function Region() { + _classCallCheck(this, Region); + + return _possibleConstructorReturn(this, _getPrototypeOf(Region).apply(this, arguments)); + } + + _createClass(Region, [{ + key: "render", + value: function render() { + var region; + var dividerClass = this.props.dividerPosition ? "slds-context-bar__item_divider-".concat(this.props.dividerPosition) : null; + + switch (this.props.region) { + case 'primary': + region = renderPrimary(dividerClass, this.props.className, this.props.children); + break; + + case 'secondary': + region = renderSecondary(dividerClass, this.props.className, this.props.children, this.props.navigation); + break; + + case 'tertiary': + region = renderTertiary(dividerClass, this.props.className, this.props.children); + break; + + default: // do nothing + + } + + return region; + } + }]); + + return Region; +}(_react.default.Component); + +_defineProperty(Region, "displayName", _constants.GLOBAL_NAVIGATION_BAR_REGION); + +_defineProperty(Region, "propTypes", { + /** + * Contents of region. Expects `GlobalNavigationBarLink`, `GlobalNavigationBarDropdown`, `GlobalNavigationBarApplicationName`, `AppSwitcher`, but could be any component. This is the place to pass in an Object Switcher until that is supported. + */ + children: _propTypes.default.node, + + /** + * Determines position of separating bar. + */ + dividerPosition: _propTypes.default.oneOf(['left', 'right']), + + /** + * CSS classes to be added to the region + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Wraps the `secondary` region in a `nav` and adds a role attribute + */ + navigation: _propTypes.default.bool, + + /** + * Region wrap children in styling specific to that region. + */ + region: _propTypes.default.oneOf(['primary', 'secondary', 'tertiary']).isRequired +}); + +var _default = Region; +exports.default = _default; \ No newline at end of file diff --git a/components/grid/index.js b/components/grid/index.js new file mode 100644 index 0000000000..ee6e4c8333 --- /dev/null +++ b/components/grid/index.js @@ -0,0 +1,93 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _classnames = _interopRequireDefault(require("classnames")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var GridColumn = +/*#__PURE__*/ +function (_React$Component) { + _inherits(GridColumn, _React$Component); + + function GridColumn() { + _classCallCheck(this, GridColumn); + + return _possibleConstructorReturn(this, _getPrototypeOf(GridColumn).apply(this, arguments)); + } + + _createClass(GridColumn, [{ + key: "getClassName", + value: function getClassName() { + return "".concat(this.props.className, " slds-col"); + } + }, { + key: "render", + value: function render() { + return _react.default.createElement("div", { + className: this.getClassName() + }, this.props.children); + } + }]); + + return GridColumn; +}(_react.default.Component); + +var Grid = +/*#__PURE__*/ +function (_React$Component2) { + _inherits(Grid, _React$Component2); + + function Grid() { + _classCallCheck(this, Grid); + + return _possibleConstructorReturn(this, _getPrototypeOf(Grid).apply(this, arguments)); + } + + _createClass(Grid, [{ + key: "getClassName", + value: function getClassName() { + var flavor = this.props.flavor; + return (0, _classnames.default)(this.props.className, 'slds-grid', _defineProperty({}, "slds-grid_".concat(flavor), flavor)); + } + }, { + key: "render", + value: function render() { + return _react.default.createElement("div", { + className: this.getClassName() + }, this.props.children); + } + }]); + + return Grid; +}(_react.default.Component); + +Grid.Column = GridColumn; +var _default = Grid; +exports.default = _default; \ No newline at end of file diff --git a/components/icon-settings/__docs__/site-stories.js b/components/icon-settings/__docs__/site-stories.js new file mode 100644 index 0000000000..3a3c9a7212 --- /dev/null +++ b/components/icon-settings/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/icon-settings/__examples__/icon-path.jsx'), require('raw-loader!@salesforce/design-system-react/components/icon-settings/__examples__/sprite.jsx'), require('raw-loader!@salesforce/design-system-react/components/icon-settings/__examples__/on-request-icon-path.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/icon-settings/__docs__/storybook-stories.js b/components/icon-settings/__docs__/storybook-stories.js new file mode 100644 index 0000000000..bb86ff8332 --- /dev/null +++ b/components/icon-settings/__docs__/storybook-stories.js @@ -0,0 +1,27 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _sprite = _interopRequireDefault(require("../__examples__/sprite")); + +var _iconPath = _interopRequireDefault(require("../__examples__/icon-path")); + +var _onRequestIconPath = _interopRequireDefault(require("../__examples__/on-request-icon-path")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.ICON_SETTINGS, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base: Icon path', function () { + return _react.default.createElement(_iconPath.default, null); +}).add('Base: Sprite imports NoTest', function () { + return _react.default.createElement(_sprite.default, null); +}).add('Base: OnRequestIconPath NoTest', function () { + return _react.default.createElement(_onRequestIconPath.default, null); +}); \ No newline at end of file diff --git a/components/icon-settings/__examples__/icon-path.js b/components/icon-settings/__examples__/icon-path.js new file mode 100644 index 0000000000..933b89894d --- /dev/null +++ b/components/icon-settings/__examples__/icon-path.js @@ -0,0 +1,111 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Announcement' + }, + category: "utility", + name: "announcement", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description' + }, + category: "action", + name: "description", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'XML' + }, + category: "doctype", + name: "xml", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'custom5' + }, + category: "custom", + name: "custom5", + size: "small" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconSettingsExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon-settings/__examples__/on-request-icon-path.js b/components/icon-settings/__examples__/on-request-icon-path.js new file mode 100644 index 0000000000..8f0580a361 --- /dev/null +++ b/components/icon-settings/__examples__/on-request-icon-path.js @@ -0,0 +1,151 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _symbols = _interopRequireDefault(require("@salesforce-ux/design-system/assets/icons/action-sprite/svg/symbols.svg")); + +var _symbols2 = _interopRequireDefault(require("@salesforce-ux/design-system/assets/icons/custom-sprite/svg/symbols.svg")); + +var _symbols3 = _interopRequireDefault(require("@salesforce-ux/design-system/assets/icons/utility-sprite/svg/symbols.svg")); + +var _symbols4 = _interopRequireDefault(require("@salesforce-ux/design-system/assets/icons/standard-sprite/svg/symbols.svg")); + +var _symbols5 = _interopRequireDefault(require("@salesforce-ux/design-system/assets/icons/doctype-sprite/svg/symbols.svg")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var sprites = { + action: _symbols.default, + custom: _symbols2.default, + utility: _symbols3.default, + standard: _symbols4.default, + doctype: _symbols5.default +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "componentDidMount", + value: function componentDidMount() { + var _this = this; + + Promise.all(Object.keys(sprites).map(function (category) { + return fetch(sprites[category]).then(function (resp) { + return resp.text(); + }); + })).then(function (texts) { + _this.spriteInlineContainer.innerHTML = texts.join(''); + }); + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + onRequestIconPath: function onRequestIconPath(_ref) { + var category = _ref.category, + name = _ref.name; + return "#".concat(name); + } + }, _react.default.createElement("div", { + ref: function ref(el) { + _this2.spriteInlineContainer = el; + } + }), _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Announcement' + }, + category: "utility", + name: "announcement", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description' + }, + category: "action", + name: "description", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'XML' + }, + category: "doctype", + name: "xml", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'custom5' + }, + category: "custom", + name: "custom5", + size: "small" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconSettingsExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon-settings/__examples__/sprite.js b/components/icon-settings/__examples__/sprite.js new file mode 100644 index 0000000000..fd252f7036 --- /dev/null +++ b/components/icon-settings/__examples__/sprite.js @@ -0,0 +1,124 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _symbols = _interopRequireDefault(require("@salesforce-ux/design-system/assets/icons/action-sprite/svg/symbols.svg")); + +var _symbols2 = _interopRequireDefault(require("@salesforce-ux/design-system/assets/icons/custom-sprite/svg/symbols.svg")); + +var _symbols3 = _interopRequireDefault(require("@salesforce-ux/design-system/assets/icons/utility-sprite/svg/symbols.svg")); + +var _symbols4 = _interopRequireDefault(require("@salesforce-ux/design-system/assets/icons/standard-sprite/svg/symbols.svg")); + +var _symbols5 = _interopRequireDefault(require("@salesforce-ux/design-system/assets/icons/doctype-sprite/svg/symbols.svg")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + standardSprite: _symbols4.default, + utilitySprite: _symbols3.default, + actionSprite: _symbols.default, + doctypeSprite: _symbols5.default, + customSprite: _symbols2.default + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Announcement' + }, + category: "utility", + name: "announcement", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description' + }, + category: "action", + name: "description", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'XML' + }, + category: "doctype", + name: "xml", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'custom5' + }, + category: "custom", + name: "custom5", + size: "small" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconSettingsExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon-settings/docs.json b/components/icon-settings/docs.json new file mode 100644 index 0000000000..3e43b27ad4 --- /dev/null +++ b/components/icon-settings/docs.json @@ -0,0 +1,6 @@ +{ + "component": "icon-settings", + "status": "prod", + "display-name": "Icon Settings", + "url-slug": "icon-settings" +} \ No newline at end of file diff --git a/components/icon-settings/index.js b/components/icon-settings/index.js new file mode 100644 index 0000000000..23eb055a74 --- /dev/null +++ b/components/icon-settings/index.js @@ -0,0 +1,137 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +/** + * The Icon Settings component allows for the path to the icons to be specified in all child components and is recommended to be used at the root of the application. It's render function is `return this.props.children`, so it can only have one child node. + * + * **Individual sprites** + * If you are using webpack it is advised to use the sprite properties + * {actionSprite, standardSprite...} to specify the individual sprite paths so that webpack can + * easily re-write the paths. + * ``` + * import actionSprite from '......'; + * + * + * ``` + * **Root icon path** + * Otherwise use the iconPath to specify the root path to where the icon files will be located in you application + * such as `/assets/icons`. + */ +var IconSettings = +/*#__PURE__*/ +function (_React$Component) { + _inherits(IconSettings, _React$Component); + + function IconSettings() { + _classCallCheck(this, IconSettings); + + return _possibleConstructorReturn(this, _getPrototypeOf(IconSettings).apply(this, arguments)); + } + + _createClass(IconSettings, [{ + key: "getChildContext", + value: function getChildContext() { + return { + iconPath: this.props.iconPath, + onRequestIconPath: this.props.onRequestIconPath, + actionSprite: this.props.actionSprite, + customSprite: this.props.customSprite, + doctypeSprite: this.props.doctypeSprite, + standardSprite: this.props.standardSprite, + utilitySprite: this.props.utilitySprite + }; + } + }, { + key: "render", + value: function render() { + return this.props.children; + } + }]); + + return IconSettings; +}(_react.default.Component); + +IconSettings.displayName = _constants.ICON_SETTINGS; +IconSettings.childContextTypes = { + iconPath: _propTypes.default.string, + onRequestIconPath: _propTypes.default.func, + actionSprite: _propTypes.default.string, + customSprite: _propTypes.default.string, + doctypeSprite: _propTypes.default.string, + standardSprite: _propTypes.default.string, + utilitySprite: _propTypes.default.string +}; +IconSettings.propTypes = { + /** + * Path to the root icon folder + * example: `/assets/icons` + */ + iconPath: _propTypes.default.string, + + /** + * Function to allow developers to return a custom icon path--for instance, on the same page with a local anchor (`#down`). This is helpful for when there are Cross-Origin Resource Sharing (CORS) issues with SVGs that are located on another domain such as a CDN. `({category, name}) => { return \`#${name}\` }` + */ + onRequestIconPath: _propTypes.default.func, + + /** + * Path to the action sprite + * example: '@salesforce-ux/design-system/assets/icons/action-sprite/svg/symbols.svg'; + */ + actionSprite: _propTypes.default.string, + + /** + * Path to the custom sprite + * example: '@salesforce-ux/design-system/assets/icons/custom-sprite/svg/symbols.svg'; + */ + customSprite: _propTypes.default.string, + + /** + * Path to the doctype sprite + * example: '@salesforce-ux/design-system/assets/icons/doctype-sprite/svg/symbols.svg'; + */ + doctypeSprite: _propTypes.default.string, + + /** + * Path to the standard sprite + * example: '@salesforce-ux/design-system/assets/icons/standard-sprite/svg/symbols.svg'; + */ + standardSprite: _propTypes.default.string, + + /** + * Path to the utility sprite + * example: '@salesforce-ux/design-system/assets/icons/utility-sprite/svg/symbols.svg'; + */ + utilitySprite: _propTypes.default.string +}; +var _default = IconSettings; +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__docs__/__snapshots__/storybook-stories.storyshot b/components/icon/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..ac9e74f547 --- /dev/null +++ b/components/icon/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,736 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSIcon Base: Imported 1`] = ` +
    + + + + Download + + +
    +`; + +exports[`DOM snapshots SLDSIcon Base: Standard (custom styles) 1`] = ` +
    + + + + Account + + +
    +`; + +exports[`DOM snapshots SLDSIcon Category: Action 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Category: Custom 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Category: Doctype 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Category: External Path 1`] = ` +
    + + + + We got news! + + +
    +`; + +exports[`DOM snapshots SLDSIcon Category: Standard 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Category: Utility 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Color: Base 1`] = ` +
    +
    + + + + Description of icon + + +
    +
    +`; + +exports[`DOM snapshots SLDSIcon Color: Default 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Color: Error 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Color: Light 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Color: Warning 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Docs site Categories 1`] = ` +
    +
    +
    + + + + Account + + +
    +
    + + + + Announcement + + +
    +
    + + + + Description + + +
    +
    + + + + XML + + +
    +
    + + + + custom5 + + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSIcon Docs site Colors 1`] = ` +
    +
    +
    + + + + Lead + + +
    +
    + + + + Lock + + +
    +
    + + + + Lock + + +
    +
    + + + + Warning + + +
    +
    + + + + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSIcon Docs site Sizes 1`] = ` +
    +
    +
    + + + + Warning + + +
    +
    + + + + Case + + +
    +
    + + + + Case + + +
    +
    + + + + Case + + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSIcon Size: Large 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Size: Medium (default) 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Size: Small 1`] = ` +
    + + + + Description of icon + + +
    +`; + +exports[`DOM snapshots SLDSIcon Size: X-Small 1`] = ` +
    + + + + Description of icon + + +
    +`; diff --git a/components/icon/__docs__/site-stories.js b/components/icon/__docs__/site-stories.js new file mode 100644 index 0000000000..be387e2599 --- /dev/null +++ b/components/icon/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/icon/__examples__/categories.jsx'), require('raw-loader!@salesforce/design-system-react/components/icon/__examples__/colors.jsx'), require('raw-loader!@salesforce/design-system-react/components/icon/__examples__/sizes.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/icon/__docs__/storybook-stories.js b/components/icon/__docs__/storybook-stories.js new file mode 100644 index 0000000000..cce0e29be3 --- /dev/null +++ b/components/icon/__docs__/storybook-stories.js @@ -0,0 +1,121 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _icon = _interopRequireDefault(require("../../icon")); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _download = _interopRequireDefault(require("../../../icons/utility/download")); + +var _standard = _interopRequireDefault(require("../__examples__/standard")); + +var _utility = _interopRequireDefault(require("../__examples__/utility")); + +var _action = _interopRequireDefault(require("../__examples__/action")); + +var _doctype = _interopRequireDefault(require("../__examples__/doctype")); + +var _custom = _interopRequireDefault(require("../__examples__/custom")); + +var _externalPath = _interopRequireDefault(require("../__examples__/external-path")); + +var _colorBase = _interopRequireDefault(require("../__examples__/color-base")); + +var _colorDefault = _interopRequireDefault(require("../__examples__/color-default")); + +var _colorError = _interopRequireDefault(require("../__examples__/color-error")); + +var _colorWarning = _interopRequireDefault(require("../__examples__/color-warning")); + +var _colorLight = _interopRequireDefault(require("../__examples__/color-light")); + +var _sizesExtraSmall = _interopRequireDefault(require("../__examples__/sizes-extra-small")); + +var _sizesSmall = _interopRequireDefault(require("../__examples__/sizes-small")); + +var _sizesMedium = _interopRequireDefault(require("../__examples__/sizes-medium")); + +var _sizesLarge = _interopRequireDefault(require("../__examples__/sizes-large")); + +var _categories = _interopRequireDefault(require("../__examples__/categories")); + +var _colors = _interopRequireDefault(require("../__examples__/colors")); + +var _sizes = _interopRequireDefault(require("../__examples__/sizes")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.ICON, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Category: Standard', function () { + return _react.default.createElement(_standard.default, null); +}).add('Category: Utility', function () { + return _react.default.createElement(_utility.default, null); +}).add('Category: Action', function () { + return _react.default.createElement(_action.default, null); +}).add('Category: Doctype', function () { + return _react.default.createElement(_doctype.default, null); +}).add('Category: Custom', function () { + return _react.default.createElement(_custom.default, null); +}).add('Category: External Path', function () { + return _react.default.createElement(_externalPath.default, null); +}).add('Size: X-Small', function () { + return _react.default.createElement(_sizesExtraSmall.default, null); +}).add('Size: Small', function () { + return _react.default.createElement(_sizesSmall.default, null); +}).add('Size: Medium (default)', function () { + return _react.default.createElement(_sizesMedium.default, null); +}).add('Size: Large', function () { + return _react.default.createElement(_sizesLarge.default, null); +}).add('Color: Base', function () { + return _react.default.createElement("div", { + style: { + backgroundColor: 'goldenrod', + padding: '10px' + } + }, _react.default.createElement(_colorBase.default, null)); +}).add('Color: Default', function () { + return _react.default.createElement(_colorDefault.default, null); +}).add('Color: Error', function () { + return _react.default.createElement(_colorError.default, null); +}).add('Color: Warning', function () { + return _react.default.createElement(_colorWarning.default, null); +}).add('Color: Light', function () { + return _react.default.createElement(_colorLight.default, null); +}).add('Base: Standard (custom styles)', function () { + return _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account", + style: { + backgroundColor: '#aceace', + fill: 'orangered' + }, + title: "This is a title" + }); +}).add('Base: Imported', function () { + return _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Download' + }, + category: "utility", + icon: _download.default + }); +}).add('Docs site Categories', function () { + return _react.default.createElement(_categories.default, null); +}).add('Docs site Colors', function () { + return _react.default.createElement(_colors.default, null); +}).add('Docs site Sizes', function () { + return _react.default.createElement(_sizes.default, null); +}); \ No newline at end of file diff --git a/components/icon/__examples__/action.js b/components/icon/__examples__/action.js new file mode 100644 index 0000000000..9ae0cc1512 --- /dev/null +++ b/components/icon/__examples__/action.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "action", + name: "description", + size: "small" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/categories.js b/components/icon/__examples__/categories.js new file mode 100644 index 0000000000..3eaea5629c --- /dev/null +++ b/components/icon/__examples__/categories.js @@ -0,0 +1,111 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Account' + }, + category: "standard", + name: "account", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Announcement' + }, + category: "utility", + name: "announcement", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description' + }, + category: "action", + name: "description", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'XML' + }, + category: "doctype", + name: "xml", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'custom5' + }, + category: "custom", + name: "custom5", + size: "small" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/color-base.js b/components/icon/__examples__/color-base.js new file mode 100644 index 0000000000..f806cd1e61 --- /dev/null +++ b/components/icon/__examples__/color-base.js @@ -0,0 +1,71 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "utility", + name: "announcement", + title: "description of icon when needed", + inverse: true + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/color-default.js b/components/icon/__examples__/color-default.js new file mode 100644 index 0000000000..58f2a618ce --- /dev/null +++ b/components/icon/__examples__/color-default.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "utility", + name: "announcement", + title: "This is a title" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/color-error.js b/components/icon/__examples__/color-error.js new file mode 100644 index 0000000000..27f7deb576 --- /dev/null +++ b/components/icon/__examples__/color-error.js @@ -0,0 +1,71 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "utility", + colorVariant: "error", + name: "announcement", + title: "description of icon" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/color-light.js b/components/icon/__examples__/color-light.js new file mode 100644 index 0000000000..73d2f381cd --- /dev/null +++ b/components/icon/__examples__/color-light.js @@ -0,0 +1,71 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "utility", + colorVariant: "light", + name: "announcement", + title: "description of icon" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/color-warning.js b/components/icon/__examples__/color-warning.js new file mode 100644 index 0000000000..da9fd127ca --- /dev/null +++ b/components/icon/__examples__/color-warning.js @@ -0,0 +1,71 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "utility", + colorVariant: "warning", + name: "announcement", + title: "description of icon" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/colors.js b/components/icon/__examples__/colors.js new file mode 100644 index 0000000000..727340a206 --- /dev/null +++ b/components/icon/__examples__/colors.js @@ -0,0 +1,111 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Lead' + }, + category: "standard", + colorVariant: "base", + name: "lead" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Lock' + }, + category: "utility", + colorVariant: "default", + name: "lock" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Lock' + }, + category: "utility", + colorVariant: "light", + name: "lock" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Warning' + }, + category: "utility", + colorVariant: "warning", + name: "warning" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + lable: 'Warning' + }, + category: "utility", + colorVariant: "error", + name: "warning" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/custom.js b/components/icon/__examples__/custom.js new file mode 100644 index 0000000000..234f056a00 --- /dev/null +++ b/components/icon/__examples__/custom.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "custom", + name: "custom5", + title: "description of icon when needed" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/doctype.js b/components/icon/__examples__/doctype.js new file mode 100644 index 0000000000..34827569f6 --- /dev/null +++ b/components/icon/__examples__/doctype.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "doctype", + name: "xml" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/external-path.js b/components/icon/__examples__/external-path.js new file mode 100644 index 0000000000..c1c227433f --- /dev/null +++ b/components/icon/__examples__/external-path.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'We got news!' + }, + inverse: true, + path: "/assets/icons/utility-sprite/svg/symbols.svg#announcement", + size: "medium" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/sizes-extra-small.js b/components/icon/__examples__/sizes-extra-small.js new file mode 100644 index 0000000000..4f08319372 --- /dev/null +++ b/components/icon/__examples__/sizes-extra-small.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "utility", + name: "warning", + size: "x-small" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/sizes-large.js b/components/icon/__examples__/sizes-large.js new file mode 100644 index 0000000000..b69920ce1f --- /dev/null +++ b/components/icon/__examples__/sizes-large.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "standard", + name: "case", + size: "large" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/sizes-medium.js b/components/icon/__examples__/sizes-medium.js new file mode 100644 index 0000000000..ee94aafe82 --- /dev/null +++ b/components/icon/__examples__/sizes-medium.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "standard", + name: "case" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/sizes-small.js b/components/icon/__examples__/sizes-small.js new file mode 100644 index 0000000000..5a5e034dd9 --- /dev/null +++ b/components/icon/__examples__/sizes-small.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "standard", + name: "case", + size: "small" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/sizes.js b/components/icon/__examples__/sizes.js new file mode 100644 index 0000000000..870c0e2c39 --- /dev/null +++ b/components/icon/__examples__/sizes.js @@ -0,0 +1,103 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Warning' + }, + category: "utility", + color: "warning", + name: "warning", + size: "x-small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Case' + }, + category: "standard", + name: "case", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Case' + }, + category: "standard", + name: "case", + size: "medium" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Case' + }, + category: "standard", + name: "case", + size: "large" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/standard.js b/components/icon/__examples__/standard.js new file mode 100644 index 0000000000..ad7944f5e1 --- /dev/null +++ b/components/icon/__examples__/standard.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "standard", + name: "account", + title: "description of icon" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/__examples__/utility.js b/components/icon/__examples__/utility.js new file mode 100644 index 0000000000..568a4ed31e --- /dev/null +++ b/components/icon/__examples__/utility.js @@ -0,0 +1,72 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Description of icon' + }, + category: "utility", + colorVariant: "default", + name: "announcement", + size: "small", + title: "description of icon when needed" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'IconExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/icon/button-icon/check-props.js b/components/icon/button-icon/check-props.js new file mode 100644 index 0000000000..0b054bfbba --- /dev/null +++ b/components/icon/button-icon/check-props.js @@ -0,0 +1,27 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _sunsetProperty = _interopRequireDefault(require("../../../utilities/warning/sunset-property")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props) { + /* eslint-disable max-len */ + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', 'The wrapping span and assistive text has been removed from this component in order to make it a more pure "higher-level component" of `UtilityIcon`.'); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/icon/button-icon/index.js b/components/icon/button-icon/index.js new file mode 100644 index 0000000000..bc40da3a45 --- /dev/null +++ b/components/icon/button-icon/index.js @@ -0,0 +1,96 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _utilityIcon = _interopRequireDefault(require("../../utilities/utility-icon")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * This is a non-interactive wrapper component for `UtilityIcon` that specifies button icon classes for an icon inside a `button` tag. Use of this component by itself is not recommended, but should be used as part of other components to obtain the correct styling for icons within buttons. This component only partially implements [Button Icons](http://www.lightningdesignsystem.com/components/button-icons). It does not return a `button` HTML tag. It only returns an icon for use within a button. Assistive text must also be rendered by the parent. + */ +var ButtonIcon = function ButtonIcon(props) { + var _classNames; + + (0, _checkProps.default)(_constants.BUTTON_ICON, props); + return _react.default.createElement(_utilityIcon.default, { + "aria-hidden": "true", + category: props.category, + className: (0, _classnames.default)('slds-button__icon', (_classNames = {}, _defineProperty(_classNames, "slds-button__icon_".concat(props.size), props.size && props.size !== 'medium'), _defineProperty(_classNames, 'slds-button__icon_inverse-hint', props.inverse && props.hint), _defineProperty(_classNames, 'slds-button__icon_hint', props.hint && !props.inverse), _defineProperty(_classNames, "slds-button__icon_".concat(props.position), props.position), _classNames), props.className) // iconClassName has been deprecated + , + icon: props.icon, + name: props.name, + path: props.path + }); +}; + +var propTypes = { + /** + * Icon category from [lightningdesignsystem.com/icons/](https://www.lightningdesignsystem.com/icons/) + */ + category: _propTypes.default.oneOf(['action', 'custom', 'doctype', 'standard', 'utility']).isRequired, + + /** + * Associates an icon button with another element on the page by changes the color of the SVG. Please reference Lightning Design System Buttons > Hint. + */ + hint: _propTypes.default.bool, + + /** + * An SVG object to use instead of name / category, look in `design-system-react/icons` for examples + */ + icon: _propTypes.default.object, + + /** + * Class names to be added to the SVG. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Setting `inverse` to true will switch the color of the icon: light to dark, dark to light. + */ + inverse: _propTypes.default.bool, + + /** + * Name of the icon. Visit Lightning Design System Icons to reference icon names. + */ + name: _propTypes.default.string, + + /** + * Path to the icon. This will override any global icon settings. + */ + path: _propTypes.default.string, + + /** + * Adds additional spacing on the opposite side specified between button icon and the button label + */ + position: _propTypes.default.oneOf(['left', 'right']), + + /** + * Size of the icon. Visit [lightningdesignsystem.com/components/icons/#flavor-sizes](https://www.lightningdesignsystem.com/components/icons/#flavor-sizes) + */ + size: _propTypes.default.oneOf(['x-small', 'small', 'medium', 'large']) +}; +var defaultProps = { + category: 'utility', + size: 'medium' +}; +ButtonIcon.displayName = _constants.BUTTON_ICON; +ButtonIcon.propTypes = propTypes; +ButtonIcon.defaultProps = defaultProps; +var _default = ButtonIcon; +exports.default = _default; \ No newline at end of file diff --git a/components/icon/check-props.js b/components/icon/check-props.js new file mode 100644 index 0000000000..15d584de9c --- /dev/null +++ b/components/icon/check-props.js @@ -0,0 +1,31 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + if (typeof props.assistiveText === 'string') { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', "`assistiveText` as a string has been deprecated and is now an object to allow for multiple uses in the component. Please use `assistiveText.label` instead. ".concat(createDocUrl('assistiveText'))); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/icon/docs.json b/components/icon/docs.json new file mode 100644 index 0000000000..0e4a986b92 --- /dev/null +++ b/components/icon/docs.json @@ -0,0 +1,11 @@ +{ + "component": "icon", + "status": "prod", + "display-name": "Icons", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/icons", + "url-slug": "icons" +} \ No newline at end of file diff --git a/components/icon/index.js b/components/icon/index.js new file mode 100644 index 0000000000..152a159886 --- /dev/null +++ b/components/icon/index.js @@ -0,0 +1,157 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _classNames2 = _interopRequireDefault(require("../../utilities/class-names")); + +var _utilityIcon = _interopRequireDefault(require("../utilities/utility-icon")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var defaultProps = { + assistiveText: {}, + category: 'standard', + colorVariant: 'default', + size: 'medium' +}; +/** + * The Icon component is the Lightning Design System Icon component and should be used for naked icons. For icons that are buttons, use the Button component component with variant='icon'. + */ + +var Icon = function Icon(props) { + (0, _checkProps.default)(_constants.ICON, props, _docs.default); + var category = props.category, + className = props.className, + colorVariant = props.colorVariant, + containerClassName = props.containerClassName, + icon = props.icon, + inverse = props.inverse, + name = props.name, + path = props.path, + size = props.size, + style = props.style, + title = props.title; + var assistiveText = typeof props.assistiveText === 'string' ? props.assistiveText : _objectSpread({}, defaultProps.assistiveText, props.assistiveText).label; + var kababCaseName = name ? name.replace(/_/g, '-') : ''; + return _react.default.createElement("span", { + className: (0, _classNames2.default)(_defineProperty({ + 'slds-icon_container': category !== 'utility', + 'slds-icon_container_circle': category === 'action' + }, "slds-icon-".concat(category, "-").concat(kababCaseName), category !== 'utility' && category !== 'doctype' && !path), containerClassName), + title: title + }, _react.default.createElement(_utilityIcon.default, { + "aria-hidden": "true", + category: category, + className: (0, _classNames2.default)(className, 'slds-icon', { + 'slds-icon_xx-small': size === 'xx-small', + 'slds-icon_x-small': size === 'x-small', + 'slds-icon_small': size === 'small', + // medium intentially not present + 'slds-icon_large': size === 'large', + // if category is `utility` and `inverse` is false (default), icon will be dark // return true + // if category is `utility` and `inverse` is true, icon will be light // return false + // if category is NOT `utility` and `inverse` is false (default), icon will be light // return false + // if category is NOT `utility` and `inverse` is true, icon will be dark // return true + 'slds-icon-text-default': colorVariant === 'default' && category === 'utility' ? !inverse : inverse, + 'slds-icon-text-warning': colorVariant === 'warning', + 'slds-icon-text-error': colorVariant === 'error', + 'slds-icon-text-light': colorVariant === 'light' + }), + icon: icon, + name: name, + path: path, + style: style + }), assistiveText ? _react.default.createElement("span", { + className: "slds-assistive-text" + }, assistiveText) : ''); +}; // ### Display Name +// Always use the canonical component name as the React display name. + + +Icon.displayName = _constants.ICON; // ### Prop Types + +Icon.propTypes = { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `label`: Text that is visually hidden but read aloud by screenreaders to tell the user what the icon means. Naked icons must have assistive text, however, if you also have visible descriptive text with the icon, declare this prop as assistiveText=''. + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string + }), + + /** + * Icon category from [lightningdesignsystem.com/icons/](https://www.lightningdesignsystem.com/icons/) + */ + category: _propTypes.default.oneOf(['action', 'custom', 'doctype', 'standard', 'utility']).isRequired, + + /** + * CSS classes that are applied to the SVG. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * CSS classes that are applied to the span. + */ + containerClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Icon color variants + */ + colorVariant: _propTypes.default.oneOf(['base', 'default', 'error', 'light', 'warning']), + + /** + * A custom SVG object to use instead of the supplied SLDS icons, look in `design-system-react/icons` for examples and syntax. + */ + icon: _propTypes.default.object, + + /** + * Setting `inverse` to true will switch the color of the icon: light to dark, dark to light. + */ + inverse: _propTypes.default.bool, + + /** + * Name of the icon. Visit Lightning Design System Icons to reference icon names. + */ + name: _propTypes.default.string, + + /** + * Path to the icon. This will override any global icon settings + */ + path: _propTypes.default.string, + + /** + * Size of the icon. Visit [lightningdesignsystem.com/components/icons/#flavor-sizes](https://www.lightningdesignsystem.com/components/icons/#flavor-sizes) + */ + size: _propTypes.default.oneOf(['xx-small', 'x-small', 'small', 'medium', 'large']), + + /** + * Custom styles to be passed to the SVG. Could be used to change icon or background color. + */ + style: _propTypes.default.object, + + /** + * Title attribute for the icon container + */ + title: _propTypes.default.string +}; +Icon.defaultProps = defaultProps; +var _default = Icon; +exports.default = _default; \ No newline at end of file diff --git a/components/icon/input-icon/index.js b/components/icon/input-icon/index.js new file mode 100644 index 0000000000..dee2b95733 --- /dev/null +++ b/components/icon/input-icon/index.js @@ -0,0 +1,114 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _lodash = _interopRequireDefault(require("lodash.isfunction")); + +var _utilityIcon = _interopRequireDefault(require("../../utilities/utility-icon")); + +var _button = _interopRequireDefault(require("../../button")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +/** + * A wrapper for icons that will be rendered inside of an Input + * + * If the `onClick` function prop is provided, the `design-system-react/components/button` component is used. + * If not, the icon will be an instance of `design-system-react/components/utilities/utility-icon`. + * Checkout out the appropriate component to see what props can be passed along via the `{...props}` rest operator + */ +var InputIcon = function InputIcon(props) { + var category = props.category, + iconPosition = props.iconPosition, + name = props.name, + path = props.path, + onClick = props.onClick, + variant = props.variant, + rest = _objectWithoutProperties(props, ["category", "iconPosition", "name", "path", "onClick", "variant"]); // need to pass click event up on SVG + + + var variants = { + combobox: _react.default.createElement("span", { + className: "slds-icon_container slds-input__icon slds-input__icon_right" + }, _react.default.createElement(_utilityIcon.default, _extends({ + "aria-hidden": true, + category: category, + className: (0, _classnames.default)('slds-icon slds-icon_x-small slds-icon-text-default'), + name: name, + path: path + }, rest))), + base: _react.default.createElement(_utilityIcon.default, _extends({ + "aria-hidden": true, + category: category, + className: (0, _classnames.default)('slds-input__icon slds-icon-text-default', _defineProperty({}, "slds-input__icon_".concat(iconPosition), iconPosition)), + name: name, + path: path + }, rest)) + }; + return (0, _lodash.default)(onClick) ? _react.default.createElement(_button.default, _extends({ + className: (0, _classnames.default)('slds-input__icon', _defineProperty({}, "slds-input__icon_".concat(iconPosition), iconPosition)), + iconCategory: category, + iconName: name, + iconPath: path, + onClick: onClick, + variant: "icon" + }, rest)) : variants[variant]; +}; + +InputIcon.displayName = _constants.ICON_INPUT; +InputIcon.propTypes = { + /** + * Icon category from [lightningdesignsystem.com/icons/](https://www.lightningdesignsystem.com/icons/) + */ + category: _propTypes.default.string, + + /** + * This is only needed if an input contains two icons, the Input component handles this prop for you. + */ + iconPosition: _propTypes.default.oneOf(['left', 'right']), + + /** + * Name of the icon. Visit Lightning Design System Icons to reference icon names. + */ + name: _propTypes.default.string, + + /** + * Path to the icon. This will override any global icon settings. + */ + path: _propTypes.default.string, + + /** + * This event fires when the icon is clicked. + */ + onClick: _propTypes.default.func, + + /** + * Changes styles of the InputIcon. + */ + variant: _propTypes.default.oneOf(['base', 'combobox']) +}; +InputIcon.defaultProps = { + category: 'utility', + variant: 'base' +}; +var _default = InputIcon; +exports.default = _default; \ No newline at end of file diff --git a/components/illustration/__docs__/__snapshots__/storybook-stories.storyshot b/components/illustration/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..41d36f8ed4 --- /dev/null +++ b/components/illustration/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,140 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSIllustration Heading Only 1`] = ` +
    +
    +
    +

    + Lorem ipsum dolor +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSIllustration Heading and Message 1`] = ` +
    +
    +
    +

    + Lorem ipsum dolor +

    +

    + Lorem ipsum dolor sit amet, consectetur +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSIllustration Large Image and Text 1`] = ` +
    +
    + +
    +

    + Lorem ipsum dolor +

    +

    + Lorem ipsum dolor sit amet, consectetur +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSIllustration Message Only 1`] = ` +
    +
    +
    +

    + Lorem ipsum dolor sit amet, consectetur +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSIllustration Small Image and Text 1`] = ` +
    +
    + +
    +

    + Lorem ipsum dolor +

    +

    + Lorem ipsum dolor sit amet, consectetur +

    +
    +
    +
    +`; diff --git a/components/illustration/__docs__/site-stories.js b/components/illustration/__docs__/site-stories.js new file mode 100644 index 0000000000..70bea1f069 --- /dev/null +++ b/components/illustration/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/illustration/__examples__/small-image-text.jsx'), require('raw-loader!@salesforce/design-system-react/components/illustration/__examples__/large-image-text.jsx'), require('raw-loader!@salesforce/design-system-react/components/illustration/__examples__/heading-message.jsx'), require('raw-loader!@salesforce/design-system-react/components/illustration/__examples__/heading-only.jsx'), require('raw-loader!@salesforce/design-system-react/components/illustration/__examples__/message-only.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/illustration/__docs__/storybook-stories.js b/components/illustration/__docs__/storybook-stories.js new file mode 100644 index 0000000000..2ae60c990f --- /dev/null +++ b/components/illustration/__docs__/storybook-stories.js @@ -0,0 +1,37 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _illustration = _interopRequireDefault(require("../../illustration")); + +var _smallImageText = _interopRequireDefault(require("../__examples__/small-image-text.jsx")); + +var _largeImageText = _interopRequireDefault(require("../__examples__/large-image-text.jsx")); + +var _headingOnly = _interopRequireDefault(require("../__examples__/heading-only.jsx")); + +var _messageOnly = _interopRequireDefault(require("../__examples__/message-only.jsx")); + +var _headingMessage = _interopRequireDefault(require("../__examples__/heading-message.jsx")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.ILLUSTRATION, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Small Image and Text', function () { + return _react.default.createElement(_smallImageText.default, null); +}).add('Large Image and Text', function () { + return _react.default.createElement(_largeImageText.default, null); +}).add('Heading Only', function () { + return _react.default.createElement(_headingOnly.default, null); +}).add('Message Only', function () { + return _react.default.createElement(_messageOnly.default, null); +}).add('Heading and Message', function () { + return _react.default.createElement(_headingMessage.default, null); +}); \ No newline at end of file diff --git a/components/illustration/__examples__/heading-message.js b/components/illustration/__examples__/heading-message.js new file mode 100644 index 0000000000..8f29fa336b --- /dev/null +++ b/components/illustration/__examples__/heading-message.js @@ -0,0 +1,60 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _illustration = _interopRequireDefault(require("../../../../components/illustration")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_illustration.default, { + heading: "Lorem ipsum dolor", + messageBody: "Lorem ipsum dolor sit amet, consectetur" + }); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'IllustrationExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/illustration/__examples__/heading-only.js b/components/illustration/__examples__/heading-only.js new file mode 100644 index 0000000000..71b15a5b7f --- /dev/null +++ b/components/illustration/__examples__/heading-only.js @@ -0,0 +1,59 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _illustration = _interopRequireDefault(require("../../../../components/illustration")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_illustration.default, { + heading: "Lorem ipsum dolor" + }); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'IllustrationExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/illustration/__examples__/large-image-text.js b/components/illustration/__examples__/large-image-text.js new file mode 100644 index 0000000000..c14ec97b50 --- /dev/null +++ b/components/illustration/__examples__/large-image-text.js @@ -0,0 +1,63 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _illustration = _interopRequireDefault(require("../../../../components/illustration")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_illustration.default, { + heading: "Lorem ipsum dolor", + messageBody: "Lorem ipsum dolor sit amet, consectetur", + name: "No Access", + path: "/assets/images/illustrations/empty-state-no-access.svg#no-access", + size: "large" + }); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'IllustrationExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/illustration/__examples__/message-only.js b/components/illustration/__examples__/message-only.js new file mode 100644 index 0000000000..25280af376 --- /dev/null +++ b/components/illustration/__examples__/message-only.js @@ -0,0 +1,59 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _illustration = _interopRequireDefault(require("../../../../components/illustration")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_illustration.default, { + messageBody: "Lorem ipsum dolor sit amet, consectetur" + }); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'IllustrationExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/illustration/__examples__/small-image-text.js b/components/illustration/__examples__/small-image-text.js new file mode 100644 index 0000000000..4a067c0c89 --- /dev/null +++ b/components/illustration/__examples__/small-image-text.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _illustration = _interopRequireDefault(require("../../../../components/illustration")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_illustration.default, { + heading: "Lorem ipsum dolor", + messageBody: "Lorem ipsum dolor sit amet, consectetur", + name: "No Access", + path: "/assets/images/illustrations/empty-state-no-access.svg#no-access" + }); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'IllustrationExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/illustration/check-props.js b/components/illustration/check-props.js new file mode 100644 index 0000000000..7ebf395370 --- /dev/null +++ b/components/illustration/check-props.js @@ -0,0 +1,51 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _oneOfRequiredProperty = _interopRequireDefault(require("../../utilities/warning/one-of-required-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ + +/* import deprecatedPropertyValue from '../../utilities/warning/deprecated-property-value'; */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + /** + * If illustration SVGs are added to SLDS in the future, we will deprecate the value + * of internalIllustration being true and give a warning. + * + if (props.internalIllustration) { + deprecatedPropertyValue(COMPONENT, { + propAsString: 'internalIllustration', + propValue: props.internalIllustration, + deprecatedPropValue: true, + replacementPropAsValue: false, + }, + 'Using illustration SVGs from inside this repo is deprecated. Please update your assets/images path to use the SVGs found in the @salesforce/design-system npm module.'); + } + */ + + if (props.illustration || props.path) { + // An illustration image must be accompanied with a heading text + (0, _oneOfRequiredProperty.default)(COMPONENT, { + heading: props.heading + }, createDocUrl('heading')); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/illustration/docs.json b/components/illustration/docs.json new file mode 100644 index 0000000000..1c8e5988f8 --- /dev/null +++ b/components/illustration/docs.json @@ -0,0 +1,7 @@ +{ + "component": "illustration", + "status": "prod", + "display-name": "Illustrations", + "SLDS-component-path": "/components/illustration", + "url-slug": "illustrations" +} \ No newline at end of file diff --git a/components/illustration/index.js b/components/illustration/index.js new file mode 100644 index 0000000000..33843f8cc5 --- /dev/null +++ b/components/illustration/index.js @@ -0,0 +1,156 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _classNames = _interopRequireDefault(require("../../utilities/class-names")); + +var _svg = _interopRequireDefault(require("../utilities/utility-icon/svg")); + +var _constants = require("../../utilities/constants"); + +var _docs = _interopRequireDefault(require("./docs.json")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// # Illustration Component +// Based on SLDS v2.6.2 +// ## Dependencies +// ### React +// This component's `checkProps` which issues warnings to developers about properties +// when in development mode (similar to React's built in development tools) +// ### classNames +// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames) +// A simple javascript utility for conditionally joining classNames together. +// ## SVG +// ## Constants + +/** + * An illustration is an image and inline text that work in tandem to communicate a state in a more friendly way. + */ +var Illustration = function Illustration(_ref) { + var className = _ref.className, + illustration = _ref.illustration, + internalIllustration = _ref.internalIllustration, + heading = _ref.heading, + messageBody = _ref.messageBody, + name = _ref.name, + path = _ref.path, + size = _ref.size, + style = _ref.style; + (0, _checkProps.default)('Illustration', { + illustration: illustration, + internalIllustration: internalIllustration, + heading: heading, + path: path + }, _docs.default); + var kababCaseName = name ? name.replace(/_| /g, '-').toLowerCase() : ''; + var illustrationSvg; + + if (illustration) { + // Use SVG data passed in with `illustration` prop + illustrationSvg = _react.default.createElement(_svg.default, { + className: "slds-illustration__svg", + "aria-hidden": "true", + data: illustration, + name: kababCaseName, + style: style + }); + } else if (path) { + illustrationSvg = _react.default.createElement("svg", { + className: "slds-illustration__svg", + "aria-hidden": "true", + name: kababCaseName, + style: style + }, _react.default.createElement("use", { + xlinkHref: path + })); + } // large illustration svg should have a default height of 400px if not already specified + + + if (illustrationSvg && size === 'large' && !style.height) { + style.height = '400px'; + } + + return _react.default.createElement("div", { + className: (0, _classNames.default)(className, 'slds-illustration', { + 'slds-illustration_small': size === 'small', + 'slds-illustration_large': size === 'large' + }) + }, illustrationSvg, _react.default.createElement("div", { + className: "slds-text-longform" + }, heading ? _react.default.createElement("h3", { + className: "slds-text-heading_medium" + }, heading) : null, messageBody ? _react.default.createElement("p", { + className: "slds-text-body_regular" + }, messageBody) : null)); +}; // ### Display Name +// Always use the canonical component name as the React display name. + + +Illustration.displayName = _constants.ILLUSTRATION; // ### Prop Types + +Illustration.propTypes = { + /** + * CSS classes that are applied to the SVG. _Tested with Mocha testing._ + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * A heading text. It is required if illustration is present. _Tested with snapshot testing._ _Tested with Mocha testing._ + */ + heading: _propTypes.default.string, + + /** + * A custom SVG object to use instead of the supplied SLDS illustrations, look in `design-system-react/icons` for examples and syntax. _Tested with snapshot testing._ _Tested with Mocha testing._ + */ + illustration: _propTypes.default.object, + + /** + * Indicates whether the illustration SVGs are from the design-system-react repo. If yes, set to true. + */ + internalIllustration: _propTypes.default.bool.isRequired, + + /** + * A message body below the heading to further communicate the state of the component. _Tested with snapshot testing._ _Tested with Mocha testing._ + */ + messageBody: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]), + + /** + * Name of the illustration. Visit Lightning Design System Illustration to reference illustration names. _Tested with snapshot testing._ _Tested with Mocha testing._ + */ + name: _propTypes.default.string, + + /** + * Path to the illustration SVG image. _Tested with snapshot testing._ + */ + path: _propTypes.default.string, + + /** + * Size of the illustration. _Tested with snapshot testing._ _Tested with Mocha testing._ + */ + size: _propTypes.default.oneOf(['small', 'large']), + + /** + * Custom styles to be passed to the illustration SVG. _Tested with Mocha testing._ + */ + style: _propTypes.default.object +}; +Illustration.defaultProps = { + internalIllustration: true, + size: 'small', + style: {} +}; +var _default = Illustration; +exports.default = _default; \ No newline at end of file diff --git a/components/index.js b/components/index.js new file mode 100644 index 0000000000..116af4e3bc --- /dev/null +++ b/components/index.js @@ -0,0 +1,1387 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "SLDSSettings", { + enumerable: true, + get: function get() { + return _settings.default; + } +}); +Object.defineProperty(exports, "Settings", { + enumerable: true, + get: function get() { + return _settings.default; + } +}); +Object.defineProperty(exports, "SLDSIconSettings", { + enumerable: true, + get: function get() { + return _iconSettings.default; + } +}); +Object.defineProperty(exports, "IconSettings", { + enumerable: true, + get: function get() { + return _iconSettings.default; + } +}); +Object.defineProperty(exports, "SLDSAccordion", { + enumerable: true, + get: function get() { + return _accordion.default; + } +}); +Object.defineProperty(exports, "Accordion", { + enumerable: true, + get: function get() { + return _accordion.default; + } +}); +Object.defineProperty(exports, "SLDSAccordionPanel", { + enumerable: true, + get: function get() { + return _panel.default; + } +}); +Object.defineProperty(exports, "AccordionPanel", { + enumerable: true, + get: function get() { + return _panel.default; + } +}); +Object.defineProperty(exports, "SLDSAlert", { + enumerable: true, + get: function get() { + return _alert.default; + } +}); +Object.defineProperty(exports, "Alert", { + enumerable: true, + get: function get() { + return _alert.default; + } +}); +Object.defineProperty(exports, "SLDSAlertContainer", { + enumerable: true, + get: function get() { + return _container.default; + } +}); +Object.defineProperty(exports, "AlertContainer", { + enumerable: true, + get: function get() { + return _container.default; + } +}); +Object.defineProperty(exports, "SLDSAppLauncher", { + enumerable: true, + get: function get() { + return _appLauncher.default; + } +}); +Object.defineProperty(exports, "AppLauncher", { + enumerable: true, + get: function get() { + return _appLauncher.default; + } +}); +Object.defineProperty(exports, "SLDSAppLauncherTile", { + enumerable: true, + get: function get() { + return _tile.default; + } +}); +Object.defineProperty(exports, "AppLauncherTile", { + enumerable: true, + get: function get() { + return _tile.default; + } +}); +Object.defineProperty(exports, "SLDSAppLauncherSection", { + enumerable: true, + get: function get() { + return _section.default; + } +}); +Object.defineProperty(exports, "AppLauncherSection", { + enumerable: true, + get: function get() { + return _section.default; + } +}); +Object.defineProperty(exports, "SLDSAvatar", { + enumerable: true, + get: function get() { + return _avatar.default; + } +}); +Object.defineProperty(exports, "Avatar", { + enumerable: true, + get: function get() { + return _avatar.default; + } +}); +Object.defineProperty(exports, "SLDSBrandBand", { + enumerable: true, + get: function get() { + return _brandBand.default; + } +}); +Object.defineProperty(exports, "BrandBand", { + enumerable: true, + get: function get() { + return _brandBand.default; + } +}); +Object.defineProperty(exports, "SLDSButton", { + enumerable: true, + get: function get() { + return _button.default; + } +}); +Object.defineProperty(exports, "Button", { + enumerable: true, + get: function get() { + return _button.default; + } +}); +Object.defineProperty(exports, "SLDSButtonGroup", { + enumerable: true, + get: function get() { + return _buttonGroup.default; + } +}); +Object.defineProperty(exports, "ButtonGroup", { + enumerable: true, + get: function get() { + return _buttonGroup.default; + } +}); +Object.defineProperty(exports, "SLDSButtonStateful", { + enumerable: true, + get: function get() { + return _buttonStateful.default; + } +}); +Object.defineProperty(exports, "ButtonStateful", { + enumerable: true, + get: function get() { + return _buttonStateful.default; + } +}); +Object.defineProperty(exports, "SLDSBreadCrumb", { + enumerable: true, + get: function get() { + return _breadcrumb.default; + } +}); +Object.defineProperty(exports, "BreadCrumb", { + enumerable: true, + get: function get() { + return _breadcrumb.default; + } +}); +Object.defineProperty(exports, "SLDSBreadcrumb", { + enumerable: true, + get: function get() { + return _breadcrumb.default; + } +}); +Object.defineProperty(exports, "Breadcrumb", { + enumerable: true, + get: function get() { + return _breadcrumb.default; + } +}); +Object.defineProperty(exports, "SLDSCard", { + enumerable: true, + get: function get() { + return _card.default; + } +}); +Object.defineProperty(exports, "Card", { + enumerable: true, + get: function get() { + return _card.default; + } +}); +Object.defineProperty(exports, "SLDSCardEmpty", { + enumerable: true, + get: function get() { + return _empty.default; + } +}); +Object.defineProperty(exports, "CardEmpty", { + enumerable: true, + get: function get() { + return _empty.default; + } +}); +Object.defineProperty(exports, "SLDSCardFilter", { + enumerable: true, + get: function get() { + return _filter.default; + } +}); +Object.defineProperty(exports, "CardFilter", { + enumerable: true, + get: function get() { + return _filter.default; + } +}); +Object.defineProperty(exports, "SLDSCarousel", { + enumerable: true, + get: function get() { + return _carousel.default; + } +}); +Object.defineProperty(exports, "Carousel", { + enumerable: true, + get: function get() { + return _carousel.default; + } +}); +Object.defineProperty(exports, "SLDSCheckbox", { + enumerable: true, + get: function get() { + return _checkbox.default; + } +}); +Object.defineProperty(exports, "Checkbox", { + enumerable: true, + get: function get() { + return _checkbox.default; + } +}); +Object.defineProperty(exports, "SLDSColorPicker", { + enumerable: true, + get: function get() { + return _colorPicker.default; + } +}); +Object.defineProperty(exports, "ColorPicker", { + enumerable: true, + get: function get() { + return _colorPicker.default; + } +}); +Object.defineProperty(exports, "SLDSCombobox", { + enumerable: true, + get: function get() { + return _combobox.default; + } +}); +Object.defineProperty(exports, "Combobox", { + enumerable: true, + get: function get() { + return _combobox.default; + } +}); +Object.defineProperty(exports, "SLDSComboboxFilterAndLimit", { + enumerable: true, + get: function get() { + return _filter2.default; + } +}); +Object.defineProperty(exports, "comboboxFilterAndLimit", { + enumerable: true, + get: function get() { + return _filter2.default; + } +}); +Object.defineProperty(exports, "comboboxAddSubheadings", { + enumerable: true, + get: function get() { + return _addSubheadings.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalHeader", { + enumerable: true, + get: function get() { + return _globalHeader.default; + } +}); +Object.defineProperty(exports, "GlobalHeader", { + enumerable: true, + get: function get() { + return _globalHeader.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalHeaderButton", { + enumerable: true, + get: function get() { + return _button2.default; + } +}); +Object.defineProperty(exports, "GlobalHeaderButton", { + enumerable: true, + get: function get() { + return _button2.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalHeaderDropdown", { + enumerable: true, + get: function get() { + return _dropdown.default; + } +}); +Object.defineProperty(exports, "GlobalHeaderDropdown", { + enumerable: true, + get: function get() { + return _dropdown.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalHeaderFavorites", { + enumerable: true, + get: function get() { + return _favorites.default; + } +}); +Object.defineProperty(exports, "GlobalHeaderFavorites", { + enumerable: true, + get: function get() { + return _favorites.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalHeaderHelp", { + enumerable: true, + get: function get() { + return _help.default; + } +}); +Object.defineProperty(exports, "GlobalHeaderHelp", { + enumerable: true, + get: function get() { + return _help.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalHeaderNotifications", { + enumerable: true, + get: function get() { + return _notifications.default; + } +}); +Object.defineProperty(exports, "GlobalHeaderNotifications", { + enumerable: true, + get: function get() { + return _notifications.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalHeaderProfile", { + enumerable: true, + get: function get() { + return _profile.default; + } +}); +Object.defineProperty(exports, "GlobalHeaderProfile", { + enumerable: true, + get: function get() { + return _profile.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalHeaderSearch", { + enumerable: true, + get: function get() { + return _search.default; + } +}); +Object.defineProperty(exports, "GlobalHeaderSearch", { + enumerable: true, + get: function get() { + return _search.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalHeaderSetup", { + enumerable: true, + get: function get() { + return _setup.default; + } +}); +Object.defineProperty(exports, "GlobalHeaderSetup", { + enumerable: true, + get: function get() { + return _setup.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalHeaderTask", { + enumerable: true, + get: function get() { + return _task.default; + } +}); +Object.defineProperty(exports, "GlobalHeaderTask", { + enumerable: true, + get: function get() { + return _task.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalNavigationBar", { + enumerable: true, + get: function get() { + return _globalNavigationBar.default; + } +}); +Object.defineProperty(exports, "GlobalNavigationBar", { + enumerable: true, + get: function get() { + return _globalNavigationBar.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalNavigationBarRegion", { + enumerable: true, + get: function get() { + return _region.default; + } +}); +Object.defineProperty(exports, "GlobalNavigationBarRegion", { + enumerable: true, + get: function get() { + return _region.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalNavigationBarLink", { + enumerable: true, + get: function get() { + return _link.default; + } +}); +Object.defineProperty(exports, "GlobalNavigationBarLink", { + enumerable: true, + get: function get() { + return _link.default; + } +}); +Object.defineProperty(exports, "SLDSGlobalNavigationBarDropdown", { + enumerable: true, + get: function get() { + return _dropdown2.default; + } +}); +Object.defineProperty(exports, "GlobalNavigationBarDropdown", { + enumerable: true, + get: function get() { + return _dropdown2.default; + } +}); +Object.defineProperty(exports, "SLDSDataTable", { + enumerable: true, + get: function get() { + return _dataTable.default; + } +}); +Object.defineProperty(exports, "DataTable", { + enumerable: true, + get: function get() { + return _dataTable.default; + } +}); +Object.defineProperty(exports, "SLDSDataTableCell", { + enumerable: true, + get: function get() { + return _cell.default; + } +}); +Object.defineProperty(exports, "DataTableCell", { + enumerable: true, + get: function get() { + return _cell.default; + } +}); +Object.defineProperty(exports, "SLDSDataTableHighlightCell", { + enumerable: true, + get: function get() { + return _highlightCell.default; + } +}); +Object.defineProperty(exports, "DataTableHighlightCell", { + enumerable: true, + get: function get() { + return _highlightCell.default; + } +}); +Object.defineProperty(exports, "SLDSDataTableColumn", { + enumerable: true, + get: function get() { + return _column.default; + } +}); +Object.defineProperty(exports, "DataTableColumn", { + enumerable: true, + get: function get() { + return _column.default; + } +}); +Object.defineProperty(exports, "SLDSDataTableRowActions", { + enumerable: true, + get: function get() { + return _rowActions.default; + } +}); +Object.defineProperty(exports, "DataTableRowActions", { + enumerable: true, + get: function get() { + return _rowActions.default; + } +}); +Object.defineProperty(exports, "SLDSDatepicker", { + enumerable: true, + get: function get() { + return _datePicker.default; + } +}); +Object.defineProperty(exports, "Datepicker", { + enumerable: true, + get: function get() { + return _datePicker.default; + } +}); +Object.defineProperty(exports, "SLDSIcon", { + enumerable: true, + get: function get() { + return _icon.default; + } +}); +Object.defineProperty(exports, "Icon", { + enumerable: true, + get: function get() { + return _icon.default; + } +}); +Object.defineProperty(exports, "SLDSIllustration", { + enumerable: true, + get: function get() { + return _illustration.default; + } +}); +Object.defineProperty(exports, "Illustration", { + enumerable: true, + get: function get() { + return _illustration.default; + } +}); +Object.defineProperty(exports, "SLDSButtonIcon", { + enumerable: true, + get: function get() { + return _buttonIcon.default; + } +}); +Object.defineProperty(exports, "ButtonIcon", { + enumerable: true, + get: function get() { + return _buttonIcon.default; + } +}); +Object.defineProperty(exports, "SLDSFilter", { + enumerable: true, + get: function get() { + return _filter3.default; + } +}); +Object.defineProperty(exports, "Filter", { + enumerable: true, + get: function get() { + return _filter3.default; + } +}); +Object.defineProperty(exports, "SLDSInlineEdit", { + enumerable: true, + get: function get() { + return _inline.default; + } +}); +Object.defineProperty(exports, "InlineEdit", { + enumerable: true, + get: function get() { + return _inline.default; + } +}); +Object.defineProperty(exports, "SLDSInput", { + enumerable: true, + get: function get() { + return _input.default; + } +}); +Object.defineProperty(exports, "Input", { + enumerable: true, + get: function get() { + return _input.default; + } +}); +Object.defineProperty(exports, "SLDSSearch", { + enumerable: true, + get: function get() { + return _search2.default; + } +}); +Object.defineProperty(exports, "Search", { + enumerable: true, + get: function get() { + return _search2.default; + } +}); +Object.defineProperty(exports, "SLDSInputIcon", { + enumerable: true, + get: function get() { + return _inputIcon.default; + } +}); +Object.defineProperty(exports, "InputIcon", { + enumerable: true, + get: function get() { + return _inputIcon.default; + } +}); +Object.defineProperty(exports, "SLDSLookup", { + enumerable: true, + get: function get() { + return _lookup.default; + } +}); +Object.defineProperty(exports, "Lookup", { + enumerable: true, + get: function get() { + return _lookup.default; + } +}); +Object.defineProperty(exports, "SLDSLookupDefaultFooter", { + enumerable: true, + get: function get() { + return _defaultFooter.default; + } +}); +Object.defineProperty(exports, "LookupDefaultFooter", { + enumerable: true, + get: function get() { + return _defaultFooter.default; + } +}); +Object.defineProperty(exports, "SLDSLookupDefaultHeader", { + enumerable: true, + get: function get() { + return _defaultHeader.default; + } +}); +Object.defineProperty(exports, "LookupDefaultHeader", { + enumerable: true, + get: function get() { + return _defaultHeader.default; + } +}); +Object.defineProperty(exports, "SLDSLookupDefaultSectionDivider", { + enumerable: true, + get: function get() { + return _defaultSectionDivider.default; + } +}); +Object.defineProperty(exports, "LookupDefaultSectionDivider", { + enumerable: true, + get: function get() { + return _defaultSectionDivider.default; + } +}); +Object.defineProperty(exports, "SLDSMediaObject", { + enumerable: true, + get: function get() { + return _mediaObject.default; + } +}); +Object.defineProperty(exports, "MediaObject", { + enumerable: true, + get: function get() { + return _mediaObject.default; + } +}); +Object.defineProperty(exports, "SLDSMenuDropdown", { + enumerable: true, + get: function get() { + return _menuDropdown.default; + } +}); +Object.defineProperty(exports, "Dropdown", { + enumerable: true, + get: function get() { + return _menuDropdown.default; + } +}); +Object.defineProperty(exports, "SLDSDropdownTrigger", { + enumerable: true, + get: function get() { + return _buttonTrigger.default; + } +}); +Object.defineProperty(exports, "DropdownTrigger", { + enumerable: true, + get: function get() { + return _buttonTrigger.default; + } +}); +Object.defineProperty(exports, "SLDSMenuPicklist", { + enumerable: true, + get: function get() { + return _menuPicklist.default; + } +}); +Object.defineProperty(exports, "Picklist", { + enumerable: true, + get: function get() { + return _menuPicklist.default; + } +}); +Object.defineProperty(exports, "SLDSModal", { + enumerable: true, + get: function get() { + return _modal.default; + } +}); +Object.defineProperty(exports, "Modal", { + enumerable: true, + get: function get() { + return _modal.default; + } +}); +Object.defineProperty(exports, "SLDSModalTrigger", { + enumerable: true, + get: function get() { + return _trigger.default; + } +}); +Object.defineProperty(exports, "ModalTrigger", { + enumerable: true, + get: function get() { + return _trigger.default; + } +}); +Object.defineProperty(exports, "SLDSNavigation", { + enumerable: true, + get: function get() { + return _verticalNavigation.default; + } +}); +Object.defineProperty(exports, "Navigation", { + enumerable: true, + get: function get() { + return _verticalNavigation.default; + } +}); +Object.defineProperty(exports, "SLDSVerticalNavigation", { + enumerable: true, + get: function get() { + return _verticalNavigation.default; + } +}); +Object.defineProperty(exports, "VerticalNavigation", { + enumerable: true, + get: function get() { + return _verticalNavigation.default; + } +}); +Object.defineProperty(exports, "SLDSNotification", { + enumerable: true, + get: function get() { + return _notification.default; + } +}); +Object.defineProperty(exports, "Notification", { + enumerable: true, + get: function get() { + return _notification.default; + } +}); +Object.defineProperty(exports, "SLDSPanel", { + enumerable: true, + get: function get() { + return _panel2.default; + } +}); +Object.defineProperty(exports, "Panel", { + enumerable: true, + get: function get() { + return _panel2.default; + } +}); +Object.defineProperty(exports, "SLDSPanelFilterGroup", { + enumerable: true, + get: function get() { + return _group.default; + } +}); +Object.defineProperty(exports, "PanelFilterGroup", { + enumerable: true, + get: function get() { + return _group.default; + } +}); +Object.defineProperty(exports, "SLDSPanelFilterList", { + enumerable: true, + get: function get() { + return _list.default; + } +}); +Object.defineProperty(exports, "PanelFilterList", { + enumerable: true, + get: function get() { + return _list.default; + } +}); +Object.defineProperty(exports, "SLDSPanelFilterListHeading", { + enumerable: true, + get: function get() { + return _listHeading.default; + } +}); +Object.defineProperty(exports, "PanelFilterListHeading", { + enumerable: true, + get: function get() { + return _listHeading.default; + } +}); +Object.defineProperty(exports, "SLDSPageHeader", { + enumerable: true, + get: function get() { + return _pageHeader.default; + } +}); +Object.defineProperty(exports, "PageHeader", { + enumerable: true, + get: function get() { + return _pageHeader.default; + } +}); +Object.defineProperty(exports, "SLDSPill", { + enumerable: true, + get: function get() { + return _pill.default; + } +}); +Object.defineProperty(exports, "Pill", { + enumerable: true, + get: function get() { + return _pill.default; + } +}); +Object.defineProperty(exports, "SLDSPillContainer", { + enumerable: true, + get: function get() { + return _pillContainer.default; + } +}); +Object.defineProperty(exports, "PillContainer", { + enumerable: true, + get: function get() { + return _pillContainer.default; + } +}); +Object.defineProperty(exports, "SLDSPopover", { + enumerable: true, + get: function get() { + return _popover.default; + } +}); +Object.defineProperty(exports, "Popover", { + enumerable: true, + get: function get() { + return _popover.default; + } +}); +Object.defineProperty(exports, "SLDSPopoverTooltip", { + enumerable: true, + get: function get() { + return _tooltip.default; + } +}); +Object.defineProperty(exports, "PopoverTooltip", { + enumerable: true, + get: function get() { + return _tooltip.default; + } +}); +Object.defineProperty(exports, "SLDSTooltip", { + enumerable: true, + get: function get() { + return _tooltip.default; + } +}); +Object.defineProperty(exports, "Tooltip", { + enumerable: true, + get: function get() { + return _tooltip.default; + } +}); +Object.defineProperty(exports, "SLDSEditDialog", { + enumerable: true, + get: function get() { + return _editDialog.default; + } +}); +Object.defineProperty(exports, "EditDialog", { + enumerable: true, + get: function get() { + return _editDialog.default; + } +}); +Object.defineProperty(exports, "SLDSProgressBar", { + enumerable: true, + get: function get() { + return _progressBar.default; + } +}); +Object.defineProperty(exports, "ProgressBar", { + enumerable: true, + get: function get() { + return _progressBar.default; + } +}); +Object.defineProperty(exports, "SLDSProgressIndicator", { + enumerable: true, + get: function get() { + return _progressIndicator.default; + } +}); +Object.defineProperty(exports, "ProgressIndicator", { + enumerable: true, + get: function get() { + return _progressIndicator.default; + } +}); +Object.defineProperty(exports, "SLDSProgressRing", { + enumerable: true, + get: function get() { + return _progressRing.default; + } +}); +Object.defineProperty(exports, "ProgressRing", { + enumerable: true, + get: function get() { + return _progressRing.default; + } +}); +Object.defineProperty(exports, "SLDSRadio", { + enumerable: true, + get: function get() { + return _radio.default; + } +}); +Object.defineProperty(exports, "Radio", { + enumerable: true, + get: function get() { + return _radio.default; + } +}); +Object.defineProperty(exports, "SLDSRadioButtonGroup", { + enumerable: true, + get: function get() { + return _radioButtonGroup.default; + } +}); +Object.defineProperty(exports, "RadioButtonGroup", { + enumerable: true, + get: function get() { + return _radioButtonGroup.default; + } +}); +Object.defineProperty(exports, "SLDSRadioGroup", { + enumerable: true, + get: function get() { + return _radioGroup.default; + } +}); +Object.defineProperty(exports, "RadioGroup", { + enumerable: true, + get: function get() { + return _radioGroup.default; + } +}); +Object.defineProperty(exports, "SLDSScopedNotification", { + enumerable: true, + get: function get() { + return _scopedNotification.default; + } +}); +Object.defineProperty(exports, "ScopedNotification", { + enumerable: true, + get: function get() { + return _scopedNotification.default; + } +}); +Object.defineProperty(exports, "SLDSSlider", { + enumerable: true, + get: function get() { + return _slider.default; + } +}); +Object.defineProperty(exports, "Slider", { + enumerable: true, + get: function get() { + return _slider.default; + } +}); +Object.defineProperty(exports, "SLDSSpinner", { + enumerable: true, + get: function get() { + return _spinner.default; + } +}); +Object.defineProperty(exports, "Spinner", { + enumerable: true, + get: function get() { + return _spinner.default; + } +}); +Object.defineProperty(exports, "SLDSSplitview", { + enumerable: true, + get: function get() { + return _splitView.default; + } +}); +Object.defineProperty(exports, "Splitview", { + enumerable: true, + get: function get() { + return _splitView.default; + } +}); +Object.defineProperty(exports, "SLDSSplitView", { + enumerable: true, + get: function get() { + return _splitView.default; + } +}); +Object.defineProperty(exports, "SplitView", { + enumerable: true, + get: function get() { + return _splitView.default; + } +}); +Object.defineProperty(exports, "SLDSSplitViewHeader", { + enumerable: true, + get: function get() { + return _header.default; + } +}); +Object.defineProperty(exports, "SplitViewHeader", { + enumerable: true, + get: function get() { + return _header.default; + } +}); +Object.defineProperty(exports, "SLDSSplitViewListbox", { + enumerable: true, + get: function get() { + return _listbox.default; + } +}); +Object.defineProperty(exports, "SplitViewListbox", { + enumerable: true, + get: function get() { + return _listbox.default; + } +}); +Object.defineProperty(exports, "SLDSTextarea", { + enumerable: true, + get: function get() { + return _textarea.default; + } +}); +Object.defineProperty(exports, "Textarea", { + enumerable: true, + get: function get() { + return _textarea.default; + } +}); +Object.defineProperty(exports, "SLDSTimepicker", { + enumerable: true, + get: function get() { + return _timePicker.default; + } +}); +Object.defineProperty(exports, "Timepicker", { + enumerable: true, + get: function get() { + return _timePicker.default; + } +}); +Object.defineProperty(exports, "SLDSTabs", { + enumerable: true, + get: function get() { + return _tabs.default; + } +}); +Object.defineProperty(exports, "Tabs", { + enumerable: true, + get: function get() { + return _tabs.default; + } +}); +Object.defineProperty(exports, "SLDSTabsPanel", { + enumerable: true, + get: function get() { + return _panel3.default; + } +}); +Object.defineProperty(exports, "TabsPanel", { + enumerable: true, + get: function get() { + return _panel3.default; + } +}); +Object.defineProperty(exports, "SLDSToast", { + enumerable: true, + get: function get() { + return _toast.default; + } +}); +Object.defineProperty(exports, "Toast", { + enumerable: true, + get: function get() { + return _toast.default; + } +}); +Object.defineProperty(exports, "SLDSToastContainer", { + enumerable: true, + get: function get() { + return _container2.default; + } +}); +Object.defineProperty(exports, "ToastContainer", { + enumerable: true, + get: function get() { + return _container2.default; + } +}); +Object.defineProperty(exports, "SLDSUtilityIcon", { + enumerable: true, + get: function get() { + return _utilityIcon.default; + } +}); +Object.defineProperty(exports, "UtilityIcon", { + enumerable: true, + get: function get() { + return _utilityIcon.default; + } +}); +Object.defineProperty(exports, "SLDSTree", { + enumerable: true, + get: function get() { + return _tree.default; + } +}); +Object.defineProperty(exports, "Tree", { + enumerable: true, + get: function get() { + return _tree.default; + } +}); +Object.defineProperty(exports, "SLDSDynamicIcon", { + enumerable: true, + get: function get() { + return _dynamicIcon.default; + } +}); +Object.defineProperty(exports, "DynamicIcon", { + enumerable: true, + get: function get() { + return _dynamicIcon.default; + } +}); +Object.defineProperty(exports, "log", { + enumerable: true, + get: function get() { + return _log2.default; + } +}); + +var _settings = _interopRequireDefault(require("./settings")); + +var _iconSettings = _interopRequireDefault(require("./icon-settings")); + +var _accordion = _interopRequireDefault(require("./accordion")); + +var _panel = _interopRequireDefault(require("./accordion/panel")); + +var _alert = _interopRequireDefault(require("./alert")); + +var _container = _interopRequireDefault(require("./alert/container")); + +var _appLauncher = _interopRequireDefault(require("./app-launcher")); + +var _tile = _interopRequireDefault(require("./app-launcher/tile")); + +var _section = _interopRequireDefault(require("./app-launcher/section")); + +var _avatar = _interopRequireDefault(require("./avatar")); + +var _brandBand = _interopRequireDefault(require("./brand-band")); + +var _button = _interopRequireDefault(require("./button")); + +var _buttonGroup = _interopRequireDefault(require("./button-group")); + +var _buttonStateful = _interopRequireDefault(require("./button-stateful")); + +var _breadcrumb = _interopRequireDefault(require("./breadcrumb")); + +var _card = _interopRequireDefault(require("./card")); + +var _empty = _interopRequireDefault(require("./card/empty")); + +var _filter = _interopRequireDefault(require("./card/filter")); + +var _carousel = _interopRequireDefault(require("./carousel")); + +var _checkbox = _interopRequireDefault(require("./forms/checkbox")); + +var _colorPicker = _interopRequireDefault(require("./color-picker")); + +var _combobox = _interopRequireDefault(require("./combobox")); + +var _filter2 = _interopRequireDefault(require("./combobox/filter")); + +var _addSubheadings = _interopRequireDefault(require("./combobox/add-subheadings")); + +var _globalHeader = _interopRequireDefault(require("./global-header")); + +var _button2 = _interopRequireDefault(require("./global-header/button")); + +var _dropdown = _interopRequireDefault(require("./global-header/dropdown")); + +var _favorites = _interopRequireDefault(require("./global-header/favorites")); + +var _help = _interopRequireDefault(require("./global-header/help")); + +var _notifications = _interopRequireDefault(require("./global-header/notifications")); + +var _profile = _interopRequireDefault(require("./global-header/profile")); + +var _search = _interopRequireDefault(require("./global-header/search")); + +var _setup = _interopRequireDefault(require("./global-header/setup")); + +var _task = _interopRequireDefault(require("./global-header/task")); + +var _globalNavigationBar = _interopRequireDefault(require("./global-navigation-bar")); + +var _region = _interopRequireDefault(require("./global-navigation-bar/region")); + +var _link = _interopRequireDefault(require("./global-navigation-bar/link")); + +var _dropdown2 = _interopRequireDefault(require("./global-navigation-bar/dropdown")); + +var _dataTable = _interopRequireDefault(require("./data-table")); + +var _cell = _interopRequireDefault(require("./data-table/cell")); + +var _highlightCell = _interopRequireDefault(require("./data-table/highlight-cell")); + +var _column = _interopRequireDefault(require("./data-table/column")); + +var _rowActions = _interopRequireDefault(require("./data-table/row-actions")); + +var _datePicker = _interopRequireDefault(require("./date-picker")); + +var _icon = _interopRequireDefault(require("./icon")); + +var _illustration = _interopRequireDefault(require("./illustration")); + +var _buttonIcon = _interopRequireDefault(require("./icon/button-icon")); + +var _filter3 = _interopRequireDefault(require("./filter")); + +var _inline = _interopRequireDefault(require("./forms/input/inline")); + +var _input = _interopRequireDefault(require("./input")); + +var _search2 = _interopRequireDefault(require("./input/search")); + +var _inputIcon = _interopRequireDefault(require("./icon/input-icon")); + +var _lookup = _interopRequireDefault(require("./lookup")); + +var _defaultFooter = _interopRequireDefault(require("./lookup/menu/default-footer")); + +var _defaultHeader = _interopRequireDefault(require("./lookup/menu/default-header")); + +var _defaultSectionDivider = _interopRequireDefault(require("./lookup/menu/default-section-divider")); + +var _mediaObject = _interopRequireDefault(require("./media-object")); + +var _menuDropdown = _interopRequireDefault(require("./menu-dropdown")); + +var _buttonTrigger = _interopRequireDefault(require("./menu-dropdown/button-trigger")); + +var _menuPicklist = _interopRequireDefault(require("./menu-picklist")); + +var _modal = _interopRequireDefault(require("./modal")); + +var _trigger = _interopRequireDefault(require("./modal/trigger")); + +var _verticalNavigation = _interopRequireDefault(require("./vertical-navigation")); + +var _notification = _interopRequireDefault(require("./notification")); + +var _panel2 = _interopRequireDefault(require("./panel")); + +var _group = _interopRequireDefault(require("./panel/filtering/group")); + +var _list = _interopRequireDefault(require("./panel/filtering/list")); + +var _listHeading = _interopRequireDefault(require("./panel/filtering/list-heading")); + +var _pageHeader = _interopRequireDefault(require("./page-header")); + +var _pill = _interopRequireDefault(require("./pill")); + +var _pillContainer = _interopRequireDefault(require("./pill-container")); + +var _popover = _interopRequireDefault(require("./popover")); + +var _tooltip = _interopRequireDefault(require("./tooltip")); + +var _editDialog = _interopRequireDefault(require("./popover/edit-dialog")); + +var _progressBar = _interopRequireDefault(require("./progress-bar")); + +var _progressIndicator = _interopRequireDefault(require("./progress-indicator")); + +var _progressRing = _interopRequireDefault(require("./progress-ring")); + +var _radio = _interopRequireDefault(require("./radio")); + +var _radioButtonGroup = _interopRequireDefault(require("./radio-button-group")); + +var _radioGroup = _interopRequireDefault(require("./radio-group")); + +var _scopedNotification = _interopRequireDefault(require("./scoped-notification")); + +var _slider = _interopRequireDefault(require("./slider")); + +var _spinner = _interopRequireDefault(require("./spinner")); + +var _splitView = _interopRequireDefault(require("./split-view")); + +var _header = _interopRequireDefault(require("./split-view/header")); + +var _listbox = _interopRequireDefault(require("./split-view/listbox")); + +var _textarea = _interopRequireDefault(require("./textarea")); + +var _timePicker = _interopRequireDefault(require("./time-picker")); + +var _tabs = _interopRequireDefault(require("./tabs")); + +var _panel3 = _interopRequireDefault(require("./tabs/panel")); + +var _toast = _interopRequireDefault(require("./toast")); + +var _container2 = _interopRequireDefault(require("./toast/container")); + +var _utilityIcon = _interopRequireDefault(require("./utilities/utility-icon")); + +var _tree = _interopRequireDefault(require("./tree")); + +var _dynamicIcon = _interopRequireDefault(require("./dynamic-icon")); + +var _log2 = _interopRequireDefault(require("../utilities/log")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/components/input/__docs__/__snapshots__/storybook-stories.storyshot b/components/input/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..1f1df4576b --- /dev/null +++ b/components/input/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,1960 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSInput Base 1`] = ` +
    +
    +
      +
    1. +

      + 1. Base Input with visible label +

      +
      + +
      + +
      +
      +
    2. +
    3. +

      + 2. Base Input with hidden label (assistive text) +

      +
      + +
      + +
      +
      +
    4. +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Base with Icons 1`] = ` +
    +
    +
      +
    1. +

      + 1. Base Input with left icon +

      +
      + +
      + + + + +
      +
      +
    2. +
    3. +

      + 2. Base Input with Clickable left icon +

      +
      + +
      + + +
      +
      +
    4. +
    5. +

      + 3. Base Input with right icon +

      +
      + +
      + + + + +
      +
      +
    6. +
    7. +

      + 4. Base Input with Clickable right icon +

      +
      + +
      + + +
      +
      +
    8. +
    9. +

      + 5. Base Input with left and right icons +

      +
      + +
      + + + + + + + +
      +
      +
    10. +
    11. +

      + 6. Base Input with Clickable left and right icon +

      +
      + +
      + + + +
      +
      +
    12. +
    13. +

      + 7. Base Input with left and clickable right icon +

      +
      + +
      + + + + + +
      +
      +
    14. +
    15. +

      + 8. Base Input with left, clickable right icon, and loading spinner +

      +
      + +
      + + + + +
      +
      +
      + + Field data is loading + +
      +
      +
      +
      + +
      +
      +
      +
    16. +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Counter Input 1`] = ` +
    +
    +
    +

    + 1. Simple counter input +

    +
    + +
    + + + +
    +
    +
    +
    +

    + 2. Controlled counter input +

    +
    + +
    + + + +
    +
    +
    +
    +

    + 3. Controlled counter input with min/max values and custom step size +

    +
    + +
    + + + +
    +
    +
    +
    +

    + 4. Counter input with floating step size +

    +
    + +
    + + + +
    +
    +
    +
    +

    + 5. Disabled counter input +

    +
    + +
    + + + +
    +
    +
    +
    +

    + 6. Readonly counter input +

    +
    + +
    + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Counter Static Input 1`] = ` +
    +
    +

    + 1. Static counter input +

    +
    + + My Label + +
    + + 10 + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Custom style and autocomplete 1`] = ` +
    +
    +
      +
    1. +

      + Input with custom style +

      +
      + +
      + +
      +
      +
    2. +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Disabled Input 1`] = ` +
    +
    +

    + Disabled Input +

    +
    + +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Docs site Default 1`] = ` +
    +
    +
    +

    + Base Input with visible label +

    +
    + +
    + +
    +
    +
    +
    +

    + Base Input with hidden label (assistive text) +

    +
    + +
    + +
    +
    +
    +
    +

    + Base Input with Fixed Text +

    +
    + +
    + + $ + + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Docs site Error 1`] = ` +
    +
    +
    +
    + +
    + +
    +
    + Error Message +
    +
    +
    +
    +
    + +
    + + +
    +
    + Error Message +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Docs site Icons 1`] = ` +
    +
    +

    + Input with Icons +

    +
    +
    + +
    + + + + +
    +
    +
    +
    +
    + +
    + + + +
    +
    +
    +
    +
    + +
    + + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + + Field data is loading + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Docs site InactiveInputs 1`] = ` +
    +
    +
    +

    + Disabled Input +

    +
    + +
    + +
    +
    +
    +
    +

    + ReadOnly Input +

    +
    + +
    + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Field Level Help 1`] = ` +
    +
    +

    + Field Level Help +

    +
    + +
    + + +
    +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Field Level Help, Tooltip Open 1`] = ` +
    +
    +

    + Field Level Help +

    +
    + +
    + + +
    +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Fixed Text 1`] = ` +
    +
    +

    + Input with Fixed Text +

    +
    + +
    + + $ + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Inline Help 1`] = ` +
    +
    +

    + Inline Help +

    +
    + +
    + +
    + ex: (415) 111-2222 +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Read Only 1`] = ` +
    +
    +

    + Read only Input +

    +
    + +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Required Input in Error State 1`] = ` +
    +
    +

    + Example Button +

    + +

    + Required Input with Error +

    +
    + +
    + +
    +
    + This field is required. +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSInput Static Input 1`] = ` +
    +
    +

    + Static Input +

    +
    + + My Label + +
    + + Static value + +
    +
    +
    +
    +`; diff --git a/components/input/__docs__/search/storybook-stories.js b/components/input/__docs__/search/storybook-stories.js new file mode 100644 index 0000000000..4fb7ddd100 --- /dev/null +++ b/components/input/__docs__/search/storybook-stories.js @@ -0,0 +1,33 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../../icon-settings")); + +var _constants = require("../../../../utilities/constants"); + +var _search = _interopRequireDefault(require("../../search")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.SEARCH, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Standard', function () { + return _react.default.createElement(_search.default, { + assistiveText: { + label: 'Search' + }, + placeholder: "Search", + name: "search-input", + onChange: (0, _addonActions.action)('change'), + onSearch: (0, _addonActions.action)('search') + }); +}); \ No newline at end of file diff --git a/components/input/__docs__/site-stories.js b/components/input/__docs__/site-stories.js new file mode 100644 index 0000000000..c58d15a74d --- /dev/null +++ b/components/input/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/input/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/input/__examples__/icons.jsx'), require('raw-loader!@salesforce/design-system-react/components/input/__examples__/error.jsx'), require('raw-loader!@salesforce/design-system-react/components/input/__examples__/inactiveInputs.jsx'), require('raw-loader!@salesforce/design-system-react/components/input/__examples__/inline-help.jsx'), require('raw-loader!@salesforce/design-system-react/components/input/__examples__/field-level-help.jsx'), require('raw-loader!@salesforce/design-system-react/components/input/__examples__/counter-input.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/input/__docs__/storybook-stories.js b/components/input/__docs__/storybook-stories.js new file mode 100644 index 0000000000..7da90cb1a4 --- /dev/null +++ b/components/input/__docs__/storybook-stories.js @@ -0,0 +1,290 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _constants = require("../../../utilities/constants"); + +var _button = _interopRequireDefault(require("../../button")); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _ = _interopRequireDefault(require("../")); + +var _tooltip = _interopRequireDefault(require("../../tooltip")); + +var _inputIcon = _interopRequireDefault(require("../../icon/input-icon")); + +var _counterInput = _interopRequireDefault(require("../__examples__/counter-input")); + +var _counterStaticInput = _interopRequireDefault(require("../__examples__/counter-static-input")); + +var _inlineHelp = _interopRequireDefault(require("../__examples__/inline-help")); + +var _fieldLevelHelp = _interopRequireDefault(require("../__examples__/field-level-help")); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _error = _interopRequireDefault(require("../__examples__/error")); + +var _icons = _interopRequireDefault(require("../__examples__/icons")); + +var _inactiveInputs = _interopRequireDefault(require("../__examples__/inactiveInputs")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var iconClicked = _addonActions.action; + +var clearIcon = _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'clear' + }, + name: "clear", + category: "utility" +}); + +var clearIconClickable = _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'clear' + }, + name: "clear", + category: "utility", + onClick: iconClicked('Clear icon clicked') +}); + +var searchIcon = _react.default.createElement(_inputIcon.default, { + name: "search", + category: "utility" +}); + +var searchIconClickable = _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'Search' + }, + name: "search", + category: "utility", + onClick: iconClicked('Search icon clicked') +}); + +(0, _react2.storiesOf)(_constants.INPUT, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base', function () { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("section", null, _react.default.createElement("ol", null, _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "1. Base Input with visible label"), _react.default.createElement(_.default, { + id: "base-id", + label: "My Label", + placeholder: "My placeholder" + })), _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "2. Base Input with hidden label (assistive text)"), _react.default.createElement(_.default, { + assistiveText: { + label: 'My label' + }, + id: "assistiveLabel-id", + placeholder: "My placeholder" + }))))); +}).add('Custom style and autocomplete', function () { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("section", null, _react.default.createElement("ol", null, _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Input with custom style"), _react.default.createElement(_.default, { + autoComplete: "off", + styleInput: { + width: 130, + height: 30, + background: '#efffff' + }, + id: "custom-style", + label: "My Label", + placeholder: "My placeholder" + }))))); +}).add('Base with Icons', function () { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("section", null, _react.default.createElement("ol", null, _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "1. Base Input with left icon"), _react.default.createElement(_.default, { + id: "with-left-icon", + label: "My label", + iconLeft: searchIcon, + placeholder: "My placeholder" + })), _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "2. Base Input with Clickable left icon"), _react.default.createElement(_.default, { + id: "with-left-clickable-icon", + label: "My Label", + iconLeft: searchIconClickable, + placeholder: "My placeholder" + })), _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "3. Base Input with right icon"), _react.default.createElement(_.default, { + id: "with-right-icon", + label: "My Label", + iconRight: searchIcon, + placeholder: "My placeholder" + })), _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "4. Base Input with Clickable right icon"), _react.default.createElement(_.default, { + id: "with-right-clickable-icon", + label: "My Label", + iconRight: clearIconClickable, + placeholder: "My placeholder" + })), _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "5. Base Input with left and right icons"), _react.default.createElement(_.default, { + id: "with-left-and-right-icons", + label: "My Label", + iconLeft: searchIcon, + iconRight: clearIcon, + placeholder: "My placeholder" + })), _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "6. Base Input with Clickable left and right icon"), _react.default.createElement(_.default, { + id: "with-clickable-left-and-right-icon", + label: "My label", + iconLeft: searchIconClickable, + iconRight: clearIconClickable, + placeholder: "My placeholder" + })), _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "7. Base Input with left and clickable right icon"), _react.default.createElement(_.default, { + id: "with-left-and-clickable-right-icon", + label: "My Label", + iconLeft: searchIcon, + iconRight: clearIconClickable, + placeholder: "My placeholder" + })), _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "8. Base Input with left, clickable right icon, and loading spinner"), _react.default.createElement(_.default, { + id: "with-left-clickable-right-and-spinner", + assistiveText: { + spinner: 'Field data is loading' + }, + hasSpinner: true, + iconLeft: searchIcon, + iconRight: clearIconClickable, + label: "My Label", + name: "right-clickable-icon", + placeholder: "My placeholder" + }))))); +}).add('Fixed Text', function () { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("section", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Input with Fixed Text"), _react.default.createElement(_.default, { + id: "fixed-text", + assistiveText: { + label: 'My Label' + }, + name: "fixed-text", + label: "My Label", + fixedTextLeft: "$", + placeholder: "My placeholder" + }))); +}).add('Read Only', function () { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("section", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Read only Input"), _react.default.createElement(_.default, { + id: "read-only", + name: "read-only", + label: "My Label", + readOnly: true, + value: "Read Only Value" + }))); +}).add('Static Input', function () { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("section", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Static Input"), _react.default.createElement(_.default, { + id: "static-input", + name: "static-input", + label: "My Label", + isStatic: true, + value: "Static value" + }))); +}).add('Disabled Input', function () { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("section", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Disabled Input"), _react.default.createElement(_.default, { + id: "disabled-input", + name: "disabled-input", + label: "My Label", + disabled: true, + value: "Disabled value" + }))); +}).add('Required Input in Error State', function () { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("section", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Example Button"), _react.default.createElement(_button.default, { + label: "Test" + }), _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Required Input with Error"), _react.default.createElement(_.default, { + id: "required-input-error", + "aria-describedby": "error-1", + name: "required-input-error", + label: "My Label", + required: true, + errorText: "This field is required.", + placeholder: "My placeholder" + }))); +}).add('Inline Help', function () { + return _react.default.createElement(_inlineHelp.default, null); +}).add('Field Level Help', function () { + return _react.default.createElement(_fieldLevelHelp.default, null); +}).add('Field Level Help, Tooltip Open', function () { + return _react.default.createElement(_fieldLevelHelp.default, { + tooltipOpen: true + }); +}).add('Counter Input', function () { + return _react.default.createElement(_counterInput.default, null); +}).add('Counter Static Input', function () { + return _react.default.createElement(_counterStaticInput.default, null); +}).add('Docs site Default', function () { + return _react.default.createElement(_default.default, null); +}).add('Docs site Error', function () { + return _react.default.createElement(_error.default, null); +}).add('Docs site Icons', function () { + return _react.default.createElement(_icons.default, null); +}).add('Docs site InactiveInputs', function () { + return _react.default.createElement(_inactiveInputs.default, null); +}); \ No newline at end of file diff --git a/components/input/__examples__/counter-input.js b/components/input/__examples__/counter-input.js new file mode 100644 index 0000000000..9485861786 --- /dev/null +++ b/components/input/__examples__/counter-input.js @@ -0,0 +1,127 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _input = _interopRequireDefault(require("../../../../components/input")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + counter2value: 10, + counter3value: 10 + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement("div", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "1. Simple counter input"), _react.default.createElement(_input.default, { + id: "counter-input-1", + label: "My Label", + variant: "counter" + })), _react.default.createElement("div", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "2. Controlled counter input"), _react.default.createElement(_input.default, { + id: "counter-input-2", + label: "My Label", + onChange: function onChange(event, data) { + _this2.setState({ + counter2value: data.value + }); + }, + value: this.state.counter2value, + variant: "counter" + })), _react.default.createElement("div", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "3. Controlled counter input with min/max values and custom step size"), _react.default.createElement(_input.default, { + id: "counter-input-3", + label: "My Label", + minValue: 2, + maxValue: 30, + onChange: function onChange(event, data) { + _this2.setState({ + counter3value: data.value + }); + }, + step: 2, + value: this.state.counter3value, + variant: "counter" + })), _react.default.createElement("div", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "4. Counter input with floating step size"), _react.default.createElement(_input.default, { + defaultValue: 10.0, + id: "counter-input-4", + label: "My Label", + step: 0.1, + variant: "counter" + })), _react.default.createElement("div", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "5. Disabled counter input"), _react.default.createElement(_input.default, { + disabled: true, + id: "counter-input-5", + label: "My Label", + variant: "counter", + value: "10" + })), _react.default.createElement("div", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "6. Readonly counter input"), _react.default.createElement(_input.default, { + id: "counter-input-6", + label: "My Label", + readOnly: true, + variant: "counter", + value: "10" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'CounterInputExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/input/__examples__/counter-static-input.js b/components/input/__examples__/counter-static-input.js new file mode 100644 index 0000000000..c99718fa57 --- /dev/null +++ b/components/input/__examples__/counter-static-input.js @@ -0,0 +1,76 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _input = _interopRequireDefault(require("../../../../components/input")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + counter2value: 10, + counter3value: 10 + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "1. Static counter input"), _react.default.createElement(_input.default, { + isStatic: true, + id: "counter-static-input-1", + label: "My Label", + variant: "counter", + value: "10" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'CounterStaticInputExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/input/__examples__/default.js b/components/input/__examples__/default.js new file mode 100644 index 0000000000..ec252889f9 --- /dev/null +++ b/components/input/__examples__/default.js @@ -0,0 +1,93 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _input = _interopRequireDefault(require("../../../../components/input")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("section", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Base Input with visible label"), _react.default.createElement(_input.default, { + id: "base-id", + label: "My Label", + placeholder: "My placeholder" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Base Input with hidden label (assistive text)"), _react.default.createElement(_input.default, { + assistiveText: { + label: 'My label' + }, + id: "assistiveLabel-id", + placeholder: "My placeholder" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Base Input with Fixed Text"), _react.default.createElement(_input.default, { + id: "fixed-text-id", + fixedTextLeft: "$", + label: "Total amount", + placeholder: "Enter amount in USD" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'BaseInputExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/input/__examples__/error.js b/components/input/__examples__/error.js new file mode 100644 index 0000000000..d7b76d839a --- /dev/null +++ b/components/input/__examples__/error.js @@ -0,0 +1,97 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _input = _interopRequireDefault(require("../../../../components/input")); + +var _inputIcon = _interopRequireDefault(require("../../../../components/icon/input-icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_input.default, { + "aria-describedby": "error-4", + id: "unique-id-4", + label: "Input Label", + required: true, + errorText: "Error Message", + placeholder: "Placeholder Text" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_input.default, { + iconLeft: _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'Search' + }, + name: "error", + category: "utility", + color: "error", + onClick: function onClick() { + console.log('Icon Clicked'); + } + }), + "aria-describedby": "error-5", + id: "unique-id-5", + label: "Input Label", + required: true, + errorText: "Error Message", + placeholder: "Placeholder Text" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ErrorInputExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/input/__examples__/field-level-help.js b/components/input/__examples__/field-level-help.js new file mode 100644 index 0000000000..716200988c --- /dev/null +++ b/components/input/__examples__/field-level-help.js @@ -0,0 +1,81 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _input = _interopRequireDefault(require("../../../../components/input")); + +var _tooltip = _interopRequireDefault(require("../../../../components/tooltip")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var propTypes = { + tooltipOpen: _propTypes.default.bool +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Field Level Help"), _react.default.createElement(_input.default, { + id: "field-level-help", + label: "My Label", + fieldLevelHelpTooltip: _react.default.createElement(_tooltip.default, { + id: "field-level-help-tooltip", + align: "top left", + content: "Some helpful information", + isOpen: this.props.tooltipOpen + }) + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'FieldLevelHelpInputExample'; +Example.propTypes = propTypes; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/input/__examples__/icons.js b/components/input/__examples__/icons.js new file mode 100644 index 0000000000..94a50d8f24 --- /dev/null +++ b/components/input/__examples__/icons.js @@ -0,0 +1,145 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _input = _interopRequireDefault(require("../../../../components/input")); + +var _inputIcon = _interopRequireDefault(require("../../../../components/icon/input-icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Input with Icons"), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_input.default, { + iconLeft: _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'Search' + }, + name: "search", + category: "utility" + }), + id: "unique-id-1", + label: "Input Label", + placeholder: "Static Icon on the left" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_input.default, { + iconLeft: _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'Search' + }, + name: "search", + category: "utility", + onClick: function onClick() { + console.log('Icon Clicked'); + } + }), + iconRight: _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'Clear' + }, + name: "clear", + category: "utility", + onClick: function onClick() { + console.log('Icon Clicked'); + } + }), + id: "unique-id-2", + label: "Input Label", + placeholder: "Clickable Icons (Left and Right)" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_input.default, { + iconRight: _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'Clear' + }, + name: "clear", + category: "utility", + onClick: function onClick() { + console.log('Icon Clicked'); + } + }), + id: "unique-id-3", + label: "Input Label", + placeholder: "Clickable Icon on the right" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_input.default, { + assistiveText: { + spinner: 'Field data is loading' + }, + iconRight: _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'Clear' + }, + name: "clear", + category: "utility", + onClick: function onClick() { + console.log('Icon Clicked'); + } + }), + hasSpinner: true, + id: "unique-id-4", + label: "Input Label", + placeholder: "Loading Spinner Icon on the right" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'InputExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/input/__examples__/inactiveInputs.js b/components/input/__examples__/inactiveInputs.js new file mode 100644 index 0000000000..bfa363c0a8 --- /dev/null +++ b/components/input/__examples__/inactiveInputs.js @@ -0,0 +1,84 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _input = _interopRequireDefault(require("../../../../components/input")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("section", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Disabled Input"), _react.default.createElement(_input.default, { + id: "disabled-input-id", + label: "My Label", + disabled: true, + value: "Disabled value" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "ReadOnly Input"), _react.default.createElement(_input.default, { + id: "unique-id-3", + label: "Input Label", + readOnly: true, + value: "Read Only Value" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'InactiveInputExamples'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/input/__examples__/inline-help.js b/components/input/__examples__/inline-help.js new file mode 100644 index 0000000000..33c52584f5 --- /dev/null +++ b/components/input/__examples__/inline-help.js @@ -0,0 +1,63 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _input = _interopRequireDefault(require("../../../../components/input")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "Inline Help"), _react.default.createElement(_input.default, { + id: "inline-help", + label: "My Label", + inlineHelpText: "ex: (415) 111-2222" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'InlineHelpInputExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/input/check-props.js b/components/input/check-props.js new file mode 100644 index 0000000000..73928e1ae8 --- /dev/null +++ b/components/input/check-props.js @@ -0,0 +1,75 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _deprecatedProperty = _interopRequireDefault(require("../../utilities/warning/deprecated-property")); + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +var _onlyOneOfProperties = _interopRequireDefault(require("../../utilities/warning/only-one-of-properties")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ + +/* eslint-disable max-len */ +// import oneOfRequiredProperty from '../../../utilities/warning/one-of-required-property'; +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + + if (COMPONENT === _constants.INPUT) { + var iconDeprecatedMessage = "Please use `iconLeft` and `iconRight` to pass in a customized component. ".concat(createDocUrl()); // Deprecated and changed to another property + + (0, _deprecatedProperty.default)(COMPONENT, props.assistiveText.fieldLevelHelpButton, 'assistiveText.fieldLevelHelpButton', undefined, "Please pass a `Tooltip` component into `fieldLevelHelpTooltip` with `assistiveText.triggerLearnMoreIcon`."); + (0, _deprecatedProperty.default)(COMPONENT, props.iconCategory, 'iconCategory', undefined, iconDeprecatedMessage); + (0, _deprecatedProperty.default)(COMPONENT, props.iconName, 'iconName', undefined, iconDeprecatedMessage); + (0, _deprecatedProperty.default)(COMPONENT, props.iconPosition, 'iconPosition', undefined, iconDeprecatedMessage); + (0, _deprecatedProperty.default)(COMPONENT, props.iconAssistiveText, 'iconAssistiveText', undefined, iconDeprecatedMessage); + (0, _deprecatedProperty.default)(COMPONENT, props.onIconClick, 'onIconClick', undefined, iconDeprecatedMessage); + + if (typeof props.assistiveText === 'string') { + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', "AssistiveText as a string has been deprecated and is now an object to allow for multiple uses in the component. Please use either assistiveText.label or assistiveText.spinner. ".concat(createDocUrl('assistiveText'))); + } + + (0, _onlyOneOfProperties.default)(COMPONENT, { + 'assistiveText.label': props.assistiveText && props.assistiveText.label, + label: props.label + }, createDocUrl('assistiveText')); + (0, _onlyOneOfProperties.default)(COMPONENT, { + fixedTextLeft: props.fixedTextLeft, + fixedTextRight: props.fixedTextRight + }, createDocUrl('assistiveText')); + /* + * Once we support horizontal labels, then I think we can enable this check + * + if (!props.inlineEditTrigger) { + oneOfRequiredProperty(COMPONENT, { + assistiveText: props.assistiveText, + label: props.label + }); + } + */ + } else if (COMPONENT === _constants.SEARCH) { + if (typeof props.assistiveText === 'string') { + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', "`assistiveText` as a string has been deprecated and is now an object to allow for multiple uses in the component. Please use `assistiveText.label` instead. ".concat(createDocUrl('assistiveText'))); + } + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/input/docs.json b/components/input/docs.json new file mode 100644 index 0000000000..ac1def8bba --- /dev/null +++ b/components/input/docs.json @@ -0,0 +1,11 @@ +{ + "component": "input", + "status": "prod", + "display-name": "Inputs", + "last-accessibility-review": { + "date-iso-8601": "2017/09/22", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/input", + "url-slug": "inputs" +} \ No newline at end of file diff --git a/components/input/index.js b/components/input/index.js new file mode 100644 index 0000000000..659a87299f --- /dev/null +++ b/components/input/index.js @@ -0,0 +1,670 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _button = _interopRequireDefault(require("../button")); + +var _inputIcon = _interopRequireDefault(require("../icon/input-icon")); + +var _innerInput = _interopRequireDefault(require("./private/inner-input")); + +var _label = _interopRequireDefault(require("../utilities/label")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _constants = require("../../utilities/constants"); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _fieldLevelHelpTooltip = _interopRequireDefault(require("../tooltip/private/field-level-help-tooltip")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var COUNTER = 'counter'; +var DECREMENT = 'Decrement'; +var INCREMENT = 'Increment'; +var defaultProps = { + assistiveText: { + decrement: "".concat(DECREMENT, " ").concat(COUNTER), + increment: "".concat(INCREMENT, " ").concat(COUNTER) + }, + type: 'text' +}; +/** + * The HTML `input` with a label and error messaging. + */ + +var Input = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Input, _React$Component); + + function Input(props) { + var _this; + + _classCallCheck(this, Input); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Input).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "getId", function () { + return _this.props.id || _this.generatedId; + }); + + _defineProperty(_assertThisInitialized(_this), "getErrorId", function () { + return _this.props['aria-describedby'] || _this.generatedErrorId; + }); + + _defineProperty(_assertThisInitialized(_this), "getValueAsNumber", function () { + var value = 0; + + if (_this.props.value !== undefined) { + value = Number(_this.props.value); + } else if (_this.inputRef) { + value = Number(_this.inputRef.value); + } + + return value; + }); + + _defineProperty(_assertThisInitialized(_this), "getCounterButtonIcon", function (direction) { + var value = _this.getValueAsNumber(); + + var disabled = false; + + if (_this.props.disabled || direction === INCREMENT && _this.props.maxValue !== undefined && value >= _this.props.maxValue || direction === DECREMENT && _this.props.minValue !== undefined && value <= _this.props.minValue) { + disabled = true; + } + + return _react.default.createElement(_button.default, { + assistiveText: { + icon: _this.props.assistiveText[direction.toLowerCase()] + }, + className: (0, _classnames.default)('slds-button_icon-small', "slds-input__button_".concat(direction.toLowerCase())), + disabled: disabled, + iconCategory: "utility", + iconName: direction === DECREMENT ? 'ban' : 'new', + onKeyDown: function onKeyDown(event) { + if (event.keyCode === 13) { + _this.performStep(direction, event); + } + }, + onKeyUp: _this.stopStepping, + onMouseDown: function onMouseDown(event) { + _this.performStep(direction, event); + }, + onMouseLeave: _this.stopStepping, + onMouseUp: _this.stopStepping, + variant: "icon" + }); + }); + + _defineProperty(_assertThisInitialized(_this), "getIconRender", function (position, iconPositionProp) { + var icon; // Remove at next breaking change + + /* eslint-disable react/prop-types */ + + var deprecatedProps = { + assistiveText: { + icon: _this.props[iconPositionProp] && _this.props[iconPositionProp].props.assistiveText || _this.props.iconAssistiveText + }, + category: _this.props[iconPositionProp] && _this.props[iconPositionProp].props.category || _this.props.iconCategory, + name: _this.props[iconPositionProp] && _this.props[iconPositionProp].props.name || _this.props.iconName, + onClick: _this.props[iconPositionProp] && _this.props[iconPositionProp].props.onClick || _this.props.onIconClick + }; + /* eslint-enable react/prop-types */ + + if (_this.props[iconPositionProp] && position && _this.props[iconPositionProp]) { + icon = _react.default.cloneElement(_this.props[iconPositionProp], { + iconPosition: "".concat(position) + }); + } else if (deprecatedProps.name) { + icon = _react.default.createElement(_inputIcon.default, _extends({ + iconPosition: position + }, deprecatedProps)); + } + + return icon; + }); + + _defineProperty(_assertThisInitialized(_this), "setInputRef", function (ref) { + _this.inputRef = ref; + + if (_this.props.inputRef) { + _this.props.inputRef(ref); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (event) { + if (_this.props.onChange) { + var data = { + value: event.target.value + }; + + if (_this.props.variant === COUNTER) { + data.number = Number(data.value); + } + + _this.props.onChange(event, data); + } + }); + + _defineProperty(_assertThisInitialized(_this), "performStep", function (direction, event) { + clearTimeout(_this.stepping.timeout); + var maxValue = _this.props.maxValue; + var minValue = _this.props.minValue; + var step = _this.props.step !== undefined ? Number(_this.props.step) : 1; + + var value = _this.getValueAsNumber(); + + var valueChanged = false; + + if (direction === DECREMENT && maxValue !== undefined && value > maxValue) { + value = Number(maxValue); + valueChanged = true; + } else if (direction === INCREMENT && minValue !== undefined && value < minValue) { + value = Number(minValue); + valueChanged = true; + } else { + var decimalPlaces = String(step).search(/\./) >= 0 ? String(step).split('.')[1].length : 0; + var minOverflow = 0; + + if (minValue !== undefined) { + minOverflow = (value - minValue) % step; + } + + if (minOverflow > 0) { + // Default browser inputs of type number with a min attribute alter the value upon change as needed so + // that with enough decrements it can reach the exact min value. This behavior is reflected here + value = direction === DECREMENT ? value - minOverflow : value + (step - minOverflow); + } else { + value = direction === DECREMENT ? value - step : value + step; + } + + value = Number(value.toFixed(decimalPlaces)); + + if (!(maxValue !== undefined && value > maxValue) && !(minValue !== undefined && value < minValue)) { + valueChanged = true; + } + } + + if (valueChanged) { + /* + * Use of `this.forceUpdate` is an anti-pattern. This code only executes if this `input` element is uncontrolled which this library believes is an anti-pattern, also. This code is only present to allow for the edge case of uncontrolled use of an `input`. + */ + if (_this.props.value === undefined && _this.inputRef) { + _this.inputRef.value = String(value); + + _this.forceUpdate(); + } else if (_this.props.onChange) { + _this.props.onChange(event, { + number: value, + value: String(value) + }); + } + } + + if (direction === INCREMENT && maxValue !== undefined && value >= maxValue || direction === DECREMENT && minValue !== undefined && value <= minValue) { + _this.stopStepping(); + } else { + _this.stepping.timeout = setTimeout(function () { + _this.stepping.currentDelay = _this.stepping.speedDelay; + + _this.performStep(direction); + }, _this.stepping.currentDelay); + } + }); + + _defineProperty(_assertThisInitialized(_this), "stopStepping", function () { + clearTimeout(_this.stepping.timeout); + _this.stepping.currentDelay = _this.stepping.initialDelay; + }); + + _this.inputRef = null; + _this.stepping = { + currentDelay: 500, + initialDelay: 500, + speedDelay: 75, + timeout: {} + }; + return _this; + } + + _createClass(Input, [{ + key: "componentWillMount", + value: function componentWillMount() { + // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + (0, _checkProps.default)(_constants.INPUT, this.props, _docs.default); + this.generatedId = _shortid.default.generate(); + + if (this.props.errorText) { + this.generatedErrorId = _shortid.default.generate(); + } + } + }, { + key: "render", + value: function render() { + var assistiveText = _objectSpread({}, defaultProps.assistiveText, this.props.assistiveText); + + var inputRef = this.props.variant === COUNTER ? this.setInputRef : this.props.inputRef; + var iconLeft = null; + var iconRight = null; + var hasRenderedLabel = this.props.label || assistiveText && assistiveText.label; // Remove at next breaking change + // this is a hack to make left the default prop unless overwritten by `iconPosition="right"` + + if (!!this.props.iconLeft || (this.props.iconPosition === 'left' || this.props.iconPosition === undefined) && !!this.props.iconName) { + iconLeft = this.getIconRender('left', 'iconLeft'); + } else if (this.props.variant === COUNTER && !this.props.isStatic && !this.props.readOnly) { + iconLeft = this.getCounterButtonIcon(DECREMENT); + } + + if (!!this.props.iconRight || this.props.iconPosition === 'right' && !!this.props.iconName) { + iconRight = this.getIconRender('right', 'iconRight'); + } else if (this.props.variant === COUNTER && !this.props.isStatic && !this.props.readOnly) { + iconRight = this.getCounterButtonIcon(INCREMENT); + } + + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-form-element', { + 'slds-has-error': this.props.errorText + }, this.props.className), + style: this.props.styleContainer + }, _react.default.createElement(_label.default, { + assistiveText: assistiveText, + htmlFor: this.props.isStatic ? undefined : this.getId(), + label: this.props.label, + required: this.props.required, + variant: this.props.isStatic ? 'static' : 'base' + }), this.props.fieldLevelHelpTooltip && hasRenderedLabel ? _react.default.createElement(_fieldLevelHelpTooltip.default, { + assistiveText: { + triggerLearnMoreIcon: assistiveText.fieldLevelHelpButton + }, + fieldLevelHelpTooltip: this.props.fieldLevelHelpTooltip + }) : null, _react.default.createElement(_innerInput.default, { + "aria-activedescendant": this.props['aria-activedescendant'], + "aria-autocomplete": this.props['aria-autocomplete'], + "aria-controls": this.props['aria-controls'], + "aria-labelledby": this.props['aria-labelledby'], + "aria-describedby": this.getErrorId(), + "aria-expanded": this.props['aria-expanded'], + "aria-owns": this.props['aria-owns'], + "aria-required": this.props['aria-required'], + autoComplete: this.props.autoComplete, + className: (0, _classnames.default)({ + 'slds-input_counter': this.props.variant === COUNTER, + 'slds-p-horizontal_none': this.props.variant === COUNTER && this.props.readOnly + }), + containerProps: { + className: 'slds-form-element__control' + }, + defaultValue: this.props.defaultValue, + disabled: this.props.disabled, + fixedTextLeft: this.props.fixedTextLeft, + fixedTextRight: this.props.fixedTextRight, + hasSpinner: this.props.hasSpinner, + id: this.getId(), + iconLeft: iconLeft, + iconRight: iconRight, + inlineEditTrigger: this.props.inlineEditTrigger, + inlineHelpText: this.props.inlineHelpText, + isStatic: this.props.isStatic, + minLength: this.props.minLength, + minValue: this.props.minValue, + maxLength: this.props.maxLength, + maxValue: this.props.maxValue, + name: this.props.name, + onBlur: this.props.onBlur, + onChange: this.handleChange, + onClick: this.props.onClick, + onFocus: this.props.onFocus, + onInput: this.props.onInput, + onInvalid: this.props.onInvalid, + onKeyDown: this.props.onKeyDown, + onKeyPress: this.props.onKeyPress, + onKeyUp: this.props.onKeyUp, + onSelect: this.props.onSelect, + onSubmit: this.props.onSubmit, + placeholder: this.props.placeholder, + inputRef: inputRef, + readOnly: this.props.readOnly, + required: this.props.required, + role: this.props.role, + assistiveText: this.props.assistiveText, + type: this.props.variant === COUNTER ? 'number' : this.props.type, + value: this.props.value, + variant: this.props.variant, + step: this.props.step, + style: this.props.styleInput + }), this.props.errorText && _react.default.createElement("div", { + id: this.getErrorId(), + className: "slds-form-element__help" + }, this.props.errorText), this.props.children); + } + }]); + + return Input; +}(_react.default.Component); + +_defineProperty(Input, "displayName", _constants.INPUT); + +_defineProperty(Input, "propTypes", { + /** + * The aria-activedescendant attribute contains the ID of the currently active child object that is part of a composite widget within the Document Object Model. It makes do with the overhead of having all or more than one child focusable. As the name specifies, it helps in managing the current active child of the composite widget. + */ + 'aria-activedescendant': _propTypes.default.string, + + /** + * Indicates if the suggestions in a composite widget are values that complete the current textbox input. + */ + 'aria-autocomplete': _propTypes.default.string, + + /** + * An HTML ID that is shared with ARIA-supported devices with the + * `aria-controls` attribute in order to relate the input with + * another region of the page. An example would be a select box + * that shows or hides a panel. + */ + 'aria-controls': _propTypes.default.string, + + /** + * The `aria-describedby` attribute is used to indicate the IDs of the elements that describe the object. It is used to establish a relationship between widgets or groups and text that described them. This is very similar to aria-labelledby: a label describes the essence of an object, while a description provides more information that the user might need. + */ + 'aria-describedby': _propTypes.default.string, + + /** + * Use the `aria-expanded` state to indicate whether regions of the content are collapsible, and to expose whether a region is currently expanded or collapsed. + */ + 'aria-expanded': _propTypes.default.bool, + + /** + * Indicates that the element has a popup context menu or sub-level menu. + */ + 'aria-haspopup': _propTypes.default.bool, + + /** + * The aria-labelledby attribute contains the element IDs of labels in objects such as input elements, widgets, and groups. The attribute establishes relationships between objects and their labels. Assistive technology, such as screen readers, use this attribute to catalog the objects in a document so that users can navigate between them. Without an element ID, the assistive technology cannot catalog the object. + */ + 'aria-labelledby': _propTypes.default.string, + + /** + * An HTML ID that is shared with ARIA-supported devices with the + * `aria-controls` attribute in order to relate the input with + * another region of the page. An example would be a search field + * that shows search results. + */ + 'aria-owns': _propTypes.default.string, + + /** + * The `aria-required` attribute is used to indicate that user input is required on an element before a form can be submitted. + */ + 'aria-required': _propTypes.default.bool, + + /** + * **Assistive text for accessibility** + * * `label`: Visually hidden label but read out loud by screen readers. + * * `spinner`: Text for loading spinner icon. + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string, + spinner: _propTypes.default.string + }), + + /** + * Disabled brower's autocomplete when "off" is used. + */ + autoComplete: _propTypes.default.string, + + /** + * Elements are added after the `input`. + */ + children: _propTypes.default.node, + + /** + * Class names to be added to the outer container of the input. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * This is the initial value of an uncontrolled form element and + * is present only to provide compatibility with hybrid framework + * applications that are not entirely React. It should only be used + * in an application without centralized state (Redux, Flux). + * "Controlled components" with centralized state is highly recommended. + * See [Code Overview](https://github.com/salesforce/design-system-react/blob/master/docs/codebase-overview.md#controlled-and-uncontrolled-components) for more information. + */ + defaultValue: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), + + /** + * Disables the input and prevents editing the contents. + */ + disabled: _propTypes.default.bool, + + /** + * Message to display when the input is in an error state. When this is present, also visually highlights the component as in error. + */ + errorText: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * A [Tooltip](https://react.lightningdesignsystem.com/components/tooltips/) component that is displayed next to the label. + */ + fieldLevelHelpTooltip: _propTypes.default.node, + + /** + * Displays text or node to the left of the input. This follows the fixed text input UX pattern. + */ + fixedTextLeft: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * Displays text or node to the right of the input. This follows the fixed text input UX pattern. + */ + fixedTextRight: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * If true, loading spinner appears inside input on right hand side. + */ + hasSpinner: _propTypes.default.bool, + + /** + * Left aligned icon, must be instace of `design-system-react/components/icon/input-icon` + */ + iconLeft: _propTypes.default.node, + + /** + * Right aligned icon, must be instace of `design-system-react/components/icon/input-icon` + */ + iconRight: _propTypes.default.node, + + /** + * Every input must have a unique ID in order to support keyboard navigation and ARIA support. + */ + id: _propTypes.default.string, + + /** + * Displays help text under the input. + */ + inlineHelpText: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * This callback exposes the input reference / DOM node to parent components. ` this.input = inputComponent} /> + */ + inputRef: _propTypes.default.func, + + /** + * Displays the value of the input statically. This follows the static input UX pattern. + */ + isStatic: _propTypes.default.bool, + + /** + * This label appears above the input. + */ + label: _propTypes.default.string, + + /** + * Triggered when focus is removed. + */ + onBlur: _propTypes.default.func, + + /** + * This callback fires when the input changes. Passes in `event, { value }`. + */ + onChange: _propTypes.default.func, + + /** + * This event fires when the input is clicked. + */ + onClick: _propTypes.default.func, + + /** + * Triggered when component is focused. + */ + onFocus: _propTypes.default.func, + + /** + * Similar to `onchange`. Triggered when an element gets user input. + */ + onInput: _propTypes.default.func, + + /** + * Triggered when a submittable `` element is invalid. + */ + onInvalid: _propTypes.default.func, + + /** + * Triggered when a key is pressed down + */ + onKeyDown: _propTypes.default.func, + + /** + * Triggered when a key is pressed and released + */ + onKeyPress: _propTypes.default.func, + + /** + * Triggered when a key is released + */ + onKeyUp: _propTypes.default.func, + + /** + * Triggered after some text has been selected in an element. + */ + onSelect: _propTypes.default.func, + + /** + * Fires when a form is submitted. + */ + onSubmit: _propTypes.default.func, + + /** + * Text that will appear in an empty input. + */ + placeholder: _propTypes.default.string, + + /** + * Sets the minimum number of characters that an `` can accept. + */ + minLength: _propTypes.default.string, + + /** + * Specifies minimum accepted value for a counter input + */ + minValue: _propTypes.default.number, + + /** + * Sets the maximum number of characters that an `` can accept. + */ + maxLength: _propTypes.default.string, + + /** + * Specifies maximum accepted value for a counter input + */ + maxValue: _propTypes.default.number, + + /** + * Name of the submitted form parameter. + */ + name: _propTypes.default.string, + + /** + * Displays the value of the input as read-only. This is used in the inline edit UX pattern. + */ + readOnly: _propTypes.default.bool, + + /** + * Highlights the input as a required field (does not perform any validation). + */ + required: _propTypes.default.bool, + + /** + * ARIA role + */ + role: _propTypes.default.string, + + /** + * Determines the step size upon increment or decrement. Can be set to decimal values. + */ + step: _propTypes.default.number, + + /** + * styles to be added to input + */ + styleInput: _propTypes.default.object, + + /** + * Custom styles to be passed to the component container + */ + styleContainer: _propTypes.default.object, + + /** + * The `` element includes support for all HTML5 types. + */ + type: _propTypes.default.oneOf(['text', 'password', 'datetime', 'datetime-local', 'date', 'month', 'time', 'week', 'number', 'email', 'url', 'search', 'tel', 'color']), + + /** + * The input is a controlled component, and will always display this value. + */ + value: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), + + /** + * Which UX pattern of input? The default is `base` while other option is `counter` + */ + variant: _propTypes.default.oneOf(['base', COUNTER]) +}); + +_defineProperty(Input, "defaultProps", defaultProps); + +var _default = Input; +exports.default = _default; \ No newline at end of file diff --git a/components/input/private/inner-input.js b/components/input/private/inner-input.js new file mode 100644 index 0000000000..6e06ac6166 --- /dev/null +++ b/components/input/private/inner-input.js @@ -0,0 +1,329 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _spinner = _interopRequireDefault(require("../../../components/spinner")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +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 COUNTER = 'counter'; +var propTypes = { + 'aria-activedescendant': _propTypes.default.string, + 'aria-autocomplete': _propTypes.default.string, + + /** + * An HTML ID that is shared with ARIA-supported devices with the + * `aria-controls` attribute in order to relate the input with + * another region of the page. An example would be a select box + * that shows or hides a panel. + */ + 'aria-controls': _propTypes.default.string, + 'aria-describedby': _propTypes.default.string, + 'aria-expanded': _propTypes.default.bool, + 'aria-haspopup': _propTypes.default.bool, + 'aria-labelledby': _propTypes.default.string, + + /** + * An HTML ID that is shared with ARIA-supported devices with the + * `aria-controls` attribute in order to relate the input with + * another region of the page. An example would be a search field + * that shows search results. + */ + 'aria-owns': _propTypes.default.string, + 'aria-required': _propTypes.default.bool, + + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `spinner`: Assistive text on the spinner. + */ + assistiveText: _propTypes.default.shape({ + spinner: _propTypes.default.string + }), + + /** + * Disabled brower's autocomplete when "off" is used. + */ + autoComplete: _propTypes.default.string, + + /** + * Class names to be added to the `input` element. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Class names to be added to the outer container `div` of the input. + */ + containerClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Props to be added to the outer container `div` of the input (excluding `containerClassName`). + */ + containerProps: _propTypes.default.object, + + /** + * Disables the input and prevents editing the contents. + */ + disabled: _propTypes.default.bool, + + /** + * Displays text or node to the left of the input. This follows the fixed text input UX pattern. + */ + fixedTextLeft: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * Displays text or node to the right of the input. This follows the fixed text input UX pattern. + */ + fixedTextRight: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * If true, loading spinner appears inside input on right hand side. + */ + hasSpinner: _propTypes.default.bool, + + /** + * Left aligned icon, must be instance of `design-system-react/components/icon/input-icon` + */ + iconLeft: _propTypes.default.node, + + /** + * Right aligned icon, must be instance of `design-system-react/components/icon/input-icon` + */ + iconRight: _propTypes.default.node, + + /** + * Every input must have a unique ID in order to support keyboard navigation and ARIA support. + */ + id: _propTypes.default.string.isRequired, + + /** + * Displays help text under the input. + */ + inlineHelpText: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * This callback exposes the input reference / DOM node to parent components. ` this.input = inputComponent} /> + */ + inputRef: _propTypes.default.func, + + /** + * Displays the value of the input statically. This follows the static input UX pattern. + */ + isStatic: _propTypes.default.bool, + + /** + * This label appears above the input. + */ + label: _propTypes.default.string, + onBlur: _propTypes.default.func, + + /** + * This callback fires when the input changes. The synthetic React event will be the first parameter to the callback. You will probably want to reference `event.target.value` in your callback. No custom data object is provided. + */ + onChange: _propTypes.default.func, + + /** + * This event fires when the input is clicked. + */ + onClick: _propTypes.default.func, + onFocus: _propTypes.default.func, + onInput: _propTypes.default.func, + onInvalid: _propTypes.default.func, + onKeyDown: _propTypes.default.func, + onKeyPress: _propTypes.default.func, + onKeyUp: _propTypes.default.func, + onSelect: _propTypes.default.func, + onSubmit: _propTypes.default.func, + + /** + * Text that will appear in an empty input. + */ + placeholder: _propTypes.default.string, + minLength: _propTypes.default.string, + + /** + * Specifies minimum accepted value for an input of type "number" + */ + minValue: _propTypes.default.number, + maxLength: _propTypes.default.string, + + /** + * Specifies maximum accepted value for an input of type "number" + */ + maxValue: _propTypes.default.number, + + /** + * Name of the submitted form parameter. + */ + name: _propTypes.default.string, + + /** + * Specifies `readOnly` for `input` node. + */ + readOnly: _propTypes.default.bool, + + /** + * Highlights the input as a required field (does not perform any validation). + */ + required: _propTypes.default.bool, + + /** + * `role` to be added to `input` node + */ + role: _propTypes.default.string, + + /** + * Determines the step size upon increment or decrement. Can be set to decimal values. + */ + step: _propTypes.default.number, + + /** + * Style object to be added to `input` node + */ + style: _propTypes.default.object, + + /** + * Specifies `tabIndex` for `input` node + */ + tabIndex: _propTypes.default.string, + + /** + * The `` element includes support for all HTML5 types. + */ + type: _propTypes.default.oneOf(['text', 'password', 'datetime', 'datetime-local', 'date', 'month', 'time', 'week', 'number', 'email', 'url', 'search', 'tel', 'color']), + + /** + * The input is a controlled component, and will always display this value. + */ + value: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), + + /** + * Which UX pattern of input? The default is `base` while other option is `counter` + */ + variant: _propTypes.default.oneOf(['base', COUNTER]), + + /** + * This is the initial value of an uncontrolled form element and is present only to provide + * compatibility with hybrid framework applications that are not entirely React. It should only + * be used in an application without centralized state (Redux, Flux). "Controlled components" + * with centralized state is highly recommended. + * See [Code Overview](https://github.com/salesforce/design-system-react/blob/master/docs/codebase-overview.md#controlled-and-uncontrolled-components) for more information. + */ + defaultValue: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]) +}; +var defaultProps = { + assistiveText: { + spinner: 'Loading ...' + }, + type: 'text' +}; +/* + * This component was created to allow the DIV wrapped input to be used within other components such as combobox. This components API is not public. + */ + +var InnerInput = function InnerInput(props) { + var _props$containerProps = props.containerProps, + containerClassName = _props$containerProps.className, + containerProps = _objectWithoutProperties(_props$containerProps, ["className"]); + + var assistiveText = _objectSpread({}, defaultProps.assistiveText, props.assistiveText); + + return _react.default.createElement("div", _extends({ + className: (0, _classnames.default)(containerClassName, { + 'slds-input-has-icon': props.variant !== COUNTER && (props.iconLeft || props.iconRight), + 'slds-input-has-icon_left': props.iconLeft && !props.iconRight, + 'slds-input-has-icon_right': !props.iconLeft && props.iconRight, + 'slds-input-has-icon_left-right': props.variant !== COUNTER && props.iconLeft && props.iconRight, + 'slds-input-has-fixed-addon': props.fixedTextLeft || props.fixedTextRight, + 'slds-has-divider_bottom': props.isStatic + }) + }, containerProps), props.iconLeft && props.iconLeft, props.fixedTextLeft && _react.default.createElement("span", { + className: "slds-form-element__addon" + }, props.fixedTextLeft), !props.isStatic && _react.default.createElement("input", { + "aria-activedescendant": props['aria-activedescendant'], + "aria-autocomplete": props['aria-autocomplete'], + "aria-controls": props['aria-controls'], + "aria-labelledby": props['aria-labelledby'], + "aria-describedby": props.hasSpinner ? "loading-status-icon ".concat(props['aria-describedby']) : props['aria-describedby'], + "aria-expanded": props['aria-expanded'], + "aria-owns": props['aria-owns'], + "aria-required": props['aria-required'], + autoComplete: props.autoComplete, + className: (0, _classnames.default)('slds-input', { + 'slds-text-align_left': props.variant === COUNTER && props.readOnly + }, props.className), + disabled: props.disabled, + id: props.id, + min: props.minValue, + minLength: props.minLength, + max: props.maxValue, + maxLength: props.maxLength, + name: props.name, + onBlur: props.onBlur, + onChange: props.onChange, + onClick: props.onClick, + onFocus: props.onFocus, + onInput: props.onInput, + onInvalid: props.onInvalid, + onKeyDown: props.onKeyDown, + onKeyPress: props.onKeyPress, + onKeyUp: props.onKeyUp, + onSelect: props.onSelect, + onSubmit: props.onSubmit, + placeholder: props.placeholder, + readOnly: props.readOnly, + ref: props.inputRef, + required: props.required, + role: props.role, + step: props.step, + style: props.style, + tabIndex: props.tabIndex, + type: props.type, + value: props.value, + defaultValue: props.defaultValue + }), props.hasSpinner ? _react.default.createElement("div", { + className: "slds-input__icon-group slds-input__icon-group_right" + }, _react.default.createElement(_spinner.default, { + assistiveText: { + label: assistiveText.spinner + }, + id: "loading-status-icon", + isInput: true, + size: "x-small", + variant: "brand" + }), props.iconRight && props.iconRight) : props.iconRight && props.iconRight, props.fixedTextRight && _react.default.createElement("span", { + className: "slds-form-element__addon" + }, props.fixedTextRight), props.isStatic && _react.default.createElement("span", { + className: (0, _classnames.default)('slds-form-element__static', 'slds-grid', { + 'slds-grid_align-spread': props.variant !== COUNTER + }), + onClick: props.onClick + }, props.value, props.inlineEditTrigger), props.inlineHelpText && _react.default.createElement("div", { + className: "slds-form-element__help" + }, props.inlineHelpText)); +}; + +InnerInput.displayName = 'SLDSInnerInput'; +InnerInput.propTypes = propTypes; +InnerInput.defaultProps = defaultProps; +var _default = InnerInput; +exports.default = _default; \ No newline at end of file diff --git a/components/input/search.js b/components/input/search.js new file mode 100644 index 0000000000..3b8caea72b --- /dev/null +++ b/components/input/search.js @@ -0,0 +1,122 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _index = _interopRequireDefault(require("./index")); + +var _inputIcon = _interopRequireDefault(require("../icon/input-icon")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _keyCode = _interopRequireDefault(require("../../utilities/key-code")); + +var _event = _interopRequireDefault(require("../../utilities/event")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +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 handleKeyDown = function handleKeyDown(event, onSearch) { + if (event.keyCode === _keyCode.default.ENTER) { + _event.default.trapImmediate(event); + + onSearch(event); + } +}; + +var defaultProps = { + assistiveText: {} +}; +/** + * A `Search` is an `Input` which renders the search icon by default. It can be cleared, too. All `Input` props not specified as props already may be used with this component and will override defaults. + */ + +var Search = function Search(_ref) { + var clearable = _ref.clearable, + onClear = _ref.onClear, + onSearch = _ref.onSearch, + placeholder = _ref.placeholder, + props = _objectWithoutProperties(_ref, ["clearable", "onClear", "onSearch", "placeholder"]); + + (0, _checkProps.default)(_constants.SEARCH, props, _docs.default); + var assistiveText = typeof props.assistiveText === 'string' ? props.assistiveText : _objectSpread({}, defaultProps.assistiveText, props.assistiveText).label; + return _react.default.createElement(_index.default, _extends({ + assistiveText: { + label: assistiveText + }, + iconLeft: _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'Search' + }, + category: "utility", + name: "search", + onClick: onSearch + }), + iconRight: clearable ? _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'Clear' + }, + category: "utility", + name: "clear", + onClick: onClear + }) : null, + onKeyDown: onSearch ? function (event) { + return handleKeyDown(event, onSearch); + } : null, + placeholder: placeholder + }, props)); +}; + +Search.displayName = _constants.SEARCH; +Search.propTypes = { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `label`: Assistive text to search input + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string + }), + + /** + * Adds a clear button to right side of the input + */ + clearable: _propTypes.default.bool, + + /** + * Triggers when the clear button is clicked + */ + onClear: _propTypes.default.func, + + /** + * This event fires when enter is pressed in the `input` or the search button is clicked. + */ + onSearch: _propTypes.default.func, + + /** + * Placeholder for the input + */ + placeholder: _propTypes.default.string +}; +Search.defaultProps = defaultProps; +var _default = Search; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/__docs__/site-stories.js b/components/lookup/__docs__/site-stories.js new file mode 100644 index 0000000000..7d2a0fb1e5 --- /dev/null +++ b/components/lookup/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/lookup/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/lookup/__examples__/files.jsx'), require('raw-loader!@salesforce/design-system-react/components/lookup/__examples__/with-selection.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/lookup/__docs__/storybook-stories.js b/components/lookup/__docs__/storybook-stories.js new file mode 100644 index 0000000000..e47ed33823 --- /dev/null +++ b/components/lookup/__docs__/storybook-stories.js @@ -0,0 +1,234 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _lookup = _interopRequireDefault(require("../../lookup")); + +var _header = _interopRequireDefault(require("../../lookup/header")); + +var _footer = _interopRequireDefault(require("../../lookup/footer")); + +var _button = _interopRequireDefault(require("../../button")); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _files = _interopRequireDefault(require("../__examples__/files")); + +var _withSelection = _interopRequireDefault(require("../__examples__/with-selection")); + +var _deprecatedWarning = _interopRequireDefault(require("../../utilities/deprecated-warning")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var DemoLookup = +/*#__PURE__*/ +function (_React$Component) { + _inherits(DemoLookup, _React$Component); + + function DemoLookup() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, DemoLookup); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DemoLookup)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + options: [{ + label: 'File 1' + }, { + label: 'File 2' + }, { + label: 'File 3' + }, { + label: 'File 4' + }] + }); + + _defineProperty(_assertThisInitialized(_this), "clearSelected", function () { + _this.setState({ + currentSelected: -1 + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleSelect", function (selectedItem) { + for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + rest[_key2 - 1] = arguments[_key2]; + } + + (0, _addonActions.action)('select').apply(void 0, [selectedItem].concat(rest)); + + _this.setState({ + currentSelected: _this.state.options.indexOf(selectedItem) + }); + }); + + return _this; + } + + _createClass(DemoLookup, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement("div", null, _react.default.createElement(_button.default, { + onClick: this.clearSelected + }, "Clear Selected")), _react.default.createElement(_lookup.default, _extends({}, this.props, { + onChange: (0, _addonActions.action)('change'), + onSelect: this.handleSelect, + options: this.state.options, + selectedItem: this.state.currentSelected + }))); + } + }]); + + return DemoLookup; +}(_react.default.Component); + +_defineProperty(DemoLookup, "displayName", 'DemoLookup'); + +var DemoLookupAccounts = +/*#__PURE__*/ +function (_React$Component2) { + _inherits(DemoLookupAccounts, _React$Component2); + + function DemoLookupAccounts() { + var _getPrototypeOf3; + + var _this2; + + _classCallCheck(this, DemoLookupAccounts); + + for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + _this2 = _possibleConstructorReturn(this, (_getPrototypeOf3 = _getPrototypeOf(DemoLookupAccounts)).call.apply(_getPrototypeOf3, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this2), "state", { + options: [{ + label: "Paddy's Pub", + subTitle: 'Boston, MA' + }, { + label: 'Tyrell Corp', + subTitle: 'San Francisco, CA' + }, { + label: 'Paper St. Soap Company', + subTitle: 'Beloit, WI' + }, { + label: 'Nakatomi Investments', + subTitle: 'Chicago, IL' + }, { + label: 'Acme Landscaping' + }, { + label: 'Acme Construction', + subTitle: 'Grand Marais, MN' + }] + }); + + _defineProperty(_assertThisInitialized(_this2), "handleSelect", function (selectedItem) { + for (var _len4 = arguments.length, rest = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + rest[_key4 - 1] = arguments[_key4]; + } + + (0, _addonActions.action)('select').apply(void 0, [selectedItem].concat(rest)); + + _this2.setState({ + selectedItem: selectedItem + }); + }); + + return _this2; + } + + _createClass(DemoLookupAccounts, [{ + key: "render", + value: function render() { + return _react.default.createElement(_lookup.default, _extends({}, this.props, { + footerRenderer: _footer.default, + headerRenderer: _header.default, + onChange: (0, _addonActions.action)('change'), + onSelect: this.handleSelect, + options: this.state.options + })); + } + }]); + + return DemoLookupAccounts; +}(_react.default.Component); + +_defineProperty(DemoLookupAccounts, "displayName", 'DemoLookupAccounts'); + +(0, _react2.storiesOf)(_constants.LOOKUP, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_deprecatedWarning.default, null), getStory())); +}).add('Standard', function () { + return _react.default.createElement(DemoLookup, { + emptyMessage: "No Files found", + hasError: false, + iconCategory: "utility", + iconName: "open_folder", + isInline: true, + label: "Files" + }); +}).add('Disabled', function () { + return _react.default.createElement(DemoLookup, { + disabled: true + }); +}).add('Standard with Accounts', function () { + return _react.default.createElement(DemoLookupAccounts, { + emptyMessage: "No Accounts found", + hasError: false, + iconCategory: "standard", + iconName: "account", + isInline: true, + label: "Account" + }); +}).add('Custom Empty Message Content', function () { + return _react.default.createElement(DemoLookup, { + emptyMessage: _react.default.createElement("span", null, "No matches."), + isInline: true + }); +}).add('Docs site Default', function () { + return _react.default.createElement(_default.default, null); +}).add('Docs site Files', function () { + return _react.default.createElement(_files.default, null); +}).add('Docs site WithSelection', function () { + return _react.default.createElement(_withSelection.default, null); +}); \ No newline at end of file diff --git a/components/lookup/__examples__/default.js b/components/lookup/__examples__/default.js new file mode 100644 index 0000000000..c9e21714ee --- /dev/null +++ b/components/lookup/__examples__/default.js @@ -0,0 +1,97 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _lookup = _interopRequireDefault(require("../../../../components/lookup")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_lookup.default, { + emptyMessage: "No items found", + hasError: false, + label: "Account", + onChange: function onChange(newValue) { + console.log('New search term: ', newValue); + }, + onSelect: function onSelect(item) { + console.log(item, ' Selected'); + }, + options: [{ + type: 'section', + label: 'SECTION 1' + }, { + label: "Paddy's Pub" + }, { + label: 'Tyrell Corp' + }, { + type: 'section', + label: 'SECTION 2' + }, { + label: 'Paper St. Soap Company' + }, { + label: 'Nakatomi Investments' + }, { + label: 'Acme Landscaping' + }, { + type: 'section', + label: 'SECTION 3' + }, { + label: 'Acme Construction' + }], + sectionDividerRenderer: _lookup.default.DefaultSectionDivider + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'LookupExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/__examples__/files.js b/components/lookup/__examples__/files.js new file mode 100644 index 0000000000..7aef3250c0 --- /dev/null +++ b/components/lookup/__examples__/files.js @@ -0,0 +1,83 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _lookup = _interopRequireDefault(require("../../../../components/lookup")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_lookup.default, { + emptyMessage: "No Files found", + hasError: false, + iconCategory: "utility", + iconInverse: false, + iconName: "open_folder", + label: "Files", + onSelect: function onSelect(item) { + console.log(item, ' Selected'); + }, + options: [{ + label: 'File 1' + }, { + label: 'File 2' + }, { + label: 'File 3' + }, { + label: 'File 4' + }] + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'LookupExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/__examples__/with-selection.js b/components/lookup/__examples__/with-selection.js new file mode 100644 index 0000000000..9ea6f49444 --- /dev/null +++ b/components/lookup/__examples__/with-selection.js @@ -0,0 +1,92 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _lookup = _interopRequireDefault(require("../../../../components/lookup")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_lookup.default, { + emptyMessage: "No items found", + footerRenderer: _lookup.default.DefaultFooter, + hasError: false, + headerRenderer: _lookup.default.DefaultHeader, + iconCategory: "standard", + iconName: "account", + label: "Account", + onChange: function onChange(newValue) { + console.log('New search term: ', newValue); + }, + onSelect: function onSelect(item) { + console.log(item, ' Selected'); + }, + options: [{ + label: "Paddy's Pub" + }, { + label: 'Tyrell Corp' + }, { + label: 'Paper St. Soap Company' + }, { + label: 'Nakatomi Investments' + }, { + label: 'Acme Landscaping' + }, { + label: 'Acme Construction' + }], + selectedItem: 1 + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'LookupExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/check-props.js b/components/lookup/check-props.js new file mode 100644 index 0000000000..5aa125e44b --- /dev/null +++ b/components/lookup/check-props.js @@ -0,0 +1,26 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _componentIsDeprecated = _interopRequireDefault(require("../../utilities/warning/component-is-deprecated")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT) { + (0, _componentIsDeprecated.default)(COMPONENT, 'Please use an auto-complete Combobox instead. It is more accessible and closer aligned to SLDS.'); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/footer.js b/components/lookup/footer.js new file mode 100644 index 0000000000..fdf476c4e8 --- /dev/null +++ b/components/lookup/footer.js @@ -0,0 +1,110 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../icon")); + +var _event = _interopRequireDefault(require("../../utilities/event")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var displayName = 'LookupDefaultFooter'; +var propTypes = {}; +var defaultProps = {}; + +var DefaultFooter = +/*#__PURE__*/ +function (_React$Component) { + _inherits(DefaultFooter, _React$Component); + + function DefaultFooter() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, DefaultFooter); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DefaultFooter)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function () { + if (_this.props.onClose) { + _this.props.onClose(); + } + }); + + return _this; + } + + _createClass(DefaultFooter, [{ + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + if (nextProps.isActive !== this.props.isActive && nextProps.isActive === true) { + this.props.setFocus('newItem'); + } + } + }, { + key: "render", + value: function render() { + var className = 'slds-lookup__item-action slds-lookup__item-action_label'; + if (this.props.isActive) className += ' slds-theme_shade'; + return ( + /* eslint-disable jsx-a11y/no-static-element-interactions */ + _react.default.createElement("div", { + className: "js-slds-lookup__item", + onClick: this.handleClick, + onMouseDown: _event.default.trapImmediate + }, _react.default.createElement("a", { + id: "newItem", + href: "javascript:void(0);", + className: className + }, _react.default.createElement("span", { + className: "lookup__item-action-label" + }, _react.default.createElement(_icon.default, { + name: "add", + category: "utility", + size: "x-small", + className: "slds-icon-text-default" + }), _react.default.createElement("span", { + className: "slds-truncate" + }, this.props.newItemLabel ? this.props.newItemLabel : 'Add New Item')))) + ); + } + }]); + + return DefaultFooter; +}(_react.default.Component); + +DefaultFooter.displayName = displayName; +DefaultFooter.propTypes = propTypes; +DefaultFooter.defaultProps = defaultProps; +var _default = DefaultFooter; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/header.js b/components/lookup/header.js new file mode 100644 index 0000000000..361a6712dc --- /dev/null +++ b/components/lookup/header.js @@ -0,0 +1,110 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../icon")); + +var _event = _interopRequireDefault(require("../../utilities/event")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var displayName = 'LookupDefaultHeader'; +var propTypes = {}; +var defaultProps = {}; + +var DefaultHeader = +/*#__PURE__*/ +function (_React$Component) { + _inherits(DefaultHeader, _React$Component); + + function DefaultHeader() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, DefaultHeader); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DefaultHeader)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function () { + if (_this.props.onClose) { + _this.props.onClose(); + } + }); + + return _this; + } + + _createClass(DefaultHeader, [{ + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + if (nextProps.isActive !== this.props.isActive && nextProps.isActive === true) { + this.props.setFocus('searchRecords'); + } + } + }, { + key: "render", + value: function render() { + var className = 'slds-lookup__item-action slds-lookup__item-action_label'; + if (this.props.isActive) className += ' slds-theme_shade'; + return ( + /* eslint-disable jsx-a11y/no-static-element-interactions */ + _react.default.createElement("div", { + className: "js-slds-lookup__item", + onMouseDown: _event.default.trapImmediate, + onClick: this.handleClick + }, _react.default.createElement("a", { + id: "searchRecords", + href: "javascript:void(0);", + className: className + }, _react.default.createElement("span", { + className: "lookup__item-action-label" + }, _react.default.createElement(_icon.default, { + name: "search", + category: "utility", + size: "x-small", + className: "slds-icon-text-default" + }), _react.default.createElement("span", { + className: "slds-truncate" + }, this.props.searchTerm)))) + ); + } + }]); + + return DefaultHeader; +}(_react.default.Component); + +DefaultHeader.displayName = displayName; +DefaultHeader.propTypes = propTypes; +DefaultHeader.defaultProps = defaultProps; +var _default = DefaultHeader; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/index.js b/components/lookup/index.js new file mode 100644 index 0000000000..69708b0069 --- /dev/null +++ b/components/lookup/index.js @@ -0,0 +1,47 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "DefaultFooter", { + enumerable: true, + get: function get() { + return _defaultFooter.default; + } +}); +Object.defineProperty(exports, "DefaultHeader", { + enumerable: true, + get: function get() { + return _defaultHeader.default; + } +}); +Object.defineProperty(exports, "DefaultSectionDivider", { + enumerable: true, + get: function get() { + return _defaultSectionDivider.default; + } +}); +exports.default = void 0; + +var _reactOnclickoutside = _interopRequireDefault(require("react-onclickoutside")); + +var _defaultFooter = _interopRequireDefault(require("./menu/default-footer")); + +var _defaultHeader = _interopRequireDefault(require("./menu/default-header")); + +var _defaultSectionDivider = _interopRequireDefault(require("./menu/default-section-divider")); + +var _lookup = _interopRequireDefault(require("./lookup")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// ### onClickOutside +// Listen for clicks that occur somewhere in the document, outside of the element itself +var _default = (0, _reactOnclickoutside.default)(_lookup.default, { + excludeScrollbar: true +}); + +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/lookup.js b/components/lookup/lookup.js new file mode 100644 index 0000000000..e873bb0c8a --- /dev/null +++ b/components/lookup/lookup.js @@ -0,0 +1,849 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.escaperegexp")); + +var _lodash2 = _interopRequireDefault(require("lodash.isequal")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _dialog = _interopRequireDefault(require("../utilities/dialog")); + +var _button = _interopRequireDefault(require("../button")); + +var _icon = _interopRequireDefault(require("../icon")); + +var _inputIcon = _interopRequireDefault(require("../icon/input-icon")); + +var _input = _interopRequireDefault(require("../input")); + +var _event = _interopRequireDefault(require("../../utilities/event")); + +var _keyCode = _interopRequireDefault(require("../../utilities/key-code")); + +var _menu = _interopRequireDefault(require("./menu")); + +var _constants = require("../../utilities/constants"); + +var _class, _temp; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * A function that takes a term string and an item and returns a truthy value if the item should be kept. + */ +var defaultFilter = function defaultFilter(term, item) { + if (!term) return true; + return item.data && item.data.type === 'section' || item.label.match(new RegExp((0, _lodash.default)(term), 'ig')); +}; + +var normalizeSearchTerm = function normalizeSearchTerm(string) { + return (string || '').toString().replace(/^\s+/, ''); +}; +/** + * ** Lookup is deprecated. Please use an auto-complete Combobox instead.** + * + * Lookup is an advanced inline search form. The lookup can parse through single or multi scoped datasets. The parsed dataset can be filtered by single or multi option selects. + * + * This component is wrapped in a [higher order component to listen for clicks outside itself](https://github.com/kentor/react-click-outside) and thus requires use of `ReactDOM`. + */ + + +var Lookup = (_temp = _class = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Lookup, _React$Component); + + function Lookup() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Lookup); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Lookup)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + currentFocus: null, + focusIndex: null, + items: [], + listLength: _this.props.options.length, + searchTerm: normalizeSearchTerm(_this.props.searchTerm), + selectedIndex: _this.props.selectedItem + }); + + _defineProperty(_assertThisInitialized(_this), "getClassName", function () { + return (0, _classnames.default)(_this.props.className, 'slds-form-element slds-lookup', { + 'slds-has-selection': _this.isSelected(), + 'slds-is-open': _this.getIsOpen() + }); + }); + + _defineProperty(_assertThisInitialized(_this), "setFirstIndex", function () { + var nextFocusIndex = 0; + var filteredItem = _this.state.items[0]; + + if (_this.menuComponent && _this.menuComponent.getFilteredItemForIndex) { + filteredItem = _this.menuComponent.getFilteredItemForIndex(nextFocusIndex); + } + + if (filteredItem && filteredItem.data.type === 'section') { + nextFocusIndex += 1; + } + + _this.setState({ + focusIndex: nextFocusIndex + }); + }); + + _defineProperty(_assertThisInitialized(_this), "getHeader", function () { + var Header = _this.props.headerRenderer; + var headerActive = _this.state.focusIndex === 0; + return _react.default.createElement(Header, _extends({ + ref: function ref(header) { + _this.headerComponent = header; + } + }, _this.props, { + focusIndex: _this.state.focusIndex, + isActive: headerActive, + onClose: _this.handleClose, + searchTerm: _this.state.searchTerm, + setFocus: _this.setFocus + })); + }); + + _defineProperty(_assertThisInitialized(_this), "getFooter", function () { + var Footer = _this.props.footerRenderer; + + var numFocusable = _this.getNumFocusableItems(); + + var footerActive = _this.state.focusIndex === numFocusable; + return _react.default.createElement(Footer, _extends({ + ref: function ref(footer) { + _this.footerComponent = footer; + } + }, _this.props, { + focusIndex: _this.state.focusIndex, + isActive: footerActive, + onClose: _this.handleClose, + setFocus: _this.setFocus + })); + }); + + _defineProperty(_assertThisInitialized(_this), "setFocus", function (id) { + _this.setState({ + currentFocus: id + }); + }); + + _defineProperty(_assertThisInitialized(_this), "getIsOpen", function () { + return !!(typeof _this.props.isOpen === 'boolean' ? _this.props.isOpen : _this.state.isOpen); + }); + + _defineProperty(_assertThisInitialized(_this), "getListLength", function (qty) { + if (qty !== _this.state.listLength) { + _this.setState({ + listLength: qty + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "getNumFocusableItems", function () { + var offset = 0; + + if (_this.footerComponent) { + offset += 1; + } + + if (_this.headerComponent) { + offset += 1; + } + + return _this.state.listLength - 1 + offset; + }); + + _defineProperty(_assertThisInitialized(_this), "increaseIndex", function () { + var numFocusable = _this.getNumFocusableItems(); + + var nextFocusIndex = _this.state.focusIndex < numFocusable ? _this.state.focusIndex + 1 : 0; + + var filteredItem = _this.menuComponent.getFilteredItemForIndex(nextFocusIndex); + + if (filteredItem && filteredItem.data.type === 'section') { + nextFocusIndex += 1; + } + + _this.setState({ + focusIndex: nextFocusIndex + }); + }); + + _defineProperty(_assertThisInitialized(_this), "decreaseIndex", function () { + var numFocusable = _this.getNumFocusableItems(); + + var prevFocusIndex = _this.state.focusIndex > 0 ? _this.state.focusIndex - 1 : numFocusable; + + var filteredItem = _this.menuComponent.getFilteredItemForIndex(prevFocusIndex); + + if (filteredItem && filteredItem.data.type === 'section') { + prevFocusIndex = prevFocusIndex === 0 ? numFocusable : prevFocusIndex - 1; + } + + _this.setState({ + focusIndex: prevFocusIndex + }); + }); + + _defineProperty(_assertThisInitialized(_this), "selectItem", function (itemId) { + if (itemId) { + var index = itemId.replace('item-', ''); + + _this.selectItemByIndex(index); + } + }); + + _defineProperty(_assertThisInitialized(_this), "selectItemByIndex", function (index) { + if (index >= 0 && index < _this.state.items.length) { + if (_this.props.onRequestClose) { + _this.props.onRequestClose(); + } + + _this.setState({ + isOpen: false, + selectedIndex: index, + searchTerm: '' + }); + + var data = _this.state.items[index].data; + + if (_this.props.onSelect) { + _this.props.onSelect(data); + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleDeleteSelected", function () { + if (_this.props.onRequestOpen) { + _this.props.onRequestOpen(); + } + + _this.setState({ + selectedIndex: null, + isOpen: true + }); + + _this.focusInput(); + + if (_this.props.onUnselect) { + _this.props.onUnselect(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleClose", function () { + if (_this.props.onRequestClose) { + _this.props.onRequestClose(); + } + + _this.setState({ + isOpen: false, + focusIndex: null, + currentFocus: null + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClickOutside", function () { + _this.handleClose(); + }); + + _defineProperty(_assertThisInitialized(_this), "handleEscape", function (event) { + if (_this.getIsOpen() && event) { + _event.default.trap(event); + } + + _this.handleClose(); + }); + + _defineProperty(_assertThisInitialized(_this), "handleCancel", function () { + _this.handleClose(); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function () { + if (_this.props.onRequestOpen) { + _this.props.onRequestOpen(); + } + + _this.setState({ + isOpen: true + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleBlur", function (event) { + if (_this.props.onBlur) { + var target = event.target || event.currentTarget; + + _this.props.onBlur(target.value); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleFocus", function (event) { + if (_this.props.onFocus) { + var target = event.target || event.currentTarget; + + _this.props.onFocus(target.value); + } + + if (_this.props.onRequestOpen) { + _this.props.onRequestOpen(); + } + + _this.setState({ + isOpen: true + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (event) { + var target = event.target || event.currentTarget; + + _this.setState({ + searchTerm: normalizeSearchTerm(target.value) + }); + + if (_this.props.onChange) { + _this.props.onChange(target.value); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) { + if (event.keyCode) { + // If user hits esc key or tab key, close menu + if (event.keyCode === _keyCode.default.ESCAPE) { + _this.handleEscape(event); + } else if (event.keyCode === _keyCode.default.TAB) { + // remove the focus on input, tab focus shoud move to next tabbale elemnt + setTimeout(function () { + _this.handleClose(); + }, 200); + + _this.handleBlur(event); + } else { + _this.handleClick(); + } // If user hits down key, advance aria activedescendant to next item + + + if (event.keyCode === _keyCode.default.DOWN) { + _event.default.trapImmediate(event); + + if (_this.state.focusIndex === null) { + _this.setFirstIndex(); + } else { + _this.increaseIndex(); + } + } else if (event.keyCode === _keyCode.default.UP) { + // If user hits up key, advance aria activedescendant to previous item + _event.default.trapImmediate(event); + + var numFocusable = _this.getNumFocusableItems(); + + if (_this.state.focusIndex === null) { + _this.setState({ + focusIndex: numFocusable + }); + } else { + _this.decreaseIndex(); + } + } else if (event.keyCode === _keyCode.default.ENTER && _this.state.focusIndex !== null) { + // If user hits enter, select current activedescendant item + _event.default.trapImmediate(event); // If the focus is on the first fixed Action Item in Menu, click it + + + if (_this.headerComponent && _this.state.focusIndex === 0) { + _this.headerComponent.handleClick(); + } else if (_this.footerComponent && _this.state.focusIndex === _this.state.listLength + 1) { + // If the focus is on the last fixed Action Item in Menu, click it + _this.footerComponent.handleClick(); + } else { + // If not, then select menu item + _this.selectItem(_this.state.currentFocus); + } + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "handlePillKeyDown", function (event) { + if (event.keyCode) { + if (event.keyCode === _keyCode.default.DELETE || event.keyCode === _keyCode.default.BACKSPACE) { + _event.default.trapImmediate(event); + + _this.handleDeleteSelected(); + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "inputRefId", function () { + return "".concat(_this.props.label, "Lookup"); + }); + + _defineProperty(_assertThisInitialized(_this), "focusInput", function () { + _this.focusOnRender = true; + }); + + _defineProperty(_assertThisInitialized(_this), "isSelected", function () { + var hasSelection = !isNaN(parseInt(_this.state.selectedIndex, 10)) && _this.state.selectedIndex >= 0; + return hasSelection; + }); + + _defineProperty(_assertThisInitialized(_this), "modifyItems", function (itemsToModify) { + var items = itemsToModify.map(function (item, index) { + return { + id: "item-".concat(index), + label: item.label, + data: item + }; + }); + + _this.setState({ + items: items + }); + }); + + _defineProperty(_assertThisInitialized(_this), "renderMenuContent", function () { + return _react.default.createElement(_menu.default, { + ref: function ref(menu) { + _this.menuComponent = menu; + }, + emptyMessage: _this.props.emptyMessage, + filterWith: _this.props.filterWith, + focusIndex: _this.state.focusIndex, + footer: _this.props.footerRenderer ? _this.getFooter() : null, + getListLength: _this.getListLength, + header: _this.props.headerRenderer ? _this.getHeader() : null, + iconCategory: _this.props.iconCategory, + iconInverse: _this.props.iconInverse, + iconName: _this.props.iconName, + items: _this.state.items, + label: _this.props.label, + listItemLabelRenderer: _this.props.listItemLabelRenderer, + listLength: _this.state.listLength, + onSelect: _this.selectItem, + searchTerm: _this.state.searchTerm, + sectionDividerRenderer: _this.props.sectionDividerRenderer, + setFocus: _this.setFocus + }); + }); + + _defineProperty(_assertThisInitialized(_this), "renderInlineMenu", function () { + return _this.getIsOpen() ? _react.default.createElement("div", { + className: "ignore-react-onclickoutside slds-lookup__menu", + role: "listbox" + }, _this.renderMenuContent()) : null; + }); + + _defineProperty(_assertThisInitialized(_this), "renderSeparateMenu", function () { + // FOR BACKWARDS COMPATIBILITY + var menuPosition = _this.props.isInline ? 'relative' : _this.props.menuPosition; // eslint-disable-line react/prop-types + + return _this.getIsOpen() ? _react.default.createElement(_dialog.default, { + align: "bottom", + className: "slds-lookup__menu slds-show", + closeOnTabKey: true, + contentsClassName: "slds-lookup__menu slds-show", + context: _this.context, + inheritWidthOf: "target", + onClose: _this.handleCancel, + hasStaticAlignement: !_this.props.flippable, + constrainToScrollParent: _this.props.constrainToScrollParent, + onRequestTargetElement: function onRequestTargetElement() { + return _this.input; + }, + position: menuPosition + }, _this.renderMenuContent()) : null; + }); + + _defineProperty(_assertThisInitialized(_this), "renderInput", function () { + return _react.default.createElement(_input.default, { + "aria-activedescendant": _this.state.currentFocus ? _this.state.currentFocus : '', + "aria-autocomplete": "list", + "aria-describedby": _this.props.describedById, + "aria-expanded": !!_this.getIsOpen(), + assistiveText: _this.props.assistiveText, + className: "slds-lookup__search-input", + disabled: _this.props.disabled, + iconRight: _react.default.createElement(_inputIcon.default, { + assistiveText: { + icon: 'Search' + }, + category: "utility", + name: "search" + }), + id: _this.inputRefId(), + onBlur: _this.handleBlur, + onChange: _this.handleChange, + onClick: _this.handleClick, + onFocus: _this.handleFocus, + onKeyDown: _this.handleKeyDown, + inputRef: function inputRef(component) { + _this.input = component; + + if (_this.focusOnRender) { + _this.input.focus(); + + _this.focusOnRender = false; + } + }, + placeholder: _this.props.placeholder, + role: "combobox", + type: "text", + value: _this.state.searchTerm + }); + }); + + _defineProperty(_assertThisInitialized(_this), "renderSelectedItem", function () { + var selectedItem = _this.props.options[_this.state.selectedIndex].label; + var renderIcon = _this.props.iconName ? _react.default.createElement(_icon.default, { + category: _this.props.iconCategory, + className: "slds-icon slds-pill__icon", + inverse: _this.props.iconInverse, + name: _this.props.iconName + }) : null; + var labelClassName = _this.props.iconName ? 'slds-pill__label' : 'slds-pill__label slds-m-left_x-small'; // i18n + + return _react.default.createElement("div", { + className: "slds-pill__container" + }, _react.default.createElement("a", { + href: "javascript:void(0)", + className: "slds-pill", + ref: function ref(pill) { + _this.pills[_this.state.selectedIndex] = pill; + }, + onKeyDown: _this.handlePillKeyDown + }, renderIcon, _react.default.createElement("span", { + className: labelClassName + }, selectedItem), _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Press delete to remove' + }, + className: "slds-pill__remove slds-button_icon-bare", + iconCategory: "utility", + iconName: "close", + onClick: _this.handleDeleteSelected, + tabIndex: "-1", + variant: "icon" + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "renderLabel", function () { + var inputLabel; + var required = _this.props.required ? _react.default.createElement("span", { + className: "slds-required" + }, "*") : null; + + if (_this.isSelected()) { + // inline style override + inputLabel = _react.default.createElement("span", { + className: "slds-form-element__label", + style: { + width: '100%' + } + }, required, _this.props.label); + } else { + inputLabel = _react.default.createElement("label", { + className: "slds-form-element__label", + htmlFor: _this.inputRefId(), + style: { + width: '100%' + } + }, required, _this.props.label); + } + + return inputLabel; + }); + + return _this; + } + + _createClass(Lookup, [{ + key: "componentWillMount", + value: function componentWillMount() { + // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + (0, _checkProps.default)(_constants.LOOKUP, this.props); // Keeps track of references of children for keyboard navigation + + this.pills = []; + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + this.modifyItems(this.props.options); + } + }, { + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(newProps) { + if (newProps.options) { + this.modifyItems(newProps.options); + } + + if (newProps.selectedItem !== this.props.selectedItem || !(0, _lodash2.default)(newProps.options, this.props.options)) { + this.setState({ + selectedIndex: newProps.selectedItem + }); + } + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps, prevState) { + if (!isNaN(parseInt(prevState.selectedIndex, 10)) && isNaN(parseInt(this.state.selectedIndex, 10))) { + if (this.input) { + this.input.focus(); + } + } else if (isNaN(parseInt(prevState.selectedIndex, 10)) && !isNaN(parseInt(this.state.selectedIndex, 10))) { + if (this.pills[this.state.selectedIndex]) { + this.pills[this.state.selectedIndex].focus(); + } + } + } + }, { + key: "render", + value: function render() { + var isInline; + /* eslint-disable react/prop-types */ + + if (this.props.isInline) { + isInline = true; + } else if (this.props.modal !== undefined) { + isInline = !this.props.modal; + } + /* eslint-enable react/prop-types */ + + + var formElementControlClasses = _defineProperty({ + 'slds-form-element__control': true + }, "slds-input-has-icon slds-input-has-icon_".concat(this.props.iconPosition), !this.isSelected()); + + return _react.default.createElement("div", { + className: this.getClassName(), + "data-select": "single", + "data-scope": "single", + onScroll: this.props.onScroll + }, this.props.label ? this.renderLabel() : null, _react.default.createElement("div", { + className: (0, _classnames.default)(formElementControlClasses) + }, this.isSelected() ? this.renderSelectedItem() : null, !this.isSelected() ? this.renderInput() : null), isInline ? this.renderInlineMenu() : this.renderSeparateMenu()); + } + }]); + + return Lookup; +}(_react.default.Component), _defineProperty(_class, "displayName", _constants.LOOKUP), _defineProperty(_class, "propTypes", { + /** + * If present, the label associated with this `input` is overwritten + * by this text and is visually not shown. + */ + assistiveText: _propTypes.default.string, + + /** + * Class names to be added to the tag classed with `slds-lookup`. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * If true, constrains the menu to the scroll parent. Has no effect if `isInline` is `true`. + */ + constrainToScrollParent: _propTypes.default.bool, + + /** + * ID for aria-describedby (e.g. for an error message or a description) + */ + describedById: _propTypes.default.string, + + /** + * Please select one of the following: + * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog. + * * `overflowBoundaryElement` - The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree. + * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing. + */ + menuPosition: _propTypes.default.string, + + /** + * This prop is passed onto the `input`. Prevents dropdown menu from opening. Also applies disabled styling to input. + */ + disabled: _propTypes.default.bool, + + /** + * Custom message that renders when no matches found. The default empty state is just text that says, 'No matches found.'. + */ + emptyMessage: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + + /** + * Custom function to filter the Lookup items when typing into input field. The default function is case-insensitive and uses the searchTerm to filter Lookup items on their labels. + */ + filterWith: _propTypes.default.func, + + /** + * If true, the menu is constrained to the window and may be flipped up. Has no effect if `isInline` is `true`. In other components, its opposite is used `hasStaticAlignment`. + */ + flippable: _propTypes.default.bool, + + /** + * Custom component for Lookup footer. The default footer allows user to add new item - see Lightning Design System Lookup > Base. To use the default footer, pass in Lookup.DefaultFooter. + */ + footerRenderer: _propTypes.default.func, + + /** + * Custom component for Lookup header. The default header has a search icon and shows the search term - see Lightning Design System Lookup > Base. To use the default header, pass in Lookup.DefaultHeader. + */ + headerRenderer: _propTypes.default.func, + + /** + * Please refer to Lightning Design System Icons to view categories. + */ + iconCategory: _propTypes.default.string, + + /** + * If true, icon color is white. If false, icon color is the default text color. + */ + iconInverse: _propTypes.default.bool, + + /** + * Name of icon. Please refer to Lightning Design System Icons to view icon names. + */ + iconName: _propTypes.default.string, + + /** + * Determines whether the input's icon will display that icon on the left or the right. + */ + iconPosition: _propTypes.default.oneOf(['left', 'right']), + + /** + * Renders menu within the wrapping trigger as a sibling of the button. By default, you will have an absolutely positioned container at an elevated z-index. + */ + isInline: _propTypes.default.bool, + + /** + * Whether or not the dropdown menu is open. This overrides the default behavior. + */ + isOpen: _propTypes.default.bool, + + /** + * Form label for input. + */ + label: _propTypes.default.string, + + /** + * Custom component that overrides the default Lookup Item component. + */ + listItemLabelRenderer: _propTypes.default.func, + + /** + * Triggered when input focus is removed. + */ + onBlur: _propTypes.default.func, + + /** + * Triggered when the contents of the input changes. + */ + onChange: _propTypes.default.func, + + /** + * Triggered when input is focused. + */ + onFocus: _propTypes.default.func, + + /** + * Function called when the lookup dropdown would like hide. This will turn the Lookup into into a controlled component. Please use with `isOpen`. + */ + onRequestClose: _propTypes.default.func, + + /** + * Function called when the lookup dropdown would like show. This will turn the Lookup into into a controlled component. Please use with `isOpen`. + */ + onRequestOpen: _propTypes.default.func, + + /** + * Triggered when the user scrolls in the dropdown menu. + */ + onScroll: _propTypes.default.func, + + /** + * Triggered when an item is selected from the dropdown menu. + */ + onSelect: _propTypes.default.func, + + /** + * Triggered when an item is an item is removed from the input. + */ + onUnselect: _propTypes.default.func, + + /** + * Item added to the dropdown menu. + */ + options: _propTypes.default.array.isRequired, + + /** + * Text that will appear in an empty input. + */ + placeholder: _propTypes.default.string, + + /** + * If true, adds asterisk next to input label to indicate it is a required field. + */ + required: _propTypes.default.bool, + + /** + * Text passed on to header search input of dropdown menu. + */ + searchTerm: _propTypes.default.string, + + /** + * Custom component that overrides the default section divider + */ + sectionDividerRenderer: _propTypes.default.func, + + /** + * Index of current selected item. To clear the selection, pass in -1. + */ + selectedItem: _propTypes.default.number +}), _defineProperty(_class, "defaultProps", { + constrainToScrollParent: true, + filterWith: defaultFilter, + iconPosition: 'right', + searchTerm: '', + menuPosition: 'absolute' +}), _temp); +Lookup.contextTypes = { + iconPath: _propTypes.default.string +}; +var _default = Lookup; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/menu/default-footer/index.js b/components/lookup/menu/default-footer/index.js new file mode 100644 index 0000000000..1423c9eca6 --- /dev/null +++ b/components/lookup/menu/default-footer/index.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _header = _interopRequireDefault(require("../../header")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Alias +var _default = _header.default; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/menu/default-header/index.js b/components/lookup/menu/default-header/index.js new file mode 100644 index 0000000000..fedded76c4 --- /dev/null +++ b/components/lookup/menu/default-header/index.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _footer = _interopRequireDefault(require("../../footer")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Alias +var _default = _footer.default; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/menu/default-section-divider/index.js b/components/lookup/menu/default-section-divider/index.js new file mode 100644 index 0000000000..6dfb87ea5b --- /dev/null +++ b/components/lookup/menu/default-section-divider/index.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _sectionDivider = _interopRequireDefault(require("../../section-divider")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Alias +var _default = _sectionDivider.default; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/menu/index.js b/components/lookup/menu/index.js new file mode 100644 index 0000000000..79848e7fd9 --- /dev/null +++ b/components/lookup/menu/index.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _menu = _interopRequireDefault(require("../private/menu")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Alias +var _default = _menu.default; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/menu/item/index.js b/components/lookup/menu/item/index.js new file mode 100644 index 0000000000..66550cbbc6 --- /dev/null +++ b/components/lookup/menu/item/index.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _item = _interopRequireDefault(require("../../private/item")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Alias +var _default = _item.default; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/private/item.js b/components/lookup/private/item.js new file mode 100644 index 0000000000..55e965df35 --- /dev/null +++ b/components/lookup/private/item.js @@ -0,0 +1,183 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _icon = _interopRequireDefault(require("../../icon")); + +var _event = _interopRequireDefault(require("../../../utilities/event")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var displayName = 'Lookup-Menu-Item'; +var propTypes = { + data: _propTypes.default.object, + handleItemFocus: _propTypes.default.func, + href: _propTypes.default.string, + iconCategory: _propTypes.default.string, + id: _propTypes.default.string, + index: _propTypes.default.number, + isActive: _propTypes.default.bool, + isDisabled: _propTypes.default.bool, + listItemLabelRenderer: _propTypes.default.func, + onSelect: _propTypes.default.func, + searchTerm: _propTypes.default.string, + setFocus: _propTypes.default.func +}; + +var Item = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Item, _React$Component); + + function Item() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Item); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Item)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function () { + return _this.props.onSelect(_this.props.id, _this.props.data); + }); + + return _this; + } + + _createClass(Item, [{ + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + if (nextProps.isActive !== this.props.isActive && nextProps.isActive === true) { + this.scrollFocus(); + this.props.setFocus(this.props.id); + } + } + }, { + key: "getCustomLabel", + value: function getCustomLabel() { + var ListItemLabel = this.props.listItemLabelRenderer; + return _react.default.createElement(ListItemLabel, this.props); + } + }, { + key: "getIcon", + value: function getIcon() { + if (this.props.iconName && !this.props.listItemLabelRenderer) { + return _react.default.createElement("span", { + className: "slds-media__figure" + }, _react.default.createElement(_icon.default, { + category: this.props.iconCategory, + inverse: this.props.iconInverse, + key: this.props.iconName, + name: this.props.iconName, + size: "small" + })); + } + + return null; + } + }, { + key: "getLabel", + value: function getLabel() { + var label; + + if (this.props.children.data.subTitle) { + label = _react.default.createElement("div", { + className: "slds-media__body" + }, _react.default.createElement("div", { + className: "slds-lookup__result-text" + }, this.props.children.label), _react.default.createElement("span", { + className: "slds-lookup__result-meta slds-text-body_small" + }, this.props.children.data.subTitle)); + } else { + var labelClassName = (0, _classnames.default)('slds-lookup__result-text', { + 'slds-m-left_x-small': !this.props.iconName + }); + label = _react.default.createElement("div", { + className: "slds-media__body" + }, _react.default.createElement("div", { + className: labelClassName + }, this.props.children.label)); + } + + return label; + } + }, { + key: "scrollFocus", + // Scroll menu item based on up/down mouse keys (assumes all items are the same height) + value: function scrollFocus() { + var height = this.itemRef.offsetHeight; + + if (height && this.props.handleItemFocus) { + this.props.handleItemFocus(this.props.index, height); + } + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var itemClassName = 'js-slds-lookup__item'; + var id = this.props.id; + if (this.props.isActive) itemClassName += ' slds-theme_shade'; + return (// IMPORTANT: anchor id is used to set lookup's input's aria-activedescendant + _react.default.createElement("li", { + className: itemClassName, + ref: function ref(li) { + _this2.itemRef = li; + } + }, _react.default.createElement("a", { + "aria-disabled": this.props.isDisabled, + className: "slds-lookup__item-action slds-media slds-media_center", + href: this.props.href, + id: id, + onClick: this.handleClick, + onMouseDown: _event.default.trapImmediate, + ref: id, + role: "option", + tabIndex: "-1" + }, this.getIcon(), this.props.listItemLabelRenderer ? this.getCustomLabel() : this.getLabel())) + ); + } + }]); + + return Item; +}(_react.default.Component); + +Item.displayName = displayName; +Item.propTypes = propTypes; +var _default = Item; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/private/menu.js b/components/lookup/private/menu.js new file mode 100644 index 0000000000..74df49b86e --- /dev/null +++ b/components/lookup/private/menu.js @@ -0,0 +1,242 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _item = _interopRequireDefault(require("./item")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/no-did-update-set-state */ +var displayName = 'Lookup-Menu'; +var propTypes = { + boldRegex: _propTypes.default.instanceOf(RegExp), + emptyMessage: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + filterWith: _propTypes.default.func, + focusIndex: _propTypes.default.number, + getListLength: _propTypes.default.func, + iconCategory: _propTypes.default.string, + items: _propTypes.default.array, + label: _propTypes.default.string, + listLength: _propTypes.default.number, + searchTerm: _propTypes.default.string, + setFocus: _propTypes.default.func +}; +var defaultProps = { + emptyMessage: 'No matches found.' +}; + +var Menu = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Menu, _React$Component); + + function Menu(props) { + var _this; + + _classCallCheck(this, Menu); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Menu).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "handleItemFocus", function (itemIndex, itemHeight) { + if (_this.listRef) { + _this.listRef.scrollTop = itemIndex * itemHeight; + } + }); + + _this.state = { + filteredItems: _this.filteredItems() + }; + return _this; + } // Set filtered list length in parent to determine active indexes for aria-activedescendent + + + _createClass(Menu, [{ + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps) { + // make an array of the children of the list but only count the actual items (but include section dividers) + var childFilter = function childFilter(child) { + return child.className.indexOf('js-slds-lookup__item') > -1 || child.className.indexOf('slds-lookup__divider') > -1; + }; + + var list = [].slice.call(this.listRef.children).filter(childFilter).length; + this.props.getListLength(list); + + if (prevProps.items !== this.props.items || prevProps.filter !== this.props.filter || prevProps.searchTerm !== this.props.searchTerm) { + // eslint-disable-next-line class-methods-use-this + this.setState({ + filteredItems: this.filteredItems() + }); + } + } + }, { + key: "getFilteredItemForIndex", + value: function getFilteredItemForIndex(i) { + if (i > -1 && this.state.filteredItems && i < this.state.filteredItems.length) { + return this.state.filteredItems[i]; + } + + return null; + } + }, { + key: "filter", + value: function filter(item) { + return this.props.filterWith(this.props.searchTerm, item); + } // eslint-disable-next-line class-methods-use-this + + }, { + key: "filterEmptySections", + value: function filterEmptySections(items) { + var result = []; + items.forEach(function (item, index) { + if (item && item.data && item.data.type === 'section') { + if (index + 1 < items.length) { + var nextItem = items[index + 1]; + + if (nextItem.data && nextItem.data.type !== 'section') { + result.push(item); + } + } + } else { + result.push(item); + } + }); + return result; + } + }, { + key: "filteredItems", + value: function filteredItems() { + return this.filterEmptySections(this.props.items.filter(this.filter, this)); + } // Scroll menu up/down when using mouse keys + + }, { + key: "renderContent", + value: function renderContent() { + if (this.state.filteredItems.length === 0) { + return _react.default.createElement("li", { + className: "slds-lookup__message", + "aria-live": "polite" + }, _react.default.createElement("span", { + className: "slds-m-left_x-large slds-p-vertical_medium" + }, this.props.emptyMessage)); + } + + return this.renderItems(); + } + }, { + key: "renderFooter", + value: function renderFooter() { + return this.props.footer; + } + }, { + key: "renderHeader", + value: function renderHeader() { + return this.props.header; + } + }, { + key: "renderItems", + value: function renderItems() { + var _this2 = this; + + var focusIndex = this.props.focusIndex; + return this.state.filteredItems.map(function (component, i) { + // isActive means it is aria-activedescendant + var id = component.id; + var isActive = false; + + if (_this2.props.header) { + isActive = focusIndex === i + 1; + } else { + isActive = focusIndex === i; + } + + if (component.data.type === 'section') { + if (_this2.props.sectionDividerRenderer) { + var SectionDivider = _this2.props.sectionDividerRenderer; + return _react.default.createElement(SectionDivider, _extends({ + data: component.data, + key: "section_header_".concat(id) + }, _this2.props)); + } + } + + return _react.default.createElement(_item.default, { + boldRegex: _this2.props.boldRegex, + data: component.data, + handleItemFocus: _this2.handleItemFocus, + iconCategory: _this2.props.iconCategory, + iconInverse: _this2.props.iconInverse, + iconName: _this2.props.iconName, + id: id, + index: i, + isActive: isActive, + key: id, + listItemLabelRenderer: _this2.props.listItemLabelRenderer, + onSelect: _this2.props.onSelect, + searchTerm: _this2.props.searchTerm, + setFocus: _this2.props.setFocus + }, component); + }); + } + }, { + key: "renderSectionDivider", + value: function renderSectionDivider() { + return this.props.sectionDivider; + } + }, { + key: "render", + value: function render() { + var _this3 = this; + + return _react.default.createElement("section", { + id: "menuContainer", + className: "ignore-react-onclickoutside" + }, this.renderHeader(), _react.default.createElement("ul", { + id: "list", + className: "slds-lookup__list", + role: "presentation", + ref: function ref(list) { + if (list) { + _this3.listRef = list; + } + } + }, this.renderContent()), this.renderFooter()); + } + }]); + + return Menu; +}(_react.default.Component); + +Menu.displayName = displayName; +Menu.propTypes = propTypes; +Menu.defaultProps = defaultProps; +var _default = Menu; +exports.default = _default; \ No newline at end of file diff --git a/components/lookup/section-divider.js b/components/lookup/section-divider.js new file mode 100644 index 0000000000..aeb89a1822 --- /dev/null +++ b/components/lookup/section-divider.js @@ -0,0 +1,34 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +var displayName = 'LookupDefaultSectionDivider'; +var propTypes = { + data: _propTypes.default.object +}; + +var DefaultSectionDivider = function DefaultSectionDivider(props) { + return _react.default.createElement("li", { + className: "slds-p-around_x-small slds-lookup__divider", + tabIndex: "-1" + }, _react.default.createElement("span", { + className: "slds-m-left_x-small" + }, _react.default.createElement("strong", null, props.data.label))); +}; + +DefaultSectionDivider.displayName = displayName; +DefaultSectionDivider.propTypes = propTypes; +var _default = DefaultSectionDivider; +exports.default = _default; \ No newline at end of file diff --git a/components/media-object/__docs__/__snapshots__/storybook-stories.storyshot b/components/media-object/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..4514781cc9 --- /dev/null +++ b/components/media-object/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,137 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSMediaObject Base 1`] = ` +
    +
    +
    + + + + + +
    +
    + Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda. +
    +
    +
    +`; + +exports[`DOM snapshots SLDSMediaObject Docs site Default 1`] = ` +
    +
    +
    + + + + + +
    +
    + Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda. +
    +
    +
    +`; + +exports[`DOM snapshots SLDSMediaObject Docs site VerticallyCentered 1`] = ` +
    +
    +
    + + + + + +
    +
    + Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda. +
    +
    +
    +`; + +exports[`DOM snapshots SLDSMediaObject Figure Vertical Center 1`] = ` +
    +
    +
    + + + + + +
    +
    + Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda. +
    +
    +
    +`; diff --git a/components/media-object/__docs__/site-stories.js b/components/media-object/__docs__/site-stories.js new file mode 100644 index 0000000000..7c82b08979 --- /dev/null +++ b/components/media-object/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/media-object/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/media-object/__examples__/vertically-centered.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/media-object/__docs__/storybook-stories.js b/components/media-object/__docs__/storybook-stories.js new file mode 100644 index 0000000000..7fafd9d7bc --- /dev/null +++ b/components/media-object/__docs__/storybook-stories.js @@ -0,0 +1,55 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _mediaObject = _interopRequireDefault(require("../../media-object")); + +var _icon = _interopRequireDefault(require("../../icon")); + +var _constants = require("../../../utilities/constants"); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _verticallyCentered = _interopRequireDefault(require("../__examples__/vertically-centered")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var DemoMediaObject = function DemoMediaObject(props) { + return _react.default.createElement(_mediaObject.default, props); +}; + +DemoMediaObject.displayName = 'DemoMediaObject'; +(0, _react2.storiesOf)(_constants.MEDIA_OBJECT, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base', function () { + return _react.default.createElement(DemoMediaObject, { + body: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda.", + figure: _react.default.createElement(_icon.default, { + category: "standard", + name: "user", + size: "medium" + }) + }); +}).add('Figure Vertical Center', function () { + return _react.default.createElement(DemoMediaObject, { + body: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda.", + figure: _react.default.createElement(_icon.default, { + category: "standard", + name: "user", + size: "medium" + }), + verticalCenter: true + }); +}).add('Docs site Default', function () { + return _react.default.createElement(_default.default, null); +}).add('Docs site VerticallyCentered', function () { + return _react.default.createElement(_verticallyCentered.default, null); +}); \ No newline at end of file diff --git a/components/media-object/__examples__/default.js b/components/media-object/__examples__/default.js new file mode 100644 index 0000000000..02d58b7ee4 --- /dev/null +++ b/components/media-object/__examples__/default.js @@ -0,0 +1,72 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _mediaObject = _interopRequireDefault(require("../../../../components/media-object")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_mediaObject.default, { + body: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda.", + figure: _react.default.createElement(_icon.default, { + category: "standard", + name: "user", + size: "large" + }) + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'MediaObjectExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/media-object/__examples__/vertically-centered.js b/components/media-object/__examples__/vertically-centered.js new file mode 100644 index 0000000000..0e00cc24bd --- /dev/null +++ b/components/media-object/__examples__/vertically-centered.js @@ -0,0 +1,73 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _mediaObject = _interopRequireDefault(require("../../../../components/media-object")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_mediaObject.default, { + body: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat minus molestias reprehenderit consequuntur sapiente. Modi veritatis totam accusantium numquam assumenda.", + figure: _react.default.createElement(_icon.default, { + category: "standard", + name: "user", + size: "large" + }), + verticalCenter: true + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'MediaObjectExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/media-object/docs.json b/components/media-object/docs.json new file mode 100644 index 0000000000..15398a7e27 --- /dev/null +++ b/components/media-object/docs.json @@ -0,0 +1,11 @@ +{ + "component": "media-object", + "status": "prod", + "display-name": "Media Objects", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/utilities/media-object", + "url-slug": "media-objects" +} \ No newline at end of file diff --git a/components/media-object/index.js b/components/media-object/index.js new file mode 100644 index 0000000000..2d5aade675 --- /dev/null +++ b/components/media-object/index.js @@ -0,0 +1,113 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = exports.cssClasses = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// Allow for predicatable DOM queries with `querySelectorAll(cssClasses.base)` +var cssClasses = { + base: 'slds-media', + figure: 'slds-media__figure', + body: 'slds-media__body' +}; +/** + * When you need text and a figure next to each other, use a media object. + */ + +exports.cssClasses = cssClasses; + +var MediaObject = +/*#__PURE__*/ +function (_React$Component) { + _inherits(MediaObject, _React$Component); + + function MediaObject() { + _classCallCheck(this, MediaObject); + + return _possibleConstructorReturn(this, _getPrototypeOf(MediaObject).apply(this, arguments)); + } + + _createClass(MediaObject, [{ + key: "render", + // ### Display Name + // Always use the canonical component name as the React display name. + // ### Prop Types + value: function render() { + return _react.default.createElement("div", { + className: (0, _classnames.default)(cssClasses.base, { + 'slds-media_center': this.props.verticalCenter, + 'slds-has-flexi-truncate': this.props.canTruncate + }, this.props.className) + }, this.props.figure ? _react.default.createElement("div", { + className: cssClasses.figure + }, this.props.figure, " ") : null, _react.default.createElement("div", { + className: cssClasses.body + }, this.props.body)); + } + }]); + + return MediaObject; +}(_react.default.Component); + +_defineProperty(MediaObject, "displayName", _constants.MEDIA_OBJECT); + +_defineProperty(MediaObject, "propTypes", { + /** + * Often the body may need to be truncated for correct layout. This is only applicable if using the component within a flexbox container. + */ + canTruncate: _propTypes.default.bool, + + /** + * Class names to be added to the component's HTML tag with `slds-media` class. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * The body is often text such as a heading or paragraph. + */ + body: _propTypes.default.node, + + /** + * The figure is the optional visualization of the text within the body. + */ + figure: _propTypes.default.node, + + /** + * Vertically centers the body with the middle of the figure. + */ + verticalCenter: _propTypes.default.bool +}); + +var _default = MediaObject; +exports.default = _default; \ No newline at end of file diff --git a/components/menu-dropdown/__docs__/site-stories.js b/components/menu-dropdown/__docs__/site-stories.js new file mode 100644 index 0000000000..e849063599 --- /dev/null +++ b/components/menu-dropdown/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/menu-dropdown/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/menu-dropdown/__examples__/sub-heading.jsx'), require('raw-loader!@salesforce/design-system-react/components/menu-dropdown/__examples__/custom-trigger.jsx'), require('raw-loader!@salesforce/design-system-react/components/menu-dropdown/__examples__/checkmark.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/menu-dropdown/__docs__/storybook-stories.js b/components/menu-dropdown/__docs__/storybook-stories.js new file mode 100644 index 0000000000..cbfae21156 --- /dev/null +++ b/components/menu-dropdown/__docs__/storybook-stories.js @@ -0,0 +1,454 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _menuDropdown = _interopRequireDefault(require("../../menu-dropdown")); + +var _menuDropdown2 = require("../../menu-dropdown/menu-dropdown"); + +var _menuList = _interopRequireDefault(require("../../utilities/menu-list")); + +var _button = _interopRequireDefault(require("../../button")); + +var _buttonTrigger = _interopRequireDefault(require("../../menu-dropdown/button-trigger")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +var options = [{ + className: 'custom-li-class', + divider: 'bottom', + label: 'A Header', + type: 'header' +}, { + disabled: true, + label: 'An option that is Super Super Long', + value: 'A0' +}, { + label: 'Custom Class', + className: 'custom-item-class', + value: 'classssss' +}, { + href: 'http://sfdc.co/', + id: 'custom-li-id', + label: 'Has a value', + leftIcon: { + name: 'settings', + category: 'utility' + }, + rightIcon: { + name: 'settings', + category: 'utility' + }, + type: 'item', + value: 'B0' +}, { + type: 'divider' +}, { + label: 'C Option', + value: 'C0' +}, { + label: 'D Option', + value: 'D0' +}, { + label: 'E Option', + value: 'E0' +}, { + label: 'A1 Option', + value: 'A1' +}, { + label: 'B2 Option', + value: 'B1' +}, { + label: 'C2 Option', + value: 'C1' +}, { + label: 'D2 Option', + value: 'D1' +}, { + label: 'E2 Option Super Super Long', + value: 'E1' +}]; + +var getDropdown = function getDropdown(props) { + return _react.default.createElement(_menuDropdown.default, _extends({}, props, { + onClose: (0, _addonActions.action)('Closed'), + onOpen: (0, _addonActions.action)('Opened') + })); +}; + +var DropdownControlled = +/*#__PURE__*/ +function (_React$Component) { + _inherits(DropdownControlled, _React$Component); + + function DropdownControlled() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, DropdownControlled); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DropdownControlled)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + forcedState: undefined, + menuOptions: options + }); + + _defineProperty(_assertThisInitialized(_this), "handleButtonClickReset", function () { + _this.setState({ + forcedState: undefined + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleOpen", function () { + (0, _addonActions.action)('Force Open').apply(void 0, arguments); + + _this.setState({ + forcedState: true + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClose", function () { + (0, _addonActions.action)('Force Closed').apply(void 0, arguments); + + _this.setState({ + forcedState: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "toggleDisabledOption", function () { + _this.setState(function (prevState, props) { + prevState.menuOptions.splice(1, 1, { + disabled: false, + label: 'An option that is Super Super Long', + value: 'A0' + }); + return { + options: prevState.menuOptions + }; + }); + }); + + return _this; + } + + _createClass(DropdownControlled, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + className: "slds-grid" + }, _react.default.createElement("div", { + className: "slds-col" + }, _react.default.createElement(_menuDropdown.default, _extends({}, this.props, { + modal: false, + isOpen: this.state.forcedState, + onClose: (0, _addonActions.action)('Attempt Close'), + onOpen: (0, _addonActions.action)('Attempt Open'), + options: this.state.menuOptions + }))), _react.default.createElement("div", { + className: "slds-col" + }, _react.default.createElement(_button.default, { + label: "Force Open Dropdown", + onClick: this.handleOpen + }), _react.default.createElement(_button.default, { + label: "Force Close Dropdown", + onClick: this.handleClose + }), _react.default.createElement(_button.default, { + label: "Reset Dropdown", + onClick: this.handleButtonClickReset + }), _react.default.createElement(_button.default, { + label: "Toggle Option A disabled", + onClick: this.toggleDisabledOption + }))); + } + }]); + + return DropdownControlled; +}(_react.default.Component); + +_defineProperty(DropdownControlled, "displayName", 'DropdownControlled'); + +var getDropdownPositioned = function getDropdownPositioned(props) { + var positionedDropdowns = []; + + _menuDropdown2.DropdownNubbinPositions.forEach(function (position) { + positionedDropdowns.push(_react.default.createElement("div", { + className: "slds-col slds-size_1-of-3", + style: { + minHeight: '500px' + } + }, _react.default.createElement(_menuDropdown.default, _extends({}, props, { + isOpen: true, + nubbinPosition: position, + onClose: (0, _addonActions.action)('Closed'), + onOpen: (0, _addonActions.action)('Opened') + }), _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + iconVariant: "container", + iconCategory: "utility", + iconName: "settings", + label: position + }))))); + }); + + return _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-grid slds-wrap" + }, positionedDropdowns), _react.default.createElement("div", { + className: "slds-col", + style: { + minHeight: '500px' + } + }, _react.default.createElement(_menuDropdown.default, _extends({}, props, { + nubbinPosition: "top right", + onClose: (0, _addonActions.action)('Closed'), + onOpen: (0, _addonActions.action)('Opened') + }), _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + iconVariant: "container", + iconCategory: "utility", + iconName: "settings", + assistiveText: { + icon: 'top right' + } + }))))); +}; + +var getDropdownCustomTrigger = function getDropdownCustomTrigger(props) { + return _react.default.createElement(_menuDropdown.default, _extends({}, props, { + onClose: (0, _addonActions.action)('Closed'), + onOpen: (0, _addonActions.action)('Opened') + }), _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "settings" + }))); +}; +/* eslint-disable react/prop-types */ + +/* eslint-disable no-script-url */ + + +var DropdownCustomContent = function DropdownCustomContent(props) { + return _react.default.createElement("div", { + id: "custom-dropdown-menu-content" + }, _react.default.createElement("div", { + className: "slds-m-around_medium" + }, _react.default.createElement("div", { + className: "slds-tile slds-tile_board slds-m-horizontal_small" + }, _react.default.createElement("p", { + className: "tile__title slds-text-heading_small" + }, "Art Vandelay"), _react.default.createElement("div", { + className: "slds-tile__detail" + }, _react.default.createElement("p", { + className: "slds-truncate" + }, _react.default.createElement("a", { + className: "slds-m-right_medium", + href: "javascript:void(0)", + onClick: props.onClick + }, "Settings"), _react.default.createElement("a", { + href: "javascript:void(0)", + onClick: props.onClick + }, "Log Out")))))); +}; + +var getDropdownCustomContent = function getDropdownCustomContent(props) { + return _react.default.createElement(_menuDropdown.default, _extends({}, props, { + onClose: (0, _addonActions.action)('Closed'), + onOpen: (0, _addonActions.action)('Opened') + }), _react.default.createElement(DropdownCustomContent, null), _react.default.createElement(_menuList.default, { + options: [{ + label: 'Custom Content Option' + }].concat(options) + })); +}; + +(0, _react2.storiesOf)(_constants.MENU_DROPDOWN, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium slds-text-align_center" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base', function () { + return getDropdown({ + align: 'right', + label: 'Dropdown Click', + onClick: function onClick() { + (0, _addonActions.action)('Clicked').apply(void 0, arguments); + }, + onSelect: function onSelect() { + (0, _addonActions.action)('Selected').apply(void 0, arguments); + }, + options: options + }); +}).add('Base with icon', function () { + return getDropdown({ + align: 'right', + label: 'Dropdown Click', + iconCategory: 'utility', + iconName: 'down', + iconPosition: 'right', + onClick: function onClick() { + (0, _addonActions.action)('Clicked').apply(void 0, arguments); + }, + onSelect: function onSelect() { + (0, _addonActions.action)('Selected').apply(void 0, arguments); + }, + options: options + }); +}).add('Render inline', function () { + return getDropdown({ + align: 'right', + label: 'Dropdown Click', + menuPosition: 'relative', + onClick: function onClick() { + (0, _addonActions.action)('Clicked').apply(void 0, arguments); + }, + onSelect: function onSelect() { + (0, _addonActions.action)('Selected').apply(void 0, arguments); + }, + options: options + }); +}).add('Render inline w/ Nubbins', function () { + return getDropdownPositioned({ + menuPosition: 'relative', + onSelect: function onSelect() { + (0, _addonActions.action)('Selected').apply(void 0, arguments); + }, + options: options + }); +}).add('Custom Trigger', function () { + return getDropdownCustomTrigger({ + tabIndex: '-1', + assistiveText: { + icon: 'Custom Dropdown Trigger' + }, + onSelect: function onSelect() { + (0, _addonActions.action)('Selected').apply(void 0, arguments); + }, + options: options + }); +}).add('Custom Content', function () { + return getDropdownCustomContent({ + label: 'Custom Content Dropdown Click', + onSelect: function onSelect() { + (0, _addonActions.action)('Selected').apply(void 0, arguments); + }, + options: options + }); +}).add('Hover', function () { + return getDropdown({ + assistiveText: { + icon: 'Icon More large' + }, + buttonVariant: 'icon', + iconCategory: 'utility', + iconName: 'settings', + iconVariant: 'more', + onSelect: function onSelect() { + (0, _addonActions.action)('Selected').apply(void 0, arguments); + }, + openOn: 'hover', + options: options + }); +}).add('Two Hovers', function () { + return _react.default.createElement("div", null, getDropdown({ + assistiveText: { + icon: 'Icon More large' + }, + buttonVariant: 'icon', + iconCategory: 'utility', + iconName: 'settings', + iconVariant: 'more', + onSelect: function onSelect() { + (0, _addonActions.action)('Selected').apply(void 0, arguments); + }, + openOn: 'hover', + options: options + }), ' ', getDropdown({ + assistiveText: { + icon: 'Icon More large' + }, + buttonVariant: 'icon', + iconCategory: 'utility', + iconName: 'settings', + iconVariant: 'more', + onSelect: function onSelect() { + (0, _addonActions.action)('Selected').apply(void 0, arguments); + }, + openOn: 'hover', + options: options + })); +}).add('Checkmark', function () { + return getDropdown({ + assistiveText: { + icon: 'More Options' + }, + buttonVariant: 'icon', + checkmark: true, + iconCategory: 'utility', + iconName: 'down', + iconVariant: 'border-filled', + onSelect: function onSelect() { + (0, _addonActions.action)('Selected').apply(void 0, arguments); + }, + options: options, + value: 'C0' + }); +}).add('Hover with Checkmark', function () { + return getDropdown({ + assistiveText: { + icon: 'More Options' + }, + buttonVariant: 'icon', + checkmark: true, + iconCategory: 'utility', + iconName: 'down', + iconVariant: 'border-filled', + onMouseEnter: (0, _addonActions.action)('Mouse enter'), + onMouseLeave: (0, _addonActions.action)('Mouse leave'), + onSelect: function onSelect() { + (0, _addonActions.action)('Selected').apply(void 0, arguments); + }, + openOn: 'hover', + options: options, + value: 'C0' + }); +}).add('Controled w/ isOpen', function () { + return _react.default.createElement(DropdownControlled, { + align: "right", + label: "Dropdown Click", + options: options + }); +}); \ No newline at end of file diff --git a/components/menu-dropdown/__examples__/checkmark.js b/components/menu-dropdown/__examples__/checkmark.js new file mode 100644 index 0000000000..78b07e635e --- /dev/null +++ b/components/menu-dropdown/__examples__/checkmark.js @@ -0,0 +1,127 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement("span", null, "Checkmark "), _react.default.createElement(_menuDropdown.default, { + assistiveText: { + icon: 'Checkmark' + }, + checkmark: true, + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + onSelect: function onSelect(value) { + console.log('selected: ', value); + }, + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }], + value: "A0" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement("span", null, "Checkmark with right icon "), _react.default.createElement(_menuDropdown.default, { + assistiveText: { + icon: 'Checkmark with right icon' + }, + buttonVariant: "icon", + checkmark: true, + iconName: "settings", + iconSize: "large", + iconVariant: "more", + onSelect: function onSelect(value) { + console.log('selected: ', value); + }, + options: [{ + label: 'Table View', + value: 'A0', + rightIcon: { + category: 'utility', + name: 'table' + } + }, { + label: 'Kanban Board', + value: 'A0', + rightIcon: { + category: 'utility', + name: 'kanban' + } + }, { + label: 'List View', + value: 'A0', + rightIcon: { + category: 'utility', + name: 'side_list' + } + }], + value: "A0" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'MediaObjectExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/menu-dropdown/__examples__/custom-trigger.js b/components/menu-dropdown/__examples__/custom-trigger.js new file mode 100644 index 0000000000..a480b864df --- /dev/null +++ b/components/menu-dropdown/__examples__/custom-trigger.js @@ -0,0 +1,91 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +var _buttonTrigger = _interopRequireDefault(require("../../../../components/menu-dropdown/button-trigger")); + +var _button = _interopRequireDefault(require("../../../../components/button/")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_menuDropdown.default, { + tabIndex: "-1", + align: "right", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] + }, _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "down", + iconPosition: "right", + label: "Dropdown" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'DropdownExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/menu-dropdown/__examples__/default-icon-label.js b/components/menu-dropdown/__examples__/default-icon-label.js new file mode 100644 index 0000000000..b2e03d17e6 --- /dev/null +++ b/components/menu-dropdown/__examples__/default-icon-label.js @@ -0,0 +1,85 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +var _buttonTrigger = _interopRequireDefault(require("../../../../components/menu-dropdown/button-trigger")); + +var _button = _interopRequireDefault(require("../../../../components/button/")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_menuDropdown.default, { + align: "right", + iconCategory: "utility", + iconName: "down", + iconPosition: "right", + label: "Dropdown", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] + }); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'DropdownExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/menu-dropdown/__examples__/default.js b/components/menu-dropdown/__examples__/default.js new file mode 100644 index 0000000000..52e6324336 --- /dev/null +++ b/components/menu-dropdown/__examples__/default.js @@ -0,0 +1,89 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_menuDropdown.default, { + assistiveText: { + icon: 'More Options' + }, + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + onSelect: function onSelect(value) { + console.log('selected: ', value); + }, + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'MediaObjectExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/menu-dropdown/__examples__/sub-heading.js b/components/menu-dropdown/__examples__/sub-heading.js new file mode 100644 index 0000000000..5ca20e41d8 --- /dev/null +++ b/components/menu-dropdown/__examples__/sub-heading.js @@ -0,0 +1,93 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_menuDropdown.default, { + assistiveText: { + icon: 'More Options' + }, + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + onSelect: function onSelect(value) { + console.log('selected: ', value); + }, + options: [{ + label: 'Menu Sub Heading', + type: 'header' + }, { + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Sub Heading', + type: 'header' + }, { + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }] + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'MediaObjectExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/menu-dropdown/button-trigger.js b/components/menu-dropdown/button-trigger.js new file mode 100644 index 0000000000..9d110e687e --- /dev/null +++ b/components/menu-dropdown/button-trigger.js @@ -0,0 +1,217 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _button = _interopRequireDefault(require("../button")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * The Dropdown Button Trigger renders the default trigger button for the dropdown menu. If this component has children, it does not render itself to the DOM. Instead, it renders its child element, `Button`, and all that child's properties. This component may be used as a template to create custom triggers that do not use `Button`. + */ +var Trigger = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Trigger, _React$Component); + + function Trigger() { + _classCallCheck(this, Trigger); + + return _possibleConstructorReturn(this, _getPrototypeOf(Trigger).apply(this, arguments)); + } + + _createClass(Trigger, [{ + key: "render", + // ### Display Name + // Always use the canonical component name (set in the core) as the React + // display name. + // ### Prop Types + // ### Render + value: function render() { + // The following are required for use with dropdown. Any other custom props for `Button` should be set with a `Button` child of this component, and are technically just here for backwards compatibility. See `children` prop description for more information. + var _this$props = this.props, + assistiveText = _this$props.assistiveText, + children = _this$props.children, + className = _this$props.className, + id = _this$props.id, + isInline = _this$props.isInline, + isOpen = _this$props.isOpen, + onBlur = _this$props.onBlur, + menu = _this$props.menu, + onClick = _this$props.onClick, + onFocus = _this$props.onFocus, + onKeyDown = _this$props.onKeyDown, + onMouseDown = _this$props.onMouseDown, + onMouseEnter = _this$props.onMouseEnter, + onMouseLeave = _this$props.onMouseLeave, + openOn = _this$props.openOn, + triggerRef = _this$props.triggerRef, + triggerClassName = _this$props.triggerClassName, + deprecatedPropsFromMenuDropdown = _objectWithoutProperties(_this$props, ["assistiveText", "children", "className", "id", "isInline", "isOpen", "onBlur", "menu", "onClick", "onFocus", "onKeyDown", "onMouseDown", "onMouseEnter", "onMouseLeave", "openOn", "triggerRef", "triggerClassName"]); // Trigger manipulation + + + var propsFromGrandchildButton = {}; // if there are no children, render the default button + + if (_react.default.Children.count(this.props.children) !== 0) { + _react.default.Children.forEach(this.props.children, function (child) { + if (child && child.type.displayName === _button.default.displayName) { + propsFromGrandchildButton = child.props; + } + }); + } // If Trigger has a Button child, then use the explicitly declared child's props layered on top of those passed down by dropdown's props to allow manual override + + + return ( + /* eslint-disable jsx-a11y/no-static-element-interactions */ + _react.default.createElement("div", { + className: (0, _classnames.default)("slds-dropdown-trigger slds-dropdown-trigger_".concat(openOn), { + 'slds-is-open': isOpen + }, triggerClassName), + id: id, + onBlur: onBlur, + onClick: onClick, + onKeyDown: onKeyDown, + onFocus: onFocus, + onMouseDown: onMouseDown, + onMouseEnter: onMouseEnter, + onMouseLeave: onMouseLeave + }, _react.default.createElement(_button.default, _extends({ + assistiveText: assistiveText, + className: className, + "aria-expanded": isOpen, + "aria-haspopup": true + }, deprecatedPropsFromMenuDropdown, propsFromGrandchildButton, { + buttonRef: triggerRef + })), menu) + ); + } + }]); + + return Trigger; +}(_react.default.Component); + +_defineProperty(Trigger, "displayName", _constants.MENU_DROPDOWN_TRIGGER); + +_defineProperty(Trigger, "propTypes", { + /** + * Import the module `design-system-react/dropdown/button-trigger` and render a grandchild of the element type `Button`. Any `props` specified on that `Button` will be assigned to the triggering button. Any `id` prop or event hanlders (`onBlur`, `onClick`, etc.) set on the button grandchild will be overwritten by `MenuDropdown` to allow functionality and accessibility. + * ``` + * + * + * + +
    + + +
    + +
    +
    +
    +
    + + + + +`; + +exports[`DOM snapshots SLDSPageHeader Docs site RecordHome 1`] = ` +
    +
    +
    +
    +
    +
    +
    + + + + + +
    +
    +
    +

    + Record Type +

    +

    + Record Title +

    +
    +
    +
    +
    +
    +
    +
    + +
    + + + + +
    +
    +
    +
    +
    +
      +
    • +

      + Field 1 +

      +

      + Description that demonstrates truncation with content. Description that demonstrates truncation with content. +

      +
    • +
    • +

      + Field 2 +

      +

      + Multiple Values +

      +
    • +
    • +

      + Field 3 +

      + + Hyperlink + +
    • +
    • +

      + Field 4 +

      +

      + Description (2-line truncation) +

      +
    • +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPageHeader Docs site RelatedList 1`] = ` +
    +
    +
    +
    +
    +
    +
    +
    + +

    + Contacts (will truncate) +

    +
    +
    +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +

    + 10 items • sorted by name +

    +
    +
    +
    +
    +
    + +
    +
    + + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPageHeader Object Home 1`] = ` +
    +
    +
    +
    +
    +
    +
    + + + + + +
    +
    +
    +

    + Leads +

    +

    +
    + +
    +

    +
    +
    +
    +
    +
    +
    +
    +
    + + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +

    + 10 items • sorted by name +

    +
    +
    +
    +
    +
    + +
    +
    + +
    + + +
    + + +
    +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPageHeader Record Home (field updates) 1`] = ` +
    +
    + +
    +
    +
    +
    +
    +
    + + + + + +
    +
    +
    +

    + Record Type +

    +

    + Record Title +

    +
    +
    +
    +
    +
    + +
    +
    +
      +
    • +

      + Field 1 +

      +

      + hi +

      +
    • +
    • +

      + Field 2 +

      +

      + Multiple Values +

      +
    • +
    • +

      + Field 3 +

      +

      + Description (2-line truncation) +

      +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPageHeader Record Home (truncates) 1`] = ` +
    +
    +
    +
    +
    +
    +
    + + + + + +
    +
    +
    +

    + Record Type +

    +

    + Record Title +

    +
    +
    +
    +
    +
    +
    +
    + +
    + + + +
    + +
    +
    +
    +
    +
    +
    +
      +
    • +

      + Field 1 +

      +

      + Description that demonstrates truncation with content. Description that demonstrates truncation with content. +

      +
    • +
    • +

      + Field 2 +

      +

      + Multiple Values +

      +
    • +
    • +

      + Field 3 +

      +
      +

      + here is a super long description that will truncate and the rest of it will show in the tooltip. +

      + +
      +
    • +
    • +

      + Field 4 +

      +

      + Description (2-line truncation) +

      +
    • +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPageHeader Related List 1`] = ` +
    +
    +
    +
    +
    +
    +
    +
    + +

    + Contacts +

    +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +
    +
    +

    + 10 items • sorted by name +

    +
    +
    +
    +
    + +
    + + + +
    +
    +
    +
    +
    +
    +
    +
    +`; diff --git a/components/page-header/__docs__/site-stories.js b/components/page-header/__docs__/site-stories.js new file mode 100644 index 0000000000..9bd5c93d9f --- /dev/null +++ b/components/page-header/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/page-header/__examples__/record-home.jsx'), require('raw-loader!@salesforce/design-system-react/components/page-header/__examples__/object-home.jsx'), require('raw-loader!@salesforce/design-system-react/components/page-header/__examples__/related-list.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/page-header/__docs__/storybook-stories.js b/components/page-header/__docs__/storybook-stories.js new file mode 100644 index 0000000000..622f966129 --- /dev/null +++ b/components/page-header/__docs__/storybook-stories.js @@ -0,0 +1,441 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _constants = require("../../../utilities/constants"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _pageHeader = _interopRequireDefault(require("../../page-header")); + +var _buttonStateful = _interopRequireDefault(require("../../button-stateful")); + +var _buttonGroup = _interopRequireDefault(require("../../button-group")); + +var _button = _interopRequireDefault(require("../../button")); + +var _menuDropdown = _interopRequireDefault(require("../../menu-dropdown")); + +var _tooltip = _interopRequireDefault(require("../../tooltip")); + +var _objectHome = _interopRequireDefault(require("../__examples__/object-home")); + +var _recordHome = _interopRequireDefault(require("../__examples__/record-home")); + +var _relatedList = _interopRequireDefault(require("../__examples__/related-list")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var recordHomeDetails1 = [{ + label: 'Field 1', + content: 'Description that demonstrates truncation with content. Description that demonstrates truncation with content.', + flavor: '1-of-4', + truncate: true +}, { + label: 'Field 2', + content: 'Multiple Values' +}, { + label: 'Field 3', + content: 'Description (2-line truncation)' +}]; +var recordHomeDetails2 = [{ + label: 'Field 1', + content: 'hi', + flavor: '1-of-4', + truncate: true +}, { + label: 'Field 2', + content: 'Multiple Values' +}, { + label: 'Field 3', + content: 'Description (2-line truncation)' +}]; + +var DemoPageHeader = +/*#__PURE__*/ +function (_React$Component) { + _inherits(DemoPageHeader, _React$Component); + + function DemoPageHeader() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, DemoPageHeader); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DemoPageHeader)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + recordHomeDetails: recordHomeDetails2 + }); + + _defineProperty(_assertThisInitialized(_this), "changeDescription", function () { + if (_this.state.recordHomeDetails[0].content === 'hi') { + _this.setState({ + recordHomeDetails: recordHomeDetails1 + }); + } else { + _this.setState({ + recordHomeDetails: recordHomeDetails2 + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleSelect", function (selectedItem) { + for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + rest[_key2 - 1] = arguments[_key2]; + } + + (0, _addonActions.action)('select').apply(void 0, [selectedItem].concat(rest)); + + _this.setState({ + currentSelected: _this.state.options.indexOf(selectedItem) + }); + }); + + return _this; + } + + _createClass(DemoPageHeader, [{ + key: "render", + value: function render() { + var defaultProps = { + iconAssistiveText: 'User', + iconCategory: 'standard', + iconName: 'user', + label: 'Record Type', + title: 'Record Title', + variant: 'record-home', + details: this.state.recordHomeDetails + }; + return _react.default.createElement("div", null, _react.default.createElement(_button.default, { + onClick: this.changeDescription + }, "Change Description"), _react.default.createElement(_pageHeader.default, defaultProps)); + } + }]); + + return DemoPageHeader; +}(_react.default.Component); + +_defineProperty(DemoPageHeader, "displayName", 'DemoPageHeader'); + +var getPageHeader = function getPageHeader(props) { + return _react.default.createElement(_pageHeader.default, props); +}; + +var recordHomeActions = function recordHomeActions() { + return _react.default.createElement("div", null, _react.default.createElement(_buttonStateful.default, { + key: "PageHeaderFollowButton", + disabled: false, + iconSize: "medium", + responsive: false, + stateOne: { + iconName: 'add', + label: 'Follow' + }, + stateTwo: { + iconCategory: 'utility', + iconName: 'check', + label: 'Following' + }, + stateThree: { + iconCategory: 'utility', + iconName: 'close', + label: 'Unfollow' + } + }), _react.default.createElement(_buttonGroup.default, { + key: "" + }, _react.default.createElement(_button.default, { + label: "Edit" + }), _react.default.createElement(_button.default, { + label: "Delete" + }), _react.default.createElement(_button.default, { + label: "Clone" + }), _react.default.createElement(_menuDropdown.default, { + assistiveText: { + icon: 'More Options' + }, + buttonVariant: "icon", + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + id: "page-header-dropdown-record-home-content-right", + onSelect: (0, _addonActions.action)('select'), + openOn: "click", + align: "right", + options: [{ + label: 'Disable', + value: 'A0' + }, { + label: 'Promote', + value: 'C0' + }] + }))); +}; + +var customTooltip = function customTooltip() { + var content = 'here is a super long description that will truncate and the rest of it will show in the tooltip.'; + return _react.default.createElement(_tooltip.default, { + align: "top", + content: content, + id: "page-header-truncate-tooltip", + triggerStyle: { + display: 'inline' + } + }, _react.default.createElement("p", { + tabIndex: "0", + className: "slds-truncate" + }, content)); +}; + +var recordHomeDetails = [{ + label: 'Field 1', + content: 'Description that demonstrates truncation with content. Description that demonstrates truncation with content.', + flavor: '1-of-4', + truncate: true +}, { + label: 'Field 2', + content: 'Multiple Values' +}, { + label: 'Field 3', + content: customTooltip(), + flavor: '1-of-4' +}, { + label: 'Field 4', + content: 'Description (2-line truncation)' +}]; + +var objectHomeActions = function objectHomeActions() { + return _react.default.createElement("div", null, _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "settings", + variant: "icon", + iconVariant: "more", + className: "slds-m-left_xx-small", + assistiveText: { + icon: 'Settings' + } + }), _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "table", + variant: "icon", + iconVariant: "more", + className: "slds-m-left_xx-small", + assistiveText: { + icon: 'Table' + } + }), _react.default.createElement(_buttonGroup.default, null, _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "chart", + variant: "icon", + iconVariant: "border", + assistiveText: { + icon: 'Chart' + } + }), _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "filterList", + variant: "icon", + iconVariant: "border", + className: "slds-m-left_xx-small", + assistiveText: { + icon: 'Filter List' + } + }), _react.default.createElement(_menuDropdown.default, { + assistiveText: { + icon: 'Sort' + }, + buttonVariant: "icon", + iconCategory: "utility", + iconName: "sort", + iconVariant: "more", + id: "page-header-dropdown-object-home-content-right", + onSelect: (0, _addonActions.action)('select'), + openOn: "click", + align: "right", + options: [{ + label: 'Last Name (ascending)', + value: 'LNA' + }, { + label: 'Last Name (descending)', + value: 'LND' + }, { + label: 'Last Contacted (descending)', + value: 'LCD' + }, { + label: 'Last Contacted (ascending)', + value: 'LCA' + }] + }))); +}; + +var relatedListActions = function relatedListActions() { + return _react.default.createElement("div", null, _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "table", + variant: "icon", + iconVariant: "more", + className: "slds-m-left_xx-small", + assistiveText: { + icon: 'Table' + } + }), _react.default.createElement(_buttonGroup.default, null, _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "chart", + variant: "icon", + iconVariant: "border", + className: "slds-m-left_xx-small", + assistiveText: { + icon: 'Chart' + } + }), _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "filterList", + variant: "icon", + iconVariant: "border", + className: "slds-m-left_xx-small", + assistiveText: { + icon: 'Filter List' + } + }), _react.default.createElement(_menuDropdown.default, { + assistiveText: { + icon: 'Sort' + }, + buttonVariant: "icon", + iconCategory: "utility", + iconName: "sort", + iconVariant: "more", + id: "page-header-dropdown-related-list-content-right", + onSelect: (0, _addonActions.action)('select'), + openOn: "click", + align: "right", + options: [{ + label: 'Last Name (ascending)', + value: 'LNA' + }, { + label: 'Last Name (descending)', + value: 'LND' + }, { + label: 'Last Contacted (descending)', + value: 'LCD' + }, { + label: 'Last Contacted (ascending)', + value: 'LCA' + }] + }))); +}; + +var relatedListControls = function relatedListControls() { + return _react.default.createElement(_buttonGroup.default, null, _react.default.createElement(_button.default, { + label: "Add Contact", + variant: "neutral" + }), _react.default.createElement(_menuDropdown.default, { + assistiveText: { + icon: 'More Options' + }, + buttonVariant: "icon", + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + id: "page-header-dropdown-related-list-nav-right", + onSelect: (0, _addonActions.action)('select'), + openOn: "click", + align: "right", + options: [{ + label: 'Refresh List', + value: 'A0' + }, { + label: 'Duplicate Selected Leads', + value: 'B0' + }, { + label: 'Disabled Selected Leads', + value: 'C0' + }] + })); +}; + +var relatedListTrail = [_react.default.createElement("a", { + href: "javascript:void(0);" +}, "Accounts"), _react.default.createElement("a", { + href: "javascript:void(0);" +}, "Company One")]; +(0, _react2.storiesOf)(_constants.PAGE_HEADER, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base', function () { + return getPageHeader({ + iconAssistiveText: 'Opportunity', + iconCategory: 'standard', + iconName: 'opportunity', + title: 'Rohde Corp - 80,000 Widgets', + info: 'Mark Jaeckal • Unlimited Customer • 11/13/15' + }); +}).add('Base with actions', function () { + return getPageHeader({ + iconAssistiveText: 'Opportunity', + iconCategory: 'standard', + iconName: 'opportunity', + title: 'Rohde Corp - 80,000 Widgets', + info: 'Mark Jaeckal • Unlimited Customer • 11/13/15', + onRenderControls: objectHomeActions + }); +}).add('Record Home (truncates)', function () { + return getPageHeader({ + iconAssistiveText: 'User', + iconCategory: 'standard', + iconName: 'user', + label: 'Record Type', + title: 'Record Title', + variant: 'record-home', + onRenderActions: recordHomeActions, + details: recordHomeDetails + }); +}).add('Object Home', function () { + return _react.default.createElement(_objectHome.default, null); +}).add('Related List', function () { + return getPageHeader({ + title: 'Contacts', + variant: 'object-home', + info: '10 items • sorted by name', + onRenderActions: relatedListActions, + onRenderControls: relatedListControls, + trail: relatedListTrail + }); +}).add('Record Home (field updates)', function () { + return _react.default.createElement(DemoPageHeader, null); +}).add('Docs site RecordHome', function () { + return _react.default.createElement(_recordHome.default, null); +}).add('Docs site RelatedList', function () { + return _react.default.createElement(_relatedList.default, null); +}); \ No newline at end of file diff --git a/components/page-header/__examples__/object-home.js b/components/page-header/__examples__/object-home.js new file mode 100644 index 0000000000..29e3b50be4 --- /dev/null +++ b/components/page-header/__examples__/object-home.js @@ -0,0 +1,236 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _pageHeader = _interopRequireDefault(require("../../../../components/page-header")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _buttonGroup = _interopRequireDefault(require("../../../../components/button-group")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +var _buttonTrigger = _interopRequireDefault(require("../../../../components/menu-dropdown/button-trigger")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var controls = function controls() { + return _react.default.createElement("div", null, _react.default.createElement(_buttonGroup.default, null, _react.default.createElement(_button.default, { + label: "New Lead" + }), _react.default.createElement(_button.default, { + label: "Import Leads" + }), _react.default.createElement(_menuDropdown.default, { + align: "right", + assistiveText: { + icon: 'More Options' + }, + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + id: "page-header-dropdown-object-home-nav-right", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] + }))); + }; + + var actions = function actions() { + return _react.default.createElement("div", null, _react.default.createElement(_menuDropdown.default, { + align: "right", + id: "page-header-dropdown-object-home-content-right", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] + }, _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + assistiveText: { + icon: 'List View Controls' + }, + className: "slds-m-right_xx-small", + iconCategory: "utility", + iconName: "settings", + iconVariant: "more" + }))), _react.default.createElement(_menuDropdown.default, { + align: "right", + assistiveText: { + icon: 'Change view' + }, + iconCategory: "utility", + iconName: "settings", + iconVariant: "more", + id: "page-header-dropdown-object-home-content-right-2", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] + }, _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Change view' + }, + className: "slds-m-right_xx-small", + iconCategory: "utility", + iconName: "table", + iconVariant: "more", + variant: "icon" + }))), _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Edit List' + }, + iconCategory: "utility", + iconName: "edit", + iconVariant: "border", + variant: "icon" + }), _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Refresh' + }, + iconCategory: "utility", + iconName: "refresh", + iconVariant: "border", + variant: "icon" + }), _react.default.createElement(_buttonGroup.default, null, _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Charts' + }, + iconCategory: "utility", + iconName: "chart", + iconVariant: "border", + variant: "icon" + }), _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Filters' + }, + iconCategory: "utility", + iconName: "filterList", + iconVariant: "border", + variant: "icon" + }))); + }; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_pageHeader.default, { + onRenderActions: actions, + iconAssistiveText: "User", + iconCategory: "standard", + iconName: "lead", + info: "10 items \u2022 sorted by name", + label: "Leads", + onRenderControls: controls, + title: _react.default.createElement("h1", { + className: "slds-page-header__title slds-p-right_x-small" + }, _react.default.createElement(_menuDropdown.default, { + id: "page-header-dropdown-object-home-header", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] + }, _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + className: "slds-button_reset slds-type-focus", + iconCategory: "utility", + iconName: "down", + iconPosition: "right", + label: "Dropdown", + responsive: true, + variant: "base" + })))), + truncate: true, + variant: "object-home" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ObjectHomePageHeaderExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/__examples__/record-home.js b/components/page-header/__examples__/record-home.js new file mode 100644 index 0000000000..5f0857427c --- /dev/null +++ b/components/page-header/__examples__/record-home.js @@ -0,0 +1,148 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _pageHeader = _interopRequireDefault(require("../../../../components/page-header")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _buttonGroup = _interopRequireDefault(require("../../../../components/button-group")); + +var _buttonStateful = _interopRequireDefault(require("../../../../components/button-stateful")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var actions = function actions() { + return _react.default.createElement("div", null, _react.default.createElement(_buttonStateful.default, { + key: "PageHeaderFollowButton", + iconSize: "medium", + stateOne: { + iconName: 'add', + label: 'Follow' + }, + stateTwo: { + iconName: 'check', + label: 'Following' + }, + stateThree: { + iconName: 'close', + label: 'Unfollow' + } + }), _react.default.createElement(_buttonGroup.default, null, _react.default.createElement(_button.default, { + label: "Edit" + }), _react.default.createElement(_button.default, { + label: "Delete" + }), _react.default.createElement(_button.default, { + label: "Clone" + }), _react.default.createElement(_menuDropdown.default, { + align: "right", + assistiveText: { + icon: 'More Options' + }, + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + id: "dropdown-record-home-example", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] + }))); + }; + + var details = [{ + label: 'Field 1', + content: 'Description that demonstrates truncation with content. Description that demonstrates truncation with content.', + truncate: true + }, { + label: 'Field 2', + content: 'Multiple Values' + }, { + label: 'Field 3', + content: _react.default.createElement("a", { + href: "javascript:void(0);" + }, "Hyperlink") + }, { + label: 'Field 4', + content: 'Description (2-line truncation)', + truncate: true + }]; + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_pageHeader.default, { + onRenderActions: actions, + details: details, + iconAssistiveText: { + icon: 'User' + }, + iconCategory: "standard", + iconName: "user", + label: "Record Type", + title: "Record Title", + variant: "record-home" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'RecordHomePageHeaderExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/__examples__/related-list.js b/components/page-header/__examples__/related-list.js new file mode 100644 index 0000000000..cb20742341 --- /dev/null +++ b/components/page-header/__examples__/related-list.js @@ -0,0 +1,183 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _pageHeader = _interopRequireDefault(require("../../../../components/page-header")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _buttonGroup = _interopRequireDefault(require("../../../../components/button-group")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +var _buttonTrigger = _interopRequireDefault(require("../../../../components/menu-dropdown/button-trigger")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var controls = function controls() { + return _react.default.createElement("div", { + className: "slds-button-group", + role: "group" + }, _react.default.createElement("button", { + className: "slds-button slds-button_neutral" + }, "Add Contact"), _react.default.createElement("div", { + className: "slds-button_last" + }, _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "down", + variant: "icon", + iconVariant: "border-filled", + assistiveText: { + icon: 'More Actions' + } + }))); + }; + + var actions = function actions() { + return _react.default.createElement("div", null, _react.default.createElement(_menuDropdown.default, { + align: "right", + assistiveText: { + icon: 'Change view' + }, + iconCategory: "utility", + iconName: "settings", + iconVariant: "more", + id: "content-right-dropdown", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] + }, _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Change view' + }, + className: "slds-m-right_xx-small", + iconCategory: "utility", + iconName: "table", + iconVariant: "more", + variant: "icon" + }))), _react.default.createElement(_buttonGroup.default, null, _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "chart", + variant: "icon", + iconVariant: "border", + className: "slds-m-left_xx-small", + assistiveText: { + icon: 'Chart' + } + }), _react.default.createElement(_button.default, { + iconCategory: "utility", + iconName: "filterList", + variant: "icon", + iconVariant: "border", + className: "slds-m-left_xx-small", + assistiveText: { + icon: 'Filter List' + } + }), _react.default.createElement(_menuDropdown.default, { + triggerClassname: true, + align: "right", + assistiveText: { + icon: 'List View Controls' + }, + iconCategory: "utility", + iconName: "sort", + iconVariant: "more", + id: "content-right-dropdown-2", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] + }))); + }; + + var trail = [_react.default.createElement("a", { + href: "javascript:void(0);" + }, "Accounts"), _react.default.createElement("a", { + href: "javascript:void(0);" + }, "Company One")]; + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_pageHeader.default, { + title: "Contacts (will truncate)", + onRenderControls: controls, + onRenderActions: actions, + variant: "object-home", + truncate: true, + trail: trail, + info: "10 items \u2022 sorted by name" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'RelatedListPageHeaderExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/check-props.js b/components/page-header/check-props.js new file mode 100644 index 0000000000..ba5e225bb0 --- /dev/null +++ b/components/page-header/check-props.js @@ -0,0 +1,59 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _deprecatedPropertyValue = _interopRequireDefault(require("../../utilities/warning/deprecated-property-value")); + +var _deprecatedProperty = _interopRequireDefault(require("../../utilities/warning/deprecated-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + + if (props.variant === 'objectHome') { + (0, _deprecatedPropertyValue.default)(COMPONENT, { + propAsString: 'variant', + propValue: props.variant, + deprecatedPropValue: 'objectHome', + replacementPropAsValue: 'object-home' + }, "Using value of variants in camelCase is deprecated. Use kebab-case ('object-home') instead. ".concat(createDocUrl('variant'))); + } + + if (props.variant === 'recordHome') { + (0, _deprecatedPropertyValue.default)(COMPONENT, { + propAsString: 'variant', + propValue: props.variant, + deprecatedPropValue: 'recordHome', + replacementPropAsValue: 'record-home' + }, "Using value of variants in camelCase is deprecated. Use kebab-case ('record-home') instead. ".concat(createDocUrl('variant'))); + } + + if (props.variant === 'relatedList') { + (0, _deprecatedPropertyValue.default)(COMPONENT, { + propAsString: 'variant', + propValue: props.variant, + deprecatedPropValue: 'relatedList', + replacementPropAsValue: 'related-list' + }, "Using value of variants in camelCase is deprecated. Use kebab-case ('related-list') instead. ".concat(createDocUrl('variant'))); + } + + (0, _deprecatedProperty.default)(COMPONENT, props.navRight, 'navRight', 'onRenderControls', createDocUrl('onRenderControls')); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/docs.json b/components/page-header/docs.json new file mode 100644 index 0000000000..845dd701bd --- /dev/null +++ b/components/page-header/docs.json @@ -0,0 +1,7 @@ +{ + "component": "page-header", + "status": "prod", + "display-name": "Page Headers", + "SLDS-component-path": "/components/page-headers", + "url-slug": "page-headers" +} \ No newline at end of file diff --git a/components/page-header/index.js b/components/page-header/index.js new file mode 100644 index 0000000000..0c85b7f6bb --- /dev/null +++ b/components/page-header/index.js @@ -0,0 +1,423 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "Info", { + enumerable: true, + get: function get() { + return _info.default; + } +}); +Object.defineProperty(exports, "Title", { + enumerable: true, + get: function get() { + return _title.default; + } +}); +Object.defineProperty(exports, "DetailRow", { + enumerable: true, + get: function get() { + return _detailRow.default; + } +}); +Object.defineProperty(exports, "DetailBlock", { + enumerable: true, + get: function get() { + return _detailBlock.default; + } +}); +exports.default = void 0; + +var _react = _interopRequireWildcard(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _info = _interopRequireDefault(require("./private/info")); + +var _title = _interopRequireDefault(require("./private/title")); + +var _detailRow = _interopRequireDefault(require("./private/detail-row")); + +var _detailBlock = _interopRequireDefault(require("./private/detail-block")); + +var _base = _interopRequireDefault(require("./private/base")); + +var _recordHome = _interopRequireDefault(require("./private/record-home")); + +var _objectHome = _interopRequireDefault(require("./private/object-home")); + +var _relatedList = _interopRequireDefault(require("./private/related-list")); + +var _icon = _interopRequireDefault(require("../icon")); + +var _breadcrumb = _interopRequireDefault(require("../breadcrumb")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var displayName = _constants.PAGE_HEADER; +var propTypes = { + /** + * Optional class name + */ + className: _propTypes.default.string, + + /** + * The type of component + * Note: Extra options are added to make the version backward compatible + */ + variant: _propTypes.default.oneOf(['base', 'object-home', 'record-home', 'related-list']), + + /** + * The info property can be a string or a React element + */ + label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + + /** + * The title property can be a string or a React element + */ + title: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + + /** + * The info property can be a string or a React element + */ + info: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + + /** + * The page header icon + */ + icon: _propTypes.default.element, + + /** + * Name of the icon. Visit Lightning Design System Icons to reference icon names. + */ + iconName: _propTypes.default.string, + + /** + * The icons category + */ + iconCategory: _propTypes.default.oneOf(['action', 'custom', 'doctype', 'standard', 'utility']), + + /** + * If omitted, icon position is centered. + */ + iconPosition: _propTypes.default.oneOf(['left', 'right']), + + /** + * Determines the size of the icon. + */ + iconSize: _propTypes.default.oneOf(['x-small', 'small', 'medium', 'large']), + + /** + * For icon variants, please reference Lightning Design System Icons. + */ + iconVariant: _propTypes.default.oneOf(['container', 'border', 'border-filled', 'small', 'more']), + + /** + * Content to appear on the right hand side of the page header + * prop 'contentRight' will be deprecated soon, use 'onRenderActions' instead + */ + onRenderActions: _propTypes.default.func, + + /** + * An array of buttons which appear on the component's right hand side. + */ + details: _propTypes.default.array, + + /** + * Nav content which appears in the upper right hand corner. + * prop 'navRight' will be deprecated soon, use 'onRenderControls' instead + */ + onRenderControls: _propTypes.default.func, + + /** + * An array of react elements presumably anchor elements. + */ + trail: _propTypes.default.array +}; +var defaultProps = { + className: '', + variant: 'base', + details: [], + trail: [] +}; +/** + * The PageHeader component adds PageHeader, PageHeader.Info, PageHeader.Title, PageHeader.DetailRow, and PageHeader.DetailBlock. + */ + +var PageHeader = +/*#__PURE__*/ +function (_Component) { + _inherits(PageHeader, _Component); + + function PageHeader() { + _classCallCheck(this, PageHeader); + + return _possibleConstructorReturn(this, _getPrototypeOf(PageHeader).apply(this, arguments)); + } + + _createClass(PageHeader, [{ + key: "componentDidMount", + value: function componentDidMount() { + (0, _checkProps.default)(_constants.PAGE_HEADER, this.props, _docs.default); + } + }, { + key: "_getClassNames", + value: function _getClassNames(className) { + return (0, _classnames.default)('slds-page-header', { + 'slds-page-header_object-home': this.props.variant === 'object-home' || this.props.variant === 'objectHome' + }, className); + } + }, { + key: "render", + value: function render() { + /** + * OPTIMIZE ES7 style object destructuring removes the need for _.omit. + * Example: const {foo, ...bar} = this.props; + */ + var _this$props = this.props, + className = _this$props.className, + contentRight = _this$props.contentRight, + details = _this$props.details, + icon = _this$props.icon, + iconCategory = _this$props.iconCategory, + iconName = _this$props.iconName, + iconPosition = _this$props.iconPosition, + iconSize = _this$props.iconSize, + iconVariant = _this$props.iconVariant, + info = _this$props.info, + label = _this$props.label, + navRight = _this$props.navRight, + onRenderActions = _this$props.onRenderActions, + onRenderControls = _this$props.onRenderControls, + title = _this$props.title, + trail = _this$props.trail, + variant = _this$props.variant; + + var classes = this._getClassNames(className); + /** + * Render the icon + */ + + + var renderIcon = function renderIcon() { + if (iconName) { + return _react.default.createElement(_icon.default, { + name: iconName, + category: iconCategory, + position: iconPosition, + size: iconSize, + variant: iconVariant + }); + } + + return icon; + }; + /** + * Render the label + */ + + + var renderLabel = function renderLabel() { + var type = _typeof(label); + + if (trail.length > 0) { + return _react.default.createElement("nav", { + className: "slds-m-bottom_xx-small", + role: "navigation" + }, _react.default.createElement(_breadcrumb.default, { + trail: trail + })); + } + + if (type === 'string') { + return _react.default.createElement("p", { + className: "slds-line-height_reset" + }, label); + } + + return label; + }; + /** + * Render the title + */ + + + var renderTitle = function renderTitle() { + var type = _typeof(title); + + if (type === 'string') { + return _react.default.createElement(_title.default, { + title: title + }); + } + + return title; + }; + /** + * Render info + */ + + + var renderInfo = function renderInfo() { + var type = _typeof(info); + + if (type === 'string') { + return _react.default.createElement(_info.default, null, info); + } + + return info; + }; + /** + * Handles onRenderActions + */ + + + var renderOnRenderActions = function renderOnRenderActions() { + if (onRenderActions) { + var Actions = onRenderActions; + return _react.default.createElement("div", { + className: "slds-col slds-no-flex slds-grid slds-align-top" + }, _react.default.createElement(Actions, null)); + } + + return null; + }; + /** + * Steal contentRight's children + */ + + + var renderContentRight = function renderContentRight() { + if (onRenderActions) { + return ''; + } else if (contentRight) { + var type = _typeof(contentRight); + + if (type !== 'string') { + return _react.default.createElement("div", _extends({ + className: "slds-col slds-no-flex slds-grid slds-align-top" + }, contentRight.props)); + } + } + + return ''; + }; + /** + * Handles onRenderControls + */ + + + var renderOnRenderControls = function renderOnRenderControls() { + if (onRenderControls) { + var Controls = onRenderControls; + return _react.default.createElement("div", { + className: "slds-col slds-no-flex slds-grid slds-align-top" + }, _react.default.createElement(Controls, null)); + } + + return null; + }; + /** + * Steal navRight's children + * For backward compatibility, this function can be deleted once 'navRight' prop is deprecated + */ + + + var renderNavRight = function renderNavRight() { + if (onRenderControls) { + return ''; + } else if (navRight) { + var type = _typeof(navRight); + + if (type !== 'string') { + return _react.default.createElement("div", _extends({ + className: "slds-col slds-no-flex slds-grid slds-align-top" + }, navRight.props)); + } + } + + return ''; + }; + + var Variant; + + switch (variant) { + case 'object-home': + case 'objectHome': + // For backward compatibility + Variant = _objectHome.default; + break; + + case 'record-home': + case 'recordHome': + // For backward compatibility + Variant = _recordHome.default; + break; + + case 'related-list': + case 'relatedList': + // For backward compatibility + Variant = _relatedList.default; + break; + + default: + Variant = _base.default; + } + + return _react.default.createElement("div", { + className: classes + }, _react.default.createElement(Variant, { + label: renderLabel(), + icon: renderIcon(), + title: renderTitle(), + info: renderInfo(), + contentRight: renderContentRight() // For backward compatibility, 'contentRight' prop will be deprecated sooon + , + navRight: renderNavRight() // For backward compatibility, 'navRight' prop will be deprecate soon + , + onRenderActions: renderOnRenderActions(), + onRenderControls: renderOnRenderControls(), + details: details + })); + } + }]); + + return PageHeader; +}(_react.Component); + +PageHeader.displayName = displayName; +PageHeader.propTypes = propTypes; +PageHeader.defaultProps = defaultProps; +var _default = PageHeader; +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/private/base/index.js b/components/page-header/private/base/index.js new file mode 100644 index 0000000000..000faa17f0 --- /dev/null +++ b/components/page-header/private/base/index.js @@ -0,0 +1,60 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _mediaObject = _interopRequireDefault(require("../../../media-object")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +var displayName = 'PageHeaderBase'; +var propTypes = { + /** + * Icon node passed by PageHeader + */ + icon: _propTypes.default.node, + + /** + * Title node passed by PageHeader + */ + title: _propTypes.default.node, + + /** + * Info node passed by PageHeader + */ + info: _propTypes.default.node, + + /** + * Nav content which appears in the upper right hand corner. + * 'navRight' prop will be deprecated soon, instaed use 'onRenderControls' + */ + navRight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]) +}; + +var Base = function Base(props) { + return _react.default.createElement("div", { + className: "slds-grid slds-page-header__row" + }, _react.default.createElement("div", { + className: "slds-col slds-page-header__col-title" + }, _react.default.createElement(_mediaObject.default, { + body: _react.default.createElement("div", null, props.title, props.info), + className: "slds-no-space slds-grow", + figure: props.icon + })), _react.default.createElement("div", { + className: "slds-col slds-no-flex slds-grid slds-align-top" + }, props.onRenderControls ? props.onRenderControls : props.navRight)); +}; + +Base.displayName = displayName; +Base.propTypes = propTypes; +var _default = Base; +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/private/detail-block.js b/components/page-header/private/detail-block.js new file mode 100644 index 0000000000..1cc87c949c --- /dev/null +++ b/components/page-header/private/detail-block.js @@ -0,0 +1,209 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireWildcard(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames2 = _interopRequireDefault(require("classnames")); + +var _tooltip = _interopRequireDefault(require("../../tooltip")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var displayName = 'PageHeaderDetailRow'; +var propTypes = { + /** + * Optional class name + */ + className: _propTypes.default.string, + + /** + * label + */ + label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + + /** + * The content property can be a string or a React element + */ + content: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + + /** + * Sets whether the fields truncate + */ + truncate: _propTypes.default.bool, + flavor: _propTypes.default.string +}; +var defaultProps = { + label: '', + content: '' +}; + +var DetailBlock = +/*#__PURE__*/ +function (_Component) { + _inherits(DetailBlock, _Component); + + function DetailBlock(props) { + var _this; + + _classCallCheck(this, DetailBlock); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(DetailBlock).call(this, props)); + _this.state = { + showTooltip: false + }; + return _this; + } + + _createClass(DetailBlock, [{ + key: "componentDidMount", + value: function componentDidMount() { + this._renderFieldTruncation(); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps) { + if (this.props.content !== prevProps.content) { + this._renderFieldTruncation(); + } + } // eslint-disable-next-line class-methods-use-this + + }, { + key: "_getClassNames", + value: function _getClassNames(className, flavor) { + return (0, _classnames2.default)('slds-page-header__detail-block', className, _defineProperty({}, "slds-size_".concat(flavor), flavor)); + } + }, { + key: "_renderFieldTruncation", + value: function _renderFieldTruncation() { + var fieldContent = this.fieldContentRef; + var isTruncated = fieldContent && fieldContent.scrollWidth > fieldContent.offsetWidth; + + if (isTruncated) { + this.setState({ + showTooltip: true + }); + } else { + this.setState({ + showTooltip: false + }); + } + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var _this$props = this.props, + className = _this$props.className, + content = _this$props.content, + flavor = _this$props.flavor, + label = _this$props.label, + truncate = _this$props.truncate; + + var classes = this._getClassNames(className, flavor); + /** + * Render the label + */ + + + var renderLabel = function renderLabel() { + var type = _typeof(label); + + if (type === 'string') { + var labelClasses = (0, _classnames2.default)('slds-text-title', { + 'slds-truncate': truncate + }); + return _react.default.createElement("p", { + className: labelClasses, + title: label + }, label); + } + + return label; + }; + /** + * Render the content + */ + + + var renderContent = function renderContent() { + var type = _typeof(content); + + if (type === 'string') { + var labelClasses = (0, _classnames2.default)('slds-text-body_regular', { + 'slds-truncate': truncate + }); + return _react.default.createElement("p", { + ref: function ref(field) { + _this2.fieldContentRef = field; + }, + className: labelClasses, + content: content + }, content); + } + + return content; + }; + /** + * Render the content with a tooltip (for content that truncates) + */ + + + var renderContentWithTooltip = function renderContentWithTooltip() { + var labelClasses = (0, _classnames2.default)('slds-text-body_regular', { + 'slds-truncate': truncate + }); + return _react.default.createElement(_tooltip.default, { + align: "top", + content: content, + triggerStyle: { + display: 'inline' + } + }, _react.default.createElement("p", { + tabIndex: "0", + className: labelClasses + }, content)); + }; + + return _react.default.createElement("li", { + className: classes + }, renderLabel(), this.state.showTooltip ? renderContentWithTooltip() : renderContent()); + } + }]); + + return DetailBlock; +}(_react.Component); + +DetailBlock.displayName = displayName; +DetailBlock.propTypes = propTypes; +DetailBlock.defaultProps = defaultProps; +var _default = DetailBlock; +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/private/detail-row.js b/components/page-header/private/detail-row.js new file mode 100644 index 0000000000..7c1b221eb8 --- /dev/null +++ b/components/page-header/private/detail-row.js @@ -0,0 +1,115 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireWildcard(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _detailBlock = _interopRequireDefault(require("./detail-block")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var displayName = 'PageHeaderDetailRow'; +var propTypes = { + children: _propTypes.default.node, + + /** + * Optional class name + */ + className: _propTypes.default.string, + + /** + * An array of detail blocks + */ + details: _propTypes.default.array +}; +var defaultProps = {}; + +var DetailRow = +/*#__PURE__*/ +function (_Component) { + _inherits(DetailRow, _Component); + + function DetailRow() { + _classCallCheck(this, DetailRow); + + return _possibleConstructorReturn(this, _getPrototypeOf(DetailRow).apply(this, arguments)); + } + + _createClass(DetailRow, [{ + key: "_getClassNames", + // eslint-disable-next-line class-methods-use-this + value: function _getClassNames(className) { + return (0, _classnames.default)('slds-grid slds-page-header__detail-row', className); + } + }, { + key: "render", + value: function render() { + var _this$props = this.props, + children = _this$props.children, + className = _this$props.className, + details = _this$props.details; + + var classes = this._getClassNames(className); + /** + * Render the deets + */ + + + var renderDetails = function renderDetails() { + if (children !== undefined) { + return children; + } + + return details.map(function (detail, i) { + var key = "PageHeader.detailBlock.".concat(i); + return _react.default.createElement(_detailBlock.default, { + key: key, + flavor: detail.flavor, + label: detail.label, + content: detail.content, + truncate: detail.truncate + }); + }); + }; + + return _react.default.createElement("ul", { + className: classes + }, renderDetails()); + } + }]); + + return DetailRow; +}(_react.Component); + +DetailRow.displayName = displayName; +DetailRow.propTypes = propTypes; +DetailRow.defaultProps = defaultProps; +var _default = DetailRow; +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/private/info.js b/components/page-header/private/info.js new file mode 100644 index 0000000000..c0fa988d14 --- /dev/null +++ b/components/page-header/private/info.js @@ -0,0 +1,41 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +var displayName = 'PageHeaderInfo'; +var propTypes = { + /** + * Contents of info section + */ + children: _propTypes.default.node, + + /** + * Optional class name + */ + className: _propTypes.default.string +}; + +var Info = function Info(props) { + return _react.default.createElement("p", { + className: (0, _classnames.default)('slds-text-body_small slds-line-height_reset', props.className) + }, props.children); +}; + +Info.displayName = displayName; +Info.propTypes = propTypes; +var _default = Info; +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/private/object-home/index.js b/components/page-header/private/object-home/index.js new file mode 100644 index 0000000000..6eced96a3a --- /dev/null +++ b/components/page-header/private/object-home/index.js @@ -0,0 +1,77 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _mediaObject = _interopRequireDefault(require("../../../media-object")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +var displayName = 'PageHeaderObjectHome'; +var propTypes = { + /** + * Content to appear on the right hand side of the page header + * 'contentRight' prop will be deprecated soon, instead use 'onRenderActions' + */ + contentRight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + + /** + * Icon node passed by PageHeader + */ + icon: _propTypes.default.node, + + /** + * Info node passed by PageHeader + */ + info: _propTypes.default.node, + + /** + * Heading above title + */ + label: _propTypes.default.node, + + /** + * Nav content which appears in the upper right hand corner. + * 'navRight' prop will be deprecated soon, instaed use 'onRenderControls' + */ + navRight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + + /** + * Title node passed by PageHeader + */ + title: _propTypes.default.node +}; + +var ObjectHome = function ObjectHome(props) { + return _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-grid" + }, _react.default.createElement("div", { + className: "slds-col slds-has-flexi-truncate" + }, _react.default.createElement(_mediaObject.default, { + body: _react.default.createElement("div", null, props.label, props.title), + className: "slds-no-space slds-grow", + figure: props.icon + })), _react.default.createElement("div", { + className: "slds-col slds-no-flex slds-grid slds-align-top slds-p-bottom_xx-small" + }, props.onRenderControls ? props.onRenderControls : props.navRight)), _react.default.createElement("div", { + className: "slds-grid" + }, _react.default.createElement("div", { + className: "slds-col slds-align-bottom" + }, props.info), _react.default.createElement("div", { + className: "slds-col slds-no-flex slds-grid slds-align-bottom" + }, props.onRenderActions ? props.onRenderActions : props.contentRight))); +}; + +ObjectHome.displayName = displayName; +ObjectHome.propTypes = propTypes; +var _default = ObjectHome; +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/private/record-home/index.js b/components/page-header/private/record-home/index.js new file mode 100644 index 0000000000..cdadbd1fd2 --- /dev/null +++ b/components/page-header/private/record-home/index.js @@ -0,0 +1,74 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _detailRow = _interopRequireDefault(require("../detail-row")); + +var _mediaObject = _interopRequireDefault(require("../../../media-object")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +var displayName = 'PageHeaderRecordHome'; +var propTypes = { + /** + * Content to appear on the right hand side of the page header + * 'contentRight' prop will be deprecated soon, instead use 'onRenderActions' + */ + contentRight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + + /** + * An array of detail blocks + */ + details: _propTypes.default.array, + + /** + * Icon node passed by PageHeader + */ + icon: _propTypes.default.node, + + /** + * Info node passed by PageHeader + */ + info: _propTypes.default.node, + + /** + * Heading above title + */ + label: _propTypes.default.node, + + /** + * Title node passed by PageHeader + */ + title: _propTypes.default.node +}; + +var RecordHome = function RecordHome(props) { + return _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-grid" + }, _react.default.createElement("div", { + className: "slds-col slds-has-flexi-truncate" + }, _react.default.createElement(_mediaObject.default, { + body: _react.default.createElement("div", null, props.label, props.title, props.info), + className: "slds-no-space slds-grow", + figure: props.icon + })), _react.default.createElement("div", { + className: "slds-col slds-no-flex slds-grid slds-align-top" + }, props.onRenderActions ? props.onRenderActions : props.contentRight)), _react.default.createElement(_detailRow.default, { + details: props.details + })); +}; + +RecordHome.displayName = displayName; +RecordHome.propTypes = propTypes; +var _default = RecordHome; +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/private/related-list/index.js b/components/page-header/private/related-list/index.js new file mode 100644 index 0000000000..b81f787be3 --- /dev/null +++ b/components/page-header/private/related-list/index.js @@ -0,0 +1,97 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireWildcard(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var displayName = 'PageHeaderRelatedList'; +var propTypes = { + /** + * Title node passed by PageHeader + */ + title: _propTypes.default.node, + + /** + * Info node passed by PageHeader + */ + info: _propTypes.default.node, + + /** + * Content to appear on the right hand side of the page header + * 'contentRight' prop will be deprecated soon, instead use 'onRenderActions' + */ + contentRight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + + /** + * Nav content which appears in the upper right hand corner. + * 'navRight' prop will be deprecated soon, instaed use 'onRenderControls' + */ + navRight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]) +}; +var defaultProps = {}; + +var RelatedList = +/*#__PURE__*/ +function (_Component) { + _inherits(RelatedList, _Component); + + function RelatedList() { + _classCallCheck(this, RelatedList); + + return _possibleConstructorReturn(this, _getPrototypeOf(RelatedList).apply(this, arguments)); + } + + _createClass(RelatedList, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-grid" + }, _react.default.createElement("div", { + className: "slds-col slds-has-flexi-truncate" + }, this.props.label, this.props.title), _react.default.createElement("div", { + className: "slds-col slds-no-flex slds-grid slds-align-top" + }, this.props.onRenderControls ? this.props.onRenderControls : this.props.navRight)), _react.default.createElement("div", { + className: "slds-grid" + }, _react.default.createElement("div", { + className: "slds-col slds-align-bottom" + }, this.props.info), _react.default.createElement("div", { + className: "slds-col slds-no-flex slds-grid slds-align-bottom" + }, this.props.onRenderActions ? this.props.onRenderActions : this.props.contentRight))); + } + }]); + + return RelatedList; +}(_react.Component); + +RelatedList.displayName = displayName; +RelatedList.propTypes = propTypes; +RelatedList.defaultProps = defaultProps; +var _default = RelatedList; +exports.default = _default; \ No newline at end of file diff --git a/components/page-header/private/title.js b/components/page-header/private/title.js new file mode 100644 index 0000000000..2fd2c69607 --- /dev/null +++ b/components/page-header/private/title.js @@ -0,0 +1,112 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireWildcard(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames2 = _interopRequireDefault(require("classnames")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var displayName = 'PageHeaderTitle'; +var propTypes = { + /** + * Sets whether the title will truncate its content responsively. + */ + truncate: _propTypes.default.bool, + + /** + * Sets the vertical alignment on the title + */ + align: _propTypes.default.oneOf(['top', 'middle', 'bottom']), + + /** + * The title string (required) + */ + title: _propTypes.default.string.isRequired, + + /** + * Optional class name + */ + className: _propTypes.default.string +}; +var defaultProps = { + truncate: true, + align: 'middle', + title: 'Page Header Title', + className: '' +}; + +var Title = +/*#__PURE__*/ +function (_Component) { + _inherits(Title, _Component); + + function Title() { + _classCallCheck(this, Title); + + return _possibleConstructorReturn(this, _getPrototypeOf(Title).apply(this, arguments)); + } + + _createClass(Title, [{ + key: "_getClassNames", + // eslint-disable-next-line class-methods-use-this + value: function _getClassNames(truncate, align, className) { + return (0, _classnames2.default)('slds-page-header__title slds-m-right_small', className, _defineProperty({ + 'slds-truncate': truncate + }, "slds-align-".concat(align), align)); + } + }, { + key: "render", + value: function render() { + var _this$props = this.props, + children = _this$props.children, + title = _this$props.title, + truncate = _this$props.truncate, + align = _this$props.align, + className = _this$props.className; + + var classes = this._getClassNames(truncate, align, className); + + return _react.default.createElement("h1", { + className: classes, + title: title + }, title, children); + } + }]); + + return Title; +}(_react.Component); + +Title.displayName = displayName; +Title.propTypes = propTypes; +Title.defaultProps = defaultProps; +var _default = Title; +exports.default = _default; \ No newline at end of file diff --git a/components/panel/__docs__/site-stories.js b/components/panel/__docs__/site-stories.js new file mode 100644 index 0000000000..92c122b14e --- /dev/null +++ b/components/panel/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/panel/__examples__/filtering.jsx'), require('raw-loader!@salesforce/design-system-react/components/panel/__examples__/filtering-locked.jsx'), require('raw-loader!@salesforce/design-system-react/components/panel/__examples__/filtering-error.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/panel/__docs__/storybook-stories.js b/components/panel/__docs__/storybook-stories.js new file mode 100644 index 0000000000..30ad9dc78f --- /dev/null +++ b/components/panel/__docs__/storybook-stories.js @@ -0,0 +1,40 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _filtering = _interopRequireDefault(require("../__examples__/filtering")); + +var _filteringLocked = _interopRequireDefault(require("../__examples__/filtering-locked")); + +var _filteringError = _interopRequireDefault(require("../__examples__/filtering-error")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.PANEL, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-grid", + style: { + backgroundColor: '#ccc', + padding: '20px' + } + }, _react.default.createElement("div", { + className: "slds-col_bump-left", + style: { + width: '420px' + } + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory()))); +}).add('Filters', function () { + return _react.default.createElement(_filtering.default, null); +}).add('Filters Locked', function () { + return _react.default.createElement(_filteringLocked.default, null); +}).add('Filters Error', function () { + return _react.default.createElement(_filteringError.default, null); +}); \ No newline at end of file diff --git a/components/panel/__examples__/filtering-error.js b/components/panel/__examples__/filtering-error.js new file mode 100644 index 0000000000..ddcfce9398 --- /dev/null +++ b/components/panel/__examples__/filtering-error.js @@ -0,0 +1,249 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _panel = _interopRequireDefault(require("../../../../components/panel")); + +var _group = _interopRequireDefault(require("../../../../components/panel/filtering/group")); + +var _list = _interopRequireDefault(require("../../../../components/panel/filtering/list")); + +var _listHeading = _interopRequireDefault(require("../../../../components/panel/filtering/list-heading")); + +var _filter = _interopRequireDefault(require("../../../../components/filter")); + +var _menuPicklist = _interopRequireDefault(require("../../../../components/menu-picklist")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var options = { + 'show-me': [{ + label: 'All Products', + value: 'all-products' + }, { + label: 'All Wackamoles', + value: 'all-Wackamoles' + }], + 'created-date': [{ + label: 'equals THIS WEEK', + value: 'this-week' + }, { + label: 'equals LAST WEEK', + value: 'last-week' + }], + 'list-price': [{ + label: 'greater than "500"', + value: 'greater-than-500' + }, { + label: 'greater than "100"', + value: 'greater-than-100' + }] +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + modifiedPanel: false, + 'show-me': { + selectedPicklistItem: options['show-me'][0], + selectedItem: options['show-me'][0] + }, + 'created-date': { + selectedPicklistItem: options['created-date'][0], + selectedItem: options['created-date'][0], + isActive: true + }, + 'list-price': { + selectedPicklistItem: options['list-price'][0], + selectedItem: options['list-price'][0], + isActive: true + } + }); + + _defineProperty(_assertThisInitialized(_this), "onChangePredicate", function (event, _ref) { + var id = _ref.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({ + modifiedPanel: _this.state[idSuffix].selectedItem !== _this.state[idSuffix].selectedPicklistItem + }, idSuffix, _objectSpread({}, _this.state[idSuffix], { + selectedItem: _this.state[idSuffix].selectedPicklistItem + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onSelectPicklist", function (selectedItem, id) { + _this.setState(_defineProperty({}, id, _objectSpread({}, _this.state[id], { + selectedPicklistItem: selectedItem + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemove", function (event, _ref2) { + var id = _ref2.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + isActive: false + }))); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + var hasActiveFilters = this.state['created-date'].isActive || this.state['list-price'].isActive || this.state.new.isActive; + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_panel.default, { + variant: "filters" + }, _react.default.createElement(_group.default, { + errorLabel: "Filters could not be applied. Please fix the validation errors below.", + modified: this.state.modifiedPanel, + onClickAdd: function onClickAdd() { + _this2.setState({ + modifiedPanel: true, + new: { + isActive: true, + new: true + } + }); + }, + onClickRemoveAll: function onClickRemoveAll() { + _this2.onRemove(null, { + id: 'sample-panel-filtering-created-date' + }); + + _this2.onRemove(null, { + id: 'sample-panel-filtering-list-price' + }); + + _this2.onRemove(null, { + id: 'sample-panel-filtering-new' + }); + }, + onRequestCancel: function onRequestCancel() { + _this2.setState({ + modifiedPanel: false + }); + }, + onRequestClose: function onRequestClose() { + console.log('Request filtering panel to close'); + }, + onRequestSave: function onRequestSave() { + _this2.setState({ + modifiedPanel: false + }); + }, + variant: "panel" + }, _react.default.createElement(_list.default, null, _react.default.createElement(_filter.default, { + id: "sample-panel-filtering-show-me", + isPermanent: true, + onChange: this.onChangePredicate, + property: "Show Me", + predicate: this.state['show-me'].selectedItem.label + }, _react.default.createElement(_menuPicklist.default, { + isInline: true, + label: "Show Me", + onSelect: function onSelect(selectedItem) { + _this2.onSelectPicklist(selectedItem, 'show-me'); + }, + options: options['show-me'], + placeholder: "Select record type", + value: this.state['show-me'].selectedPicklistItem.value + }))), hasActiveFilters ? _react.default.createElement(_listHeading.default, { + label: "Matching all these filters" + }) : null, hasActiveFilters ? _react.default.createElement(_list.default, null, this.state['created-date'].isActive ? _react.default.createElement(_filter.default, { + id: "sample-panel-filtering-created-date", + onChange: this.onChangePredicate, + onRemove: this.onRemove, + predicate: this.state['created-date'].selectedItem.label, + property: "Created Date" + }, _react.default.createElement(_menuPicklist.default, { + isInline: true, + label: "Created Date EQUALS", + onSelect: function onSelect(selectedItem) { + _this2.onSelectPicklist(selectedItem, 'created-date'); + }, + options: options['created-date'], + placeholder: "Select a time range", + value: this.state['created-date'].selectedPicklistItem.value + })) : null, this.state['list-price'].isActive ? _react.default.createElement(_filter.default, { + id: "sample-panel-filtering-list-price", + onChange: this.onChangePredicate, + onRemove: this.onRemove, + predicate: this.state['list-price'].selectedItem.label, + property: "List Price" + }, _react.default.createElement(_menuPicklist.default, { + isInline: true, + label: "List Price", + onSelect: function onSelect(selectedItem) { + _this2.onSelectPicklist(selectedItem, 'list-price'); + }, + options: options['list-price'], + placeholder: "Select a price", + value: this.state['list-price'].selectedPicklistItem.value + })) : null, _react.default.createElement(_filter.default, { + errorLabel: "Error Message", + id: "sample-panel-filtering-error", + predicate: 'equals "Red"', + property: "Stage" + })) : null))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PanelExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/panel/__examples__/filtering-locked.js b/components/panel/__examples__/filtering-locked.js new file mode 100644 index 0000000000..2205f2156c --- /dev/null +++ b/components/panel/__examples__/filtering-locked.js @@ -0,0 +1,250 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _panel = _interopRequireDefault(require("../../../../components/panel")); + +var _group = _interopRequireDefault(require("../../../../components/panel/filtering/group")); + +var _list = _interopRequireDefault(require("../../../../components/panel/filtering/list")); + +var _listHeading = _interopRequireDefault(require("../../../../components/panel/filtering/list-heading")); + +var _filter = _interopRequireDefault(require("../../../../components/filter")); + +var _menuPicklist = _interopRequireDefault(require("../../../../components/menu-picklist")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var options = { + 'show-me': [{ + label: 'All Products', + value: 'all-products' + }, { + label: 'All Wackamoles', + value: 'all-Wackamoles' + }], + 'created-date': [{ + label: 'equals THIS WEEK', + value: 'this-week' + }, { + label: 'equals LAST WEEK', + value: 'last-week' + }], + 'list-price': [{ + label: 'greater than "500"', + value: 'greater-than-500' + }, { + label: 'greater than "100"', + value: 'greater-than-100' + }] +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + modifiedPanel: false, + 'show-me': { + selectedPicklistItem: options['show-me'][0], + selectedItem: options['show-me'][0] + }, + 'created-date': { + selectedPicklistItem: options['created-date'][0], + selectedItem: options['created-date'][0], + isActive: true + }, + 'list-price': { + selectedPicklistItem: options['list-price'][0], + selectedItem: options['list-price'][0], + isActive: true + } + }); + + _defineProperty(_assertThisInitialized(_this), "onChangePredicate", function (event, _ref) { + var id = _ref.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({ + modifiedPanel: _this.state[idSuffix].selectedItem !== _this.state[idSuffix].selectedPicklistItem + }, idSuffix, _objectSpread({}, _this.state[idSuffix], { + selectedItem: _this.state[idSuffix].selectedPicklistItem + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onSelectPicklist", function (selectedItem, id) { + _this.setState(_defineProperty({}, id, _objectSpread({}, _this.state[id], { + selectedPicklistItem: selectedItem + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemove", function (event, _ref2) { + var id = _ref2.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + isActive: false + }))); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + var hasActiveFilters = this.state['created-date'].isActive || this.state['list-price'].isActive || this.state.new.isActive; + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_panel.default, { + variant: "filters" + }, _react.default.createElement(_group.default, { + modified: this.state.modifiedPanel, + onClickAdd: function onClickAdd() { + _this2.setState({ + modifiedPanel: true, + new: { + isActive: true, + new: true + } + }); + }, + onClickRemoveAll: function onClickRemoveAll() { + _this2.onRemove(null, { + id: 'sample-panel-filtering-created-date' + }); + + _this2.onRemove(null, { + id: 'sample-panel-filtering-list-price' + }); + + _this2.onRemove(null, { + id: 'sample-panel-filtering-new' + }); + }, + onRequestCancel: function onRequestCancel() { + _this2.setState({ + modifiedPanel: false + }); + }, + onRequestClose: function onRequestClose() { + console.log('Request filtering panel to close'); + }, + onRequestSave: function onRequestSave() { + _this2.setState({ + modifiedPanel: false + }); + }, + variant: "panel" + }, _react.default.createElement(_list.default, null, _react.default.createElement(_filter.default, { + id: "sample-panel-filtering-show-me", + isPermanent: true, + onChange: this.onChangePredicate, + property: "Show Me", + predicate: this.state['show-me'].selectedItem.label + }, _react.default.createElement(_menuPicklist.default, { + isInline: true, + label: "Show Me", + onSelect: function onSelect(selectedItem) { + _this2.onSelectPicklist(selectedItem, 'show-me'); + }, + options: options['show-me'], + placeholder: "Select record type", + value: this.state['show-me'].selectedPicklistItem.value + }))), hasActiveFilters ? _react.default.createElement(_listHeading.default, { + label: "Matching all these filters" + }) : null, hasActiveFilters ? _react.default.createElement(_list.default, null, this.state['created-date'].isActive ? _react.default.createElement(_filter.default, { + id: "sample-panel-filtering-created-date", + onChange: this.onChangePredicate, + onRemove: this.onRemove, + predicate: this.state['created-date'].selectedItem.label, + property: "Created Date" + }, _react.default.createElement(_menuPicklist.default, { + isInline: true, + label: "Created Date EQUALS", + onSelect: function onSelect(selectedItem) { + _this2.onSelectPicklist(selectedItem, 'created-date'); + }, + options: options['created-date'], + placeholder: "Select a time range", + value: this.state['created-date'].selectedPicklistItem.value + })) : null, this.state['list-price'].isActive ? _react.default.createElement(_filter.default, { + id: "sample-panel-filtering-list-price", + onChange: this.onChangePredicate, + onRemove: this.onRemove, + predicate: this.state['list-price'].selectedItem.label, + property: "List Price" + }, _react.default.createElement(_menuPicklist.default, { + isInline: true, + label: "List Price", + onSelect: function onSelect(selectedItem) { + _this2.onSelectPicklist(selectedItem, 'list-price'); + }, + options: options['list-price'], + placeholder: "Select a price", + value: this.state['list-price'].selectedPicklistItem.value + })) : null) : null, _react.default.createElement(_listHeading.default, { + isLocked: true + }), _react.default.createElement(_list.default, null, _react.default.createElement(_filter.default, { + id: "sample-panel-filtering-name", + isLocked: true, + predicate: 'equals "ACME"', + property: "Name" + }))))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PanelExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/panel/__examples__/filtering.js b/components/panel/__examples__/filtering.js new file mode 100644 index 0000000000..73bc6ae36b --- /dev/null +++ b/components/panel/__examples__/filtering.js @@ -0,0 +1,270 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _panel = _interopRequireDefault(require("../../../../components/panel")); + +var _group = _interopRequireDefault(require("../../../../components/panel/filtering/group")); + +var _list = _interopRequireDefault(require("../../../../components/panel/filtering/list")); + +var _listHeading = _interopRequireDefault(require("../../../../components/panel/filtering/list-heading")); + +var _filter = _interopRequireDefault(require("../../../../components/filter")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _menuPicklist = _interopRequireDefault(require("../../../../components/menu-picklist")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var options = { + 'show-me': [{ + label: 'All Products', + value: 'all-products' + }, { + label: 'All Wackamoles', + value: 'all-Wackamoles' + }], + 'created-date': [{ + label: 'equals THIS WEEK', + value: 'this-week' + }, { + label: 'equals LAST WEEK', + value: 'last-week' + }], + 'list-price': [{ + label: 'greater than "500"', + value: 'greater-than-500' + }, { + label: 'greater than "100"', + value: 'greater-than-100' + }], + new: [{ + label: 'less than "1000"', + value: 'less-than-1000' + }, { + label: 'less than "800"', + value: 'less-than-800' + }] +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + modifiedPanel: false, + 'show-me': { + selectedPicklistItem: options['show-me'][0], + selectedItem: options['show-me'][0] + }, + 'created-date': { + selectedPicklistItem: options['created-date'][0], + selectedItem: options['created-date'][0], + isActive: true + }, + 'list-price': { + selectedPicklistItem: options['list-price'][0], + selectedItem: options['list-price'][0], + isActive: true + }, + new: {} + }); + + _defineProperty(_assertThisInitialized(_this), "onChangePredicate", function (event, _ref) { + var id = _ref.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({ + modifiedPanel: _this.state[idSuffix].selectedItem !== _this.state[idSuffix].selectedPicklistItem + }, idSuffix, _objectSpread({}, _this.state[idSuffix], { + selectedItem: _this.state[idSuffix].selectedPicklistItem + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onSelectPicklist", function (selectedItem, id) { + _this.setState(_defineProperty({}, id, _objectSpread({}, _this.state[id], { + selectedPicklistItem: selectedItem + }))); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemove", function (event, _ref2) { + var id = _ref2.id; + var idSuffix = id.split('sample-panel-filtering-')[1]; + + _this.setState(_defineProperty({}, idSuffix, _objectSpread({}, _this.state[idSuffix], { + isActive: false + }))); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + var hasActiveFilters = this.state['created-date'].isActive || this.state['list-price'].isActive || this.state.new.isActive; + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_panel.default, { + variant: "filters" + }, _react.default.createElement(_group.default, { + assistiveText: { + closeButton: 'Close Panel' + }, + modified: this.state.modifiedPanel, + onClickAdd: function onClickAdd() { + _this2.setState({ + modifiedPanel: true, + new: { + isActive: true, + new: true + } + }); + }, + onClickRemoveAll: function onClickRemoveAll() { + _this2.onRemove(null, { + id: 'sample-panel-filtering-created-date' + }); + + _this2.onRemove(null, { + id: 'sample-panel-filtering-list-price' + }); + + _this2.onRemove(null, { + id: 'sample-panel-filtering-new' + }); + }, + onRequestCancel: function onRequestCancel() { + _this2.setState({ + modifiedPanel: false + }); + }, + onRequestClose: function onRequestClose() { + console.log('Request filtering panel to close'); + }, + onRequestSave: function onRequestSave() { + _this2.setState({ + modifiedPanel: false + }); + }, + variant: "panel" + }, _react.default.createElement(_list.default, null, _react.default.createElement(_filter.default, { + id: "sample-panel-filtering-show-me", + isPermanent: true, + onChange: this.onChangePredicate, + property: "Show Me", + predicate: this.state['show-me'].selectedItem.label + }, _react.default.createElement(_menuPicklist.default, { + isInline: true, + label: "Show Me", + onSelect: function onSelect(selectedItem) { + _this2.onSelectPicklist(selectedItem, 'show-me'); + }, + options: options['show-me'], + placeholder: "Select record type", + value: this.state['show-me'].selectedPicklistItem.value + }))), hasActiveFilters ? _react.default.createElement(_listHeading.default, { + label: "Matching all these filters" + }) : null, hasActiveFilters ? _react.default.createElement(_list.default, null, this.state['created-date'].isActive ? _react.default.createElement(_filter.default, { + id: "sample-panel-filtering-created-date", + onChange: this.onChangePredicate, + onRemove: this.onRemove, + predicate: this.state['created-date'].selectedItem.label, + property: "Created Date" + }, _react.default.createElement(_menuPicklist.default, { + isInline: true, + label: "Created Date EQUALS", + onSelect: function onSelect(selectedItem) { + _this2.onSelectPicklist(selectedItem, 'created-date'); + }, + options: options['created-date'], + placeholder: "Select a time range", + value: this.state['created-date'].selectedPicklistItem.value + })) : null, this.state['list-price'].isActive ? _react.default.createElement(_filter.default, { + id: "sample-panel-filtering-list-price", + onChange: this.onChangePredicate, + onRemove: this.onRemove, + predicate: this.state['list-price'].selectedItem.label, + property: "List Price" + }, _react.default.createElement(_menuPicklist.default, { + isInline: true, + label: "List Price", + onSelect: function onSelect(selectedItem) { + _this2.onSelectPicklist(selectedItem, 'list-price'); + }, + options: options['list-price'], + placeholder: "Select a price", + value: this.state['list-price'].selectedPicklistItem.value + })) : null, this.state.new.isActive ? _react.default.createElement(_filter.default, { + id: "sample-panel-filtering-new", + isNew: this.state.new.new && this.state.modifiedPanel, + onChange: this.onChangePredicate, + onRemove: this.onRemove, + predicate: this.state.new.selectedItem && this.state.new.selectedItem.label, + property: this.state.new.selectedItem && this.state.new.selectedItem.label && 'List Price' + }, _react.default.createElement(_menuPicklist.default, { + isInline: true, + label: "List Price", + onSelect: function onSelect(selectedItem) { + _this2.onSelectPicklist(selectedItem, 'new'); + }, + options: options.new, + placeholder: "Select Criteria", + value: this.state.new.selectedPicklistItem && this.state.new.selectedPicklistItem.value + })) : null) : null))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PanelExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/panel/check-props.js b/components/panel/check-props.js new file mode 100644 index 0000000000..0ca6ef9db4 --- /dev/null +++ b/components/panel/check-props.js @@ -0,0 +1,29 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _componentIsPrototype = _interopRequireDefault(require("../../utilities/warning/component-is-prototype")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + (0, _componentIsPrototype.default)(COMPONENT, createDocUrl()); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/panel/docs.json b/components/panel/docs.json new file mode 100644 index 0000000000..90ae429abf --- /dev/null +++ b/components/panel/docs.json @@ -0,0 +1,18 @@ +{ + "component": "panel", + "status": "prototype", + "display-name": "Panels", + "SLDS-component-path": "/components/panels", + "dependencies": [ + { + "component": "filtering/group" + }, + { + "component": "filtering/list-heading" + }, + { + "component": "filtering/list" + } + ], + "url-slug": "panels" +} \ No newline at end of file diff --git a/components/panel/filtering/check-props.js b/components/panel/filtering/check-props.js new file mode 100644 index 0000000000..7b504ac091 --- /dev/null +++ b/components/panel/filtering/check-props.js @@ -0,0 +1,26 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _deprecatedProperty = _interopRequireDefault(require("../../../utilities/warning/deprecated-property")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props) { + (0, _deprecatedProperty.default)(COMPONENT, props.assistiveTextCloseFilterPanel, 'assistiveTextCloseFilterPanel', "assistiveText['closeButton']"); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/panel/filtering/group.js b/components/panel/filtering/group.js new file mode 100644 index 0000000000..2182e6e2b2 --- /dev/null +++ b/components/panel/filtering/group.js @@ -0,0 +1,197 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _panelFooter = _interopRequireDefault(require("./private/panel-footer")); + +var _panelHeader = _interopRequireDefault(require("./private/panel-header")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var defaultProps = { + addFilterLabel: 'Add Filter', + cancelLabel: 'Cancel', + assistiveText: { + closeButton: 'Close Filter Panel' + }, + heading: 'Filter', + saveLabel: 'Save', + removeAllLabel: 'Remove All' +}; +/** + * A filtering panel contextual filtering options. + */ + +var PanelFilterGroup = function PanelFilterGroup(props) { + (0, _checkProps.default)(_constants.PANEL_FILTER_GROUP, props); + var children = props.children, + errorLabel = props.errorLabel, + footer = props.footer, + header = props.header, + variant = props.variant, + addFilterLabel = props.addFilterLabel, + onClickAdd = props.onClickAdd, + onClickRemoveAll = props.onClickRemoveAll, + removeAllLabel = props.removeAllLabel, + cancelLabel = props.cancelLabel, + heading = props.heading, + modified = props.modified, + onRequestCancel = props.onRequestCancel, + onRequestClose = props.onRequestClose, + onRequestSave = props.onRequestSave, + saveLabel = props.saveLabel; + + var assistiveText = _objectSpread({}, defaultProps.assistiveText, props.assistiveText); + + if (props.assistiveTextCloseFilterPanel) { + assistiveText.closeButton = props.assistiveTextCloseFilterPanel; + } + + return _react.default.createElement("div", { + className: "slds-filters" + }, variant === 'panel' ? _react.default.createElement(_panelHeader.default, { + assistiveText: assistiveText, + cancelLabel: cancelLabel, + heading: heading, + modified: modified, + onRequestCancel: onRequestCancel, + onRequestClose: onRequestClose, + onRequestSave: onRequestSave, + saveLabel: saveLabel + }) : header || null, _react.default.createElement("div", { + className: "slds-filters__body" + }, errorLabel ? _react.default.createElement("div", { + className: "slds-text-color_error slds-m-bottom_x-small", + role: "alert" + }, errorLabel) : null, children), variant === 'panel' ? _react.default.createElement(_panelFooter.default, { + addFilterLabel: addFilterLabel, + onClickAdd: onClickAdd, + onClickRemoveAll: onClickRemoveAll, + removeAllLabel: removeAllLabel + }) : footer || null); +}; + +PanelFilterGroup.displayName = _constants.PANEL_FILTER_GROUP; +PanelFilterGroup.propTypes = { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `closeButton`: Localized description of the close button for the panel for screen readers + */ + assistiveText: _propTypes.default.shape({ + closeButton: _propTypes.default.string + }), + + /** + * Localized description of the "Add Filter" button in the footer + */ + addFilterLabel: _propTypes.default.node, + + /** + * Label for button that cancels modified filters + */ + cancelLabel: _propTypes.default.string, + + /** + * Pass in `FilterList`'s of `Filters`: + * + * ``` + * + * + * + * {popoverContents} + * + * + * + * ``` + */ + children: _propTypes.default.node, + + /** + * Label for the error message at the top of the panel. + */ + errorLabel: _propTypes.default.string, + + /** + * Allows for customization of footer. This will be added after any `FilterList`'s in the DOM. If using Panel Filter Group outside of a panel, do not set the variant to `panel` and header and footer will be removed. + */ + footer: _propTypes.default.node, + + /** + * Allows for customization of header. This will be added before any `FilterList`'s in the DOM. If using Panel Filter Group outside of a panel, do not set the variant to `panel` and header and footer will be removed. + */ + header: _propTypes.default.node, + + /** + * The heading within the header of the filtering panel + */ + heading: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * Shows confirmation heading. Please see `onRequestCancel` and `onRequestSave`. + */ + modified: _propTypes.default.bool, + + /** + * Callback triggered when "Add Filter" is clicked. Recieves an `event`. + */ + onClickAdd: _propTypes.default.func, + + /** + * Callback triggered when "Remove All" is clicked. Recieves an `event`. + */ + onClickRemoveAll: _propTypes.default.func, + + /** + * When the panel's cancel button is clicked in order to reset filter panel to previous state. + */ + onRequestCancel: _propTypes.default.func, + + /** + * When the panel's close button is clicked. Please place Panel within another element to control position and visibility. + */ + onRequestClose: _propTypes.default.func, + + /** + * When the panel's save button is clicked in order to confirm filter panel state. + */ + onRequestSave: _propTypes.default.func, + + /** + * Localized description of the "Remove All" button in the footer + */ + removeAllLabel: _propTypes.default.node, + + /** + * Label for button that saves modified filters + */ + saveLabel: _propTypes.default.string, + + /** + * Adds in default Panel header and footer + */ + variant: _propTypes.default.oneOf(['panel']) +}; +PanelFilterGroup.defaultProps = defaultProps; +var _default = PanelFilterGroup; +exports.default = _default; \ No newline at end of file diff --git a/components/panel/filtering/list-heading.js b/components/panel/filtering/list-heading.js new file mode 100644 index 0000000000..7465a8288a --- /dev/null +++ b/components/panel/filtering/list-heading.js @@ -0,0 +1,75 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _icon = _interopRequireDefault(require("../../icon")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// # FIlter List Heading +// Implements the [Panel design pattern](https://www.lightningdesignsystem.com/components/panels) in React. +// Based on SLDS v2.2.0-rc.1 +// ## Dependencies +// ### React +// ### classNames +// ## Constants + +/** + * A filtering panel contextual filtering options. + */ +var PanelFilterListHeading = function PanelFilterListHeading(_ref) { + var heading = _ref.heading, + isLocked = _ref.isLocked, + lockedHeading = _ref.lockedHeading; + return _react.default.createElement("h3", { + className: (0, _classnames.default)('slds-text-body_small', 'slds-m-vertical_x-small', { + 'slds-grid': isLocked + }) + }, isLocked ? lockedHeading : heading, isLocked ? _react.default.createElement(_icon.default, { + className: "slds-m-left_x-small", + assistiveText: { + label: 'locked' + }, + category: "utility", + name: "lock", + size: "x-small" + }) : null); +}; + +PanelFilterListHeading.displayName = _constants.PANEL_FILTER_LIST_HEADING; +PanelFilterListHeading.propTypes = { + /** + * Heading for following PanelFilterList + */ + heading: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * Displayed a heading for a locked list of filters + */ + isLocked: _propTypes.default.bool, + + /** + * Heading for a group of filters that are locked + */ + lockedHeading: _propTypes.default.string +}; +PanelFilterListHeading.defaultProps = { + heading: 'Matching all these filters', + lockedLabel: 'Locked filters' +}; +var _default = PanelFilterListHeading; +exports.default = _default; \ No newline at end of file diff --git a/components/panel/filtering/list.js b/components/panel/filtering/list.js new file mode 100644 index 0000000000..06f8b5f565 --- /dev/null +++ b/components/panel/filtering/list.js @@ -0,0 +1,102 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * A list of Filters. This is a higher order component for filters that decorates the filter to work within a Filtering Panel. It also adds support for a Filter error label. + */ +var PanelFilterList = +/*#__PURE__*/ +function (_React$Component) { + _inherits(PanelFilterList, _React$Component); + + function PanelFilterList() { + _classCallCheck(this, PanelFilterList); + + return _possibleConstructorReturn(this, _getPrototypeOf(PanelFilterList).apply(this, arguments)); + } + + _createClass(PanelFilterList, [{ + key: "componentWillMount", + value: function componentWillMount() { + this.generatedId = _shortid.default.generate(); + } + }, { + key: "render", + value: function render() { + var _this = this; + + var children = _react.default.Children.map(this.props.children, function (child, index) { + var id = child && child.props.id ? child.props.id : "".concat(_this.generatedId, "-").concat(index); + var clonedChild; + + if (child && child.props.errorLabel) { + clonedChild = _react.default.cloneElement(child, { + isError: true + }); + } + + return child ? _react.default.createElement("li", { + className: "slds-item slds-hint-parent" + }, clonedChild || child, child.props.errorLabel ? _react.default.createElement("p", { + id: "".concat(id, "-error"), + className: "slds-text-color_error slds-m-top_xx-small" + }, child.props.errorLabel) : null) : null; + }); + + return _react.default.createElement("ol", { + className: "slds-list_vertical slds-list_vertical-space" + }, children); + } + }], [{ + key: "propTypes", + value: function propTypes() { + return { + /** + * Pass in `Filter` components + */ + children: _propTypes.default.node + }; + } + }]); + + return PanelFilterList; +}(_react.default.Component); + +_defineProperty(PanelFilterList, "displayName", _constants.PANEL_FILTER_LIST); + +var _default = PanelFilterList; +exports.default = _default; \ No newline at end of file diff --git a/components/panel/filtering/private/panel-footer.js b/components/panel/filtering/private/panel-footer.js new file mode 100644 index 0000000000..f5412ab5a9 --- /dev/null +++ b/components/panel/filtering/private/panel-footer.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _button = _interopRequireDefault(require("../../../button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// # Panel Filter Group Footer +// Implements the [Panel design pattern](https://www.lightningdesignsystem.com/components/panels) in React. +// Based on SLDS v2.2.0-rc.1 +// ## Dependencies +// ### React + +/** + * A filtering panel contextual filtering options. + */ +var PanelFilterFooter = function PanelFilterFooter(_ref) { + var addFilterLabel = _ref.addFilterLabel, + onClickAdd = _ref.onClickAdd, + onClickRemoveAll = _ref.onClickRemoveAll, + removeAllLabel = _ref.removeAllLabel; + return _react.default.createElement("div", { + className: "slds-filters__footer slds-grid slds-shrink-none" + }, _react.default.createElement(_button.default, { + label: addFilterLabel, + onClick: onClickAdd, + variant: "link" + }), _react.default.createElement(_button.default, { + className: "slds-col_bump-left", + label: removeAllLabel, + onClick: onClickRemoveAll, + variant: "link" + })); +}; + +PanelFilterFooter.displayName = 'SLDSPanelFilterFooter'; +PanelFilterFooter.propTypes = { + /** + * Localized description of the "Add Filter" button in the footer + */ + addFilterLabel: _propTypes.default.node.isRequired, + + /** + * Callback triggered when "Add Filter" is clicked. Recieves an `event`. + */ + onClickAdd: _propTypes.default.func.isRequired, + + /** + * Callback triggered when "Remove All" is clicked. Recieves an `event`. + */ + onClickRemoveAll: _propTypes.default.func.isRequired, + + /** + * Localized description of the "Remove All" button in the footer + */ + removeAllLabel: _propTypes.default.node.isRequired +}; +var _default = PanelFilterFooter; +exports.default = _default; \ No newline at end of file diff --git a/components/panel/filtering/private/panel-header.js b/components/panel/filtering/private/panel-header.js new file mode 100644 index 0000000000..1da7a5b001 --- /dev/null +++ b/components/panel/filtering/private/panel-header.js @@ -0,0 +1,113 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _button = _interopRequireDefault(require("../../../button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// # Panel Filter Group Header +// Implements the [Panel design pattern](https://www.lightningdesignsystem.com/components/panels) in React. +// Based on SLDS v2.2.0-rc.1 +// ## Dependencies +// ### React + +/** + * Header for a Filter Group within a Panel. + */ +var PanelFilterHeader = function PanelFilterHeader(_ref) { + var assistiveText = _ref.assistiveText, + cancelLabel = _ref.cancelLabel, + heading = _ref.heading, + modified = _ref.modified, + onRequestCancel = _ref.onRequestCancel, + onRequestClose = _ref.onRequestClose, + onRequestSave = _ref.onRequestSave, + saveLabel = _ref.saveLabel; + return modified ? _react.default.createElement("div", { + className: "slds-filters__header slds-grid slds-has-divider_bottom-space slds-grid_align-spread" + }, _react.default.createElement(_button.default, { + label: cancelLabel, + onClick: onRequestCancel, + variant: "neutral" + }), _react.default.createElement(_button.default, { + label: saveLabel, + onClick: onRequestSave, + variant: "brand" + })) : _react.default.createElement("div", { + className: "slds-filters__header slds-grid slds-has-divider_bottom-space" + }, _react.default.createElement("h2", { + className: "slds-align-middle slds-text-heading_small" + }, heading), _react.default.createElement(_button.default, { + className: "slds-col_bump-left", + assistiveText: { + icon: assistiveText.closeButton + }, + iconCategory: "utility", + iconName: "forward", + iconVariant: "bare", + iconSize: "small", + onClick: onRequestClose, + title: assistiveText.closeButton, + variant: "icon" + })); +}; + +PanelFilterHeader.displayName = 'SLDSPanelFilterHeader'; +PanelFilterHeader.propTypes = { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `closeButton`: Localized description of the close button for the panel for screen readers + */ + assistiveText: _propTypes.default.shape({ + closeButton: _propTypes.default.string + }), + + /** + * Label for button that cancels modified filters + */ + cancelLabel: _propTypes.default.string, + + /** + * The heading of the filtering panel + */ + heading: _propTypes.default.node, + + /** + * Shows confirmation heading. Please see `onRequestCancel` and `onRequestSave`. + */ + modified: _propTypes.default.bool, + + /** + * When the panel's cancel button is clicked in order to reset filter panel to previous state. + */ + onRequestCancel: _propTypes.default.func, + + /** + * When the panel's close button is clicked. Please place Panel within another element to control position and visibility. + */ + onRequestClose: _propTypes.default.func, + + /** + * When the panel's save button is clicked in order to confirm filter panel state. + */ + onRequestSave: _propTypes.default.func, + + /** + * Label for button that saves modified filters + */ + saveLabel: _propTypes.default.string +}; +var _default = PanelFilterHeader; +exports.default = _default; \ No newline at end of file diff --git a/components/panel/index.js b/components/panel/index.js new file mode 100644 index 0000000000..26a68946da --- /dev/null +++ b/components/panel/index.js @@ -0,0 +1,92 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +/** + * A panel provides detailed contextual information or contextual filtering options. [Filter](/components/filters/) component should be used as children. Menus within a Filter Popover will need to not have "portal mounts" and be inline. */ +var Panel = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Panel, _React$Component); + + function Panel() { + _classCallCheck(this, Panel); + + return _possibleConstructorReturn(this, _getPrototypeOf(Panel).apply(this, arguments)); + } + + _createClass(Panel, [{ + key: "componentWillMount", + value: function componentWillMount() { + (0, _checkProps.default)(_constants.PANEL, _docs.default); + } + }, { + key: "render", + value: function render() { + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-panel', 'slds-grid', 'slds-grid_vertical', 'slds-nowrap', { + 'slds-panel_filters': this.props.variant === 'filters' + }, this.props.className) + }, _react.default.createElement("div", { + className: "slds-form_stacked slds-grow slds-scrollable_y slds-grid slds-grid_vertical" + }, this.props.children)); + } + }]); + + return Panel; +}(_react.default.Component); + +Panel.displayName = _constants.PANEL; +Panel.propTypes = { + /** + * The contents of the panel + */ + children: _propTypes.default.node, + + /** + * CSS classes to be added to `slds-panel`. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * The type of panel + */ + variant: _propTypes.default.oneOf(['filters']) +}; +var _default = Panel; +exports.default = _default; \ No newline at end of file diff --git a/components/pill-container/__docs__/__snapshots__/storybook-stories.storyshot b/components/pill-container/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..ae74a18783 --- /dev/null +++ b/components/pill-container/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,1024 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSPillContainer Bare Pill Container 1`] = ` +
    +
    +
    +

    + Static Examples +

    +
    +
    +
    +
      +
    • + + + Pill Label 1 + + + + + + + Press delete or backspace to remove + + + +
    • +
    • + + + Pill Label 2 + + + + + + + Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPillContainer Base Pill Container 1`] = ` +
    +
    +
    +

    + Static Examples +

    +
    +
    +
    +
      +
    • + + + Pill Label 1 + + + + + + + Press delete or backspace to remove + + + +
    • +
    • + + + Pill Label 2 + + + + + + + Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPillContainer Pill Container With Avatars 1`] = ` +
    +
    +
    +

    + Static Examples +

    +
    +
    +
    +
      +
    • + + +
      + + + +
      +
      + + Pill Label 1 + + + + + + + Press delete or backspace to remove + + +
      +
    • +
    • + + +
      + + + +
      +
      + + Pill Label 2 + + + + + + + Press delete or backspace to remove + + +
      +
    • +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPillContainer Pill Container With Icons 1`] = ` +
    +
    +
    +

    + Static Examples +

    +
    +
    +
    +
      +
    • + + + + + + + + + Pill Label 1 + + + + + + + Press delete or backspace to remove + + + +
    • +
    • + + + + + + + + + Pill Label 2 + + + + + + + Press delete or backspace to remove + + + +
    • +
    • + + + + + + + + + Pill Label 3 + + + + + + + Press delete or backspace to remove + + + +
    • +
    • + + + + + + + + + Pill Label 4 + + + + + + + Press delete or backspace to remove + + + +
    • +
    • + + + + + + + + + Pill Label 5 + + + + + + + Press delete or backspace to remove + + + +
    • +
    • + + + + + + + + + Pill Label 6 + + + + + + + Press delete or backspace to remove + + + +
    • +
    • + + + + + + + + + Pill Label 7 + + + + + + + Press delete or backspace to remove + + + +
    • +
    • + + + + + + + + + Pill Label 8 + + + + + + + Press delete or backspace to remove + + + +
    • +
    • + + + + + + + + + Pill Label 9 + + + + + + + Press delete or backspace to remove + + + +
    • +
    +
    +
    +
    +
    +`; diff --git a/components/pill-container/__docs__/site-stories.js b/components/pill-container/__docs__/site-stories.js new file mode 100644 index 0000000000..ab65c34c19 --- /dev/null +++ b/components/pill-container/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/pill-container/__examples__/base.jsx'), require('raw-loader!@salesforce/design-system-react/components/pill-container/__examples__/icons.jsx'), require('raw-loader!@salesforce/design-system-react/components/pill-container/__examples__/avatars.jsx'), require('raw-loader!@salesforce/design-system-react/components/pill-container/__examples__/bare.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/pill-container/__docs__/storybook-stories.js b/components/pill-container/__docs__/storybook-stories.js new file mode 100644 index 0000000000..7a4482a018 --- /dev/null +++ b/components/pill-container/__docs__/storybook-stories.js @@ -0,0 +1,45 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _constants = require("../../../utilities/constants"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +var _icons = _interopRequireDefault(require("../__examples__/icons")); + +var _avatars = _interopRequireDefault(require("../__examples__/avatars")); + +var _bare = _interopRequireDefault(require("../__examples__/bare")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.PILL_CONTAINER, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base Pill Container', function () { + return _react.default.createElement(_base.default, { + action: _addonActions.action + }); +}).add('Pill Container With Icons', function () { + return _react.default.createElement(_icons.default, { + action: _addonActions.action + }); +}).add('Pill Container With Avatars', function () { + return _react.default.createElement(_avatars.default, { + action: _addonActions.action + }); +}).add('Bare Pill Container', function () { + return _react.default.createElement(_bare.default, { + action: _addonActions.action + }); +}); \ No newline at end of file diff --git a/components/pill-container/__examples__/avatars.js b/components/pill-container/__examples__/avatars.js new file mode 100644 index 0000000000..a71af8bb19 --- /dev/null +++ b/components/pill-container/__examples__/avatars.js @@ -0,0 +1,121 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _avatar = _interopRequireDefault(require("../../../../components/avatar")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _pillContainer = _interopRequireDefault(require("../../../../components/pill-container")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "onClickPill", function (event, data) { + if (window && window.console && window.console.log) { + console.log('onClickPill: ', event, data); + } + }); + + _defineProperty(_assertThisInitialized(_this), "onRequestRemovePill", function (event, data) { + var options = _this.state.options.filter(function (option) { + return option.id !== data.option.id; + }); + + _this.setState({ + options: options + }); + + if (window && window.console && window.console.log) { + console.log('onRequestRemovePill: ', event, data); + } + }); + + _this.state = { + options: [{ + avatar: _react.default.createElement(_avatar.default, { + imgSrc: "https://lightningdesignsystem.com/assets/images/avatar1.jpg", + title: "User 1", + variant: "user" + }), + id: '1', + label: 'Pill Label 1', + title: 'Full pill label verbiage mirrored here' + }, { + avatar: _react.default.createElement(_avatar.default, { + imgSrc: "https://lightningdesignsystem.com/assets/images/avatar2.jpg", + title: "User 2", + variant: "user" + }), + id: '2', + label: 'Pill Label 2', + title: 'Full pill label verbiage mirrored here' + }] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-p-vertical_medium" + }, _react.default.createElement("h3", { + className: "slds-text-heading_small" + }, "Static Examples")), _react.default.createElement("div", { + className: "slds-grid slds-grid_vertical-align-start" + }, _react.default.createElement(_pillContainer.default, { + id: "pill-container-with-avatars", + options: this.state.options, + onClickPill: this.onClickPill, + onRequestRemovePill: this.onRequestRemovePill + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PillContainerWithAvatarsExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/pill-container/__examples__/bare.js b/components/pill-container/__examples__/bare.js new file mode 100644 index 0000000000..3fa1fcc1a1 --- /dev/null +++ b/components/pill-container/__examples__/bare.js @@ -0,0 +1,110 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _pillContainer = _interopRequireDefault(require("../../../../components/pill-container")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "onClickPill", function (event, data) { + if (window && window.console && window.console.log) { + console.log('onClickPill: ', event, data); + } + }); + + _defineProperty(_assertThisInitialized(_this), "onRequestRemovePill", function (event, data) { + var options = _this.state.options.filter(function (option) { + return option.id !== data.option.id; + }); + + _this.setState({ + options: options + }); + + if (window && window.console && window.console.log) { + console.log('onRequestRemovePill: ', event, data); + } + }); + + _this.state = { + options: [{ + id: '1', + label: 'Pill Label 1', + title: 'Full pill label verbiage mirrored here' + }, { + id: '2', + label: 'Pill Label 2', + title: 'Full pill label verbiage mirrored here' + }] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-p-vertical_medium" + }, _react.default.createElement("h3", { + className: "slds-text-heading_small" + }, "Static Examples")), _react.default.createElement("div", { + className: "slds-grid slds-grid_vertical-align-start" + }, _react.default.createElement(_pillContainer.default, { + id: "bare-pill-container", + options: this.state.options, + onClickPill: this.onClickPill, + onRequestRemovePill: this.onRequestRemovePill, + variant: "bare" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'BarePillContainerExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/pill-container/__examples__/base.js b/components/pill-container/__examples__/base.js new file mode 100644 index 0000000000..a7ba0d59d7 --- /dev/null +++ b/components/pill-container/__examples__/base.js @@ -0,0 +1,109 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _pillContainer = _interopRequireDefault(require("../../../../components/pill-container")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "onClickPill", function (event, data) { + if (window && window.console && window.console.log) { + console.log('onClickPill: ', event, data); + } + }); + + _defineProperty(_assertThisInitialized(_this), "onRequestRemovePill", function (event, data) { + var options = _this.state.options.filter(function (option) { + return option.id !== data.option.id; + }); + + _this.setState({ + options: options + }); + + if (window && window.console && window.console.log) { + console.log('onRequestRemovePill: ', event, data); + } + }); + + _this.state = { + options: [{ + id: '1', + label: 'Pill Label 1', + title: 'Full pill label verbiage mirrored here' + }, { + id: '2', + label: 'Pill Label 2', + title: 'Full pill label verbiage mirrored here' + }] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-p-vertical_medium" + }, _react.default.createElement("h3", { + className: "slds-text-heading_small" + }, "Static Examples")), _react.default.createElement("div", { + className: "slds-grid slds-grid_vertical-align-start" + }, _react.default.createElement(_pillContainer.default, { + id: "base-pill-container", + options: this.state.options, + onClickPill: this.onClickPill, + onRequestRemovePill: this.onRequestRemovePill + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'BasePillContainerExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/pill-container/__examples__/icons.js b/components/pill-container/__examples__/icons.js new file mode 100644 index 0000000000..18c8a9c494 --- /dev/null +++ b/components/pill-container/__examples__/icons.js @@ -0,0 +1,184 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _pillContainer = _interopRequireDefault(require("../../../../components/pill-container")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "onClickPill", function (event, data) { + if (window && window.console && window.console.log) { + console.log('onClickPill: ', event, data); + } + }); + + _defineProperty(_assertThisInitialized(_this), "onRequestRemovePill", function (event, data) { + var options = _this.state.options.filter(function (option) { + return option.id !== data.option.id; + }); + + _this.setState({ + options: options + }); + + if (window && window.console && window.console.log) { + console.log('onRequestRemovePill: ', event, data); + } + }); + + _this.state = { + options: [{ + icon: _react.default.createElement(_icon.default, { + category: "standard", + name: "account", + title: "Account" + }), + id: '1', + label: 'Pill Label 1', + title: 'Full pill label verbiage mirrored here' + }, { + icon: _react.default.createElement(_icon.default, { + category: "standard", + name: "case", + title: "Case" + }), + id: '2', + label: 'Pill Label 2', + title: 'Full pill label verbiage mirrored here' + }, { + icon: _react.default.createElement(_icon.default, { + category: "utility", + name: "retweet", + title: "Retweet" + }), + id: '3', + label: 'Pill Label 3', + title: 'Full pill label verbiage mirrored here' + }, { + icon: _react.default.createElement(_icon.default, { + category: "standard", + name: "solution", + title: "Solution" + }), + id: '4', + label: 'Pill Label 4', + title: 'Full pill label verbiage mirrored here' + }, { + icon: _react.default.createElement(_icon.default, { + category: "standard", + name: "custom_notification", + title: "Custom Notification" + }), + id: '5', + label: 'Pill Label 5', + title: 'Full pill label verbiage mirrored here' + }, { + icon: _react.default.createElement(_icon.default, { + category: "standard", + name: "email", + title: "Email" + }), + id: '6', + label: 'Pill Label 6', + title: 'Full pill label verbiage mirrored here' + }, { + icon: _react.default.createElement(_icon.default, { + category: "standard", + name: "endorsement", + title: "Endorsement" + }), + id: '7', + label: 'Pill Label 7', + title: 'Full pill label verbiage mirrored here' + }, { + icon: _react.default.createElement(_icon.default, { + category: "standard", + name: "recent", + title: "Recent" + }), + id: '8', + label: 'Pill Label 8', + title: 'Full pill label verbiage mirrored here' + }, { + icon: _react.default.createElement(_icon.default, { + category: "custom", + name: "custom31", + title: "Custom 31" + }), + id: '9', + label: 'Pill Label 9', + title: 'Full pill label verbiage mirrored here' + }] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-p-vertical_medium" + }, _react.default.createElement("h3", { + className: "slds-text-heading_small" + }, "Static Examples")), _react.default.createElement("div", { + className: "slds-grid slds-grid_vertical-align-start" + }, _react.default.createElement(_pillContainer.default, { + id: "pill-container-with-icons", + options: this.state.options, + onClickPill: this.onClickPill, + onRequestRemovePill: this.onRequestRemovePill + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PillContainerWithIconsExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/pill-container/docs.json b/components/pill-container/docs.json new file mode 100644 index 0000000000..4f77618b4e --- /dev/null +++ b/components/pill-container/docs.json @@ -0,0 +1,7 @@ +{ + "component": "pill-container", + "status": "prod", + "display-name": "Pill Container", + "SLDS-component-path": "/components/pill-container", + "url-slug": "pill-container" +} diff --git a/components/pill-container/index.js b/components/pill-container/index.js new file mode 100644 index 0000000000..9d33a192d6 --- /dev/null +++ b/components/pill-container/index.js @@ -0,0 +1,336 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _selectedListbox = _interopRequireDefault(require("./private/selected-listbox")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * **Assistive text for accessibility** + * * `listboxLabel`: This is a label for the listbox. The default is `Selected Options:`. + * * `removePill`: Used to remove a selected item (pill). Focus is on the pill. This is not a button. The default is `Press delete or backspace to remove`. + */ + assistiveText: _propTypes.default.shape({ + listboxLabel: _propTypes.default.string, + removePill: _propTypes.default.string + }), + + /** + * CSS classes to be added to the pill container + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * HTML id for pill container + */ + id: _propTypes.default.string, + + /** + * **Text labels for internationalization** + * * `removePillTitle`: Title on `X` icon + */ + labels: _propTypes.default.shape({ + removePillTitle: _propTypes.default.string + }), + + /** + * **Array of pill objects.** + * Each object can contain: + * * `avatar`: An `Avatar` component. + * * `error`: Adds error styling + * * `icon`: An `Icon` component. + * * `id`: A unique identifier string. + * * `label`: A primary string of text. + * * `title`: Text that appears on mouse hover. Most helpful for long labels. + * ``` + * { + * id: '2', + * label: 'Salesforce.com, Inc.', + * title: 'Salesforce.com, Inc. - Want to work here?', + * }, + * ``` + * `options` with array length of zero will remove this component from the DOM. + */ + options: _propTypes.default.arrayOf(_propTypes.default.shape({ + avatar: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.shape({ + imgSrc: _propTypes.default.string, + title: _propTypes.default.string, + variant: _propTypes.default.string + })]), + bare: _propTypes.default.bool, + error: _propTypes.default.bool, + icon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.shape({ + category: _propTypes.default.string, + name: _propTypes.default.string + })]), + id: _propTypes.default.string, + label: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + title: _propTypes.default.string + })), + + /** + * Function called when a pill is clicked + */ + onClickPill: _propTypes.default.func, + + /** + * Function called when a pill is requested to be 'removed' via the delete key or 'X' icon click. + */ + onRequestRemovePill: _propTypes.default.func, + + /** + * Custom style object to be passed to the pill container + */ + style: _propTypes.default.object, + + /** + * Specifies the pill styling at the container level. `bare` removes border styling from all pills. + */ + variant: _propTypes.default.oneOf(['base', 'bare']) +}; +/** + * A `PillContainer` is a container that holds one or more pills. Use it for a list of pills in a container that resembles an `input` form field. It is not intended for navigation. + */ + +var PillContainer = +/*#__PURE__*/ +function (_React$Component) { + _inherits(PillContainer, _React$Component); + + function PillContainer(props) { + var _this; + + _classCallCheck(this, PillContainer); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(PillContainer).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "getId", function () { + return _this.props.id || _this.generatedId; + }); + + _defineProperty(_assertThisInitialized(_this), "getNewActiveOptionIndex", function (_ref) { + var activeOptionIndex = _ref.activeOptionIndex, + offset = _ref.offset, + options = _ref.options; + var nextIndex = activeOptionIndex + offset; + return options.length > nextIndex && nextIndex >= 0 ? nextIndex : activeOptionIndex; + }); + + _defineProperty(_assertThisInitialized(_this), "handleBlurPill", function () { + if (!_this.preserveFocus) { + _this.setState({ + listboxHasFocus: false + }); + } else { + _this.preserveFocus = false; + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleClickPill", function (event, data) { + _this.setState({ + activeSelectedOption: data.option, + activeSelectedOptionIndex: data.index, + listboxHasFocus: true + }); + + if (_this.props.onClickPill) { + _this.props.onClickPill(event, { + index: data.index, + option: data.option + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handlePillFocus", function () { + if (!_this.state.listboxHasFocus) { + _this.setState({ + listboxHasFocus: true + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleNavigatePillContainer", function (event, _ref2) { + var direction = _ref2.direction; + var offsets = { + next: 1, + previous: -1 + }; + + _this.setState(function (prevState) { + var options = _this.props.options; + var isLastOptionAndRightIsPressed = prevState.activeSelectedOptionIndex + 1 === options.length && direction === 'next'; + var isFirstOptionAndLeftIsPressed = prevState.activeSelectedOptionIndex === 0 && direction === 'previous'; + var newState; + + if (isLastOptionAndRightIsPressed) { + newState = { + activeSelectedOption: options[0], + activeSelectedOptionIndex: 0, + listboxHasFocus: true + }; + } else if (isFirstOptionAndLeftIsPressed) { + newState = { + activeSelectedOption: options[options.length - 1], + activeSelectedOptionIndex: options.length - 1, + listboxHasFocus: true + }; + } else { + var newIndex = _this.getNewActiveOptionIndex({ + activeOptionIndex: prevState.activeSelectedOptionIndex, + offset: offsets[direction], + options: options + }); + + newState = { + activeSelectedOption: options[newIndex], + activeSelectedOptionIndex: newIndex, + listboxHasFocus: true + }; + } + + _this.preserveFocus = true; + return newState; + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleRequestFocusPillContainer", function (event, _ref3) { + var ref = _ref3.ref; + + if (ref) { + _this.activeSelectedOptionRef = ref; + + _this.activeSelectedOptionRef.focus(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleRequestRemove", function (event, data) { + if (_this.props.onRequestRemovePill) { + _this.preserveFocus = true; + + _this.props.onRequestRemovePill(event, { + index: data.index, + option: data.option + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "resetActiveSelectedOption", function () { + var options = _this.props.options; + var activeSelectedOptionIndex = _this.state.activeSelectedOptionIndex; + + if (!options[activeSelectedOptionIndex]) { + if (options.length > 0 && activeSelectedOptionIndex >= options.length) { + activeSelectedOptionIndex = options.length - 1; + } else { + activeSelectedOptionIndex = 0; + } + } + + _this.setState({ + activeSelectedOption: options[activeSelectedOptionIndex] || undefined, + activeSelectedOptionIndex: activeSelectedOptionIndex, + listboxHasFocus: !!options[activeSelectedOptionIndex] + }); + }); + + _this.state = { + // seeding initial state with this.props.options[0] + activeSelectedOption: _this.props.options && _this.props.options[0] || undefined, + activeSelectedOptionIndex: 0, + listboxHasFocus: false + }; + _this.activeSelectedOptionRef = null; + _this.generatedId = _shortid.default.generate(); + _this.preserveFocus = false; + return _this; + } + + _createClass(PillContainer, [{ + key: "componentDidUpdate", + value: function componentDidUpdate() { + if (this.props.options && this.props.options.length > 0 && !this.props.options[this.state.activeSelectedOptionIndex] || this.preserveFocus) { + this.resetActiveSelectedOption(); + this.preserveFocus = false; + } + } + }, { + key: "render", + value: function render() { + return this.props.options.length > 0 ? _react.default.createElement(_selectedListbox.default, { + activeOption: this.state.activeSelectedOption, + activeOptionIndex: this.state.activeSelectedOptionIndex, + assistiveText: { + removePill: this.props.assistiveText.removePill, + selectedListboxLabel: this.props.assistiveText.listboxLabel + }, + className: this.props.className, + events: { + onBlurPill: this.handleBlurPill, + onClickPill: this.handleClickPill, + onPillFocus: this.handlePillFocus, + onRequestFocus: this.handleRequestFocusPillContainer, + onRequestFocusOnNextPill: this.handleNavigatePillContainer, + onRequestFocusOnPreviousPill: this.handleNavigatePillContainer, + onRequestRemove: this.handleRequestRemove + }, + id: "".concat(this.getId(), "-listbox-of-pill-options"), + isBare: this.props.variant === 'bare', + isPillContainer: true, + labels: this.props.labels, + listboxHasFocus: this.state.listboxHasFocus, + renderAtSelectionLength: 0, + selection: this.props.options, + style: this.props.style + }) : null; + } + }]); + + return PillContainer; +}(_react.default.Component); + +PillContainer.displayName = _constants.PILL_CONTAINER; +PillContainer.defaultProps = { + assistiveText: { + listboxLabel: 'Selected Options:', + removePill: 'Press delete or backspace to remove' + }, + labels: { + removePillTitle: 'Remove' + } +}; +PillContainer.propTypes = propTypes; +var _default = PillContainer; +exports.default = _default; \ No newline at end of file diff --git a/components/pill-container/private/selected-listbox.js b/components/pill-container/private/selected-listbox.js new file mode 100644 index 0000000000..8c33d61c7c --- /dev/null +++ b/components/pill-container/private/selected-listbox.js @@ -0,0 +1,245 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _avatar = _interopRequireDefault(require("../../avatar")); + +var _icon = _interopRequireDefault(require("../../icon")); + +var _pill = _interopRequireDefault(require("../../utilities/pill")); + +var _isReactComponent = _interopRequireDefault(require("../../../utilities/is-react-component")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /* + * The option object within the selection prop that should have focus. + */ + activeOption: _propTypes.default.object, + + /* + * The index of the option object within the selection prop that should have focus. + */ + activeOptionIndex: _propTypes.default.number, + + /** + * **Assistive text for accessibility** + * This object is merged with the default props object on every render. + * * `label`: This is used as a visually hidden label if, no `labels.label` is provided. + * * `removePill`: Aids in keyboard interaction with Pills. + * * `selectedListboxLabel`: Used to identify the listbox + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string, + removePill: _propTypes.default.string, + selectedListboxLabel: _propTypes.default.string + }), + + /** + * CSS classes to be added to the top-level `div` tag. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /* + * Callbacks for various pill events such as click, focus, etc + */ + events: _propTypes.default.shape({ + onClickPill: _propTypes.default.func.isRequired, + onPillFocus: _propTypes.default.func.isRequired, + onRequestFocus: _propTypes.default.func.isRequired, + onRequestFocusOnNextPill: _propTypes.default.func.isRequired, + onRequestFocusOnPreviousPill: _propTypes.default.func.isRequired, + onRequestRemove: _propTypes.default.func.isRequired + }), + + /** + * HTML id for component main container + */ + id: _propTypes.default.string, + + /** + * Determines whether component renders as a bare pill container with associated styling for child pills + */ + isBare: _propTypes.default.bool, + + /** + * Adds inline (inside of input) styling + */ + isInline: _propTypes.default.bool, + + /** + * Determines whether component renders as a pill container with associated styling and behavior + */ + isPillContainer: _propTypes.default.bool, + + /* + * Pill Label + */ + labels: _propTypes.default.shape({ + label: _propTypes.default.string, + remove: _propTypes.default.string, + title: _propTypes.default.string + }), + + /** + * Changes styles of the input. Currently `entity` is not supported. + */ + renderAtSelectionLength: _propTypes.default.number, + + /** + * This callback exposes the selected listbox reference / DOM node to parent components. + */ + selectedListboxRef: _propTypes.default.func, + + /** + * Accepts an array of item objects. + */ + selection: _propTypes.default.array, + + /** + * Custom styles to be passed to the top-level `div` tag + */ + style: _propTypes.default.object, + + /** + * Requests that the active option set focus on render + */ + listboxHasFocus: _propTypes.default.bool, + + /** + * Changes styles of the input. Currently `entity` is not supported. + */ + variant: _propTypes.default.oneOf(['base', 'inline-listbox', 'readonly']) +}; +var defaultProps = { + renderAtSelectionLength: 1 +}; + +var getAvatar = function getAvatar(option) { + var avatarObject = option.avatar; + var avatar = null; + + if (avatarObject) { + if ((0, _isReactComponent.default)(avatarObject) || avatarObject instanceof HTMLElement) { + avatar = avatarObject; + } else if (avatarObject.imgSrc) { + avatar = _react.default.createElement(_avatar.default, { + imgSrc: avatarObject.imgSrc, + title: avatarObject.title || option.label, + variant: avatarObject.variant || 'user' + }); + } + } + + return avatar; +}; + +var getIcon = function getIcon(option) { + var iconObject = option.icon; + var icon = null; + + if (iconObject) { + if ((0, _isReactComponent.default)(iconObject) || iconObject instanceof HTMLElement) { + icon = iconObject; + } else if (iconObject.category && iconObject.name) { + icon = _react.default.createElement(_icon.default, { + category: iconObject.category, + name: iconObject.name, + title: iconObject.title || option.label + }); + } + } + + return icon; +}; + +var SelectedListBox = function SelectedListBox(props) { + return props.selection.length >= props.renderAtSelectionLength ? _react.default.createElement("div", { + // eslint-disable-line jsx-a11y/role-supports-aria-props + className: (0, _classnames.default)({ + 'slds-pill_container': props.isPillContainer + }, props.className) || undefined, + id: props.id, + ref: function ref(_ref) { + if (props.selectedListboxRef) { + props.selectedListboxRef(_ref); + } + }, + role: "listbox", + style: props.style, + "aria-orientation": "horizontal" + }, _react.default.createElement("ul", { + className: (0, _classnames.default)('slds-listbox', { + 'slds-listbox_inline': props.isInline, + 'slds-listbox_horizontal': !props.isInline, + 'slds-p-top_xxx-small': !props.isInline + }), + role: "group", + "aria-label": props.assistiveText.selectedListboxLabel + }, props.selection.map(function (option, renderIndex) { + var hasTabIndex = renderIndex === props.activeOptionIndex; + var icon = getIcon(option); + var avatar = !icon ? getAvatar(option) : null; + return _react.default.createElement("li", { + role: "presentation", + className: "slds-listbox__item", + key: "".concat(props.id, "-list-item-").concat(option.id) + }, _react.default.createElement(_pill.default, { + active: hasTabIndex && props.listboxHasFocus, + assistiveText: { + remove: props.assistiveText.removePill + }, + avatar: avatar, + bare: option.bare || props.isBare, + error: option.error, + events: { + onBlur: props.events.onBlurPill, + onClick: function onClick(event, data) { + props.events.onClickPill(event, _objectSpread({}, data, { + index: renderIndex + })); + }, + onFocus: props.events.onPillFocus, + onRequestFocusOnNextPill: props.events.onRequestFocusOnNextPill, + onRequestFocusOnPreviousPill: props.events.onRequestFocusOnPreviousPill, + onRequestRemove: function onRequestRemove(event, data) { + props.events.onRequestRemove(event, _objectSpread({}, data, { + index: renderIndex + })); + }, + onRequestFocus: props.events.onRequestFocus + }, + eventData: { + option: option + }, + hasError: option.error, + icon: icon, + labels: { + label: option.label, + removeTitle: props.labels.removePillTitle + }, + requestFocus: props.listboxHasFocus, + tabIndex: hasTabIndex ? 0 : -1 + })); + }))) : null; +}; + +SelectedListBox.displayName = 'SelectedListBox'; +SelectedListBox.propTypes = propTypes; +SelectedListBox.defaultProps = defaultProps; +var _default = SelectedListBox; +exports.default = _default; \ No newline at end of file diff --git a/components/pill/__docs__/site-stories.js b/components/pill/__docs__/site-stories.js new file mode 100644 index 0000000000..e50f277281 --- /dev/null +++ b/components/pill/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/pill/__examples__/base.jsx'), require('raw-loader!@salesforce/design-system-react/components/pill/__examples__/icon.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/pill/__docs__/storybook-stories.js b/components/pill/__docs__/storybook-stories.js new file mode 100644 index 0000000000..911469af4d --- /dev/null +++ b/components/pill/__docs__/storybook-stories.js @@ -0,0 +1,37 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _constants = require("../../../utilities/constants"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +var _icon = _interopRequireDefault(require("../__examples__/icon")); + +var _snapshot = _interopRequireDefault(require("../__examples__/snapshot")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.PILL, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Linked, Unlinked, Truncated', function () { + return _react.default.createElement(_base.default, { + action: _addonActions.action + }); +}).add('Icon, Avatar, Error', function () { + return _react.default.createElement(_icon.default, { + action: _addonActions.action + }); +}).add('Docs site Snapshot', function () { + return _react.default.createElement(_snapshot.default, null); +}); \ No newline at end of file diff --git a/components/pill/__examples__/base.js b/components/pill/__examples__/base.js new file mode 100644 index 0000000000..e3a3d04a0d --- /dev/null +++ b/components/pill/__examples__/base.js @@ -0,0 +1,183 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _pill = _interopRequireDefault(require("../../../../components/pill")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var noop = function noop() { + return undefined; +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + linked: true, + unlinked: true, + truncated: true + }); + + _defineProperty(_assertThisInitialized(_this), "onClick", function (event) { + _this.props.action('onClick')(event); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemoveLinked", function (event) { + _this.props.action('onRemove')(event); + + _this.setState({ + linked: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemoveUnlinked", function (event) { + _this.props.action('onRemove')(event); + + _this.setState({ + unlinked: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemoveTruncated", function (event) { + _this.props.action('onRemove')(event); + + _this.setState({ + truncated: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "renderLinked", function () { + if (_this.state.linked) { + return _react.default.createElement(_pill.default, { + labels: { + label: 'Pill Label', + title: 'Full pill label verbiage mirrored here', + removeTitle: 'Remove' + }, + onClick: _this.onClick, + onRemove: _this.onRemoveLinked + }); + } + + return null; + }); + + _defineProperty(_assertThisInitialized(_this), "renderUnlinked", function () { + if (_this.state.unlinked) { + return _react.default.createElement(_pill.default, { + labels: { + label: 'Pill Label', + title: 'Full pill label verbiage mirrored here', + removeTitle: 'Remove' + }, + onRemove: _this.onRemoveUnlinked + }); + } + + return null; + }); + + _defineProperty(_assertThisInitialized(_this), "renderTruncated", function () { + if (_this.state.truncated) { + return _react.default.createElement("div", { + style: { + width: '220px', + position: 'relative' + } + }, _react.default.createElement("div", { + className: "slds-pill_container" + }, _react.default.createElement(_pill.default, { + labels: { + label: 'Pill label that is longer than the area that contains it', + removeTitle: 'Remove' + }, + onClick: _this.onClick, + onRemove: _this.onRemoveTruncated + }))); + } + + return null; + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded-medium" + }, _react.default.createElement("div", { + className: "slds-p-horizontal_medium" + }, this.renderLinked()), _react.default.createElement("div", { + className: "slds-p-horizontal_medium" + }, this.renderUnlinked()), _react.default.createElement("div", { + className: "slds-p-horizontal_medium" + }, this.renderTruncated()))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'BasePillExample'); + +_defineProperty(Example, "propTypes", { + action: _propTypes.default.func +}); + +_defineProperty(Example, "defaultProps", { + action: function action() { + return noop; + } +}); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/pill/__examples__/icon.js b/components/pill/__examples__/icon.js new file mode 100644 index 0000000000..288ff0890a --- /dev/null +++ b/components/pill/__examples__/icon.js @@ -0,0 +1,166 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _pill = _interopRequireDefault(require("../../../../components/pill")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _avatar = _interopRequireDefault(require("../../../../components/avatar")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var noop = function noop() { + return undefined; +}; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + pill1: true, + pill2: true, + pill3: true + }); + + _defineProperty(_assertThisInitialized(_this), "onClick", function (event) { + _this.props.action('onClick')(event); + }); + + _defineProperty(_assertThisInitialized(_this), "onRemove", function (event, pill) { + _this.props.action('onRemove')(event); + + _this.setState(_defineProperty({}, pill, false)); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded-medium" + }, _react.default.createElement("div", { + className: "slds-p-horizontal_medium" + }, this.state.pill1 ? _react.default.createElement(_pill.default, { + labels: { + label: 'Pill Label', + title: 'Full pill label verbiage mirrored here', + removeTitle: 'Remove' + }, + icon: _react.default.createElement(_icon.default, { + title: "Account", + category: "standard", + name: "account" + }), + onClick: this.onClick, + onRemove: function onRemove(event) { + return _this2.onRemove(event, 'pill1'); + } + }) : null), _react.default.createElement("div", { + className: "slds-p-horizontal_medium" + }, this.state.pill2 ? _react.default.createElement(_pill.default, { + labels: { + label: 'Pill Label', + title: 'Full pill label verbiage mirrored here', + removeTitle: 'Remove' + }, + avatar: _react.default.createElement(_avatar.default, { + variant: "user", + title: "User avatar", + imgSrc: "https://lightningdesignsystem.com/assets/images/avatar2.jpg" + }), + onClick: this.onClick, + onRemove: function onRemove(event) { + return _this2.onRemove(event, 'pill2'); + } + }) : null), _react.default.createElement("div", { + className: "slds-p-horizontal_medium" + }, this.state.pill3 ? _react.default.createElement(_pill.default, { + labels: { + label: 'Pill Label', + title: 'Full pill label verbiage mirrored here', + removeTitle: 'Remove' + }, + hasError: true, + icon: _react.default.createElement(_icon.default, { + title: "Error", + category: "utility", + name: "warning", + className: "slds-icon-text-error" + }), + onClick: this.onClick, + onRemove: function onRemove(event) { + return _this2.onRemove(event, 'pill3'); + } + }) : null))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PillWithIconExample'); + +_defineProperty(Example, "propTypes", { + action: _propTypes.default.func +}); + +_defineProperty(Example, "defaultProps", { + action: function action() { + return noop; + } +}); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/pill/__examples__/snapshot.js b/components/pill/__examples__/snapshot.js new file mode 100644 index 0000000000..fd44ccd797 --- /dev/null +++ b/components/pill/__examples__/snapshot.js @@ -0,0 +1,153 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _pill = _interopRequireDefault(require("../../../../components/pill")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _avatar = _interopRequireDefault(require("../../../../components/avatar")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function noop() {} + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_pill.default, { + labels: { + label: 'Pill Label', + title: 'Full pill label verbiage mirrored here', + removeTitle: 'Remove' + }, + onClick: noop, + onRemove: noop + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_pill.default, { + labels: { + label: 'Pill Label', + title: 'Full pill label verbiage mirrored here', + removeTitle: 'Remove' + }, + onRemove: noop + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_pill.default, { + labels: { + label: 'Pill Label', + title: 'Full pill label verbiage mirrored here', + removeTitle: 'Remove' + }, + icon: _react.default.createElement(_icon.default, { + title: "Account", + category: "standard", + name: "account" + }), + onClick: noop, + onRemove: noop + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_pill.default, { + labels: { + label: 'Pill Label', + title: 'Full pill label verbiage mirrored here', + removeTitle: 'Remove' + }, + avatar: _react.default.createElement(_avatar.default, { + variant: "user", + title: "User avatar", + imgSrc: "https://lightningdesignsystem.com/assets/images/avatar2.jpg" + }), + onClick: noop, + onRemove: noop + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_pill.default, { + labels: { + label: 'Pill Label', + title: 'Full pill label verbiage mirrored here', + removeTitle: 'Remove' + }, + hasError: true, + icon: _react.default.createElement(_icon.default, { + title: "Error", + category: "utility", + name: "warning", + className: "slds-icon-text-error" + }), + onClick: noop, + onRemove: noop + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_pill.default, { + labels: { + label: 'Pill Label', + title: 'Full pill label verbiage mirrored here', + removeTitle: 'Remove' + }, + assistiveText: { + remove: 'Press delete or backspace to remove' + }, + bare: true, + variant: "option", + tabIndex: "0", + "aria-selected": "true", + onRemove: noop + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PillExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/pill/docs.json b/components/pill/docs.json new file mode 100644 index 0000000000..1709627418 --- /dev/null +++ b/components/pill/docs.json @@ -0,0 +1,7 @@ +{ + "component": "pill", + "status": "prod", + "display-name": "Pills", + "SLDS-component-path": "/components/pills", + "url-slug": "pills" +} diff --git a/components/pill/index.js b/components/pill/index.js new file mode 100644 index 0000000000..4fbe71b7d2 --- /dev/null +++ b/components/pill/index.js @@ -0,0 +1,361 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _constants = require("../../utilities/constants"); + +var _utilityIcon = _interopRequireDefault(require("../utilities/utility-icon")); + +var _keyCode = _interopRequireDefault(require("../../utilities/key-code")); + +var _event = _interopRequireDefault(require("../../utilities/event")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * **Assistive text for accessibility** + * This object is merged with the default props object on every render. + * * `remove`: This is a visually hidden label for the close button. + * _Tested with snapshot testing._ + */ + assistiveText: _propTypes.default.shape({ + remove: _propTypes.default.string + }), + + /** + * SLDSAvatar component to show on the left of the pill. + * _Tested with Mocha framework._ + */ + avatar: _propTypes.default.element, + + /** + * Applies the bare style to the component. + * _Tested with Mocha framework._ + */ + bare: _propTypes.default.bool, + + /** + * This is a way to specify custom contents for the pill in the case a simple text label is not enough. + * _Tested with Mocha framework._ + */ + children: _propTypes.default.node, + + /** + * CSS classes to be added to tag with `.slds-pill`. Uses `classNames` [API](https://github.com/JedWatson/classnames). + * _Tested with Mocha framework._ + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Applies the error style to the component. + * _Tested with Mocha framework._ + */ + hasError: _propTypes.default.bool, + + /** + * An href to use if the pill is shown as a link. + * _Tested with Mocha framework._ + */ + href: _propTypes.default.string, + + /** + * SLDSIcon component to show on the left of the pill. + * _Tested with Mocha framework._ + */ + icon: _propTypes.default.element, + + /** + * **Text labels for internationalization** + * This object is merged with the default props object on every render. + * * `label`: Pill's label. + * * `title`: Pill's title. + * * `removeTitle`: A title to use for the remove icon. + * + * _Tested with snapshot testing._ + */ + labels: _propTypes.default.shape({ + label: _propTypes.default.string, + title: _propTypes.default.string, + removeTitle: _propTypes.default.string + }), + + /** + * `onBlur` callback executes when the component loses focus. + * _Tested with Mocha framework._ + */ + onBlur: _propTypes.default.func, + + /** + * `onClick` callback executes when a user clicks on the pill or presses the Enter key. + * _Tested with Mocha framework._ + */ + onClick: _propTypes.default.func, + + /** + * `onFocus` callback executes when the component receives focus. + * _Tested with Mocha framework._ + */ + onFocus: _propTypes.default.func, + + /** + * `onKeyDown` callback executes when a user presses a key. + * _Tested with Mocha framework._ + */ + onKeyDown: _propTypes.default.func, + + /** + * `onRemove` callback executes when a user clicks on the pill's remove icon or presses the delete or the backspace keys. + * _Tested with Mocha framework._ + */ + onRemove: _propTypes.default.func, + + /** + * A variant of a pill + * _Tested with Mocha framework._ + */ + variant: _propTypes.default.oneOf(['link', 'option']) +}; +/** + * A pill displays a label that can contain links and can be removed from view. Use `PillContainer` for a list of pills in a container that resembles an `input` form field. A pill is useful for displaying read-only text that can be added and removed on demand. + */ + +var Pill = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Pill, _React$Component); + + function Pill() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Pill); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Pill)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "getHref", function () { + return typeof _this.props.href === 'string' ? _this.props.href : 'javascript:void(0);'; + }); + + _defineProperty(_assertThisInitialized(_this), "blur", function () { + _this.root.blur(); + }); + + _defineProperty(_assertThisInitialized(_this), "focus", function () { + _this.root.focus(); + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) { + if (typeof _this.props.onKeyDown === 'function') { + var _this$props$onKeyDown; + + for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + rest[_key2 - 1] = arguments[_key2]; + } + + // Make a callback to onKeyDown. + (_this$props$onKeyDown = _this.props.onKeyDown).call.apply(_this$props$onKeyDown, [null, event].concat(rest)); // Cancel further handling if the default handling for the event was prevented. + + + if (event.defaultPrevented) { + return; + } + } + + switch (event.keyCode) { + case _keyCode.default.ENTER: + if (typeof _this.props.onClick === 'function') { + _event.default.trap(event); + + _this.props.onClick(); + } + + break; + + case _keyCode.default.BACKSPACE: + case _keyCode.default.DELETE: + if (typeof _this.props.onRemove === 'function') { + _event.default.trap(event); + + _this.props.onRemove(); + } + + break; + + default: + break; + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleRef", function (root) { + // Keeping the top-most element to support focus() and blur() + _this.root = root; + }); + + _defineProperty(_assertThisInitialized(_this), "restProps", function () { + var _this$props = _this.props, + bare = _this$props.bare, + hasError = _this$props.hasError, + variant = _this$props.variant, + className = _this$props.className, + onClick = _this$props.onClick, + onRemove = _this$props.onRemove, + labels = _this$props.labels, + assistiveText = _this$props.assistiveText, + children = _this$props.children, + href = _this$props.href, + icon = _this$props.icon, + avatar = _this$props.avatar, + onKeyDown = _this$props.onKeyDown, + other = _objectWithoutProperties(_this$props, ["bare", "hasError", "variant", "className", "onClick", "onRemove", "labels", "assistiveText", "children", "href", "icon", "avatar", "onKeyDown"]); + + return other; + }); + + _defineProperty(_assertThisInitialized(_this), "renderIcon", function () { + var icon = _this.props.icon || _this.props.avatar; + + if (icon) { + return _react.default.createElement("span", { + className: "slds-pill__icon_container" + }, icon); + } + + return null; + }); + + _defineProperty(_assertThisInitialized(_this), "renderLabel", function () { + if (_this.props.labels.label) { + if (_this.props.variant === 'link') { + return _react.default.createElement("a", { + href: _this.getHref(), + className: "slds-pill__action", + title: _this.props.labels.title || _this.props.labels.label, + onClick: _this.props.onClick + }, _react.default.createElement("span", { + className: "slds-pill__label" + }, _this.props.labels.label)); + } + + return _react.default.createElement("span", { + className: "slds-pill__label", + title: _this.props.labels.title || _this.props.labels.label + }, _this.props.labels.label); + } + + return _this.props.children; + }); + + _defineProperty(_assertThisInitialized(_this), "renderRemoveIcon", function () { + if (typeof _this.props.onRemove === 'function') { + return _react.default.createElement("span", { + // eslint-disable-line jsx-a11y/interactive-supports-focus + className: "slds-icon_container slds-pill__remove", + title: _this.props.labels.removeTitle, + role: "button", + onClick: _this.props.onRemove + }, _react.default.createElement(_utilityIcon.default, { + style: { + cursor: 'pointer' + } // remove when fixed by SLDS CSS + , + category: "utility", + className: "slds-icon slds-icon_x-small slds-icon-text-default", + name: "close" + }), _react.default.createElement("span", { + className: "slds-assistive-text" + }, _this.props.assistiveText.remove || _this.props.labels.removeTitle)); + } + + return null; + }); + + return _this; + } + + _createClass(Pill, [{ + key: "render", + value: function render() { + var role; + + switch (this.props.variant) { + case 'link': + role = 'button'; + break; + + case 'option': + role = 'option'; + break; + + default: + } + + return ( + /* eslint-disable jsx-a11y/no-static-element-interactions */ + _react.default.createElement("span", _extends({}, this.restProps(), { + role: role, + className: (0, _classnames.default)('slds-pill', { + 'slds-pill_link': this.props.variant === 'link', + 'slds-has-error': this.props.hasError, + 'slds-pill_bare': this.props.bare + }, this.props.className), + onClick: !this.props.labels.label || this.props.variant !== 'link' ? this.props.onClick : null, + onKeyDown: typeof this.props.onRemove === 'function' ? this.handleKeyDown : null, + ref: this.handleRef + }), this.renderIcon(), this.renderLabel(), this.renderRemoveIcon()) + ); + } + }]); + + return Pill; +}(_react.default.Component); + +Pill.displayName = _constants.PILL; +Pill.defaultProps = { + variant: 'link', + labels: {}, + assistiveText: {} +}; +Pill.propTypes = propTypes; +var _default = Pill; +exports.default = _default; \ No newline at end of file diff --git a/components/popover-tooltip/index.js b/components/popover-tooltip/index.js new file mode 100644 index 0000000000..b3ba4e0dc6 --- /dev/null +++ b/components/popover-tooltip/index.js @@ -0,0 +1,25 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _tooltip = _interopRequireDefault(require("../tooltip")); + +var _componentHasMoved = _interopRequireDefault(require("../../utilities/warning/component-has-moved")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// Alias +(0, _componentHasMoved.default)(_constants.POPOVER_TOOLTIP, { + oldFileLocation: 'components/popover-tooltip', + newFileLocation: 'components/tooltip' +}); +var _default = _tooltip.default; +exports.default = _default; \ No newline at end of file diff --git a/components/popover/__docs__/__snapshots__/storybook-stories.storyshot b/components/popover/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..f6b940b814 --- /dev/null +++ b/components/popover/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,2170 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSPopover Alignment (Button) 1`] = ` +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Alignment (ButtonIcon) 1`] = ` +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopover AlternativeHeader 1`] = ` +
    +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Controlled w/ Footer 1`] = ` +
    +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Custom Target - Open 1`] = ` +
    +
    +
    + + +
    +
    + Popover Target +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Custom Target 1`] = ` +
    +
    +
    + +
    +
    + Popover Target +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Edit Dialog - Open 1`] = ` +
    +
    + + John + + Smith + +
    + + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Edit Dialog 1`] = ` +
    +
    + + John + + Smith + +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Error - Open 1`] = ` +
    +`; + +exports[`DOM snapshots SLDSPopover Error 1`] = ` +
    +
    + +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Header 1`] = ` +
    +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Styling (dev-only) 1`] = ` +
    +
    +
    + + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Walkthrough - Open 1`] = ` +
    +
    + + +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Walkthrough 1`] = ` +
    +
    + +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Walkthrough Action - Open 1`] = ` +
    +
    + + +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Walkthrough Action 1`] = ` +
    +
    + +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Warning - Open 1`] = ` +
    +
    + + +
    +
    +`; + +exports[`DOM snapshots SLDSPopover Warning 1`] = ` +
    +
    + +
    +
    +`; diff --git a/components/popover/__docs__/site-stories.js b/components/popover/__docs__/site-stories.js new file mode 100644 index 0000000000..221e4000e9 --- /dev/null +++ b/components/popover/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/popover/__examples__/header.jsx'), require('raw-loader!@salesforce/design-system-react/components/popover/__examples__/alternative-header.jsx'), require('raw-loader!@salesforce/design-system-react/components/popover/__examples__/controlled-with-footer.jsx'), require('raw-loader!@salesforce/design-system-react/components/popover/__examples__/custom-target.jsx'), require('raw-loader!@salesforce/design-system-react/components/popover/__examples__/error.jsx'), require('raw-loader!@salesforce/design-system-react/components/popover/__examples__/walkthrough.jsx'), require('raw-loader!@salesforce/design-system-react/components/popover/__examples__/walkthrough-action.jsx'), require('raw-loader!@salesforce/design-system-react/components/popover/__examples__/warning.jsx'), require('raw-loader!@salesforce/design-system-react/components/popover/__examples__/edit-dialog.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/popover/__docs__/storybook-stories.js b/components/popover/__docs__/storybook-stories.js new file mode 100644 index 0000000000..29f7ece185 --- /dev/null +++ b/components/popover/__docs__/storybook-stories.js @@ -0,0 +1,176 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _customTarget = _interopRequireDefault(require("../__examples__/custom-target")); + +var _header = _interopRequireDefault(require("../__examples__/header")); + +var _error = _interopRequireDefault(require("../__examples__/error")); + +var _walkthrough = _interopRequireDefault(require("../__examples__/walkthrough")); + +var _editDialog = _interopRequireDefault(require("../__examples__/edit-dialog")); + +var _walkthroughAction = _interopRequireDefault(require("../__examples__/walkthrough-action")); + +var _warning = _interopRequireDefault(require("../__examples__/warning")); + +var _alternativeHeader = _interopRequireDefault(require("../__examples__/alternative-header")); + +var _controlledWithFooter = _interopRequireDefault(require("../__examples__/controlled-with-footer")); + +var _popover = _interopRequireDefault(require("../../popover")); + +var _button = _interopRequireDefault(require("../../button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +var getPopover = function getPopover(props) { + return _react.default.createElement("div", null, _react.default.createElement(_popover.default, props, _react.default.createElement(_button.default, { + label: "Trigger Popover" + }))); +}; + +var getPopoverNubbins = function getPopoverNubbins(props) { + /* eslint-disable react/prop-types */ + var children = []; + var align = ['top', 'top right', 'top left', 'right', 'right top', 'right bottom', 'bottom', 'bottom left', 'bottom right', 'left', 'left top', 'left bottom']; + align.forEach(function (value) { + children.push(_react.default.createElement("div", { + key: value, + style: { + margin: '150px auto' + } + }, _react.default.createElement(_popover.default, _extends({ + align: value, + assistiveText: { + closeButton: 'This is a popover.' + }, + body: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + hasStaticAlignment: true, + heading: "My Popover", + id: value, + isOpen: true, + position: "overflowBoundaryElement" + }, props), props.trigger))); + }); + return _react.default.createElement("div", { + key: "container" + }, children); +}; + +var bodyContent = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'; +var popoverBackgroundColor = 'rgb(255, 80, 121)'; +var containerBackgroundColor = 'rgb(255, 127, 80)'; +(0, _react2.storiesOf)(_constants.POPOVER, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium slds-m-horizontal_x-large", + style: { + margin: '300px auto', + width: '500px' + } + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Header', function () { + return _react.default.createElement(_header.default, null); +}).add('Controlled w/ Footer', function () { + return _react.default.createElement(_controlledWithFooter.default, { + log: _addonActions.action + }); +}).add('AlternativeHeader', function () { + return _react.default.createElement(_alternativeHeader.default, null); +}).add('Alignment (Button)', function () { + return getPopoverNubbins({ + trigger: _react.default.createElement(_button.default, { + label: "Trigger Popover", + tabIndex: "0" + }) + }); +}).add('Alignment (ButtonIcon)', function () { + return getPopoverNubbins({ + body: bodyContent, + hasStaticAlignment: true, + heading: 'My Popover', + id: 'myPopoverId', + isOpen: true, + trigger: _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Case Icon' + }, + iconCategory: "utility", + iconName: "filter", + iconSize: "small", + iconVariant: "border", + variant: "icon" + }) + }); +}).add('Custom Target', function () { + return _react.default.createElement(_customTarget.default, null); +}).add('Custom Target - Open', function () { + return _react.default.createElement(_customTarget.default, { + isOpen: true + }); +}).add('Styling (dev-only)', function () { + return getPopover({ + body: bodyContent, + heading: 'My Popover', + id: 'myPopoverId', + isOpen: true, + className: 'sample-classname', + assistiveText: { + closeButton: 'Shut it now!' + }, + containerClassName: 'sample-container-classname', + containerStyle: { + background: containerBackgroundColor + }, + style: { + background: popoverBackgroundColor + } + }); +}).add('Error', function () { + return _react.default.createElement(_error.default, null); +}).add('Error - Open', function () { + return _react.default.createElement(_error.default, { + isOpen: true + }); +}).add('Warning', function () { + return _react.default.createElement(_warning.default, null); +}).add('Warning - Open', function () { + return _react.default.createElement(_warning.default, { + isOpen: true + }); +}).add('Walkthrough', function () { + return _react.default.createElement(_walkthrough.default, { + action: _addonActions.action + }); +}).add('Walkthrough - Open', function () { + return _react.default.createElement(_walkthrough.default, { + action: _addonActions.action, + isOpen: true + }); +}).add('Walkthrough Action', function () { + return _react.default.createElement(_walkthroughAction.default, null); +}).add('Walkthrough Action - Open', function () { + return _react.default.createElement(_walkthroughAction.default, { + isOpen: true + }); +}).add('Edit Dialog', function () { + return _react.default.createElement(_editDialog.default, null); +}).add('Edit Dialog - Open', function () { + return _react.default.createElement(_editDialog.default, { + isOpen: true + }); +}); \ No newline at end of file diff --git a/components/popover/__examples__/alternative-header.js b/components/popover/__examples__/alternative-header.js new file mode 100644 index 0000000000..d21090e3d8 --- /dev/null +++ b/components/popover/__examples__/alternative-header.js @@ -0,0 +1,132 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _popover = _interopRequireDefault(require("../../../../components/popover")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var panelContent = _react.default.createElement("div", null, _react.default.createElement("dl", { + className: "slds-popover__body-list" +}, _react.default.createElement("dt", { + className: "slds-m-bottom_small" +}, _react.default.createElement("div", { + className: "slds-media slds-media_center" +}, _react.default.createElement("div", { + className: "slds-media__figure" +}, _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Opportunity Icon' + }, + category: "standard", + name: "opportunity", + size: "small", + tabIndex: "0" +})), _react.default.createElement("div", { + className: "slds-media__body" +}, _react.default.createElement("p", { + id: "ALTERNATIVE-HEADING", + className: "slds-text-heading_small slds-hyphenate" +}, "Opportunities (1+)")))), _react.default.createElement("dd", { + className: "slds-tile" +}, _react.default.createElement("p", { + className: "slds-truncate", + title: "Tesla - Mule ESB" +}, _react.default.createElement("a", { + href: "javascript:void(0);" +}, "Tesla - Mule ESB")), _react.default.createElement("div", { + className: "slds-tile__detail" +}, _react.default.createElement("dl", { + className: "slds-dl_horizontal slds-text-body_small" +}, _react.default.createElement("dt", { + className: "slds-dl_horizontal__label" +}, _react.default.createElement("p", { + className: "slds-truncate", + title: "Value" +}, "Value")), _react.default.createElement("dd", { + className: "slds-dl_horizontal__detail slds-tile__meta" +}, _react.default.createElement("p", { + className: "slds-truncate", + title: "$500,000" +}, "$500,000")), _react.default.createElement("dt", { + className: "slds-dl_horizontal__label" +}, _react.default.createElement("p", { + className: "slds-truncate", + title: "Close Date" +}, "Close Date")), _react.default.createElement("dd", { + className: "slds-dl_horizontal__detail slds-tile__meta" +}, _react.default.createElement("p", { + className: "slds-truncate", + title: "Dec 15, 2015" +}, "Dec 15, 2015"))))), _react.default.createElement("dd", { + className: "slds-m-top_x-small slds-text-align_right" +}, _react.default.createElement("a", { + href: "javascript:void(0);", + title: "View all Opportunities" +}, "View All")))); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement(_popover.default, { + ariaLabelledby: "ALTERNATIVE-HEADING", + body: panelContent, + id: "popover-alternative-header" + }, _react.default.createElement(_button.default, { + label: "Trigger Popover" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PopoverExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/popover/__examples__/controlled-with-footer.js b/components/popover/__examples__/controlled-with-footer.js new file mode 100644 index 0000000000..52d8903959 --- /dev/null +++ b/components/popover/__examples__/controlled-with-footer.js @@ -0,0 +1,135 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _popover = _interopRequireDefault(require("../../../../components/popover")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _addonActions = require("@storybook/addon-actions"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + isOpen: false + }); + + _defineProperty(_assertThisInitialized(_this), "handleOpen", function () { + _this.setState({ + isOpen: true + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleCancel", function () { + _this.setState({ + isOpen: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleApply", function () { + _this.setState({ + isOpen: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleRequestClose", function (event, data) { + if (_this.props.log) { + _this.props.log('onRequestClose'); + } + + _this.setState({ + isOpen: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClose", function (event, data) { + if (_this.props.log) { + _this.props.log('onClose')(event, data); + } + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement(_popover.default, { + isOpen: this.state.isOpen, + body: "Are you sure you want to continue with your action?", + footer: _react.default.createElement("div", { + className: "slds-text-align_right" + }, _react.default.createElement(_button.default, { + label: "Cancel", + onClick: this.handleCancel + }), _react.default.createElement(_button.default, { + variant: "brand", + label: "Apply", + onClick: this.handleApply + })), + heading: "Confirmation", + id: "popover-controlled-with-footer", + onClose: this.handleClose, + onRequestClose: this.handleRequestClose + }, _react.default.createElement(_button.default, { + label: "Trigger Popover", + onClick: this.handleOpen + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PopoverExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/popover/__examples__/custom-target.js b/components/popover/__examples__/custom-target.js new file mode 100644 index 0000000000..bf4cef158a --- /dev/null +++ b/components/popover/__examples__/custom-target.js @@ -0,0 +1,97 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _popover = _interopRequireDefault(require("../../../../components/popover")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + display: 'flex' + } + }, _react.default.createElement(_popover.default, _extends({ + align: "right", + body: _react.default.createElement("p", null, "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), + heading: "Custom Target", + id: "popover-custom-target", + onRequestTargetElement: function onRequestTargetElement() { + return _this.customTarget; + } + }, this.props), _react.default.createElement(_button.default, { + label: "Trigger Popover" + })), _react.default.createElement("div", { + ref: function ref(component) { + _this.customTarget = component; + }, + style: { + background: '#706e6b', + borderRadius: '4px', + color: '#fff', + height: '32px', + margin: '0 0 0 30px', + padding: '6px', + textAlign: 'center', + width: '132px' + } + }, "Popover Target"))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PopoverExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/popover/__examples__/edit-dialog.js b/components/popover/__examples__/edit-dialog.js new file mode 100644 index 0000000000..72835dceec --- /dev/null +++ b/components/popover/__examples__/edit-dialog.js @@ -0,0 +1,163 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _editDialog = _interopRequireDefault(require("../../../../components/popover/edit-dialog")); + +var _input = _interopRequireDefault(require("../../../../components/input")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var DEFAULT_FIRST_NAME = 'John'; +var DEFAULT_LAST_NAME = 'Smith'; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "onChange", function (inputName) { + return function (event, _ref) { + var value = _ref.value; + + if (inputName === 'first-name') { + _this.setState({ + firstName: value + }); + } else { + _this.setState({ + lastName: value + }); + } + }; + }); + + _defineProperty(_assertThisInitialized(_this), "handleClose", function (event, data) { + if (_this.props.log) { + _this.props.log('onClose')(event, data); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleRequestClose", function (event, data) { + if (_this.props.log) { + _this.props.log('handleRequestClose'); + } + + _this.setState({ + isOpen: false, + firstName: _this.state.prevFirstName, + lastName: _this.state.prevLastName + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleSave", function (event, data) { + _this.setState({ + prevFirstName: _this.state.firstName, + prevLastName: _this.state.lastName, + isOpen: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleOpen", function () { + _this.setState({ + isOpen: true + }); + }); + + var defaultFirstName = 'John'; + var defaultLastName = 'Smith'; + _this.state = { + isOpen: _this.props.isOpen, + firstName: DEFAULT_FIRST_NAME, + // stores firstName in edit input field + lastName: DEFAULT_LAST_NAME, + // stores lastName in edit input field + prevFirstName: DEFAULT_FIRST_NAME, + prevLastName: DEFAULT_LAST_NAME + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + // Body of Edit Dialog that is shown when clicking on edit button (pencil icon) + var editDialogPopoverBody = _react.default.createElement("div", { + className: "slds-form slds-form_stacked slds-p-top_medium slds-p-right_small slds-p-left_small" + }, _react.default.createElement(_input.default, { + id: "first-name", + label: "First Name", + value: this.state.firstName, + onChange: this.onChange('first-name') + }), _react.default.createElement(_input.default, { + id: "last-name", + label: "Last Name", + value: this.state.lastName, + onChange: this.onChange('last-name') + })); + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement("span", { + className: "slds-p-right_x-small" + }, this.state.prevFirstName, " ", this.state.prevLastName), _react.default.createElement(_editDialog.default, { + ariaLabelledby: "Edit Name", + body: editDialogPopoverBody, + isModified: this.state.firstName !== this.state.prevFirstName || this.state.lastName !== this.state.prevLastName, + onCancel: this.handleRequestClose, + onClose: this.handleClose, + onRequestClose: this.handleRequestClose, + onSave: this.handleSave, + handleOpen: this.handleOpen, + position: "absolute", + align: "top left", + id: "edit-dialog-popover", + isOpen: this.state.isOpen + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PopoverExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/popover/__examples__/error.js b/components/popover/__examples__/error.js new file mode 100644 index 0000000000..2008abd876 --- /dev/null +++ b/components/popover/__examples__/error.js @@ -0,0 +1,84 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _popover = _interopRequireDefault(require("../../../../components/popover")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_popover.default, _extends({ + align: "top left", + body: _react.default.createElement("div", null, _react.default.createElement("p", { + className: "slds-p-bottom_x-small" + }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin in pretium leo. Praesent quis risus eget libero commodo mollis."), _react.default.createElement("p", { + className: "slds-p-bottom_x-small" + }, "Quisque tincidunt eleifend pharetra. Etiam condimentum neque nec neque interdum, vitae dapibus est accumsan. Vestibulum rhoncus consectetur mi, sit amet interdum purus. Suspendisse rhoncus, orci a mattis rhoncus, nulla lacus pharetra orci, in eleifend at tristique nisi tristique."), _react.default.createElement("p", { + className: "slds-p-bottom_x-small" + }, "Pellentesque magna tellus, dapibus vitae placerat nec, viverra vel mi.", ' ', _react.default.createElement("a", { + href: "javascript:void(0);", + title: "Learn More" + }, "Learn More"))), + heading: "Resolve error", + id: "popover-error", + variant: "error" + }, this.props), _react.default.createElement(_button.default, { + label: "Trigger Popover" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PopoverExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/popover/__examples__/header.js b/components/popover/__examples__/header.js new file mode 100644 index 0000000000..e5d5040236 --- /dev/null +++ b/components/popover/__examples__/header.js @@ -0,0 +1,71 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _popover = _interopRequireDefault(require("../../../../components/popover")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement(_popover.default, { + body: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + heading: "Header Title", + id: "popover-heading" + }, _react.default.createElement(_button.default, { + label: "Trigger Popover" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PopoverExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/popover/__examples__/walkthrough-action.js b/components/popover/__examples__/walkthrough-action.js new file mode 100644 index 0000000000..d5aa2e2869 --- /dev/null +++ b/components/popover/__examples__/walkthrough-action.js @@ -0,0 +1,76 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _popover = _interopRequireDefault(require("../../../../components/popover")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_popover.default, _extends({ + align: "right", + body: _react.default.createElement("p", null, "Text that describes the action"), + heading: "Title", + id: "popover-walkthrough", + stepText: "Step 3 of 4", + variant: "walkthrough-action" + }, this.props), _react.default.createElement(_button.default, { + label: "Trigger Popover" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PopoverExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/popover/__examples__/walkthrough.js b/components/popover/__examples__/walkthrough.js new file mode 100644 index 0000000000..741c68d126 --- /dev/null +++ b/components/popover/__examples__/walkthrough.js @@ -0,0 +1,91 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _popover = _interopRequireDefault(require("../../../../components/popover")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _log = _interopRequireDefault(require("../../../../utilities/log")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_popover.default, _extends({ + align: "right", + body: _react.default.createElement("p", null, "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), + footerWalkthroughActions: _react.default.createElement(_button.default, { + onClick: function onClick(event) { + (0, _log.default)({ + action: _this.props.action, + data: {}, + event: event, + eventName: 'Next clicked!' + }); + }, + variant: "brand" + }, "Next"), + heading: "Manage your channels", + id: "popover-walkthrough", + stepText: "Step 2 of 4", + variant: "walkthrough" + }, this.props), _react.default.createElement(_button.default, { + label: "Trigger Popover" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PopoverExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/popover/__examples__/warning.js b/components/popover/__examples__/warning.js new file mode 100644 index 0000000000..4301f38193 --- /dev/null +++ b/components/popover/__examples__/warning.js @@ -0,0 +1,84 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _popover = _interopRequireDefault(require("../../../../components/popover")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_popover.default, _extends({ + align: "top left", + body: _react.default.createElement("div", null, _react.default.createElement("p", { + className: "slds-p-bottom_x-small" + }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin in pretium leo. Praesent quis risus eget libero commodo mollis."), _react.default.createElement("p", { + className: "slds-p-bottom_x-small" + }, "Quisque tincidunt eleifend pharetra. Etiam condimentum neque nec neque interdum, vitae dapibus est accumsan. Vestibulum rhoncus consectetur mi, sit amet interdum purus. Suspendisse rhoncus, orci a mattis rhoncus, nulla lacus pharetra orci, in eleifend at tristique nisi tristique."), _react.default.createElement("p", { + className: "slds-p-bottom_x-small" + }, "Pellentesque magna tellus, dapibus vitae placerat nec, viverra vel mi.", ' ', _react.default.createElement("a", { + href: "javascript:void(0);", + title: "Learn More" + }, "Learn More"))), + heading: "Review warning", + id: "popover-error", + variant: "warning" + }, this.props), _react.default.createElement(_button.default, { + label: "Trigger Popover" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'PopoverExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/popover/check-props.js b/components/popover/check-props.js new file mode 100644 index 0000000000..b56ca9a20f --- /dev/null +++ b/components/popover/check-props.js @@ -0,0 +1,53 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _oneOfRequiredProperty = _interopRequireDefault(require("../../utilities/warning/one-of-required-property")); + +var _oneOfComponent = _interopRequireDefault(require("../../utilities/warning/one-of-component")); + +var _deprecatedProperty = _interopRequireDefault(require("../../utilities/warning/deprecated-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +var _incompatibleProps = _interopRequireDefault(require("../../utilities/warning/incompatible-props")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ + +/* eslint-disable max-len */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + (0, _oneOfRequiredProperty.default)(COMPONENT, { + ariaLabelledby: props.ariaLabelledby, + heading: props.heading + }, createDocUrl()); + + if (props.children !== undefined) { + if (props.children.length && props.children.length > 1) { + (0, _oneOfComponent.default)(COMPONENT, props, 'children[0]', ['SLDSButton', 'a', 'button', 'SLDSInnerInput'], " Multiple children of any kind are allowed, but the first child must serve as the trigger component. ".concat(createDocUrl()), props.children[0]); + } else { + (0, _oneOfComponent.default)(COMPONENT, props, 'children', ['SLDSButton', 'a', 'button'], createDocUrl()); + } + } + + (0, _deprecatedProperty.default)(COMPONENT, props.offset, 'offset', undefined, "The manual setting of positional offset of dialog components has been deemed unreliable. Position logic has been re-written to deliver better and more reliable positioning. Please create an issue if you have an edge case not covered by the built-in logic. ".concat(createDocUrl())); + (0, _deprecatedProperty.default)(COMPONENT, props.isInline, 'isInline', 'position="relative"', createDocUrl('position')); + (0, _deprecatedProperty.default)(COMPONENT, props.closeButtonAssistiveText, 'closeButtonAssistiveText', "assistiveText['closeButton']", createDocUrl('assistiveText')); + (0, _incompatibleProps.default)(COMPONENT, props, 'position', ['relative'], 'target', null, "".concat(createDocUrl())); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/popover/docs.json b/components/popover/docs.json new file mode 100644 index 0000000000..7b262e1f48 --- /dev/null +++ b/components/popover/docs.json @@ -0,0 +1,11 @@ +{ + "component": "popover", + "status": "prod", + "display-name": "Popovers", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/popovers", + "url-slug": "popovers" +} \ No newline at end of file diff --git a/components/popover/edit-dialog.js b/components/popover/edit-dialog.js new file mode 100644 index 0000000000..461d2d5714 --- /dev/null +++ b/components/popover/edit-dialog.js @@ -0,0 +1,162 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _constants = require("../../utilities/constants"); + +var _button = _interopRequireDefault(require("../button")); + +var _popover = _interopRequireDefault(require("./popover")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var defaultProps = { + labels: { + cancel: 'Cancel', + save: 'Save' + } +}; + +var EditDialogPopover = +/*#__PURE__*/ +function (_React$Component) { + _inherits(EditDialogPopover, _React$Component); + + function EditDialogPopover() { + _classCallCheck(this, EditDialogPopover); + + return _possibleConstructorReturn(this, _getPrototypeOf(EditDialogPopover).apply(this, arguments)); + } + + _createClass(EditDialogPopover, [{ + key: "render", + // ### Display Name + // Always use the canonical component name as the React display name. + // ### Prop Types + value: function render() { + var _this$props = this.props, + onCancel = _this$props.onCancel, + onSave = _this$props.onSave, + restProps = _objectWithoutProperties(_this$props, ["onCancel", "onSave"]); // trigger button will either be passed in children or defaults to an edit button. + + + var children = this.children ? this.children : _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Edit: Status' + }, + "aria-controls": "".concat(this.props.id, "-edit-button"), + className: "slds-button_reset", + iconCategory: "utility", + iconClassName: "slds-button__icon slds-button__icon_hint", + iconName: "edit", + onClick: this.props.handleOpen, + variant: "icon", + style: { + verticalAlign: 'middle' + } + }); + var labels = (0, _lodash.default)({}, defaultProps.labels, this.props.labels); + return _react.default.createElement(_popover.default, _extends({ + classNameFooter: ['slds-p-top_xxx-small', 'slds-p-bottom_xx-small', 'slds-p-right_large'], + classNameBody: ['slds-p-bottom_xx-small'], + footer: _react.default.createElement("div", { + className: "slds-text-align_right slds-text-align_right slds-p-bottom_x-small slds-p-right_xx-small" + }, _react.default.createElement(_button.default, { + label: labels.cancel, + onClick: onCancel + }), _react.default.createElement(_button.default, { + disabled: !this.props.isModified, + variant: "brand", + label: labels.save, + onClick: onSave + })), + footerStyle: { + borderTop: '0px' + } + }, restProps), children); + } + }]); + + return EditDialogPopover; +}(_react.default.Component); + +_defineProperty(EditDialogPopover, "displayName", _constants.POPOVER_EDIT_DIALOG); + +_defineProperty(EditDialogPopover, "propTypes", { + /** + * By default, a unique ID will be created at render to support keyboard navigation, ARIA roles, and connect the popover to the triggering button. This ID will be applied to the triggering element. `${id}-popover`, `${id}-dialog-heading`, `${id}-dialog-body` are also created. + */ + id: _propTypes.default.string, + + /** + * Set to true when inputs within the popover are modified. + */ + isModified: _propTypes.default.bool, + + /** + * **Text labels for internationalization** + * This object is merged with the default props object on every render. + * * `cancel`: text for Cancel button + * * `save`: text for Save button + * + * _Tested with snapshot testing._ + */ + labels: _propTypes.default.shape({ + cancel: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]), + save: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]) + }), + + /** + * This function is passed onto the cancel `Button`. Triggered when the trigger button is clicked. + */ + onCancel: _propTypes.default.func, + + /** + * This function is passed onto the save `Button`. Triggered when the trigger button is clicked. + */ + onSave: _propTypes.default.func, + + /** + * Popover of type `~/components/popover`. This popover will be cloned and additional props appended, if passed in. + */ + popover: _propTypes.default.node +}); + +EditDialogPopover.defaultProps = defaultProps; +var _default = EditDialogPopover; +exports.default = _default; \ No newline at end of file diff --git a/components/popover/index.js b/components/popover/index.js new file mode 100644 index 0000000000..51cedcfbcf --- /dev/null +++ b/components/popover/index.js @@ -0,0 +1,21 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _reactOnclickoutside = _interopRequireDefault(require("react-onclickoutside")); + +var _popover = _interopRequireDefault(require("./popover")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// ### onClickOutside +// Listen for clicks that occur somewhere in the document, outside of the element itself +var _default = (0, _reactOnclickoutside.default)(_popover.default); + +exports.default = _default; \ No newline at end of file diff --git a/components/popover/popover.js b/components/popover/popover.js new file mode 100644 index 0000000000..f26eeeef51 --- /dev/null +++ b/components/popover/popover.js @@ -0,0 +1,740 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.PopoverNubbinPositions = exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _lodash = _interopRequireDefault(require("lodash.isfunction")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _button = _interopRequireDefault(require("../button")); + +var _mediaObject = _interopRequireDefault(require("../media-object")); + +var _icon = _interopRequireDefault(require("../icon")); + +var _dialog = _interopRequireDefault(require("../utilities/dialog")); + +var _keyboardNavigableDialog = _interopRequireDefault(require("../../utilities/keyboard-navigable-dialog")); + +var _keyCode = _interopRequireDefault(require("../../utilities/key-code")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var documentDefined = typeof document !== 'undefined'; // The overlay is an optional way to allow the popover to close on outside +// clicks even when those clicks are over areas that wouldn't normally fire +// click or touch events (for example, iframes). A single overlay is shared +// between all popovers in the app. + +var overlay = documentDefined ? document.createElement('span') : { + style: {} +}; +overlay.style.top = 0; +overlay.style.left = 0; +overlay.style.width = '100%'; +overlay.style.height = '100%'; +overlay.style.position = 'absolute'; +var currentOpenPopover; // FIXME - what is this exported for? Probably needs to be deprecated. + +var PopoverNubbinPositions = ['top left', 'top', 'top right', 'bottom left', 'bottom', 'bottom right']; +exports.PopoverNubbinPositions = PopoverNubbinPositions; +var defaultProps = { + align: 'right', + assistiveText: { + closeButton: 'Close dialog' + }, + hoverCloseDelay: 300, + openOn: 'click', + position: 'absolute', + variant: 'base' +}; +/** + * The Popover component is a non-modal dialog. It should be paired with a clickable trigger such as a `Button`. It traps focus from the page and must be exited if focus needs to be outside the Popover. Use a `Tooltip` if there are no call to actions within the dialog. A `Tooltip` does not need to be clicked. Multiple popovers open at the same time, each with focus trap is not supported. + */ + +var Popover = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Popover, _React$Component); + + function Popover() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Popover); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Popover)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + isOpen: false + }); + + _defineProperty(_assertThisInitialized(_this), "getId", function () { + return _this.props.id || _this.generatedId; + }); + + _defineProperty(_assertThisInitialized(_this), "getIsOpen", function () { + return !_this.props.disabled && !!(typeof _this.props.isOpen === 'boolean' ? _this.props.isOpen : _this.state.isOpen); + }); + + _defineProperty(_assertThisInitialized(_this), "getMenu", function () { + return (// needed by keyboard navigation + _this.dialog + ); + }); + + _defineProperty(_assertThisInitialized(_this), "getTargetElement", function () { + return _this.props.onRequestTargetElement && _this.props.onRequestTargetElement() ? _this.props.onRequestTargetElement() : _this.trigger; + }); + + _defineProperty(_assertThisInitialized(_this), "setMenuRef", function (component) { + _this.dialog = component; + }); + + _defineProperty(_assertThisInitialized(_this), "setContainerRef", function (component) { + _this.trigger = component; // yes, this is a re-render triggered by a render. + // Dialog/Popper.js cannot place the popover until + // the trigger/target DOM node is mounted. This + // way `findDOMNode` is not called and parent + // DOM nodes are not queried. + + if (!_this.state.inputRendered) { + _this.setState({ + inputRendered: true + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleDialogClose", function (event, data) { + var componentWillUnmount = data && data.componentWillUnmount || false; + + if (currentOpenPopover === _assertThisInitialized(_this)) { + currentOpenPopover = undefined; + } + + if (_this.props.onClose) { + _this.props.onClose(event, { + // Breaking change: component object reference has been + // removed (`this`), due to endless loop creation. + componentWillUnmount: componentWillUnmount + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleClose", function (event, data) { + var isOpen = _this.getIsOpen(); + + if (isOpen) { + // call even if closed + if (_this.props.onRequestClose) { + _this.props.onRequestClose(event, data); + } + + if (currentOpenPopover === _assertThisInitialized(_this)) { + currentOpenPopover = undefined; + } + + _this.setState({ + isOpen: false + }); + + _this.isHover = false; + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleOpen", function () { + var isOpen = _this.getIsOpen(); + + if (!isOpen) { + if (currentOpenPopover && (0, _lodash.default)(currentOpenPopover.handleClose)) { + currentOpenPopover.handleClose(undefined, { + trigger: 'newPopover', + id: currentOpenPopover.getId() + }); + } + + currentOpenPopover = _assertThisInitialized(_this); + + _this.setState({ + isOpen: true + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function (event) { + var isOpen = _this.getIsOpen(); + + _this.isHover = true; + + if (!isOpen && _this.props.openOn === 'hover') { + _this.handleOpen(); + } else { + // we want this clear when openOn is hover or hybrid + clearTimeout(_this.isClosing); + } + + if (_this.props.onMouseEnter) { + _this.props.onMouseEnter(event); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleMouseLeave", function (event) { + var isOpen = _this.getIsOpen(); + + if (isOpen) { + _this.isClosing = setTimeout(function () { + _this.handleClose(); + }, _this.props.hoverCloseDelay); + } + + if (_this.props.onMouseLeave) { + _this.props.onMouseLeave(event); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function (event, _ref) { + var triggerOnClickCallback = _ref.triggerOnClickCallback; + + var isOpen = _this.getIsOpen(); + + if (!isOpen) { + _this.handleOpen(); + } else { + _this.handleClose(); + } + + if (_this.props.onClick) { + _this.props.onClick(event); + } + + if (triggerOnClickCallback) { + triggerOnClickCallback(event); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleFocus", function (event) { + var isOpen = _this.getIsOpen(); + + if (!isOpen) { + _this.handleOpen(); + } + + if (_this.props.onFocus) { + _this.props.onFocus(event); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) { + if (event.keyCode) { + if (event.keyCode !== _keyCode.default.TAB) { + var isOpen = _this.getIsOpen(); + + (0, _keyboardNavigableDialog.default)({ + event: event, + isOpen: isOpen, + handleClick: _this.handleClick, + key: event.key, + keyCode: event.keyCode, + targetTarget: event.target, + toggleOpen: _this.toggleOpenFromKeyboard, + trigger: _this.trigger + }); + } + + if (_this.props.onKeyDown) { + _this.props.onKeyDown(event); + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleCancel", function (event) { + _this.handleClose(event, { + trigger: 'cancel' + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClickOutside", function (event) { + _this.handleClose(event, { + trigger: 'clickOutside' + }); + }); + + _defineProperty(_assertThisInitialized(_this), "toggleOpenFromKeyboard", function (event) { + var isOpen = _this.getIsOpen(); + + if (isOpen) { + _this.handleCancel(event); + } else { + _this.handleOpen(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "renderDialog", function (isOpen, outsideClickIgnoreClass) { + var props = _this.props; + var offset = props.offset; + + var assistiveText = _objectSpread({}, defaultProps.assistiveText, _this.props.assistiveText); + + var closeButtonAssistiveText = props.closeButtonAssistiveText || assistiveText.closeButton; // HEADER SUB-RENDERS + + var hasThemedHeader = _this.props.variant === 'error' || _this.props.variant === 'warning'; + var hasDefinedHeader = _this.props.heading || hasThemedHeader; + var headerIcon = { + error: _react.default.createElement(_icon.default, { + category: "utility", + name: "error", + size: "x-small", + inverse: true + }), + warning: _react.default.createElement(_icon.default, { + category: "utility", + name: "warning", + size: "x-small", + inverse: true + }) + }; + var headerVariants = { + base: _react.default.createElement("header", { + className: (0, _classnames.default)('slds-popover__header', { + 'slds-p-vertical_medium': props.variant === 'walkthrough' + }) + }, _react.default.createElement("h2", { + id: "".concat(_this.getId(), "-dialog-heading"), + className: (0, _classnames.default)({ + 'slds-text-heading_small': props.variant !== 'walkthrough', + 'slds-text-heading_medium': props.variant === 'walkthrough' + }) + }, _this.props.heading)), + themed: _react.default.createElement("header", { + className: "slds-popover__header" + }, _react.default.createElement(_mediaObject.default, { + body: _react.default.createElement("h2", { + className: "slds-truncate slds-text-heading_medium", + title: props.heading + }, props.heading), + figure: headerIcon[_this.props.variant], + verticalCenter: true + })) + }; + var header = null; + + if (hasDefinedHeader && props.variant !== 'walkthrough-action') { + header = headerVariants[hasThemedHeader ? 'themed' : 'base']; + } // BODY SUB-RENDERS + + + var body = null; + + if (props.variant === 'error' || props.variant === 'warning') { + body = // THIS WRAPPING DIV IS NOT IN SLDS MARKUP + _react.default.createElement("div", null, _react.default.createElement("div", { + id: "".concat(_this.getId(), "-dialog-body"), + className: (0, _classnames.default)('slds-popover__body slds-popover__body_scrollable', _this.props.classNameBody) // REMOVE IN THE FUTURE: SLDS OVERRIDE + // Possible solution in future is to use .slds-popover__body_small + , + style: { + borderBottom: 'none' + } + }, props.body), _react.default.createElement("div", { + // GRADIENT FOOTER - SLDS OVERRIDE + // REMOVE IN THE FUTURE (HOPEFULLY) + style: { + position: 'absolute', + bottom: 0, + left: 0, + width: '100%', + textAlign: 'center', + margin: 0, + padding: '5px 0', + + /* "transparent" only works here because == rgba(0,0,0,0) */ + backgroundImage: 'linear-gradient(to bottom, transparent, rgba(255,255,255,100)' + } + })); + } else if (props.variant === 'walkthrough-action') { + body = _react.default.createElement("div", { + className: (0, _classnames.default)('slds-popover__body', _this.props.classNameBody), + id: "".concat(_this.getId(), "-dialog-body") + }, _react.default.createElement("div", { + className: "slds-media" + }, _react.default.createElement("div", { + className: "slds-media__figure" + }, _react.default.createElement(_icon.default, { + category: "utility", + name: "touch_action", + size: "small", + inverse: true + })), _react.default.createElement("div", { + className: "slds-media__body" + }, props.heading ? _react.default.createElement("h2", { + className: "slds-text-heading_small" + }, props.heading) : null, props.body, props.stepText ? _react.default.createElement("p", { + className: "slds-m-top_medium slds-text-title" + }, props.stepText) : null))); + } else { + body = // DEFAULT - NOT SCROLLABLE + _react.default.createElement("div", { + id: "".concat(_this.getId(), "-dialog-body"), + className: (0, _classnames.default)('slds-popover__body', _this.props.classNameBody) + }, props.body); + } // FOOTER SUB-RENDERS + + + var footer = null; + + if (props.footer) { + footer = _react.default.createElement("footer", { + className: (0, _classnames.default)('slds-popover__footer', _this.props.classNameFooter, _this.props.footerClassName), + style: _this.props.footerStyle + }, _this.props.footer); + } else if (props.variant !== 'walkthrough-action' && (props.footerWalkthroughActions || props.stepText)) { + footer = _react.default.createElement("footer", { + className: "slds-popover__footer" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_vertical-align-center" + }, props.stepText ? _react.default.createElement("span", { + className: "slds-text-title" + }, props.stepText) : null, props.footerWalkthroughActions ? _react.default.createElement("div", { + className: "slds-col_bump-left", + style: { + display: 'inline-block' + } + }, props.footerWalkthroughActions) : null)); + } // MAIN RENDER + + + return isOpen ? _react.default.createElement(_dialog.default, { + hasNubbin: !_this.props.hasNoNubbin, + align: props.align, + contentsClassName: (0, _classnames.default)(_this.props.contentsClassName, 'ignore-react-onclickoutside', 'slds-popover', { + 'slds-popover_error': props.variant === 'error' + }, { + 'slds-popover_walkthrough': props.variant === 'walkthrough' || props.variant === 'walkthrough-action' + }, { + 'slds-popover_walkthrough-alt': props.variant === 'walkthrough-action' + }, { + 'slds-popover_warning': props.variant === 'warning' + }, props.className), + context: _this.context, + hasStaticAlignment: props.hasStaticAlignment, + offset: offset, + onCancel: _this.handleClose, + onClose: _this.handleDialogClose, + onOpen: _this.props.onOpen, + onKeyDown: _this.handleKeyDown, + onMouseEnter: props.openOn === 'hover' ? _this.handleMouseEnter : null, + onMouseLeave: props.openOn === 'hover' ? _this.handleMouseLeave : null, + outsideClickIgnoreClass: outsideClickIgnoreClass, + onRequestTargetElement: function onRequestTargetElement() { + return _this.getTargetElement(); + }, + position: _this.props.position, + style: _this.props.style, + variant: "popover", + ref: _this.setMenuRef, + containerProps: { + id: "".concat(_this.getId(), "-popover"), + 'aria-labelledby': _this.props.ariaLabelledby || "".concat(_this.getId(), "-dialog-heading"), + 'aria-describedby': "".concat(_this.getId(), "-dialog-body") + } + }, _react.default.createElement(_button.default, { + assistiveText: { + icon: closeButtonAssistiveText + }, + iconCategory: "utility", + iconName: "close", + className: (0, _classnames.default)('slds-button slds-button_icon-small slds-float_right slds-popover__close slds-button_icon', { + 'slds-button_icon-inverse': props.variant === 'walkthrough' || props.variant === 'walkthrough-action' + }), + onClick: _this.handleCancel, + variant: "icon", + inverse: _this.props.variant === 'error' || _this.props.variant === 'warning' + }), header, body, footer) : null; + }); + + _defineProperty(_assertThisInitialized(_this), "renderOverlay", function (isOpen) { + if ((0, _lodash.default)(overlay) && documentDefined) { + overlay(isOpen, overlay); + } else if (_this.props.overlay && isOpen && !_this.overlay && documentDefined) { + _this.overlay = overlay; + document.querySelector('body').appendChild(_this.overlay); + } else if (!isOpen && _this.overlay && _this.overlay.parentNode) { + _this.overlay.parentNode.removeChild(_this.overlay); + + _this.overlay = undefined; + } + }); + + return _this; + } + + _createClass(Popover, [{ + key: "componentWillMount", + value: function componentWillMount() { + this.generatedId = _shortid.default.generate(); // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + + (0, _checkProps.default)(_constants.POPOVER, this.props, _docs.default); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + if (currentOpenPopover === this) { + currentOpenPopover = undefined; + } + + this.isUnmounting = true; + this.renderOverlay(false); + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var otherChildren = []; + var outsideClickIgnoreClass = "ignore-click-".concat(this.getId()); + var clonedTrigger = null; + + _react.default.Children.forEach(this.props.children, function (child, index) { + if (index === 0) { + clonedTrigger = _react.default.cloneElement(child, _objectSpread({ + id: _this2.getId(), + onClick: _this2.props.openOn === 'click' || _this2.props.openOn === 'hybrid' ? function (event) { + _this2.handleClick(event, { + triggerOnClickCallback: child.props.onClick + }); + } : child.props.onClick, + onFocus: _this2.props.openOn === 'hover' ? _this2.handleFocus : null, + onMouseDown: _this2.props.onMouseDown, + onMouseEnter: _this2.props.openOn === 'hover' || _this2.props.openOn === 'hybrid' ? _this2.handleMouseEnter : null, + onMouseLeave: _this2.props.openOn === 'hover' || _this2.props.openOn === 'hybrid' ? _this2.handleMouseLeave : null, + tabIndex: child.props.tabIndex || '0' + }, child.props)); + } else { + otherChildren.push(child); + } + }); + + this.renderOverlay(this.getIsOpen()); + var containerStyles = { + display: this.props.hasNoTriggerStyles ? undefined : 'inline-block' + }; + return _react.default.createElement("div", { + className: this.props.triggerClassName, + style: containerStyles, + ref: this.setContainerRef + }, clonedTrigger, otherChildren.length > 0 ? otherChildren : null, this.renderDialog(this.getIsOpen(), outsideClickIgnoreClass)); + } + }]); + + return Popover; +}(_react.default.Component); + +_defineProperty(Popover, "displayName", _constants.POPOVER); + +_defineProperty(Popover, "propTypes", { + /** + * Aligns the popover with the respective side of the trigger. That is `top` will place the `Popover` above the trigger. + */ + align: _propTypes.default.oneOf(['top', 'top left', 'top right', 'right', 'right top', 'right bottom', 'bottom', 'bottom left', 'bottom right', 'left', 'left top', 'left bottom']), + + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `closeButton`: This is a visually hidden label for the close button. + */ + assistiveText: _propTypes.default.shape({ + closeButton: _propTypes.default.string + }), + + /** + * HTML `id` of heading for popover. Only use if your header is within your popover body. + */ + ariaLabelledby: _propTypes.default.string, + + /** + * Multiple children of any kind are allowed, but the first child must serve as the trigger component. Many props will be passed into this trigger related to popover interactions. The trigger needs to be a clickable element, such as a `Button` or an anchor tag (`a`). + */ + children: _propTypes.default.node.isRequired, + + /** + * The contents of the popover. This should also accept arrays. + */ + body: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.array]).isRequired, + + /** + * CSS classes to be added to the popover footer. That is the element with `.slds-popover__body` on it. + */ + classNameBody: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * CSS classes to be added to the popover footer. That is the element with `.slds-popover__footer` on it. + */ + classNameFooter: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * This prop is passed onto the triggering `Button`. Prevent popover from opening. Also applies disabled styling to trigger button. + */ + disabled: _propTypes.default.bool, + + /** + * A footer is an optional. Buttons are often placed here. + */ + footer: _propTypes.default.node, + + /** + * An object of CSS styles that are applied to the `slds-popover__footer` DOM element. + */ + footerStyle: _propTypes.default.object, + + /** + * Used with `walkthrough` variant to provide action buttons (ex: "Next" / "Skip" / etc) for a walkthrough popover footer. Accepts either a single node or array of nodes for multiple buttons. + */ + footerWalkthroughActions: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.arrayOf(_propTypes.default.node)]), + + /** + * Prevents the Popover from changing position based on the viewport/window. If set to true your popover can extend outside the viewport _and_ overflow outside of a scrolling parent. If this happens, you might want to consider making the popover contents scrollable to fit the menu on the screen. When enabled, `position` `absolute` is used. + */ + hasStaticAlignment: _propTypes.default.bool, + + /** + * Removes `display:inline-block` from the trigger button. + */ + hasNoTriggerStyles: _propTypes.default.bool, + + /** + * Will show the nubbin pointing from the dialog to the reference element. Positioning and offsets will be handled. + */ + hasNoNubbin: _propTypes.default.bool, + + /** + * All popovers require a heading that labels the popover for assistive technology users. This text will be placed within a heading HTML tag, or in an h2 within the popover body if used with `variant="walkthrough-action"`. A heading is **highly recommended for accessibility reasons.** Please see `ariaLabelledby` prop. + */ + heading: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]), + + /** + * By default, a unique ID will be created at render to support keyboard navigation, ARIA roles, and connect the popover to the triggering button. This ID will be applied to the triggering element. `${id}-popover`, `${id}-dialog-heading`, `${id}-dialog-body` are also created. + */ + id: _propTypes.default.string, + + /** + * Forces the popover to be open or closed. See controlled/uncontrolled callback/prop pattern for more on suggested use [](https://github.com/salesforce-ux/design-system-react/blob/master/CONTRIBUTING.md#concepts-and-best-practices) You will want this if Popover is to be a controlled component. + */ + isOpen: _propTypes.default.bool, + + /** + * This function is passed onto the triggering `Button`. Triggered when the trigger button is clicked. You will want this if Popover is to be a controlled component. + */ + onClick: _propTypes.default.func, + + /** + * This function is triggered when the dialog is closed. This occurs when the Dialog child component (that is the actual popover) is unmounted and removed from the DOM. This function returns `{event, { trigger, componentWillUnmount }`. Trigger can have the values `cancel`, `clickOutside`, or `newPopover`. + */ + onClose: _propTypes.default.func, + + /** + * Called when a key is pressed. + */ + onKeyDown: _propTypes.default.func, + + /** + * Called when mouse clicks down on the trigger button. + */ + onMouseDown: _propTypes.default.func, + + /** + * This function is triggered when the Dialog child component (that is the actual popover) is mounted and added to the DOM. The parameters are `event, { portal: }`. `portal` can be used as a React tree root node. + */ + onOpen: _propTypes.default.func, + + /** + * This function is triggered when the user clicks outside the Popover or clicks the close button. You will want to define this if Popover is to be a controlled component. Most of the time you will want to set `isOpen` to `false` when this is triggered unless you need to validate something. + */ + onRequestClose: _propTypes.default.func, + + /** + * Callback that returns an element or React `ref` to align the Popover with. If the target element has not been rendered yet, the popover will use the triggering element as the attachment target instead. NOTE: `position="relative"` is not compatible with custom targets that are not the triggering element. + */ + onRequestTargetElement: _propTypes.default.func, + + /** + * Please select one of the following: + * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog. + * * `overflowBoundaryElement` - The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree. + * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing. NOTE: this setting is not compatible with custom targets outside the trigger + */ + position: _propTypes.default.oneOf(['absolute', 'overflowBoundaryElement', 'relative']), + + /** + * Used with `walkthrough` variant to provide the step text (ex: "Step 1 of 4") for a walkthrough popover footer. If used with `variant="walkthrough-action"`, it will be placed in the popover body. + */ + stepText: _propTypes.default.string, + + /** + * An object of CSS styles that are applied to the `slds-popover` DOM element. + */ + style: _propTypes.default.object, + + /** + * If `true`, adds a transparent overlay when the menu is open to handle outside clicks. Allows clicks on iframes to be captured, but also forces a double-click to interact with other elements. If a function is passed, custom overlay logic may be defined by the app. + */ + overlay: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.func]), + + /** + * CSS classes to be added to wrapping trigger `div` around the button. + */ + triggerClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Determines the type of the popover. `error` and `warning` allows the content body to scroll. Default is `base` _Tested with snaphots._ + */ + variant: _propTypes.default.oneOf(['base', 'error', 'walkthrough', 'walkthrough-action', 'warning']) +}); + +_defineProperty(Popover, "defaultProps", defaultProps); + +Popover.contextTypes = { + iconPath: _propTypes.default.string +}; +var _default = Popover; +exports.default = _default; \ No newline at end of file diff --git a/components/progress-bar/__docs__/__snapshots__/storybook-stories.storyshot b/components/progress-bar/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..f5dc2fd7b5 --- /dev/null +++ b/components/progress-bar/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,275 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSProgressBar Color 1`] = ` +
    +
    + + Color: success + +
    + +
    + + + Progress: + 75% + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSProgressBar Default 1`] = ` +
    +
    +
    + +
    + + + Progress: + 75% + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSProgressBar Descriptive 1`] = ` +
    +
    +
    +
    + + Einstein Setup Assistant + + +
    +
    + + + Progress: + 90% + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSProgressBar Radius 1`] = ` +
    +
    + + Radius: circular + +
    + +
    + + + Progress: + 75% + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSProgressBar Thickness 1`] = ` +
    +
    + + Thickness: x-small + +
    + +
    + + + Progress: + 90% + + +
    +
    +
    + + Thickness: small + +
    + +
    + + + Progress: + 75% + + +
    +
    +
    + + Thickness: medium + +
    + +
    + + + Progress: + 50% + + +
    +
    +
    + + Thickness: large + +
    + +
    + + + Progress: + 25% + + +
    +
    +
    +
    +`; diff --git a/components/progress-bar/__docs__/site-stories.js b/components/progress-bar/__docs__/site-stories.js new file mode 100644 index 0000000000..ab5b4c05ae --- /dev/null +++ b/components/progress-bar/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/progress-bar/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/progress-bar/__examples__/descriptive.jsx'), require('raw-loader!@salesforce/design-system-react/components/progress-bar/__examples__/color.jsx'), require('raw-loader!@salesforce/design-system-react/components/progress-bar/__examples__/radius.jsx'), require('raw-loader!@salesforce/design-system-react/components/progress-bar/__examples__/thickness.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/progress-bar/__docs__/storybook-stories.js b/components/progress-bar/__docs__/storybook-stories.js new file mode 100644 index 0000000000..52c142e4ba --- /dev/null +++ b/components/progress-bar/__docs__/storybook-stories.js @@ -0,0 +1,35 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _thickness = _interopRequireDefault(require("../__examples__/thickness")); + +var _color = _interopRequireDefault(require("../__examples__/color")); + +var _radius = _interopRequireDefault(require("../__examples__/radius")); + +var _descriptive = _interopRequireDefault(require("../__examples__/descriptive")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.PROGRESS_BAR, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Default', function () { + return _react.default.createElement(_default.default, null); +}).add('Descriptive', function () { + return _react.default.createElement(_descriptive.default, null); +}).add('Color', function () { + return _react.default.createElement(_color.default, null); +}).add('Radius', function () { + return _react.default.createElement(_radius.default, null); +}).add('Thickness', function () { + return _react.default.createElement(_thickness.default, null); +}); \ No newline at end of file diff --git a/components/progress-bar/__examples__/color.js b/components/progress-bar/__examples__/color.js new file mode 100644 index 0000000000..64ac179307 --- /dev/null +++ b/components/progress-bar/__examples__/color.js @@ -0,0 +1,60 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _progressBar = _interopRequireDefault(require("../../../../components/progress-bar")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement("span", null, "Color: success"), _react.default.createElement(_progressBar.default, { + id: "progress-bar-success", + value: 75, + color: "success" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressBarColor'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-bar/__examples__/default.js b/components/progress-bar/__examples__/default.js new file mode 100644 index 0000000000..eb1e4c542a --- /dev/null +++ b/components/progress-bar/__examples__/default.js @@ -0,0 +1,59 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _progressBar = _interopRequireDefault(require("../../../../components/progress-bar")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement(_progressBar.default, { + id: "progress-bar", + value: 75 + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressBarDefault'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-bar/__examples__/descriptive.js b/components/progress-bar/__examples__/descriptive.js new file mode 100644 index 0000000000..98ffaddc40 --- /dev/null +++ b/components/progress-bar/__examples__/descriptive.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _progressBar = _interopRequireDefault(require("../../../../components/progress-bar")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement(_progressBar.default, { + id: "setup-progress-bar", + value: 90, + labels: { + label: 'Einstein Setup Assistant' + } + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressBarDescriptive'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-bar/__examples__/examples.js b/components/progress-bar/__examples__/examples.js new file mode 100644 index 0000000000..912312792f --- /dev/null +++ b/components/progress-bar/__examples__/examples.js @@ -0,0 +1,118 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.LARGE_BAR = exports.MEDIUM_BAR = exports.SMALL_BAR = exports.X_SMALL_BAR = exports.ROUNDED_BAR = exports.COMPLETE_WITH_DESCRIPTION = exports.COMPLETE_100 = exports.PROGRESS_75 = exports.PROGRESS_HALF = exports.PROGRESS_25 = exports.PROGRESS_0 = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _progressBar = _interopRequireDefault(require("../../../components/progress-bar")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var PROGRESS_0 = function PROGRESS_0() { + return _react.default.createElement(_progressBar.default, { + id: "progress-bar-1", + value: 0 + }); +}; + +exports.PROGRESS_0 = PROGRESS_0; + +var PROGRESS_25 = function PROGRESS_25() { + return _react.default.createElement(_progressBar.default, { + id: "progress-bar-2", + value: 25 + }); +}; + +exports.PROGRESS_25 = PROGRESS_25; + +var PROGRESS_HALF = function PROGRESS_HALF() { + return _react.default.createElement(_progressBar.default, { + id: "progress-bar-3", + value: 50 + }); +}; + +exports.PROGRESS_HALF = PROGRESS_HALF; + +var PROGRESS_75 = function PROGRESS_75() { + return _react.default.createElement(_progressBar.default, { + id: "progress-bar-4", + value: 75 + }); +}; + +exports.PROGRESS_75 = PROGRESS_75; + +var COMPLETE_100 = function COMPLETE_100() { + return _react.default.createElement(_progressBar.default, { + id: "progress-bar-5", + value: 100, + color: "success" + }); +}; + +exports.COMPLETE_100 = COMPLETE_100; + +var COMPLETE_WITH_DESCRIPTION = function COMPLETE_WITH_DESCRIPTION() { + return _react.default.createElement(_progressBar.default, { + value: 100, + color: "success", + label: "Einstein Setup Assistant" + }); +}; + +exports.COMPLETE_WITH_DESCRIPTION = COMPLETE_WITH_DESCRIPTION; + +var ROUNDED_BAR = function ROUNDED_BAR() { + return _react.default.createElement(_progressBar.default, { + id: "progress-bar-circular", + value: 20, + radius: "circular" + }); +}; + +exports.ROUNDED_BAR = ROUNDED_BAR; + +var X_SMALL_BAR = function X_SMALL_BAR() { + return _react.default.createElement(_progressBar.default, { + id: "progress-bar-x-small", + value: 20, + thickness: "x-small" + }); +}; + +exports.X_SMALL_BAR = X_SMALL_BAR; + +var SMALL_BAR = function SMALL_BAR() { + return _react.default.createElement(_progressBar.default, { + id: "progress-bar-small", + value: 20, + thickness: "small" + }); +}; + +exports.SMALL_BAR = SMALL_BAR; + +var MEDIUM_BAR = function MEDIUM_BAR() { + return _react.default.createElement(_progressBar.default, { + id: "progress-bar-medium", + value: 20, + thickness: "medium" + }); +}; + +exports.MEDIUM_BAR = MEDIUM_BAR; + +var LARGE_BAR = function LARGE_BAR() { + return _react.default.createElement(_progressBar.default, { + id: "progress-bar-large", + value: 20, + thickness: "large" + }); +}; + +exports.LARGE_BAR = LARGE_BAR; \ No newline at end of file diff --git a/components/progress-bar/__examples__/radius.js b/components/progress-bar/__examples__/radius.js new file mode 100644 index 0000000000..2e75bb1ad7 --- /dev/null +++ b/components/progress-bar/__examples__/radius.js @@ -0,0 +1,60 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _progressBar = _interopRequireDefault(require("../../../../components/progress-bar")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement("span", null, "Radius: circular"), _react.default.createElement(_progressBar.default, { + id: "progress-bar-circular", + value: 75, + radius: "circular" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressBarRadius'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-bar/__examples__/thickness.js b/components/progress-bar/__examples__/thickness.js new file mode 100644 index 0000000000..15f01da4d9 --- /dev/null +++ b/components/progress-bar/__examples__/thickness.js @@ -0,0 +1,72 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _progressBar = _interopRequireDefault(require("../../../../components/progress-bar")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement("span", null, "Thickness: x-small"), _react.default.createElement(_progressBar.default, { + value: 90, + id: "progress-bar-x-small", + thickness: "x-small" + }), _react.default.createElement("hr", null), _react.default.createElement("span", null, "Thickness: small"), _react.default.createElement(_progressBar.default, { + value: 75, + id: "progress-bar-small", + thickness: "small" + }), _react.default.createElement("hr", null), _react.default.createElement("span", null, "Thickness: medium"), _react.default.createElement(_progressBar.default, { + value: 50, + id: "progress-bar-medium", + thickness: "medium" + }), _react.default.createElement("hr", null), _react.default.createElement("span", null, "Thickness: large"), _react.default.createElement(_progressBar.default, { + value: 25, + id: "progress-bar-large", + thickness: "large" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressBarThickness'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-bar/docs.json b/components/progress-bar/docs.json new file mode 100644 index 0000000000..371362f7dc --- /dev/null +++ b/components/progress-bar/docs.json @@ -0,0 +1,7 @@ +{ + "component": "progress-bar", + "status": "prod", + "display-name": "Progress Bars", + "SLDS-component-path": "/components/progress-bar", + "url-slug": "progress-bars" +} diff --git a/components/progress-bar/index.js b/components/progress-bar/index.js new file mode 100644 index 0000000000..3b0fdfc94b --- /dev/null +++ b/components/progress-bar/index.js @@ -0,0 +1,163 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * HTML id for component. + */ + id: _propTypes.default.string, + + /** + * CSS classes to be added to tag with `.slds-progress-bar`. Uses `classNames` [API](https://github.com/JedWatson/classnames). + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Label for the progress bar + */ + labels: _propTypes.default.shape({ + label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]), + complete: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]) + }), + + /** + * Set radius of progress bar + */ + radius: _propTypes.default.oneOf(['circular']), + + /** + * Set fill of progress bar + */ + color: _propTypes.default.oneOf(['success']), + + /** + * Set progress bar thickness + */ + thickness: _propTypes.default.oneOf(['x-small', 'small', 'medium', 'large']), + + /** + * Percentage of progress completion, ranging [0, 100]. + */ + value: _propTypes.default.number.isRequired +}; +var defaultProps = { + labels: { + complete: 'Complete' + } +}; +/** + * A progress bar component communicates to the user the progress of a particular process + */ + +var ProgressBar = +/*#__PURE__*/ +function (_React$Component) { + _inherits(ProgressBar, _React$Component); + + function ProgressBar() { + _classCallCheck(this, ProgressBar); + + return _possibleConstructorReturn(this, _getPrototypeOf(ProgressBar).apply(this, arguments)); + } + + _createClass(ProgressBar, [{ + key: "componentWillMount", + value: function componentWillMount() { + this.generatedId = _shortid.default.generate(); + } + /** + * ID as a string + * @returns {string} id + */ + + }, { + key: "getId", + value: function getId() { + return this.props.id || this.generatedId; + } + /** + * Enables Descriptive Progress Bar if label is provided + * @returns {string} description + */ + + }, { + key: "getDescription", + value: function getDescription(_ref) { + var labels = _ref.labels; + + if (this.props.labels.label) { + return _react.default.createElement("div", { + className: "slds-grid slds-grid_align-spread slds-p-bottom_x-small", + id: "progress-bar-label-id-4" + }, _react.default.createElement("span", null, labels.label), _react.default.createElement("span", { + "aria-hidden": "true" + }, _react.default.createElement("strong", null, this.props.value, "% ", labels.complete))); + } + + return ''; + } + }, { + key: "render", + value: function render() { + var labels = (0, _lodash.default)({}, defaultProps.labels, this.props.labels); + return _react.default.createElement("div", { + id: this.getId() + }, this.getDescription({ + labels: labels + }), _react.default.createElement("div", { + className: (0, _classnames.default)('slds-progress-bar', this.props.radius ? "slds-progress-bar_".concat(this.props.radius) : null, this.props.thickness ? "slds-progress-bar_".concat(this.props.thickness) : null, this.props.className) + }, _react.default.createElement("span", { + className: (0, _classnames.default)("slds-progress-bar__value", this.props.color ? "slds-progress-bar__value_".concat(this.props.color) : null), + style: { + width: "".concat(this.props.value, "%") + } + }, _react.default.createElement("span", { + className: "slds-assistive-text" + }, "Progress: ", "".concat(this.props.value, "%"))))); + } + }]); + + return ProgressBar; +}(_react.default.Component); + +ProgressBar.displayName = _constants.PROGRESS_BAR; +ProgressBar.propTypes = propTypes; +ProgressBar.defaultProps = defaultProps; +var _default = ProgressBar; +exports.default = _default; \ No newline at end of file diff --git a/components/progress-indicator/__docs__/__snapshots__/storybook-stories.storyshot b/components/progress-indicator/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..ff278135e7 --- /dev/null +++ b/components/progress-indicator/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,1487 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSProgressIndicator Base 1`] = ` +
    +
    +
    +
      +
    1. +
      + + +
      +
    2. +
    3. +
      + + +
      +
    4. +
    5. + +
    6. +
    7. + +
    8. +
    9. + +
    10. +
    +
    + + + Progress: 0% + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSProgressIndicator Base With Disabled Steps 1`] = ` +
    +
    +
    +
      +
    1. +
      + + +
      +
    2. +
    3. +
      + + +
      +
    4. +
    5. +
      + + +
      +
    6. +
    7. + +
    8. +
    9. + +
    10. +
    +
    + + + Progress: 50% + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSProgressIndicator Base With Many Steps 1`] = ` +
    +
    +
    +
      +
    1. +
      + + +
      +
    2. +
    3. +
      + + +
      +
    4. +
    5. +
      + + +
      +
    6. +
    7. +
      + + +
      +
    8. +
    9. +
      + + +
      +
    10. +
    11. +
      + + +
      +
    12. +
    13. +
      + + +
      +
    14. +
    15. +
      + + +
      +
    16. +
    17. +
      + + +
      +
    18. +
    +
    + + + Progress: 50% + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSProgressIndicator Completed Progress 1`] = ` +
    +
    +
    +
      +
    1. +
      + + +
      +
    2. +
    3. +
      + + +
      +
    4. +
    5. +
      + + +
      +
    6. +
    7. +
      + + +
      +
    8. +
    9. +
      + + +
      +
    10. +
    +
    + + + Progress: 75% + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSProgressIndicator In A Modal (With Step Error) - Needs DOM 1`] = ` +
    +`; + +exports[`DOM snapshots SLDSProgressIndicator Step Error 1`] = ` +
    +
    +
    +
      +
    1. +
      + + +
      +
    2. +
    3. +
      + + +
      +
    4. +
    5. +
      + + +
      +
    6. +
    7. +
      + + +
      +
    8. +
    9. +
      + + +
      +
    10. +
    +
    + + + Progress: 25% + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSProgressIndicator Vertical 1`] = ` +
    +
    +
    +
      +
    1. + +
      + tooltip label #1 +
      +
    2. +
    3. + +
      + tooltip label #2 +
      +
    4. +
    5. + +
      + tooltip label #3 +
      +
    6. +
    7. + +
      + tooltip label #4 +
      +
    8. +
    9. + +
      + tooltip label #5 +
      +
    10. +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSProgressIndicator VerticalStepError 1`] = ` +
    +
    +
    +
      +
    1. + + + + + + +
      + tooltip label #1 +
      +
    2. +
    3. + + + + + + +
      + tooltip label #2 +
      +
    4. +
    5. + + + + + + +
      + tooltip label #3 +
      +
    6. +
    7. + + + + + + +
      + tooltip label #4 +
      +
    8. +
    9. + + + + + + +
      + tooltip label #5 +
      +
    10. +
    11. + +
      + tooltip label #6 +
      +
    12. +
    13. + +
      + tooltip label #7 +
      +
    14. +
    15. + +
      + tooltip label #8 +
      +
    16. +
    17. + +
      + tooltip label #9 +
      +
    18. +
    +
    +
    +
    +`; diff --git a/components/progress-indicator/__docs__/site-stories.js b/components/progress-indicator/__docs__/site-stories.js new file mode 100644 index 0000000000..7aec8f1905 --- /dev/null +++ b/components/progress-indicator/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/progress-indicator/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/progress-indicator/__examples__/vertical.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/progress-indicator/__docs__/storybook-stories.js b/components/progress-indicator/__docs__/storybook-stories.js new file mode 100644 index 0000000000..bef4b9ece1 --- /dev/null +++ b/components/progress-indicator/__docs__/storybook-stories.js @@ -0,0 +1,186 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _progressIndicator = _interopRequireDefault(require("../../../components/progress-indicator")); + +var _constants = require("../../../utilities/constants"); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _modal = _interopRequireDefault(require("../__examples__/modal")); + +var _stepError = _interopRequireDefault(require("../__examples__/step-error")); + +var _vertical = _interopRequireDefault(require("../__examples__/vertical")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var steps = [{ + id: 0, + label: _react.default.createElement("i", null, "tooltip label #1"), + assistiveText: 'This is custom text in the assistive text key' +}, { + id: 1, + label: 'tooltip label #2' +}, { + id: 2, + label: _react.default.createElement("strong", null, "tooltip label #3") +}, { + id: 3, + label: 'tooltip label #4' +}, { + id: 4, + label: 'tooltip label #5' +}]; +var stepsDisabled = [{ + id: 3, + label: 'tooltip label #4' +}, { + id: 4, + label: 'tooltip label #5' +}]; +var manySteps = [{ + id: 'a', + label: 'tooltip label #1' +}, { + id: 'b', + label: 'tooltip label #2' +}, { + id: 'c', + label: 'tooltip label #3' +}, { + id: 'd', + label: 'tooltip label #4' +}, { + id: 'e', + label: 'tooltip label #5' +}, { + id: 'f', + label: 'tooltip label #6' +}, { + id: 'g', + label: 'tooltip label #7' +}, { + id: 'h', + label: 'tooltip label #8' +}, { + id: 'i', + label: 'tooltip label #9' +}]; + +var ExampleProgressIndicator = +/*#__PURE__*/ +function (_React$Component) { + _inherits(ExampleProgressIndicator, _React$Component); + + function ExampleProgressIndicator() { + _classCallCheck(this, ExampleProgressIndicator); + + return _possibleConstructorReturn(this, _getPrototypeOf(ExampleProgressIndicator).apply(this, arguments)); + } + + _createClass(ExampleProgressIndicator, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + style: { + padding: '4rem 1rem 0px' + } + }, _react.default.createElement(_progressIndicator.default, { + id: "example-progress-indicator", + steps: this.props.steps, + selectedStep: this.props.selectedStep, + disabledSteps: this.props.disabledSteps, + completedSteps: this.props.completedSteps, + orientation: this.props.orientation, + assistiveText: this.props.assistiveText, + onStepClick: function onStepClick(event, data) { + console.log(data); + } + })); + } + }]); + + return ExampleProgressIndicator; +}(_react.default.Component); + +_defineProperty(ExampleProgressIndicator, "displayName", 'ProgressIndicatorDefault'); + +(0, _react2.storiesOf)(_constants.PROGRESS_INDICATOR, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base', function () { + return _react.default.createElement(_default.default, null); +}).add('Base With Many Steps', function () { + return _react.default.createElement(ExampleProgressIndicator, { + steps: manySteps, + selectedStep: manySteps[4], + completedSteps: manySteps.slice(0, 4) // tooltipIsOpenSteps={stepsBasic.slice(0, 2)} + + }); +}).add('Base With Disabled Steps', function () { + return _react.default.createElement(ExampleProgressIndicator, { + steps: steps, + disabledSteps: stepsDisabled, + selectedStep: steps[2], + completedSteps: steps.slice(0, 2) + }); +}).add('Step Error', function () { + return _react.default.createElement(_stepError.default, { + id: "example-progress-indicator", + steps: steps, + selectedStep: steps[1], + completedSteps: steps.slice(0, 1), + errorSteps: steps.slice(1, 2) + }); +}).add('In A Modal (With Step Error) - Needs DOM', function () { + return typeof document !== 'undefined' ? _react.default.createElement(_modal.default, null) : null; +}).add('Completed Progress', function () { + return _react.default.createElement(ExampleProgressIndicator, { + steps: steps, + selectedStep: steps[steps.length - 2], + completedSteps: steps.slice(0, steps.length - 2), + assistiveText: { + completedStep: 'Finished this step.', + disabledStep: 'Unable to proceed on this step.' + } + }); +}).add('Vertical', function () { + return _react.default.createElement(_vertical.default, null); +}).add('VerticalStepError', function () { + return _react.default.createElement(_stepError.default, { + id: "example-progress-indicator", + steps: manySteps, + completedSteps: manySteps.slice(0, 4), + errorSteps: manySteps.slice(4, 5), + orientation: "vertical" + }); +}); \ No newline at end of file diff --git a/components/progress-indicator/__examples__/default.js b/components/progress-indicator/__examples__/default.js new file mode 100644 index 0000000000..606dfc816b --- /dev/null +++ b/components/progress-indicator/__examples__/default.js @@ -0,0 +1,115 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _progressIndicator = _interopRequireDefault(require("../../../../components/progress-indicator")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var steps = [{ + id: 0, + label: _react.default.createElement("i", null, "tooltip label #1"), + assistiveText: 'This is custom text in the assistive text key' +}, { + id: 1, + label: 'tooltip label #2' +}, { + id: 2, + label: _react.default.createElement("strong", null, "tooltip label #3") +}, { + id: 3, + label: 'tooltip label #4' +}, { + id: 4, + label: 'tooltip label #5' +}]; +/* + * This example allows you to select the next step and only the next step. Typically, Progress Indicator should be paired with a modal and form errors should be explained outside of this component. + */ + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "handleStepEvent", function (event, data) { + _this.setState({ + completedSteps: steps.slice(0, data.step.id), + disabledSteps: data.step.id < steps.length ? steps.slice(data.step.id + 2, steps.length) : [], + selectedStep: data.step + }); + }); + + _this.state = { + steps: steps, + completedSteps: [], + disabledSteps: steps.slice(2, steps.length), + selectedStep: steps[0] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + padding: '4rem 1rem 0px', + background: this.props.variant === 'modal' ? 'rgb(244, 246, 249)' : undefined + } + }, _react.default.createElement(_progressIndicator.default, { + id: "example-progress-indicator", + completedSteps: this.state.completedSteps, + disabledSteps: this.state.disabledSteps, + onStepClick: this.handleStepEvent, + steps: this.state.steps, + selectedStep: this.state.selectedStep // tooltipIsOpenSteps={stepsBasic.slice(0, 2)} + + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressIndicatorDefault'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-indicator/__examples__/modal.js b/components/progress-indicator/__examples__/modal.js new file mode 100644 index 0000000000..26fdb684f6 --- /dev/null +++ b/components/progress-indicator/__examples__/modal.js @@ -0,0 +1,132 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _progressIndicator = _interopRequireDefault(require("../../../../components/progress-indicator")); + +var _modal = _interopRequireDefault(require("../../../../components/modal")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var steps = [{ + id: 0, + label: _react.default.createElement("i", null, "tooltip label #1"), + assistiveText: 'This is custom text in the assistive text key' +}, { + id: 1, + label: 'tooltip label #2' +}, { + id: 2, + label: _react.default.createElement("strong", null, "tooltip label #3") +}, { + id: 3, + label: 'tooltip label #4' +}, { + id: 4, + label: 'tooltip label #5' +}]; + +var handleStepEvent = function handleStepEvent(event, data) { + console.log(data); +}; + +var getModal = function getModal(props) { + return _react.default.createElement(_modal.default, props); +}; + +var modalFooter = function modalFooter(props) { + return [_react.default.createElement(_button.default, { + key: "modalBCancel", + label: "Cancel" + }), _react.default.createElement(_progressIndicator.default, { + key: "modal-progress-indicator", + variant: "modal", + steps: steps, + selectedStep: steps[2], + completedSteps: steps.slice(0, 2), + errorSteps: steps.slice(2, 3), + onStepClick: handleStepEvent + }), _react.default.createElement(_button.default, { + key: "modalBSave", + label: "Save", + variant: "brand" + })]; +}; + +var modalContent = _react.default.createElement("div", { + className: "slds-modal__content slds-grow slds-p-around_medium", + id: "modal-content-id-1", + style: { + height: '640px' + } +}); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + style: { + height: '640px' + } + }, getModal({ + isOpen: true, + title: 'Modal Header', + children: modalContent, + onRequestClose: (0, _addonActions.action)('modal closed'), + footer: modalFooter(this.props), + size: 'large', + footerClassNames: 'slds-grid slds-grid_align-spread' + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ProgressIndicatorModal'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-indicator/__examples__/step-error.js b/components/progress-indicator/__examples__/step-error.js new file mode 100644 index 0000000000..d3fdfcde95 --- /dev/null +++ b/components/progress-indicator/__examples__/step-error.js @@ -0,0 +1,64 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _progressIndicator = _interopRequireDefault(require("../../../../components/progress-indicator")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + style: { + padding: '4rem 1rem 0px' + } + }, _react.default.createElement(_progressIndicator.default, this.props)); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ProgressIndicatorStepError'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-indicator/__examples__/vertical.js b/components/progress-indicator/__examples__/vertical.js new file mode 100644 index 0000000000..614f331b77 --- /dev/null +++ b/components/progress-indicator/__examples__/vertical.js @@ -0,0 +1,114 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _progressIndicator = _interopRequireDefault(require("../../../../components/progress-indicator")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var steps = [{ + id: 0, + label: 'tooltip label #1' +}, { + id: 1, + label: 'tooltip label #2' +}, { + id: 2, + label: 'tooltip label #3' +}, { + id: 3, + label: 'tooltip label #4' +}, { + id: 4, + label: 'tooltip label #5' +}]; +/* + * This example allows you to select the next step and only the next step. Typically, Progress Indicator should be paired with a modal and form errors should be explained outside of this component. + */ + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "handleStepEvent", function (event, data) { + _this.setState({ + completedSteps: steps.slice(0, data.step.id), + disabledSteps: data.step.id < steps.length ? steps.slice(data.step.id + 2, steps.length) : [], + selectedStep: data.step + }); + }); + + _this.state = { + steps: steps, + completedSteps: [], + disabledSteps: steps.slice(2, steps.length), + selectedStep: steps[0] + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + padding: '4rem 1rem 0px', + background: this.props.variant === 'modal' ? 'rgb(244, 246, 249)' : undefined + } + }, _react.default.createElement(_progressIndicator.default, { + id: "vertical-progress-indicator", + completedSteps: this.state.completedSteps, + disabledSteps: this.state.disabledSteps, + onStepClick: this.handleStepEvent, + orientation: "vertical", + steps: this.state.steps, + selectedStep: this.state.selectedStep + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressIndicatorVertical'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-indicator/docs.json b/components/progress-indicator/docs.json new file mode 100644 index 0000000000..7293606e6d --- /dev/null +++ b/components/progress-indicator/docs.json @@ -0,0 +1,15 @@ +{ + "component": "progress-indicator", + "status": "prod", + "display-name": "Progress Indicators", + "SLDS-component-path": "/components/progress-indicator", + "last-accessibility-review": { + "date-iso-8601": "2018/07/25", + "commit-sha": "473c75bf424f69bf0ff66fde6b1e604c21d2835c" + }, + "last-slds-markup-review": { + "date-iso-8601": "2018/07/25", + "commit-sha": "473c75bf424f69bf0ff66fde6b1e604c21d2835c" + }, + "url-slug": "progress-indicators" +} \ No newline at end of file diff --git a/components/progress-indicator/index.js b/components/progress-indicator/index.js new file mode 100644 index 0000000000..adbfd2bad2 --- /dev/null +++ b/components/progress-indicator/index.js @@ -0,0 +1,319 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.find")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _constants = require("../../utilities/constants"); + +var _step = _interopRequireDefault(require("./private/step")); + +var _progress = _interopRequireDefault(require("./private/progress")); + +var _stepVertical = _interopRequireDefault(require("./private/step-vertical")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var displayName = _constants.PROGRESS_INDICATOR; +var propTypes = { + /** + * **Assistive text for accessibility** + * This object is merged with the default props object on every render. + * * `completedStep`: Label for a completed step. The default is `Completed Step` + * * `disabledStep`: Label for disabled step. The default is `Disabled Step` + * * `errorStep`: Label for a step with an error. The default is `Error Step` + * * `percentage`: Label for Progress Bar. The default is `Progress: [this.props.value]%`. You will need to calculate the percentage yourself if changing this string. + * * `step`: Label for a step. It will be typically followed by the number of the step such as "Step 1". + */ + assistiveText: _propTypes.default.shape({ + completedStep: _propTypes.default.string, + disabledStep: _propTypes.default.string, + percentage: _propTypes.default.string, + step: _propTypes.default.string + }), + + /** + * CSS class names to be added to the container element. `array`, `object`, or `string` are accepted. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Stores all completed steps. It is an array of step objects. + */ + completedSteps: _propTypes.default.array, + + /** + * Stores all disabled steps. It is an array of step objects. Steps are still clickable/focusable, + * this only disables cursor change and removes onClick and onFocus event callbacks. + */ + disabledSteps: _propTypes.default.array, + + /** + * Stores all error steps. It is an array of step objects and usually there is only one error step, the current step. If an error occurs a second error icon should be placed to the left of related confirmation buttons (e.g. Cancel, Save) and an Error Popover should appear indicating there are errors. These additional items are NOT part of this component. This note was included for visibility purposes. Please refer to [SLDS website](https://www.lightningdesignsystem.com/components/progress-indicator/) for full details ** + */ + errorSteps: _propTypes.default.array, + + /** + * HTML id for component. + */ + id: _propTypes.default.string, + + /** + * Determines the orientation of the progress indicator + */ + orientation: _propTypes.default.oneOf(['horizontal', 'vertical']), + + /** + * Triggered when an individual step is clicked. By default, it receives an event and returns step state and the step object clicked: `{ isCompleted, isDisabled, isError, isSelected, step }`. Users are able to pass a callback handleClick function in forms of: (event, data) where data is the callback result. + * ``` + * const handleStepClick = function(event, data) { console.log(data); }; + * + * ``` + */ + onStepClick: _propTypes.default.func, + + /** + * Triggered when an individual step is focused. By default, it receives an event and returns step state and the step object clicked: `{ isCompleted, isDisabled, isError, isSelected, step }`. Users are able to pass a callback handleClick function in forms of: (event, data) where data is the callback result. + * ``` + * const handleStepFocus = function(event, data) { console.log(data); }; + * + * ``` + */ + onStepFocus: _propTypes.default.func, + + /** + * Represents the currently selected or active step. It is a step object. + */ + selectedStep: _propTypes.default.object.isRequired, + + /** + * It is an array of step objects in the following form: + * ``` + * [{ + * id: or , has to be unique + * label: , representing the tooltip content + * assistiveText: , The default is `[Step props.index + 1]: [status]`. Status is if the step has been completed or in an error state. + * }], + * ``` + */ + steps: _propTypes.default.array.isRequired, + + /** + * Stores all steps with opened tooltips. This property is mainly for development purposes. The tooltip should only show on hover for the user. + */ + tooltipIsOpenSteps: _propTypes.default.array, + + /** + * Determines component style. + */ + variant: _propTypes.default.oneOf(['base', 'modal']), + + /** + * Please select one of the following: + * * `absolute` - (default if `variant` is `modal`) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog. + * * `overflowBoundaryElement` - (default if `variant` is `base`) The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree. + * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing. + */ + tooltipPosition: _propTypes.default.oneOf(['absolute', 'overflowBoundaryElement', 'relative']) +}; +var defaultSteps = [{ + id: 0, + label: 'tooltip label #1' +}, { + id: 1, + label: 'tooltip label #2' +}, { + id: 2, + label: 'tooltip label #3' +}, { + id: 3, + label: 'tooltip label #4' +}, { + id: 4, + label: 'tooltip label #5' +}]; +var defaultProps = { + assistiveText: { + completedStep: 'Completed', + disabledStep: 'Disabled', + errorStep: 'Error', + step: 'Step' + }, + errorSteps: [], + completedSteps: [], + disabledSteps: [], + orientation: 'horizontal', + selectedStep: defaultSteps[0], + variant: 'base', + // click/focus callbacks by default do nothing + onStepClick: function onStepClick() {}, + onStepFocus: function onStepFocus() {} +}; +/** + * Check if `steps` prop is valid + */ + +function checkSteps(steps) { + var isStepsDefined = steps !== undefined; + + var isLabelDefined = function isLabelDefined(step) { + return step.label !== undefined; + }; + + var stepLabelsDefined = Array.isArray(steps) && steps.every(isLabelDefined); + return isStepsDefined && stepLabelsDefined; +} +/** + * Check if an item is from an array of items when 'items' is an array; + * Check if an item is equal to the other item after being stringified when 'items' is a JSON object + */ + + +function findStep(item, items) { + if (Array.isArray(items)) { + return !!(0, _lodash.default)(items, item); + } + + return JSON.stringify(item) === JSON.stringify(items); +} +/** + * Progress Indicator is a component that communicates to the user the progress of a particular process. + */ + + +var ProgressIndicator = +/*#__PURE__*/ +function (_React$Component) { + _inherits(ProgressIndicator, _React$Component); + + function ProgressIndicator() { + _classCallCheck(this, ProgressIndicator); + + return _possibleConstructorReturn(this, _getPrototypeOf(ProgressIndicator).apply(this, arguments)); + } + + _createClass(ProgressIndicator, [{ + key: "componentWillMount", + value: function componentWillMount() { + this.generatedId = _shortid.default.generate(); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this.isUnmounting = true; + } + /** + * Get the progress indicator's HTML id. Generate a new one if no ID present. + */ + + }, { + key: "getId", + value: function getId() { + return this.props.id || this.generatedId; + } + }, { + key: "getSteps", + value: function getSteps() { + // check if passed steps are valid + return checkSteps(this.props.steps) ? this.props.steps : defaultSteps; + } + }, { + key: "render", + value: function render() { + var _this = this; + + // Merge objects of strings with their default object + var assistiveText = _objectSpread({}, defaultProps.assistiveText, this.props.assistiveText); + + var _this$props = this.props, + selectedStep = _this$props.selectedStep, + disabledSteps = _this$props.disabledSteps, + errorSteps = _this$props.errorSteps, + completedSteps = _this$props.completedSteps; + /** 1. preparing data */ + + var allSteps = this.getSteps(); + var currentStep = 0; // find index for the current step + + for (var i = 0; i < allSteps.length; i += 1) { + // assign step an id if it does not have one + if (allSteps[i].id === undefined) { + allSteps[i].id = i; + } + + if (findStep(allSteps[i], this.props.selectedStep)) { + currentStep = i; + } + } // Set default tooltipPosition + + + var tooltipPosition = this.props.tooltipPosition || (this.props.variant === 'modal' ? 'absolute' : 'overflowBoundaryElement'); + var StepComponent = this.props.orientation === 'vertical' ? _stepVertical.default : _step.default; + /** 2. return DOM */ + + return _react.default.createElement(_progress.default, { + assistiveText: assistiveText, + id: this.getId(), + orientation: this.props.orientation, + value: currentStep === 0 ? '0' : "".concat(100 * (currentStep / (allSteps.length - 1))), + variant: this.props.variant, + className: this.props.className + }, allSteps.map(function (step, i) { + return _react.default.createElement(StepComponent, { + assistiveText: assistiveText, + key: "".concat(_this.getId(), "-").concat(step.id), + id: _this.getId(), + index: i, + isSelected: findStep(step, selectedStep), + isDisabled: findStep(step, disabledSteps), + isError: findStep(step, errorSteps), + isCompleted: findStep(step, completedSteps), + onClick: _this.props.onStepClick, + onFocus: _this.props.onStepFocus, + step: step, + tooltipIsOpen: findStep(step, _this.props.tooltipIsOpenSteps), + tooltipPosition: tooltipPosition + }); + })); + } + }]); + + return ProgressIndicator; +}(_react.default.Component); + +ProgressIndicator.displayName = displayName; +ProgressIndicator.propTypes = propTypes; +ProgressIndicator.defaultProps = defaultProps; +var _default = ProgressIndicator; +exports.default = _default; \ No newline at end of file diff --git a/components/progress-indicator/private/progress-bar.js b/components/progress-indicator/private/progress-bar.js new file mode 100644 index 0000000000..a29a5f8541 --- /dev/null +++ b/components/progress-indicator/private/progress-bar.js @@ -0,0 +1,92 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * Assistive text for percentage + */ + assistiveText: _propTypes.default.shape({ + percentage: _propTypes.default.string + }), + + /** + * Percentage of progress completion, with range of [0, 100] + */ + value: _propTypes.default.string.isRequired +}; +/** + * ProgressBar renders the blue/gray progress bar and dynamically updates its completion percentage + */ + +var ProgressBar = +/*#__PURE__*/ +function (_React$Component) { + _inherits(ProgressBar, _React$Component); + + function ProgressBar() { + _classCallCheck(this, ProgressBar); + + return _possibleConstructorReturn(this, _getPrototypeOf(ProgressBar).apply(this, arguments)); + } + + _createClass(ProgressBar, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-progress-bar slds-progress-bar_x-small', { + 'slds-progress-bar_vertical': this.props.orientation === 'vertical' + }), + "aria-valuemin": "0", + "aria-valuemax": "100", + "aria-valuenow": this.props.value, + role: "progressbar" + }, _react.default.createElement("span", { + className: "slds-progress-bar__value", + style: this.props.orientation === 'vertical' ? { + height: "".concat(this.props.value, "%") + } : { + width: "".concat(this.props.value, "%") + } + }, _react.default.createElement("span", { + className: "slds-assistive-text" + }, this.props.assistiveText.percentage || "Progress: ".concat(this.props.value, "%")))); + } + }]); + + return ProgressBar; +}(_react.default.Component); + +ProgressBar.displayName = 'ProgressBar'; +ProgressBar.propTypes = propTypes; +var _default = ProgressBar; +exports.default = _default; \ No newline at end of file diff --git a/components/progress-indicator/private/progress.js b/components/progress-indicator/private/progress.js new file mode 100644 index 0000000000..12fbf898b5 --- /dev/null +++ b/components/progress-indicator/private/progress.js @@ -0,0 +1,127 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _progressBar = _interopRequireDefault(require("./progress-bar")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// ### Prop Types +var propTypes = { + /** + * Assistive text for percentage + */ + assistiveText: _propTypes.default.shape({ + percentage: _propTypes.default.string + }), + + /** + * Steps in the component + */ + children: _propTypes.default.node, + + /** + * CSS class names to be added to the container element. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * HTML id for component. + */ + id: _propTypes.default.string.isRequired, + + /** + * Determines the orientation of the progress indicator + */ + orientation: _propTypes.default.oneOf(['horizontal', 'vertical']), + + /** + * Percentage of progress completion, ranging [0, 100] + */ + value: _propTypes.default.string.isRequired, + + /** + * Determines component style + */ + variant: _propTypes.default.oneOf(['base', 'modal']) +}; +/** + * Progress renders all step buttons and a container wrapping these buttongs and a progress bar + */ + +var Progress = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Progress, _React$Component); + + function Progress() { + _classCallCheck(this, Progress); + + return _possibleConstructorReturn(this, _getPrototypeOf(Progress).apply(this, arguments)); + } + + _createClass(Progress, [{ + key: "getId", + + /** + * Get the progress's HTML id. Generate a new one if no ID present. + */ + value: function getId() { + return this.props.id; + } + }, { + key: "render", + value: function render() { + return _react.default.createElement("div", { + id: this.getId(), + className: (0, _classnames.default)('slds-progress', { + 'slds-progress_shade': this.props.variant === 'modal' + }, { + 'slds-progress_vertical': this.props.orientation === 'vertical' + }, this.props.className) + }, _react.default.createElement("ol", { + className: "slds-progress__list" + }, this.props.children), this.props.orientation !== 'vertical' && _react.default.createElement(_progressBar.default, { + value: this.props.value, + orientation: this.props.orientation, + assistiveText: this.props.assistiveText + })); + } + }]); + + return Progress; +}(_react.default.Component); + +Progress.propTypes = propTypes; +Progress.displayName = _constants.PROGRESS_INDICATOR_PROGRESS; +var _default = Progress; +exports.default = _default; \ No newline at end of file diff --git a/components/progress-indicator/private/step-vertical.js b/components/progress-indicator/private/step-vertical.js new file mode 100644 index 0000000000..c8109ca7d9 --- /dev/null +++ b/components/progress-indicator/private/step-vertical.js @@ -0,0 +1,157 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _constants = require("../../../utilities/constants"); + +var _icon = _interopRequireDefault(require("../../icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// ### Display Name +var displayName = _constants.PROGRESS_INDICATOR_STEP_VERTICAL; // ### Prop Types + +var propTypes = { + /** + * **Assistive text for accessibility** + * This object is merged with the default props object on every render. + * * `completedStep`: Label for a completed step. The default is `Completed Step` + * * `disabledStep`: Label for disabled step. The default is `Disabled Step` + * * `errorStep`: Label for a step with an error. The default is `Error Step` + * * `percentage`: Label for Progress Bar. The default is `Progress: [this.props.value]%`. You will need to calculate the percentage yourself if changing this string. + * * `step`: Label for a step. It will be typically followed by the number of the step such as "Step 1". + */ + assistiveText: _propTypes.default.shape({ + completedStep: _propTypes.default.string, + disabledStep: _propTypes.default.string, + percentage: _propTypes.default.string, + step: _propTypes.default.string + }), + + /** + * Id for Steps, ranging in [0, steps.length). + */ + id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), + + /** + * Index of step. Used for id's if no step ID exists + */ + index: _propTypes.default.number, + + /** + * Determines if the step has been completed + */ + isCompleted: _propTypes.default.bool, + + /** + * Determines if the step has been disabled + */ + isDisabled: _propTypes.default.bool, + + /** + * Determines if the step contains an error + */ + isError: _propTypes.default.bool, + + /** + * Determines if the step is currently selected (active) + */ + isSelected: _propTypes.default.bool, + + /** + * Step object. This is passed into event callbacks. + */ + step: _propTypes.default.object +}; +/** + * StepVertical renders a step icon and its step label if applied + */ + +var StepVertical = +/*#__PURE__*/ +function (_React$Component) { + _inherits(StepVertical, _React$Component); + + function StepVertical() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, StepVertical); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(StepVertical)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "stepIcon", function (renderIcon) { + var icon = renderIcon ? _react.default.createElement(_icon.default, { + category: "utility", + size: "x-small", + name: _this.props.isError ? 'error' : 'success' + }) : null; + return _react.default.createElement("span", { + className: (0, _classnames.default)('slds-progress__marker', { + 'slds-progress__marker_icon': renderIcon + }) + }, icon); + }); + + return _this; + } + + _createClass(StepVertical, [{ + key: "render", + value: function render() { + var renderIcon = this.props.isCompleted || this.props.isError; + return _react.default.createElement("li", { + className: (0, _classnames.default)('slds-progress__item', { + 'slds-is-completed': this.props.isCompleted, + 'slds-is-active': this.props.isSelected && !this.props.isError, + 'slds-has-error': this.props.isError + }) + }, this.stepIcon(renderIcon), _react.default.createElement("div", { + id: "progress-indicator-vertical-label-".concat(this.props.step.id || this.props.index), + className: "slds-progress__item_content slds-grid slds-grid_align-spread" + }, this.props.step.label)); + } + }]); + + return StepVertical; +}(_react.default.Component); + +StepVertical.propTypes = propTypes; +StepVertical.displayName = displayName; +var _default = StepVertical; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-indicator/private/step.js b/components/progress-indicator/private/step.js new file mode 100644 index 0000000000..1403c12661 --- /dev/null +++ b/components/progress-indicator/private/step.js @@ -0,0 +1,247 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _tooltip = _interopRequireDefault(require("../../tooltip")); + +var _constants = require("../../../utilities/constants"); + +var _buttonIcon = _interopRequireDefault(require("../../icon/button-icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// ### Display Name +var displayName = _constants.PROGRESS_INDICATOR_STEP; // ### Prop Types + +var propTypes = { + /** + * **Assistive text for accessibility** + * This object is merged with the default props object on every render. + * * `completedStep`: Label for a completed step. The default is `Completed Step` + * * `disabledStep`: Label for disabled step. The default is `Disabled Step` + * * `errorStep`: Label for a step with an error. The default is `Error Step` + * * `percentage`: Label for Progress Bar. The default is `Progress: [this.props.value]%`. You will need to calculate the percentage yourself if changing this string. + * * `step`: Label for a step. It will be typically followed by the number of the step such as "Step 1". + */ + assistiveText: _propTypes.default.shape({ + completedStep: _propTypes.default.string, + disabledStep: _propTypes.default.string, + percentage: _propTypes.default.string, + step: _propTypes.default.string + }), + + /** + * Id for Steps, ranging in [0, steps.length). + */ + id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), + + /** + * Index of step. Used for id's if no step ID exists + */ + index: _propTypes.default.number, + + /** + * Determines if the step has been completed + */ + isCompleted: _propTypes.default.bool, + + /** + * Determines if the step has been disabled + */ + isDisabled: _propTypes.default.bool, + + /** + * Determines if the step contains an error + */ + isError: _propTypes.default.bool, + + /** + * Determines if the step is currently selected (active) + */ + isSelected: _propTypes.default.bool, + + /** + * Label of tooltip attached to the step if applicable. + */ + label: _propTypes.default.node, + + /** + * Triggered when click on individual steps. By default, it receives an event and returns all info passed to that step. + * users are able to re-define it by passing a function as a prop + */ + onClick: _propTypes.default.func, + + /** + * Triggered when focus on individual steps. By default, it receives an event and returns all info passed to that step. + * users are able to re-define it by passing a function as a prop + */ + onFocus: _propTypes.default.func, + + /** + * Step object. This is passed into event callbacks. + */ + step: _propTypes.default.object, + + /** + * Determines if the tooltip attached to step is always open. + * This is mainly for dev test purpose. + * Usually the tooltip should only show when hover. + */ + tooltipIsOpen: _propTypes.default.bool, + + /** + * Please select one of the following: + * * `absolute` - (default if `variant` is `modal`) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog. + * * `overflowBoundaryElement` - (default if `variant` is `base`) The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree. + * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing. + */ + tooltipPosition: _propTypes.default.oneOf(['absolute', 'overflowBoundaryElement', 'relative']) +}; +/** + * Step renders a button icon and its tooltip if applied. + * The button is applied with different css classes under different conditions. + * Button icons have 4 types of status: completed (success), active (in progress), error (warning) and uncompleted (not approached) + */ + +var Step = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Step, _React$Component); + + function Step() { + _classCallCheck(this, Step); + + return _possibleConstructorReturn(this, _getPrototypeOf(Step).apply(this, arguments)); + } + + _createClass(Step, [{ + key: "buttonIcon", + + /** + * buttonIcon represents the button icon used for each step. + * the button is applied with different css classes under different conditions. + */ + value: function buttonIcon(renderIcon, status, props) { + var data = { + isSelected: props.isSelected, + isError: props.isError, + isCompleted: props.isCompleted, + isDisabled: props.isDisabled, + step: props.step + }; + var icon = renderIcon ? _react.default.createElement(_buttonIcon.default, { + category: "utility", + name: this.props.isError ? 'error' : 'success' + }) : null; + + var handleClick = function handleClick(event) { + return props.onClick(event, data); + }; + + var handleFocus = function handleFocus(event) { + return props.onFocus(event, data); + }; + + var stepButton = props.isDisabled ? _react.default.createElement("a", { + className: (0, _classnames.default)('slds-button', { + 'slds-button_icon': renderIcon + }, 'slds-progress__marker', { + 'slds-progress__marker_icon': renderIcon + }), + "aria-describedby": "progress-indicator-tooltip-".concat(this.props.step.id || this.props.index), + tabIndex: 0, + role: "button" + }, icon, _react.default.createElement("span", { + className: "slds-assistive-text" + }, this.props.step.assistiveText || "".concat(props.assistiveText.step, " ").concat(props.index + 1, ": ").concat(props.step.label, " - ").concat(status))) : _react.default.createElement("button", { + className: (0, _classnames.default)('slds-button', { + 'slds-button_icon': renderIcon + }, 'slds-progress__marker', { + 'slds-progress__marker_icon': renderIcon + }), + onClick: handleClick, + onFocus: handleFocus, + "aria-describedby": "progress-indicator-tooltip-".concat(this.props.step.id || this.props.index), + "aria-current": this.props.isSelected ? 'step' : null + }, icon, _react.default.createElement("span", { + className: "slds-assistive-text" + }, this.props.step.assistiveText || "".concat(props.assistiveText.step, " ").concat(props.index + 1, ": ").concat(props.step.label).concat(status ? " - ".concat(status) : ''))); + return stepButton; + } + }, { + key: "render", + value: function render() { + var renderIcon = this.props.isCompleted || this.props.isError; + var status = ''; + + if (this.props.isError) { + status = this.props.assistiveText.errorStep; + } else if (this.props.isCompleted) { + status = this.props.assistiveText.completedStep; + } else if (this.props.isDisabled) { + status = this.props.assistiveText.disabledStep; + } + + var tooltipProps = { + align: 'top', + id: "progress-indicator-tooltip-".concat(this.props.step.id || this.props.index), + content: this.props.step.label, + theme: 'info', + position: this.props.tooltipPosition, + triggerStyle: { + display: !renderIcon ? 'flex' : '' + } + }; // This is mainly for dev test purpose. + // `isOpen` is only set to true if tooltip is specified to be open + // Do not set isOpen to false or undefined otherwise, because that will + // disable any interaction with tooltips + + if (this.props.tooltipIsOpen) { + tooltipProps.isOpen = true; + } + + return _react.default.createElement("li", { + className: (0, _classnames.default)('slds-progress__item', { + 'slds-is-completed': this.props.isCompleted, + 'slds-is-active': this.props.isSelected && !this.props.isError, + 'slds-has-error': this.props.isError + }) + }, _react.default.createElement(_tooltip.default, tooltipProps, this.buttonIcon(renderIcon, status, this.props))); + } + }]); + + return Step; +}(_react.default.Component); + +Step.propTypes = propTypes; +Step.displayName = displayName; +var _default = Step; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-ring/__docs__/site-stories.js b/components/progress-ring/__docs__/site-stories.js new file mode 100644 index 0000000000..330fe6749a --- /dev/null +++ b/components/progress-ring/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/progress-ring/__examples__/base.jsx'), require('raw-loader!@salesforce/design-system-react/components/progress-ring/__examples__/complete.jsx'), require('raw-loader!@salesforce/design-system-react/components/progress-ring/__examples__/warning.jsx'), require('raw-loader!@salesforce/design-system-react/components/progress-ring/__examples__/expired.jsx'), require('raw-loader!@salesforce/design-system-react/components/progress-ring/__examples__/customIcon.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/progress-ring/__docs__/storybook-stories.js b/components/progress-ring/__docs__/storybook-stories.js new file mode 100644 index 0000000000..0a06b9bda2 --- /dev/null +++ b/components/progress-ring/__docs__/storybook-stories.js @@ -0,0 +1,39 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +var _complete = _interopRequireDefault(require("../__examples__/complete")); + +var _warning = _interopRequireDefault(require("../__examples__/warning")); + +var _expired = _interopRequireDefault(require("../__examples__/expired")); + +var _customIcon = _interopRequireDefault(require("../__examples__/customIcon")); + +var _examples = _interopRequireDefault(require("../__examples__/examples")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.PROGRESS_RING, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base', function () { + return _react.default.createElement(_base.default, null); +}).add('Theme: Complete', function () { + return _react.default.createElement(_complete.default, null); +}).add('Theme: Warning', function () { + return _react.default.createElement(_warning.default, null); +}).add('Theme: Expired', function () { + return _react.default.createElement(_expired.default, null); +}).add('Custom Icon', function () { + return _react.default.createElement(_customIcon.default, null); +}).add('Docs site Examples', function () { + return _react.default.createElement(_examples.default, null); +}); \ No newline at end of file diff --git a/components/progress-ring/__examples__/base.js b/components/progress-ring/__examples__/base.js new file mode 100644 index 0000000000..27eefe025f --- /dev/null +++ b/components/progress-ring/__examples__/base.js @@ -0,0 +1,74 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _progressRing = _interopRequireDefault(require("../../../../components/progress-ring")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 0 + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 20 + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 100 + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressRingDefault'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-ring/__examples__/complete.js b/components/progress-ring/__examples__/complete.js new file mode 100644 index 0000000000..d5e7ad13a2 --- /dev/null +++ b/components/progress-ring/__examples__/complete.js @@ -0,0 +1,75 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _progressRing = _interopRequireDefault(require("../../../../components/progress-ring")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 100, + theme: "complete" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 100, + theme: "complete", + hasIcon: true + })), _react.default.createElement("div", { + className: "slds-col_padded" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressRingDefault'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-ring/__examples__/customIcon.js b/components/progress-ring/__examples__/customIcon.js new file mode 100644 index 0000000000..4c7efbcbea --- /dev/null +++ b/components/progress-ring/__examples__/customIcon.js @@ -0,0 +1,74 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _progressRing = _interopRequireDefault(require("../../../../components/progress-ring")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 20, + theme: "expired", + hasIcon: true, + icon: _react.default.createElement(_icon.default, { + category: "utility", + name: "lock" + }) + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressRingDefault'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-ring/__examples__/examples.js b/components/progress-ring/__examples__/examples.js new file mode 100644 index 0000000000..3d9b953459 --- /dev/null +++ b/components/progress-ring/__examples__/examples.js @@ -0,0 +1,136 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _progressRing = _interopRequireDefault(require("../../../components/progress-ring")); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _icon = _interopRequireDefault(require("../../../components/icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center slds-wrap" + }, _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 0 + })), _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 0, + hasIcon: true, + icon: _react.default.createElement(_icon.default, { + category: "utility", + name: "warning" + }) + })), _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 0, + hasIcon: true, + icon: _react.default.createElement(_icon.default, { + category: "utility", + name: "lock" + }) + })), _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 20, + theme: "complete" + })), _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 100, + theme: "complete", + hasIcon: true + })), _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 100, + theme: "complete" + })), _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 20, + theme: "warning" + })), _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 100, + theme: "warning", + hasIcon: true + })), _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 100, + theme: "warning" + })), _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 20, + theme: "expired" + })), _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 100, + theme: "expired", + hasIcon: true + })), _react.default.createElement("div", { + className: "slds-col_padded slds-m-top_x-large slds-size_1-of-3 slds-align_absolute-center" + }, _react.default.createElement(_progressRing.default, { + value: 100, + theme: "expired" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'ProgressRingExamples'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/progress-ring/__examples__/expired.js b/components/progress-ring/__examples__/expired.js new file mode 100644 index 0000000000..c798edb3d2 --- /dev/null +++ b/components/progress-ring/__examples__/expired.js @@ -0,0 +1,80 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _progressRing = _interopRequireDefault(require("../../../../components/progress-ring")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 20, + theme: "expired" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 20, + theme: "expired", + hasIcon: true + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 100, + theme: "expired" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressRingDefault'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-ring/__examples__/warning.js b/components/progress-ring/__examples__/warning.js new file mode 100644 index 0000000000..12e58e78e7 --- /dev/null +++ b/components/progress-ring/__examples__/warning.js @@ -0,0 +1,78 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _progressRing = _interopRequireDefault(require("../../../../components/progress-ring")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 20, + theme: "warning" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 20, + theme: "warning", + hasIcon: true + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_progressRing.default, { + value: 100, + theme: "warning" + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ProgressRingDefault'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/progress-ring/docs.json b/components/progress-ring/docs.json new file mode 100644 index 0000000000..f816cb8b82 --- /dev/null +++ b/components/progress-ring/docs.json @@ -0,0 +1,15 @@ +{ + "component": "progress-ring", + "status": "prod", + "display-name": "Progress Rings", + "last-accessibility-review": { + "date-iso-8601": "2017/11/28", + "commit-sha": "1b7025689af65ff2b92ad359c809970f2afd8439" + }, + "last-slds-markup-review": { + "date-iso-8601": "2017/11/28", + "commit-sha": "1b7025689af65ff2b92ad359c809970f2afd8439" + }, + "SLDS-component-path": "/components/progress-ring", + "url-slug": "progress-rings" +} \ No newline at end of file diff --git a/components/progress-ring/index.js b/components/progress-ring/index.js new file mode 100644 index 0000000000..9a0674d2d0 --- /dev/null +++ b/components/progress-ring/index.js @@ -0,0 +1,179 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = exports.THEME_OPTIONS = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _constants = require("../../utilities/constants"); + +var _icon = _interopRequireDefault(require("../icon")); + +var _ringShape = _interopRequireDefault(require("./private/ring-shape")); + +var _THEME_CLASSES; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * The themes available for the progress ring + */ +var THEME_OPTIONS = Object.freeze({ + WARNING: 'warning', + EXPIRED: 'expired', + COMPLETE: 'complete' +}); +/** + * The CSS classes associated with each theme + */ + +exports.THEME_OPTIONS = THEME_OPTIONS; +var THEME_CLASSES = (_THEME_CLASSES = {}, _defineProperty(_THEME_CLASSES, THEME_OPTIONS.COMPLETE, 'slds-progress-ring_complete'), _defineProperty(_THEME_CLASSES, THEME_OPTIONS.WARNING, 'slds-progress-ring_warning'), _defineProperty(_THEME_CLASSES, THEME_OPTIONS.EXPIRED, 'slds-progress-ring_expired'), _THEME_CLASSES); +var propTypes = { + /** + * HTML id for component. + */ + id: _propTypes.default.string, + + /** + * CSS classes to be added to tag with `.slds-progress-ring`. Uses `classNames` [API](https://github.com/JedWatson/classnames). + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * The theme applied to the ring. + */ + theme: _propTypes.default.oneOf(['warning', 'expired', 'complete']), + + /** + * Overrides the icon to be displayed. + */ + icon: _propTypes.default.node, + + /** + * Display the icon associated with the theme. + */ + hasIcon: _propTypes.default.bool, + + /** + * Percentage of progress completion, ranging [0, 100]. + */ + value: _propTypes.default.number.isRequired +}; +var defaultProps = {}; +/** + * Customizable and configurable progress ring. Will display progress in a circular progress bar factor, and is capable of displaying iconography inside of the ring structure. + */ + +var ProgressRing = +/*#__PURE__*/ +function (_React$Component) { + _inherits(ProgressRing, _React$Component); + + function ProgressRing() { + _classCallCheck(this, ProgressRing); + + return _possibleConstructorReturn(this, _getPrototypeOf(ProgressRing).apply(this, arguments)); + } + + _createClass(ProgressRing, [{ + key: "icon", + + /** + * Gets the icon to display + * @returns {node} Icon + */ + value: function icon() { + var icon = ''; + + if (this.props.hasIcon) { + if (this.props.icon) { + icon = this.props.icon; + } else if (this.props.theme === THEME_OPTIONS.WARNING) { + icon = _react.default.createElement(_icon.default, { + category: "utility", + name: "warning", + title: "Warning" + }); + } else if (this.props.theme === THEME_OPTIONS.EXPIRED) { + icon = _react.default.createElement(_icon.default, { + category: "utility", + name: "error", + title: "Expired" + }); + } else if (this.props.theme === THEME_OPTIONS.COMPLETE) { + icon = _react.default.createElement(_icon.default, { + category: "utility", + name: "check", + title: "Complete" + }); + } + } + + return icon; + } + /** + * Percentage as a decimal + * @returns {decimal} Percentage + */ + + }, { + key: "percentDecimal", + value: function percentDecimal() { + return this.props.value / 100; + } + /** + * Gets the theme CSS class + * @returns {string} Class name + */ + + }, { + key: "themeClass", + value: function themeClass() { + return THEME_CLASSES[this.props.theme] || ''; + } + }, { + key: "render", + value: function render() { + return _react.default.createElement(_ringShape.default, { + id: this.props.id, + className: (0, _classnames.default)(this.props.className, this.themeClass()), + fillPercentDecimal: this.percentDecimal() + }, this.icon()); + } + }]); + + return ProgressRing; +}(_react.default.Component); + +ProgressRing.displayName = _constants.PROGRESS_RING; +ProgressRing.propTypes = propTypes; +ProgressRing.defaultProps = defaultProps; +var _default = ProgressRing; +exports.default = _default; \ No newline at end of file diff --git a/components/progress-ring/private/ring-shape.js b/components/progress-ring/private/ring-shape.js new file mode 100644 index 0000000000..601092ea05 --- /dev/null +++ b/components/progress-ring/private/ring-shape.js @@ -0,0 +1,92 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// Implements the [Progress Ring design pattern](https://lightningdesignsystem.com/components/progress-ring/) in React. +// Based on SLDS v2.4.5 +var PROGRESS_RING_SHAPE = 'SLDSProgressRingShape'; +var propTypes = { + /** + * HTML id for component. + */ + id: _propTypes.default.string, + + /** + * CSS class names to be added to the container element. `array`, `object`, or `string` are accepted. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Decimal percentage drain of the ring [0.0 - 1.0] + */ + fillPercentDecimal: _propTypes.default.number +}; +var defaultProps = { + fillPercentDecimal: 0 +}; +/** + * Generates the string for the D value of the SVG path + * @param isLong {number} a binary flag if the arc should 'take the long path' (used for > 50% fill) + * @param arcX {decimal} the arc's x position + * @param arcY {decimal} the arc's y position + */ + +var getD = function getD(isLong, arcX, arcY) { + return "M 1 0 A 1 1 0 ".concat(isLong, " 1 ").concat(arcX, " ").concat(arcY, " L 0 0"); +}; +/** + * Calculates the fill part of the ring + * @param fillPercent {decimal} Decimal percentage that represents the amount of the ring which is filled with color. + */ + + +var calculateD = function calculateD(fillPercent) { + var isLong = fillPercent > 0.5 ? 1 : 0; + var arcX = Math.cos(2 * Math.PI * fillPercent); + var arcY = Math.sin(2 * Math.PI * fillPercent); + return getD(isLong, arcX, arcY); +}; +/** + * Displays the progress ring shape. + */ + + +var ProgressRingShape = function ProgressRingShape(props) { + return _react.default.createElement("div", { + id: props.id, + className: (0, _classnames.default)('slds-progress-ring', props.className) + }, _react.default.createElement("div", { + className: "slds-progress-ring__progress", + role: "progressbar", + "aria-valuemin": "0", + "aria-valuemax": "100", + "aria-valuenow": props.fillPercentDecimal * 100 + }, _react.default.createElement("svg", { + viewBox: "-1 -1 2 2" + }, _react.default.createElement("path", { + className: "slds-progress-ring__path", + d: calculateD(props.fillPercentDecimal) + }))), _react.default.createElement("div", { + className: "slds-progress-ring__content" + }, props.children)); +}; + +ProgressRingShape.displayName = PROGRESS_RING_SHAPE; +ProgressRingShape.propTypes = propTypes; +ProgressRingShape.defaultProps = defaultProps; +var _default = ProgressRingShape; +exports.default = _default; \ No newline at end of file diff --git a/components/radio-button-group/__docs__/site-stories.js b/components/radio-button-group/__docs__/site-stories.js new file mode 100644 index 0000000000..c2ed71cd75 --- /dev/null +++ b/components/radio-button-group/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/radio-button-group/__examples__/base.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/radio-button-group/__docs__/storybook-stories.js b/components/radio-button-group/__docs__/storybook-stories.js new file mode 100644 index 0000000000..48bb23bd9e --- /dev/null +++ b/components/radio-button-group/__docs__/storybook-stories.js @@ -0,0 +1,135 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _radioButtonGroup = _interopRequireDefault(require("../../radio-button-group")); + +var _radio = _interopRequireDefault(require("../../radio-button-group/radio")); + +var _constants = require("../../../utilities/constants"); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var RadioButtonGroupExample = +/*#__PURE__*/ +function (_React$Component) { + _inherits(RadioButtonGroupExample, _React$Component); + + function RadioButtonGroupExample(props) { + var _this; + + _classCallCheck(this, RadioButtonGroupExample); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(RadioButtonGroupExample).call(this, props)); + _this.state = { + checked: 'Tue' + }; + _this.onChange = _this.onChange.bind(_assertThisInitialized(_this)); + return _this; + } + + _createClass(RadioButtonGroupExample, [{ + key: "onChange", + value: function onChange(event) { + this.setState({ + checked: event.target.value + }); + (0, _addonActions.action)('onChange')(event); + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']; + return _react.default.createElement("div", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, this.props.heading), _react.default.createElement(_radioButtonGroup.default, { + labels: this.props.labels, + onChange: this.onChange, + disabled: this.props.disabled, + required: this.props.required + }, days.map(function (day) { + return _react.default.createElement(_radio.default, { + key: day, + label: day, + value: day, + checked: _this2.state.checked === day, + variant: "button-group" + }); + }))); + } + }]); + + return RadioButtonGroupExample; +}(_react.default.Component); + +RadioButtonGroupExample.propTypes = { + labels: _propTypes.default.shape({ + error: _propTypes.default.string, + label: _propTypes.default.string + }), + disabled: _propTypes.default.bool, + required: _propTypes.default.bool, + heading: _propTypes.default.string +}; +RadioButtonGroupExample.defaultProps = { + labels: { + label: 'Day of week' + } +}; +(0, _react2.storiesOf)(_constants.RADIO_BUTTON_GROUP, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base', function () { + return _react.default.createElement(RadioButtonGroupExample, { + heading: "Base" + }); +}).add('Disabled', function () { + return _react.default.createElement(RadioButtonGroupExample, { + heading: "Disabled", + disabled: true + }); +}).add('Required', function () { + return _react.default.createElement(RadioButtonGroupExample, { + heading: "Required", + required: true + }); +}).add('Error', function () { + return _react.default.createElement(RadioButtonGroupExample, { + heading: "Error", + labels: { + label: 'Day of week', + error: 'There is an error' + } + }); +}).add('Docs site Base', function () { + return _react.default.createElement(_base.default, null); +}); \ No newline at end of file diff --git a/components/radio-button-group/__examples__/base.js b/components/radio-button-group/__examples__/base.js new file mode 100644 index 0000000000..484e944d63 --- /dev/null +++ b/components/radio-button-group/__examples__/base.js @@ -0,0 +1,109 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _radioButtonGroup = _interopRequireDefault(require("../../../../components/radio-button-group")); + +var _radio = _interopRequireDefault(require("../../../../components/radio-button-group/radio")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + checked: 'Tue' + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + var days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']; + var labels = { + label: 'Day of week' + }; + + if (this.props.errorLabel) { + labels.error = this.props.errorLabel; + } + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement(_radioButtonGroup.default, { + labels: labels, + onChange: function onChange(event) { + return _this2.setState({ + checked: event.target.value + }); + }, + disabled: this.props.disabled, + required: this.props.required, + name: this.props.name, + errorId: this.props.errorId + }, days.map(function (day) { + return _react.default.createElement(_radio.default, { + key: day, + id: day, + label: day, + value: day, + checked: _this2.state.checked === day, + variant: "button-group" + }); + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.propTypes = { + disabled: _propTypes.default.bool, + required: _propTypes.default.bool, + name: _propTypes.default.string, + errorId: _propTypes.default.string, + errorLabel: _propTypes.default.string +}; +Example.displayName = 'RadioButtonGroupExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/radio-button-group/docs.json b/components/radio-button-group/docs.json new file mode 100644 index 0000000000..357e36c894 --- /dev/null +++ b/components/radio-button-group/docs.json @@ -0,0 +1,11 @@ +{ + "component": "radio-button-group", + "status": "prod", + "display-name": "Radio Button Groups", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/radio-button-group", + "url-slug": "radio-button-groups" +} \ No newline at end of file diff --git a/components/radio-button-group/index.js b/components/radio-button-group/index.js new file mode 100644 index 0000000000..5c4e3426d7 --- /dev/null +++ b/components/radio-button-group/index.js @@ -0,0 +1,183 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * **Assistive text for accessibility** + * * `label`: This label appears in the legend. + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string + }), + + /** + * Children are expected to be Radio components. + */ + children: _propTypes.default.node.isRequired, + + /** + * Custom CSS classes added to `slds-radio_button-group` node. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * **Text labels for internationalization** + * This object is merged with the default props object on every render. + * * `error`: Message to display when any of Checkboxes are in an error state. + * * `label`: This label appears above the button group. + */ + labels: _propTypes.default.shape({ + error: _propTypes.default.string, + label: _propTypes.default.string + }), + + /** + * This event fires when the radio selection changes. + */ + onChange: _propTypes.default.func, + + /** + * Disable all radio inputs. + */ + disabled: _propTypes.default.bool, + + /** + * Adds an indicator that this field is required. + */ + required: _propTypes.default.bool, + + /** + * The name of this radio group. + */ + name: _propTypes.default.string, + + /** + * The ID of the error message, for linking to radio inputs with aria-describedby. + */ + errorId: _propTypes.default.string +}; +var defaultProps = { + labels: {}, + assistiveText: {} +}; +/** + * A styled select list that can have a single entry checked at any one time. + * The RadioButtonGroup component wraps [Radio](/components/radios) components, which should be used as children. + */ + +var RadioButtonGroup = +/*#__PURE__*/ +function (_React$Component) { + _inherits(RadioButtonGroup, _React$Component); + + function RadioButtonGroup(props) { + var _this; + + _classCallCheck(this, RadioButtonGroup); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(RadioButtonGroup).call(this, props)); // Merge objects of strings with their default object + + _this.labels = _this.props.labels ? (0, _lodash.default)({}, defaultProps.labels, _this.props.labels) : defaultProps.labels; + _this.generatedName = _shortid.default.generate(); + _this.generatedErrorId = _this.labels.error ? _shortid.default.generate() : null; + return _this; + } + + _createClass(RadioButtonGroup, [{ + key: "getErrorId", + value: function getErrorId() { + if (this.hasError()) { + return this.props.errorId || this.generatedErrorId; + } + + return undefined; + } + }, { + key: "getName", + value: function getName() { + return this.props.name || this.generatedName; + } + }, { + key: "hasError", + value: function hasError() { + return !!this.labels.error; + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var children = _react.default.Children.map(this.props.children, function (child) { + return _react.default.cloneElement(child, { + name: _this2.getName(), + onChange: _this2.props.onChange, + 'aria-describedby': _this2.getErrorId(), + disabled: _this2.props.disabled + }); + }); + + return _react.default.createElement("fieldset", { + className: (0, _classnames.default)('slds-form-element', { + 'slds-has-error': this.labels.error + }) + }, _react.default.createElement("legend", { + className: (0, _classnames.default)('slds-form-element__legend', 'slds-form-element__label', this.props.assistiveText.label ? 'slds-assistive-text' : '') + }, this.props.required ? _react.default.createElement("abbr", { + className: "slds-required", + title: "required" + }, "*") : null, this.props.assistiveText.label ? this.props.assistiveText.label : this.labels.label), _react.default.createElement("div", { + className: (0, _classnames.default)('slds-form-element__control', this.props.className) + }, _react.default.createElement("div", { + style: this.props.style, + className: "slds-radio_button-group" + }, children), this.labels.error ? _react.default.createElement("div", { + id: this.getErrorId(), + className: "slds-form-element__help" + }, this.labels.error) : null)); + } + }]); + + return RadioButtonGroup; +}(_react.default.Component); + +RadioButtonGroup.displayName = _constants.RADIO_BUTTON_GROUP; +RadioButtonGroup.propTypes = propTypes; +RadioButtonGroup.defaultProps = defaultProps; +var _default = RadioButtonGroup; +exports.default = _default; \ No newline at end of file diff --git a/components/radio-button-group/radio.js b/components/radio-button-group/radio.js new file mode 100644 index 0000000000..d2a5e09c3b --- /dev/null +++ b/components/radio-button-group/radio.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _index = _interopRequireDefault(require("../radio/index")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Alias +var _default = _index.default; +exports.default = _default; \ No newline at end of file diff --git a/components/radio-group/__docs__/site-stories.js b/components/radio-group/__docs__/site-stories.js new file mode 100644 index 0000000000..d2d3338346 --- /dev/null +++ b/components/radio-group/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/radio-group/__examples__/base.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/radio-group/__docs__/storybook-stories.js b/components/radio-group/__docs__/storybook-stories.js new file mode 100644 index 0000000000..f8c2dd696d --- /dev/null +++ b/components/radio-group/__docs__/storybook-stories.js @@ -0,0 +1,134 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _radioGroup = _interopRequireDefault(require("../../radio-group")); + +var _radio = _interopRequireDefault(require("../../radio-group/radio")); + +var _constants = require("../../../utilities/constants"); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var RadioGroupExample = +/*#__PURE__*/ +function (_React$Component) { + _inherits(RadioGroupExample, _React$Component); + + function RadioGroupExample(props) { + var _this; + + _classCallCheck(this, RadioGroupExample); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(RadioGroupExample).call(this, props)); + _this.state = {}; + _this.onChange = _this.onChange.bind(_assertThisInitialized(_this)); + return _this; + } + + _createClass(RadioGroupExample, [{ + key: "onChange", + value: function onChange(event) { + this.setState({ + checked: event.target.value + }); + (0, _addonActions.action)('onChange')(event); + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var values = ['Radio Label One', 'Radio Label Two']; + return _react.default.createElement("div", null, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, this.props.heading), _react.default.createElement(_radioGroup.default, { + labels: this.props.labels, + onChange: this.onChange, + disabled: this.props.disabled, + required: this.props.required + }, values.map(function (value) { + return _react.default.createElement(_radio.default, { + key: value, + id: value, + label: value, + value: value, + checked: _this2.state.checked === value, + variant: "base" + }); + }))); + } + }]); + + return RadioGroupExample; +}(_react.default.Component); + +RadioGroupExample.propTypes = { + labels: _propTypes.default.shape({ + error: _propTypes.default.string, + label: _propTypes.default.string + }), + disabled: _propTypes.default.bool, + required: _propTypes.default.bool, + heading: _propTypes.default.string +}; +RadioGroupExample.defaultProps = { + labels: { + label: 'Radio Group Label' + } +}; +(0, _react2.storiesOf)(_constants.RADIO_GROUP, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base', function () { + return _react.default.createElement(RadioGroupExample, { + heading: "Base" + }); +}).add('Disabled', function () { + return _react.default.createElement(RadioGroupExample, { + heading: "Disabled", + disabled: true + }); +}).add('Required', function () { + return _react.default.createElement(RadioGroupExample, { + heading: "Required", + required: true + }); +}).add('Error', function () { + return _react.default.createElement(RadioGroupExample, { + heading: "Error", + labels: { + label: 'Radio Group Label', + error: 'There is an error' + } + }); +}).add('Docs site Base', function () { + return _react.default.createElement(_base.default, null); +}); \ No newline at end of file diff --git a/components/radio-group/__examples__/base.js b/components/radio-group/__examples__/base.js new file mode 100644 index 0000000000..56c81a79b0 --- /dev/null +++ b/components/radio-group/__examples__/base.js @@ -0,0 +1,103 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _radioGroup = _interopRequireDefault(require("../../../../components/radio-group")); + +var _radio = _interopRequireDefault(require("../../../../components/radio-group/radio")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = {}; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + var values = ['Radio Label One', 'Radio Label Two']; + var labels = { + label: 'Radio Group Label' + }; + + if (this.props.errorLabel) { + labels.error = this.props.errorLabel; + } + + return _react.default.createElement("div", null, _react.default.createElement(_radioGroup.default, { + labels: labels, + onChange: function onChange(event) { + return _this2.setState({ + checked: event.target.value + }); + }, + disabled: this.props.disabled, + required: this.props.required, + name: this.props.name, + errorId: this.props.errorId + }, values.map(function (value) { + return _react.default.createElement(_radio.default, { + key: value, + id: value, + label: value, + value: value, + checked: _this2.state.checked === value, + variant: "base" + }); + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.propTypes = { + disabled: _propTypes.default.bool, + required: _propTypes.default.bool, + name: _propTypes.default.string, + errorId: _propTypes.default.string, + errorLabel: _propTypes.default.string +}; +Example.displayName = 'RadioGroupExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/radio-group/docs.json b/components/radio-group/docs.json new file mode 100644 index 0000000000..a3502394ef --- /dev/null +++ b/components/radio-group/docs.json @@ -0,0 +1,11 @@ +{ + "component": "radio-group", + "status": "prod", + "display-name": "Radio Groups", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/radio-group", + "url-slug": "radio-groups" +} \ No newline at end of file diff --git a/components/radio-group/index.js b/components/radio-group/index.js new file mode 100644 index 0000000000..379fce75c8 --- /dev/null +++ b/components/radio-group/index.js @@ -0,0 +1,171 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * Children are expected to be Radio components. + */ + children: _propTypes.default.node.isRequired, + + /** + * Custom CSS classes added to the node. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * **Text labels for internationalization** + * This object is merged with the default props object on every render. + * * `error`: Message to display when any of Checkboxes are in an error state. + * * `label`: This label appears above the radio group. + */ + labels: _propTypes.default.shape({ + error: _propTypes.default.string, + label: _propTypes.default.string + }), + + /** + * This event fires when the radio selection changes. + */ + onChange: _propTypes.default.func, + + /** + * Disable all radio inputs. + */ + disabled: _propTypes.default.bool, + + /** + * Adds an indicator that this field is required. + */ + required: _propTypes.default.bool, + + /** + * The name of this radio group. + */ + name: _propTypes.default.string, + + /** + * The ID of the error message, for linking to radio inputs with aria-describedby. + */ + errorId: _propTypes.default.string +}; +var defaultProps = { + labels: {} +}; +/** + * A styled select list that can have a single entry checked at any one time. + * The RadioGroup component wraps [Radio](/components/radios) components, which should be used as children. + */ + +var RadioGroup = +/*#__PURE__*/ +function (_React$Component) { + _inherits(RadioGroup, _React$Component); + + function RadioGroup(props) { + var _this; + + _classCallCheck(this, RadioGroup); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(RadioGroup).call(this, props)); // Merge objects of strings with their default object + + _this.labels = _this.props.labels ? (0, _lodash.default)({}, defaultProps.labels, _this.props.labels) : defaultProps.labels; + _this.generatedName = _shortid.default.generate(); + _this.generatedErrorId = _this.labels.error ? _shortid.default.generate() : null; + return _this; + } + + _createClass(RadioGroup, [{ + key: "getErrorId", + value: function getErrorId() { + if (this.hasError()) { + return this.props.errorId || this.generatedErrorId; + } + + return undefined; + } + }, { + key: "getName", + value: function getName() { + return this.props.name || this.generatedName; + } + }, { + key: "hasError", + value: function hasError() { + return !!this.labels.error; + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var children = _react.default.Children.map(this.props.children, function (child) { + return _react.default.cloneElement(child, { + name: _this2.getName(), + onChange: _this2.props.onChange, + 'aria-describedby': _this2.getErrorId(), + disabled: _this2.props.disabled + }); + }); + + return _react.default.createElement("fieldset", { + className: (0, _classnames.default)('slds-form-element', { + 'slds-has-error': this.labels.error + }) + }, _react.default.createElement("legend", { + className: "slds-form-element__legend slds-form-element__label" + }, this.props.required ? _react.default.createElement("abbr", { + className: "slds-required", + title: "required" + }, "*") : null, this.labels.label), _react.default.createElement("div", { + className: (0, _classnames.default)('slds-form-element__control', this.props.className) + }, children, this.labels.error ? _react.default.createElement("div", { + id: this.getErrorId(), + className: "slds-form-element__help" + }, this.labels.error) : null)); + } + }]); + + return RadioGroup; +}(_react.default.Component); + +RadioGroup.displayName = _constants.RADIO_GROUP; +RadioGroup.propTypes = propTypes; +RadioGroup.defaultProps = defaultProps; +var _default = RadioGroup; +exports.default = _default; \ No newline at end of file diff --git a/components/radio-group/radio.js b/components/radio-group/radio.js new file mode 100644 index 0000000000..d2a5e09c3b --- /dev/null +++ b/components/radio-group/radio.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _index = _interopRequireDefault(require("../radio/index")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Alias +var _default = _index.default; +exports.default = _default; \ No newline at end of file diff --git a/components/radio/__docs__/site-stories.js b/components/radio/__docs__/site-stories.js new file mode 100644 index 0000000000..38eb0d0239 --- /dev/null +++ b/components/radio/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/radio/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/radio/__examples__/disabled.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/radio/__docs__/storybook-stories.js b/components/radio/__docs__/storybook-stories.js new file mode 100644 index 0000000000..da47b69ca2 --- /dev/null +++ b/components/radio/__docs__/storybook-stories.js @@ -0,0 +1,70 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _react2 = require("@storybook/react"); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _constants = require("../../../utilities/constants"); + +var _disabled = _interopRequireDefault(require("../__examples__/disabled")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var RadioExample = +/*#__PURE__*/ +function (_React$Component) { + _inherits(RadioExample, _React$Component); + + function RadioExample() { + _classCallCheck(this, RadioExample); + + return _possibleConstructorReturn(this, _getPrototypeOf(RadioExample).apply(this, arguments)); + } + + _createClass(RadioExample, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_default.default, null)); + } + }]); + + return RadioExample; +}(_react.default.Component); + +(0, _react2.storiesOf)(_constants.RADIO, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base', function () { + return _react.default.createElement(RadioExample, { + heading: "Base" + }); +}).add('Docs site Disabled', function () { + return _react.default.createElement(_disabled.default, null); +}); \ No newline at end of file diff --git a/components/radio/__examples__/default.js b/components/radio/__examples__/default.js new file mode 100644 index 0000000000..0c1909080a --- /dev/null +++ b/components/radio/__examples__/default.js @@ -0,0 +1,63 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _radio = _interopRequireDefault(require("../../../../components/radio")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_radio.default, { + id: "radioId1", + label: "Radio Label" + }); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'RadioExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/radio/__examples__/disabled.js b/components/radio/__examples__/disabled.js new file mode 100644 index 0000000000..d26c23f905 --- /dev/null +++ b/components/radio/__examples__/disabled.js @@ -0,0 +1,64 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _radio = _interopRequireDefault(require("../../../../components/radio")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_radio.default, { + id: "radioId2", + label: "Radio Label", + disabled: true + }); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'RadioExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/radio/docs.json b/components/radio/docs.json new file mode 100644 index 0000000000..1c90bff97e --- /dev/null +++ b/components/radio/docs.json @@ -0,0 +1,11 @@ +{ + "component": "radio", + "status": "prod", + "display-name": "Radios", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/radio-group/", + "url-slug": "radios" +} \ No newline at end of file diff --git a/components/radio/index.js b/components/radio/index.js new file mode 100644 index 0000000000..4e35b6027c --- /dev/null +++ b/components/radio/index.js @@ -0,0 +1,242 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _keyCode = _interopRequireDefault(require("../../utilities/key-code")); + +var _constants = require("../../utilities/constants"); + +var _getDataProps = _interopRequireDefault(require("../../utilities/get-data-props")); + +var _swatch = _interopRequireDefault(require("../../components/color-picker/private/swatch")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * The ID of an element that describes this radio input. Often used for error messages. + */ + 'aria-describedby': _propTypes.default.string, + + /** + * This is a controlled component. This radio is checked according to this value. + */ + checked: _propTypes.default.bool, + + /** + * Class name to be passed to radio input wrapper ( `span` element) + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]) + /** + * This is the initial value of an uncontrolled form element and is present only to provide compatibility + * with hybrid framework applications that are not entirely React. It should only be used in an application + * without centralized state (Redux, Flux). "Controlled components" with centralized state is highly recommended. + * See [Code Overview](https://github.com/salesforce/design-system-react/blob/master/docs/codebase-overview.md#controlled-and-uncontrolled-components) for more information. + */ + , + defaultChecked: _propTypes.default.bool, + + /** + * Disable this radio input. + */ + disabled: _propTypes.default.bool, + + /** + * A unique ID that is used to associating a label to the `input` element. This ID is added to the `input` element. + */ + id: _propTypes.default.string, + + /** + * The string or element that is shown as both the title and the label for this radio input. + */ + label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]).isRequired, + + /** + * The name of the radio input group. + */ + name: _propTypes.default.string, + + /** + * This event fires when the radio selection changes. Passes in `event, { checked }`. + */ + onChange: _propTypes.default.func, + + /** + * The value of this radio input. + */ + value: _propTypes.default.string, + + /** + * Variant of the Radio button. Base is the default and button-group makes the radio button look like a normal button (should be a child of ). + */ + variant: _propTypes.default.oneOf(['base', 'button-group', 'swatch']), + + /** + * Ref callback that will pass in the radio's `input` tag + */ + refs: _propTypes.default.shape({ + input: _propTypes.default.func + }) +}; +var defaultProps = { + variant: 'base' +}; +/** + * A radio input that can have a single input checked at any one time. Radios should be wrapped with + * a [RadioGroup](/components/radio-group) or [RadioButtonGroup](/components/radio-button-group) + */ + +var Radio = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Radio, _React$Component); + + function Radio(props) { + var _this; + + _classCallCheck(this, Radio); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Radio).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (event, preventDuplicateChangeEvent) { + if (!_this.preventDuplicateChangeEvent) { + _this.preventDuplicateChangeEvent = Boolean(preventDuplicateChangeEvent); + + if (_this.props.onChange) { + _this.props.onChange(event, { + checked: !_this.props.checked + }); + } + } else { + _this.preventDuplicateChangeEvent = false; + } + }); + + _this.generatedId = _shortid.default.generate(); + _this.preventDuplicateChangeEvent = false; + return _this; + } + + _createClass(Radio, [{ + key: "getId", + value: function getId() { + return this.props.id || this.generatedId; + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var dataProps = (0, _getDataProps.default)(this.props); + var radio; + + if (this.props.variant === 'swatch') { + radio = _react.default.createElement("label", { + style: { + border: '1px' + }, + className: "slds-radio_button__label", + htmlFor: this.getId() + }, _react.default.createElement("span", null, _react.default.createElement(_swatch.default, { + label: this.props.label, + style: this.props.style, + color: this.props.value + }))); + } else if (this.props.variant === 'button-group') radio = _react.default.createElement("label", { + className: "slds-radio_button__label", + htmlFor: this.getId() + }, _react.default.createElement("span", { + className: "slds-radio_faux" + }, this.props.label));else { + radio = _react.default.createElement("label", { + className: "slds-radio__label", + htmlFor: this.getId() + }, _react.default.createElement("span", { + className: "slds-radio_faux" + }), _react.default.createElement("span", { + className: "slds-form-element__label" + }, this.props.label)); + } + + return _react.default.createElement("span", { + className: (0, _classnames.default)({ + 'slds-radio': this.props.variant === 'base' || this.props.variant === 'swatch', + 'slds-button slds-radio_button': this.props.variant === 'button-group' + }, this.props.className) + }, _react.default.createElement("input", _extends({ + type: "radio", + id: this.getId(), + name: this.props.name, + value: this.props.value, + checked: this.props.checked, + defaultChecked: this.props.defaultChecked, + onChange: function onChange(event) { + _this2.handleChange(event); + }, + onClick: function onClick(event) { + if (_this2.props.checked && _this2.props.deselectable) { + _this2.handleChange(event); + } + }, + onKeyPress: function onKeyPress(event) { + var charCode = event.charCode; + + if (charCode === _keyCode.default.SPACE && _this2.props.checked && _this2.props.deselectable) { + _this2.handleChange(event, true); + } else if (charCode === _keyCode.default.ENTER && _this2.props.checked && _this2.props.deselectable || !_this2.props.checked) { + _this2.handleChange(event); + } + }, + "aria-describedby": this.props['aria-describedby'], + disabled: this.props.disabled + }, dataProps, { + ref: function ref(input) { + if (_this2.props.refs && _this2.props.refs.input) { + _this2.props.refs.input(input); + } + } + })), radio); + } + }]); + + return Radio; +}(_react.default.Component); + +Radio.displayName = _constants.RADIO; +Radio.propTypes = propTypes; +Radio.defaultProps = defaultProps; +var _default = Radio; +exports.default = _default; \ No newline at end of file diff --git a/components/scoped-notification/__docs__/__snapshots__/storybook-stories.storyshot b/components/scoped-notification/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..640140127c --- /dev/null +++ b/components/scoped-notification/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,123 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSScopedNotification Base 1`] = ` +
    +
    +
    + + + + +
    +
    +

    + It looks as if duplicates exist for this lead. + + + View Duplicates. + + +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSScopedNotification Dark 1`] = ` +
    +
    +
    + + + + +
    +
    +

    + It looks as if duplicates exist for this lead. + + + View Duplicates. + +

    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSScopedNotification Light 1`] = ` +
    +
    +
    + + + + +
    +
    +

    + It looks as if duplicates exist for this lead. + + + View Duplicates. + + +

    +
    +
    +
    +`; diff --git a/components/scoped-notification/__docs__/site-stories.js b/components/scoped-notification/__docs__/site-stories.js new file mode 100644 index 0000000000..ba75963922 --- /dev/null +++ b/components/scoped-notification/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/scoped-notification/__examples__/light.jsx'), require('raw-loader!@salesforce/design-system-react/components/scoped-notification/__examples__/dark.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/scoped-notification/__docs__/storybook-stories.js b/components/scoped-notification/__docs__/storybook-stories.js new file mode 100644 index 0000000000..6606be84de --- /dev/null +++ b/components/scoped-notification/__docs__/storybook-stories.js @@ -0,0 +1,27 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +var _light = _interopRequireDefault(require("../__examples__/light")); + +var _dark = _interopRequireDefault(require("../__examples__/dark")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.SCOPED_NOTIFICATION, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base', function () { + return _react.default.createElement(_base.default, null); +}).add('Light', function () { + return _react.default.createElement(_light.default, null); +}).add('Dark', function () { + return _react.default.createElement(_dark.default, null); +}); \ No newline at end of file diff --git a/components/scoped-notification/__examples__/base.js b/components/scoped-notification/__examples__/base.js new file mode 100644 index 0000000000..7e90b09cde --- /dev/null +++ b/components/scoped-notification/__examples__/base.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _scopedNotification = _interopRequireDefault(require("../../../../components/scoped-notification")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_scopedNotification.default, null, _react.default.createElement("p", null, "It looks as if duplicates exist for this lead.", ' ', _react.default.createElement("a", { + href: "javascript:void(0);" + }, "View Duplicates."), ' '))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ScopedNotificationLight'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/scoped-notification/__examples__/dark.js b/components/scoped-notification/__examples__/dark.js new file mode 100644 index 0000000000..82283f2448 --- /dev/null +++ b/components/scoped-notification/__examples__/dark.js @@ -0,0 +1,64 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _scopedNotification = _interopRequireDefault(require("../../../../components/scoped-notification")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_scopedNotification.default, { + theme: "dark" + }, _react.default.createElement("p", null, "It looks as if duplicates exist for this lead.", ' ', _react.default.createElement("a", { + href: "javascript:void(0);" + }, "View Duplicates.")))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ScopedNotificationLight'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/scoped-notification/__examples__/light.js b/components/scoped-notification/__examples__/light.js new file mode 100644 index 0000000000..e75c55bfe8 --- /dev/null +++ b/components/scoped-notification/__examples__/light.js @@ -0,0 +1,64 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _scopedNotification = _interopRequireDefault(require("../../../../components/scoped-notification")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_scopedNotification.default, { + theme: "light" + }, _react.default.createElement("p", null, "It looks as if duplicates exist for this lead.", ' ', _react.default.createElement("a", { + href: "javascript:void(0);" + }, "View Duplicates."), ' '))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ScopedNotificationLight'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/scoped-notification/docs.json b/components/scoped-notification/docs.json new file mode 100644 index 0000000000..b4fe8f7bae --- /dev/null +++ b/components/scoped-notification/docs.json @@ -0,0 +1,7 @@ +{ + "component": "scoped-notification", + "status": "prod", + "display-name": "Scoped Notifications", + "SLDS-component-path": "/components/scoped-notification", + "url-slug": "scoped-notifications" +} diff --git a/components/scoped-notification/index.js b/components/scoped-notification/index.js new file mode 100644 index 0000000000..02c5783fd1 --- /dev/null +++ b/components/scoped-notification/index.js @@ -0,0 +1,104 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _icon = _interopRequireDefault(require("../icon")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * CSS classes to be added to tag with `.slds-scoped-notification`. Uses `classNames` [API](https://github.com/JedWatson/classnames). + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Theme for the scoped notification + */ + theme: _propTypes.default.oneOf(['dark', 'light']), + + /** + * Icon for the scoped notification. This is currently limited to the utility set of icons. + */ + iconName: _propTypes.default.string +}; +var defaultProps = { + iconName: 'info' +}; +/** + * A Scoped Notification Component serve advisory information for the user that is not important enough to justify an alert. + */ + +var ScopedNotification = +/*#__PURE__*/ +function (_React$Component) { + _inherits(ScopedNotification, _React$Component); + + function ScopedNotification() { + _classCallCheck(this, ScopedNotification); + + return _possibleConstructorReturn(this, _getPrototypeOf(ScopedNotification).apply(this, arguments)); + } + + _createClass(ScopedNotification, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + className: (0, _classnames.default)("slds-scoped-notification", "slds-media", "slds-media_center", { + 'slds-scoped-notification_light': this.props.theme === 'light', + 'slds-scoped-notification_dark': this.props.theme === 'dark' + }, this.props.className), + role: "status" + }, _react.default.createElement("div", { + className: "slds-media__figure" + }, _react.default.createElement(_icon.default, { + assistiveText: { + icon: this.props.assistiveText && this.props.assistiveText.icon + }, + category: "utility", + name: this.props.iconName, + colorVariant: this.props.theme === 'dark' ? 'base' : undefined, + size: "small" + })), _react.default.createElement("div", { + className: "slds-media__body" + }, this.props.children)); + } + }]); + + return ScopedNotification; +}(_react.default.Component); + +ScopedNotification.displayName = _constants.SCOPED_NOTIFICATION; +ScopedNotification.propTypes = propTypes; +ScopedNotification.defaultProps = defaultProps; +var _default = ScopedNotification; +exports.default = _default; \ No newline at end of file diff --git a/components/settings.js b/components/settings.js new file mode 100644 index 0000000000..827b2565d5 --- /dev/null +++ b/components/settings.js @@ -0,0 +1,52 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _reactModal = _interopRequireDefault(require("react-modal")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* + * The following are component utility methods that aid in global settings. +*/ +var assetsPath = 'assets/'; +var appRoot; +var settings = { + setAssetsPath: function setAssetsPath(path) { + if (path) { + assetsPath = path; + } + }, + getAssetsPath: function getAssetsPath() { + return String(assetsPath); + }, + + /* + * The app element allows you to specify the portion of your app that should be hidden (via aria-hidden) + to prevent assistive technologies such as screenreaders from reading content outside of the content of + your modal. It can be specified in the following ways: + * element + Modal.setAppElement(appElement); + * query selector - uses the first element found if you pass in a class. + Modal.setAppElement('#your-app-element'); + */ + setAppElement: function setAppElement(el) { + if (el) { + appRoot = el; + + _reactModal.default.setAppElement(el); + } + }, + getAppElement: function getAppElement() { + return appRoot; + } +}; +var _default = settings; +exports.default = _default; \ No newline at end of file diff --git a/components/site-stories.js b/components/site-stories.js new file mode 100644 index 0000000000..b9f3f1355b --- /dev/null +++ b/components/site-stories.js @@ -0,0 +1,66 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ + +/* eslint-disable import/no-extraneous-dependencies */ + +/* eslint-disable import/no-unresolved */ +var documentationSiteLiveExamples = { + accordion: require('@salesforce/design-system-react/components/accordion/__docs__/site-stories.js'), + alert: require('@salesforce/design-system-react/components/alert/__docs__/site-stories.js'), + 'app-launcher': require('@salesforce/design-system-react/components/app-launcher/__docs__/site-stories.js'), + avatar: require('@salesforce/design-system-react/components/avatar/__docs__/site-stories.js'), + 'brand-band': require('@salesforce/design-system-react/components/brand-band/__docs__/site-stories.js'), + breadcrumb: require('@salesforce/design-system-react/components/breadcrumb/__docs__/site-stories.js'), + button: require('@salesforce/design-system-react/components/button/__docs__/site-stories.js'), + 'button-group': require('@salesforce/design-system-react/components/button-group/__docs__/site-stories.js'), + 'button-stateful': require('@salesforce/design-system-react/components/button-stateful/__docs__/site-stories.js'), + card: require('@salesforce/design-system-react/components/card/__docs__/site-stories.js'), + carousel: require('@salesforce/design-system-react/components/carousel/__docs__/site-stories.js'), + combobox: require('@salesforce/design-system-react/components/combobox/__docs__/site-stories.js'), + 'color-picker': require('@salesforce/design-system-react/components/color-picker/__docs__/site-stories.js'), + filter: require('@salesforce/design-system-react/components/filter/__docs__/site-stories.js'), + checkbox: require('@salesforce/design-system-react/components/checkbox/__docs__/site-stories.js'), + 'data-table': require('@salesforce/design-system-react/components/data-table/__docs__/site-stories.js'), + 'date-picker': require('@salesforce/design-system-react/components/date-picker/__docs__/site-stories.js'), + 'dynamic-icon': require('@salesforce/design-system-react/components/dynamic-icon/__docs__/site-stories.js'), + icon: require('@salesforce/design-system-react/components/icon/__docs__/site-stories.js'), + illustration: require('@salesforce/design-system-react/components/illustration/__docs__/site-stories.js'), + input: require('@salesforce/design-system-react/components/input/__docs__/site-stories.js'), + textarea: require('@salesforce/design-system-react/components/textarea/__docs__/site-stories.js'), + 'global-header': require('@salesforce/design-system-react/components/global-header/__docs__/site-stories.js'), + 'global-navigation-bar': require('@salesforce/design-system-react/components/global-navigation-bar/__docs__/site-stories.js'), + 'icon-settings': require('@salesforce/design-system-react/components/icon-settings/__docs__/site-stories.js'), + lookup: require('@salesforce/design-system-react/components/lookup/__docs__/site-stories.js'), + 'media-object': require('@salesforce/design-system-react/components/media-object/__docs__/site-stories.js'), + 'menu-dropdown': require('@salesforce/design-system-react/components/menu-dropdown/__docs__/site-stories.js'), + 'menu-picklist': require('@salesforce/design-system-react/components/menu-picklist/__docs__/site-stories.js'), + modal: require('@salesforce/design-system-react/components/modal/__docs__/site-stories.js'), + notification: require('@salesforce/design-system-react/components/notification/__docs__/site-stories.js'), + 'page-header': require('@salesforce/design-system-react/components/page-header/__docs__/site-stories.js'), + panel: require('@salesforce/design-system-react/components/panel/__docs__/site-stories.js'), + pill: require('@salesforce/design-system-react/components/pill/__docs__/site-stories.js'), + 'pill-container': require('@salesforce/design-system-react/components/pill-container/__docs__/site-stories.js'), + popover: require('@salesforce/design-system-react/components/popover/__docs__/site-stories.js'), + 'progress-bar': require('@salesforce/design-system-react/components/progress-bar/__docs__/site-stories.js'), + 'progress-indicator': require('@salesforce/design-system-react/components/progress-indicator/__docs__/site-stories.js'), + 'progress-ring': require('@salesforce/design-system-react/components/progress-ring/__docs__/site-stories.js'), + 'radio-button-group': require('@salesforce/design-system-react/components/radio-button-group/__docs__/site-stories.js'), + 'radio-group': require('@salesforce/design-system-react/components/radio-group/__docs__/site-stories.js'), + radio: require('@salesforce/design-system-react/components/radio/__docs__/site-stories.js'), + tabs: require('@salesforce/design-system-react/components/tabs/__docs__/site-stories.js'), + 'scoped-notification': require('@salesforce/design-system-react/components/scoped-notification/__docs__/site-stories.js'), + slider: require('@salesforce/design-system-react/components/slider/__docs__/site-stories.js'), + spinner: require('@salesforce/design-system-react/components/spinner/__docs__/site-stories.js'), + 'split-view': require('@salesforce/design-system-react/components/split-view/__docs__/site-stories.js'), + 'time-picker': require('@salesforce/design-system-react/components/time-picker/__docs__/site-stories.js'), + toast: require('@salesforce/design-system-react/components/toast/__docs__/site-stories.js'), + tooltip: require('@salesforce/design-system-react/components/tooltip/__docs__/site-stories.js'), + tree: require('@salesforce/design-system-react/components/tree/__docs__/site-stories.js'), + 'vertical-navigation': require('@salesforce/design-system-react/components/vertical-navigation/__docs__/site-stories.js') +}; +module.exports = documentationSiteLiveExamples; \ No newline at end of file diff --git a/components/slider/__docs__/site-stories.js b/components/slider/__docs__/site-stories.js new file mode 100644 index 0000000000..3b17163d00 --- /dev/null +++ b/components/slider/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/slider/__examples__/base.jsx'), require('raw-loader!@salesforce/design-system-react/components/slider/__examples__/disabled.jsx'), require('raw-loader!@salesforce/design-system-react/components/slider/__examples__/error.jsx'), require('raw-loader!@salesforce/design-system-react/components/slider/__examples__/sizes.jsx'), require('raw-loader!@salesforce/design-system-react/components/slider/__examples__/vertical.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/slider/__docs__/storybook-stories.js b/components/slider/__docs__/storybook-stories.js new file mode 100644 index 0000000000..f2ffe9a7a6 --- /dev/null +++ b/components/slider/__docs__/storybook-stories.js @@ -0,0 +1,51 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +var _disabled = _interopRequireDefault(require("../__examples__/disabled")); + +var _error = _interopRequireDefault(require("../__examples__/error")); + +var _vertical = _interopRequireDefault(require("../__examples__/vertical")); + +var _sizesXSmall = _interopRequireDefault(require("../__examples__/sizes-x-small")); + +var _sizesSmall = _interopRequireDefault(require("../__examples__/sizes-small")); + +var _sizesMedium = _interopRequireDefault(require("../__examples__/sizes-medium")); + +var _sizesLarge = _interopRequireDefault(require("../__examples__/sizes-large")); + +var _sizes = _interopRequireDefault(require("../__examples__/sizes")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.SLIDER, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Slider', function () { + return _react.default.createElement(_base.default, null); +}).add('Disabled', function () { + return _react.default.createElement(_disabled.default, null); +}).add('Error', function () { + return _react.default.createElement(_error.default, null); +}).add('Vertical', function () { + return _react.default.createElement(_vertical.default, null); +}).add('Size: X-Small', function () { + return _react.default.createElement(_sizesXSmall.default, null); +}).add('Size: Small', function () { + return _react.default.createElement(_sizesSmall.default, null); +}).add('Size: Medium', function () { + return _react.default.createElement(_sizesMedium.default, null); +}).add('Size: Large', function () { + return _react.default.createElement(_sizesLarge.default, null); +}).add('Docs site Sizes', function () { + return _react.default.createElement(_sizes.default, null); +}); \ No newline at end of file diff --git a/components/slider/__examples__/base.js b/components/slider/__examples__/base.js new file mode 100644 index 0000000000..fa30fe98e9 --- /dev/null +++ b/components/slider/__examples__/base.js @@ -0,0 +1,147 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _slider = _interopRequireDefault(require("../../../../components/slider")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var DemoSlider = +/*#__PURE__*/ +function (_React$Component) { + _inherits(DemoSlider, _React$Component); + + function DemoSlider() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, DemoSlider); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DemoSlider)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + value: _this.props.value + }); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (event, _ref) { + var value = _ref.value; + + _this.setState({ + value: value + }); + }); + + return _this; + } + + _createClass(DemoSlider, [{ + key: "render", + value: function render() { + return _react.default.createElement(_slider.default, _extends({}, this.props, { + value: this.state.value, + onChange: this.handleChange + })); + } + }]); + + return DemoSlider; +}(_react.default.Component); + +_defineProperty(DemoSlider, "displayName", 'DemoSlider'); + +var Example = +/*#__PURE__*/ +function (_React$Component2) { + _inherits(Example, _React$Component2); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("section", null, _react.default.createElement("ol", null, _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "1. Base Input with label"), _react.default.createElement(DemoSlider, { + id: "base-id", + label: "My Label", + value: 0 + })), _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "2. Base Input with no label (assistive text)"), _react.default.createElement(DemoSlider, { + id: "assistiveText-id", + assistiveText: { + label: 'My Label' + }, + value: 0 + })), _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "3. Base Input with min and max."), _react.default.createElement(DemoSlider, { + id: "min-max-id", + label: "My Label", + min: 0, + max: 400, + value: 200 + })), _react.default.createElement("li", { + className: "slds-p-bottom_large" + }, _react.default.createElement("h1", { + className: "slds-text-title_caps slds-p-vertical_medium" + }, "4. Base Input with min, max and step."), _react.default.createElement(DemoSlider, { + id: "min-max-step-id", + label: "My Label", + min: 0, + max: 400, + step: 100, + value: 200 + })))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'SliderExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/slider/__examples__/disabled.js b/components/slider/__examples__/disabled.js new file mode 100644 index 0000000000..65b65073d0 --- /dev/null +++ b/components/slider/__examples__/disabled.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _slider = _interopRequireDefault(require("../../../../components/slider")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_slider.default, { + id: "disabled-id", + label: "Slider Label", + disabled: true + }); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'SliderExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/slider/__examples__/error.js b/components/slider/__examples__/error.js new file mode 100644 index 0000000000..5b1a05e35a --- /dev/null +++ b/components/slider/__examples__/error.js @@ -0,0 +1,63 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _slider = _interopRequireDefault(require("../../../../components/slider")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_slider.default, { + id: "error-id", + label: "Slider Label", + errorText: "There is a problem with this field", + "aria-describedby": "error message" + }); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'SliderExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/slider/__examples__/sizes-large.js b/components/slider/__examples__/sizes-large.js new file mode 100644 index 0000000000..e9090789ec --- /dev/null +++ b/components/slider/__examples__/sizes-large.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _slider = _interopRequireDefault(require("../../../../components/slider")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_slider.default, { + id: "large-id", + label: "Slider Label", + size: "large" + }); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'SliderExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/slider/__examples__/sizes-medium.js b/components/slider/__examples__/sizes-medium.js new file mode 100644 index 0000000000..76ceb67703 --- /dev/null +++ b/components/slider/__examples__/sizes-medium.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _slider = _interopRequireDefault(require("../../../../components/slider")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_slider.default, { + id: "medium-id", + label: "Slider Label", + size: "medium" + }); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'SliderExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/slider/__examples__/sizes-small.js b/components/slider/__examples__/sizes-small.js new file mode 100644 index 0000000000..dbb18f977a --- /dev/null +++ b/components/slider/__examples__/sizes-small.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _slider = _interopRequireDefault(require("../../../../components/slider")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_slider.default, { + id: "small-id", + label: "Slider Label", + size: "small" + }); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'SliderExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/slider/__examples__/sizes-x-small.js b/components/slider/__examples__/sizes-x-small.js new file mode 100644 index 0000000000..54630a7d29 --- /dev/null +++ b/components/slider/__examples__/sizes-x-small.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _slider = _interopRequireDefault(require("../../../../components/slider")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_slider.default, { + id: "x-small-id", + label: "Slider Label", + size: "x-small" + }); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'SliderExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/slider/__examples__/sizes.js b/components/slider/__examples__/sizes.js new file mode 100644 index 0000000000..ca3f9997e9 --- /dev/null +++ b/components/slider/__examples__/sizes.js @@ -0,0 +1,84 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _slider = _interopRequireDefault(require("../../../../components/slider")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + className: "slds-grid slds-grid_pull-padded slds-grid_vertical-align-center" + }, _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_slider.default, { + id: "x-small-id", + label: "Slider Label", + size: "x-small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_slider.default, { + id: "small-id", + label: "Slider Label", + size: "small" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_slider.default, { + id: "medium-id", + label: "Slider Label", + size: "medium" + })), _react.default.createElement("div", { + className: "slds-col_padded" + }, _react.default.createElement(_slider.default, { + id: "large-id", + label: "Slider Label", + size: "large" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'SliderExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/slider/__examples__/vertical.js b/components/slider/__examples__/vertical.js new file mode 100644 index 0000000000..9548bcba80 --- /dev/null +++ b/components/slider/__examples__/vertical.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _slider = _interopRequireDefault(require("../../../../components/slider")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_slider.default, { + id: "vertical-id", + label: "Slider Label", + vertical: true + }); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'SliderExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/slider/docs.json b/components/slider/docs.json new file mode 100644 index 0000000000..7d22741453 --- /dev/null +++ b/components/slider/docs.json @@ -0,0 +1,7 @@ +{ + "component": "slider", + "status": "prod", + "display-name": "Slider", + "SLDS-component-path": "/components/slider", + "url-slug": "slider" +} \ No newline at end of file diff --git a/components/slider/index.js b/components/slider/index.js new file mode 100644 index 0000000000..e518a373f7 --- /dev/null +++ b/components/slider/index.js @@ -0,0 +1,255 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.isfunction")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * The `aria-describedby` attribute is used to indicate the IDs of the elements that describe the object. It is used to establish a relationship between widgets or groups and text that described them. This is very similar to aria-labelledby: a label describes the essence of an object, while a description provides more information that the user might need. + */ + 'aria-describedby': _propTypes.default.string, + + /** + * Assistive text for accessibility** + * `label`: Visually hidden label but read out loud by screen readers. + * + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string + }), + + /** + * Class names to be added to the outer container of the Slider. + */ + classNameContainer: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * This is the initial value of an uncontrolled form element and is present + * only to provide compatibility with hybrid framework applications that + * are not entirely React. It should only be used in an application without + * centralized state (Redux, Flux). "Controlled components" with centralized + * state is highly recommended. See [Code Overview](https://github.com/salesforce/design-system-react/blob/master/docs/codebase-overview.md#controlled-and-uncontrolled-components) for more information. + */ + defaultValue: _propTypes.default.number, + + /** + * Disables the Slider and prevents clicking it. Only available on the horizontal view. + */ + disabled: _propTypes.default.bool, + + /** + * Message to display when the Slider is in an error state. When this is present, also visually highlights the component as in error. + */ + errorText: _propTypes.default.string, + + /** + * Set the HTML `id` of the slider. + */ + id: _propTypes.default.string, + + /** + * This label appears above the Slider. + */ + label: _propTypes.default.string, + + /** + * Maximum value of a specified range. Defaults to 100. + */ + max: _propTypes.default.number, + + /** + * Minimum value of a specified range. Defaults to 0. + */ + min: _propTypes.default.number, + + /** + * Name of the submitted form parameter. + */ + name: _propTypes.default.string, + + /** + * This event fires whenever the user has modified the data of the control. This callback recieves the following parameters `event, { value: [string] }`. + */ + onChange: _propTypes.default.func, + + /** + * This event fires when the value is committed. This callback recieves the following parameters `event, { value: [string] }`. + */ + onInput: _propTypes.default.func, + + /** + * Size of the slider. + */ + size: _propTypes.default.oneOf(['x-small', 'small', 'medium', 'large']), + + /** + * By default, the granularity is 1 and the value is always an integer. For example, If you need a value between 5 and 10, accurate to two decimal places, you should set the value of step to 0.01 + */ + step: _propTypes.default.number, + + /** + * The Slider should be a controlled component, and will always display this value. This should always be used if you are using a Flux/Redux framework. + */ + value: _propTypes.default.number, + + /** + * Modifier that makes the slider vertical + */ + vertical: _propTypes.default.bool +}; +var defaultProps = { + min: 0, + max: 100, + step: 1 +}; +/** + * The ability to style sliders with CSS varies across browsers. Using this component ensures sliders look the same everywhere. + */ + +var Slider = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Slider, _React$Component); + + function Slider(props) { + var _this; + + _classCallCheck(this, Slider); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Slider).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (event) { + if ((0, _lodash.default)(_this.props.onChange)) { + _this.props.onChange(event, { + value: Number(event.target.value) + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleInput", function (event) { + if ((0, _lodash.default)(_this.props.onInput)) { + _this.props.onInput(event, { + value: Number(event.target.value) + }); + } + }); + + _this.generatedId = _shortid.default.generate(); + + if (_this.props.errorText) { + _this.generatedErrorId = _shortid.default.generate(); + } + + return _this; + } + + _createClass(Slider, [{ + key: "getId", + value: function getId() { + return this.props.id || this.generatedId; + } + }, { + key: "getErrorId", + value: function getErrorId() { + return this.props['aria-describedby'] || this.generatedErrorId; + } + }, { + key: "render", + value: function render() { + var labelText = this.props.label || this.props.assistiveText && this.props.assistiveText.label; + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-form-element', { + 'slds-has-error': this.props.errorText + }, this.props.classNameContainer) + }, _react.default.createElement("label", { + className: (0, _classnames.default)('slds-form-element__label', { + 'slds-assistive-text': this.props.assistiveText && !this.props.label + }), + htmlFor: this.getId() + }, _react.default.createElement("span", { + className: "slds-slider-label" + }, labelText ? _react.default.createElement("span", { + className: "slds-slider-label__label" + }, labelText) : null, _react.default.createElement("span", { + className: "slds-slider-label__range" + }, this.props.min, " - ", this.props.max))), _react.default.createElement("div", { + className: "slds-form-element__control" + }, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-slider', { + 'slds-slider_vertical': this.props.vertical, + 'slds-size_x-small': this.props.size === 'x-small', + 'slds-size_small': this.props.size === 'small', + 'slds-size_medium': this.props.size === 'medium', + 'slds-size_large': this.props.size === 'large' + }) + }, _react.default.createElement("input", { + type: "range", + id: this.getId(), + name: this.props.name, + className: "slds-slider__range", + defaultValue: this.props.defaultValue, + min: this.props.min, + max: this.props.max, + step: this.props.step, + "aria-describedby": this.getErrorId(), + value: this.props.value, + disabled: this.props.disabled, + onChange: this.handleChange, + onInput: this.handleInput + }), _react.default.createElement("span", { + className: "slds-slider__value", + "aria-hidden": "true" + }, this.props.value || this.props.defaultValue || '0')), this.props.errorText ? _react.default.createElement("div", { + id: this.getErrorId(), + className: "slds-form-element__help" + }, this.props.errorText) : null)); + } + }]); + + return Slider; +}(_react.default.Component); + +_defineProperty(Slider, "displayName", _constants.SLIDER); + +_defineProperty(Slider, "propTypes", propTypes); + +_defineProperty(Slider, "defaultProps", defaultProps); + +var _default = Slider; +exports.default = _default; \ No newline at end of file diff --git a/components/spinner/__docs__/__snapshots__/storybook-stories.storyshot b/components/spinner/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..9199ec1939 --- /dev/null +++ b/components/spinner/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,366 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSSpinner Brand Large 1`] = ` +
    +
    +
    + + Loading... + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSSpinner Brand Medium 1`] = ` +
    +
    +
    + + Loading... + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSSpinner Brand Small 1`] = ` +
    +
    +
    + + Loading... + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSSpinner Docs site Default 1`] = ` +
    +
    +
    +
    +
    + + Small spinner + +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSSpinner Inverse Large 1`] = ` +
    +
    +
    +
    + + Loading... + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSSpinner Inverse Medium 1`] = ` +
    +
    +
    +
    + + Loading... + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSSpinner Inverse Small 1`] = ` +
    +
    +
    +
    + + Loading... + +
    +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSSpinner Large 1`] = ` +
    +
    +
    + + Loading... + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSSpinner Large with 300ms delay 1`] = ` +
    +
    +
    + + Loading... + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSSpinner Medium 1`] = ` +
    +
    +
    + + Loading... + +
    +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSSpinner Small 1`] = ` +
    +
    +
    + + Small spinner + +
    +
    +
    +
    +
    +`; diff --git a/components/spinner/__docs__/site-stories.js b/components/spinner/__docs__/site-stories.js new file mode 100644 index 0000000000..7646e853fd --- /dev/null +++ b/components/spinner/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/spinner/__examples__/default.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/spinner/__docs__/storybook-stories.js b/components/spinner/__docs__/storybook-stories.js new file mode 100644 index 0000000000..594fc8511b --- /dev/null +++ b/components/spinner/__docs__/storybook-stories.js @@ -0,0 +1,96 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _spinner = _interopRequireDefault(require("../../spinner")); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* eslint-disable indent */ +var getSpinner = function getSpinner(props) { + return _react.default.createElement(_spinner.default, props); +}; + +var inverseContainer = { + backgroundColor: '#4bca81', + position: 'absolute', + width: '100%', + height: '100%' +}; +(0, _react2.storiesOf)(_constants.SPINNER, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Small', function () { + return getSpinner({ + size: 'small', + variant: 'base', + assistiveText: { + label: 'Small spinner' + } + }); +}).add('Medium', function () { + return getSpinner({ + size: 'medium', + variant: 'base' + }); +}).add('Large', function () { + return getSpinner({ + size: 'large', + variant: 'base' + }); +}).add('Brand Small', function () { + return getSpinner({ + size: 'small', + variant: 'brand' + }); +}).add('Brand Medium', function () { + return getSpinner({ + size: 'medium', + variant: 'brand' + }); +}).add('Brand Large', function () { + return getSpinner({ + size: 'large', + variant: 'brand', + containerClassName: 'my-custom-classname' + }); +}).add('Large with 300ms delay', function () { + return getSpinner({ + size: 'large', + variant: 'base', + isDelayed: true + }); +}).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium", + style: inverseContainer + }, getStory()); +}).add('Inverse Small', function () { + return getSpinner({ + size: 'small', + variant: 'inverse' + }); +}).add('Inverse Medium', function () { + return getSpinner({ + size: 'medium', + variant: 'inverse' + }); +}).add('Inverse Large', function () { + return getSpinner({ + size: 'large', + variant: 'inverse' + }); +}).add('Docs site Default', function () { + return _react.default.createElement(_default.default, null); +}); \ No newline at end of file diff --git a/components/spinner/__examples__/default.js b/components/spinner/__examples__/default.js new file mode 100644 index 0000000000..fdc5e9dd6b --- /dev/null +++ b/components/spinner/__examples__/default.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _spinner = _interopRequireDefault(require("../../../../components/spinner")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + style: { + position: 'relative', + height: '5rem' + } + }, _react.default.createElement(_spinner.default, { + size: "small", + variant: "base", + assistiveText: { + label: 'Small spinner' + } + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'SpinnerExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/spinner/check-props.js b/components/spinner/check-props.js new file mode 100644 index 0000000000..8265e03c0c --- /dev/null +++ b/components/spinner/check-props.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + + if (typeof props.assistiveText === 'string') { + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', "`assistiveText` as a string has been deprecated and is now an object to allow for multiple uses in the component. Please use `assistiveText.label` instead. ".concat(createDocUrl('assistiveText'))); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/spinner/docs.json b/components/spinner/docs.json new file mode 100644 index 0000000000..29e1dfeb42 --- /dev/null +++ b/components/spinner/docs.json @@ -0,0 +1,6 @@ +{ + "component": "spinner", + "status": "prod", + "display-name": "Spinners", + "SLDS-component-path": "/components/spinner" +} \ No newline at end of file diff --git a/components/spinner/index.js b/components/spinner/index.js new file mode 100644 index 0000000000..29fe82ea04 --- /dev/null +++ b/components/spinner/index.js @@ -0,0 +1,114 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _constants = require("../../utilities/constants"); + +var _docs = _interopRequireDefault(require("./docs.json")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// ### Prop Types +var propTypes = { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `label`: Assistive text that is read out loud to screen readers. + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string + }), + + /** + * Custom css classes applied to Spinner container + */ + containerClassName: _propTypes.default.string, + + /** + * Unique html id placed on div with role="status". + */ + id: _propTypes.default.string, + + /** + * Adds delay of 300ms to the spinner + */ + isDelayed: _propTypes.default.bool, + + /** + * Add styling to support a spinner inside an input field. + */ + isInput: _propTypes.default.bool, + + /** + * Determines the size of the spinner + */ + size: _propTypes.default.oneOf(['x-small', 'small', 'medium', 'large']), + + /** + * Determines the color of the spinner: `base` is gray, `brand` is blue, and `inverse` is white. + */ + variant: _propTypes.default.oneOf(['base', 'brand', 'inverse']) +}; +var defaultProps = { + assistiveText: { + label: 'Loading...' + }, + isDelayed: false, + size: 'medium', + variant: 'base' +}; +/** + * Spinners are CSS loading indicators that should be shown when retrieving data or performing slow computations. In some cases, the first time a parent component loads, a stencil is preferred to indicate network activity. + */ + +var Spinner = function Spinner(props) { + (0, _checkProps.default)(_constants.SPINNER, props, _docs.default); + var containerClassName = props.containerClassName, + id = props.id, + isDelayed = props.isDelayed, + isInput = props.isInput, + size = props.size, + variant = props.variant; + var assistiveText = typeof props.assistiveText === 'string' ? props.assistiveText : _objectSpread({}, defaultProps.assistiveText, props.assistiveText).label; + var spinnerClassName = (0, _classnames.default)('slds-spinner', _defineProperty({ + 'slds-input__spinner': isInput, + 'slds-spinner_brand': variant === 'brand', + 'slds-spinner_inverse': variant === 'inverse', + 'slds-spinner_delayed': isDelayed + }, "slds-spinner_".concat(size), size)); + return _react.default.createElement("div", { + className: (0, _classnames.default)(containerClassName, 'slds-spinner_container') + }, _react.default.createElement("div", { + "aria-hidden": "false", + className: spinnerClassName, + id: id, + role: "status" + }, assistiveText && _react.default.createElement("span", { + className: "slds-assistive-text" + }, assistiveText), _react.default.createElement("div", { + className: "slds-spinner__dot-a" + }), _react.default.createElement("div", { + className: "slds-spinner__dot-b" + }))); +}; + +Spinner.displayName = _constants.SPINNER; +Spinner.propTypes = propTypes; +Spinner.defaultProps = defaultProps; +var _default = Spinner; +exports.default = _default; \ No newline at end of file diff --git a/components/split-view/__docs__/site-stories.js b/components/split-view/__docs__/site-stories.js new file mode 100644 index 0000000000..6d6ebc365d --- /dev/null +++ b/components/split-view/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/split-view/__examples__/base.jsx'), require('raw-loader!@salesforce/design-system-react/components/split-view/__examples__/base-multiple.jsx'), require('raw-loader!@salesforce/design-system-react/components/split-view/__examples__/external-state.jsx'), require('raw-loader!@salesforce/design-system-react/components/split-view/__examples__/custom-item-list.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/split-view/__docs__/storybook-stories.js b/components/split-view/__docs__/storybook-stories.js new file mode 100644 index 0000000000..4761ddb541 --- /dev/null +++ b/components/split-view/__docs__/storybook-stories.js @@ -0,0 +1,35 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +var _baseMultiple = _interopRequireDefault(require("../__examples__/base-multiple")); + +var _externalState = _interopRequireDefault(require("../__examples__/external-state")); + +var _customItemList = _interopRequireDefault(require("../__examples__/custom-Item-list")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.SPLIT_VIEW, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base: Open', function () { + return _react.default.createElement(_base.default, null); +}).add('Base: Closed', function () { + return _react.default.createElement(_base.default, { + isOpen: false + }); +}).add('Base: Multiple', function () { + return _react.default.createElement(_baseMultiple.default, null); +}).add('External State', function () { + return _react.default.createElement(_externalState.default, null); +}).add('Custom List', function () { + return _react.default.createElement(_customItemList.default, null); +}); \ No newline at end of file diff --git a/components/split-view/__examples__/base-multiple.js b/components/split-view/__examples__/base-multiple.js new file mode 100644 index 0000000000..81f17f5ca4 --- /dev/null +++ b/components/split-view/__examples__/base-multiple.js @@ -0,0 +1,331 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _index = _interopRequireDefault(require("../../../../components/split-view/index")); + +var _header = _interopRequireDefault(require("../../../../components/split-view/header")); + +var _listbox = _interopRequireDefault(require("../../../../components/split-view/listbox")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +var _buttonTrigger = _interopRequireDefault(require("../../../../components/menu-dropdown/button-trigger")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var SORT_OPTIONS = { + UP: 'up', + DOWN: 'down' +}; +var listOptions = [{ + id: '001', + label: 'Riley Shultz', + topRightText: '99', + bottomLeftText: 'Biotech, Inc.', + bottomRightText: 'Nurturing' +}, { + id: '002', + label: 'Jason A. - VP of Sales', + topRightText: '92', + bottomLeftText: 'Case Management Solutions', + bottomRightText: 'Contacted' +}, { + id: '003', + label: 'Josh Smith', + topRightText: '90', + bottomLeftText: 'Acme, Inc.', + bottomRightText: 'Contacted' +}, { + id: '004', + label: 'Bobby Tree', + topRightText: '89', + bottomLeftText: 'Salesforce, Inc.', + bottomRightText: 'Closing' +}, { + id: '005', + label: 'Riley Shultz', + topRightText: '74', + bottomLeftText: 'Tesla', + bottomRightText: 'Contacted' +}, { + id: '006', + label: 'Andy Smith', + topRightText: '72', + bottomLeftText: 'Universal Technologies', + bottomRightText: 'New' +}, { + id: '007', + label: 'Jim Steele', + topRightText: '71', + bottomLeftText: 'BigList, Inc.', + bottomRightText: 'New' +}, { + id: '008', + label: 'John Gardner', + topRightText: '70', + bottomLeftText: '3C Systems', + bottomRightText: 'Contacted' +}, { + id: '009', + label: 'Sarah Loehr', + topRightText: '68', + bottomLeftText: 'MedLife, Inc.', + bottomRightText: 'New' +}]; + +var headerNavRight = _react.default.createElement("div", null, _react.default.createElement(_menuDropdown.default, { + id: "header-nav-right-more", + align: "right", + assistiveText: { + icon: 'More Options' + }, + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }] +})); + +var headerContentRight = _react.default.createElement("div", null, _react.default.createElement(_menuDropdown.default, { + id: "header-right-refresh", + buttonClassName: "slds-m-right_xx-small", + assistiveText: { + icon: 'Checkmark with right icon' + }, + buttonVariant: "icon", + checkmark: true, + iconCategory: "utility", + iconName: "side_list", + iconSize: "large", + iconVariant: "more", + align: "right", + onSelect: function onSelect(value) { + console.log('selected: ', value); + }, + options: [{ + label: 'Display As', + type: 'header' + }, { + label: 'Table View', + value: 'A0', + rightIcon: { + category: 'utility', + name: 'table' + } + }, { + label: 'List View', + value: 'B0', + rightIcon: { + category: 'utility', + name: 'side_list' + } + }], + value: "B0" +}), _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Refresh' + }, + iconCategory: "utility", + iconName: "refresh", + iconVariant: "border", + variant: "icon" +})); + +var headerTitle = _react.default.createElement("div", { + className: "slds-media__body" +}, _react.default.createElement("h1", { + className: "slds-text-heading_small slds-text-color_default slds-p-right_x-small" +}, _react.default.createElement(_menuDropdown.default, { + id: "header-title-leads", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] +}, _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + className: "slds-button_reset slds-type-focus", + iconCategory: "utility", + iconName: "down", + iconPosition: "right", + label: "My Leads", + responsive: true, + variant: "base" +}))))); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + options: listOptions, + selected: [listOptions[listOptions.length - 2]], + unread: [listOptions[0], listOptions[2]], + sortDirection: SORT_OPTIONS.DOWN + }; + _this.sortList = _this.sortList.bind(_assertThisInitialized(_this)); + return _this; + } + + _createClass(Example, [{ + key: "sortList", + value: function sortList() { + var sortDirection = this.state.sortDirection === SORT_OPTIONS.DOWN ? SORT_OPTIONS.UP : SORT_OPTIONS.DOWN; + this.setState({ + options: this.state.options.sort(function (a, b) { + return sortDirection === SORT_OPTIONS.DOWN ? a.label > b.label : b.label > a.label; + }), + sortDirection: sortDirection + }); + } // For multiple elements you need to pass an array in order for the scrolling to in the SplitViewList to work. + // React also requires a key prop on each items [React Lists and Keys](https://reactjs.org/docs/lists-and-keys.html#keys). + + }, { + key: "masterView", + value: function masterView() { + var _this2 = this; + + return [_react.default.createElement(_header.default, { + key: "1", + contentRight: headerContentRight, + navRight: headerNavRight, + iconAssistiveText: "User", + iconCategory: "standard", + iconName: "lead", + info: "42 items \u2022 Updated just now", + title: headerTitle, + truncate: true, + variant: "objectHome" + }), _react.default.createElement(_listbox.default, { + key: "2", + labels: { + header: 'Lead Score' + }, + multiple: true, + sortDirection: this.state.sortDirection, + options: this.state.options, + events: { + onSort: this.sortList, + onSelect: function onSelect(event, _ref) { + var selectedItems = _ref.selectedItems, + item = _ref.item; + + _this2.setState({ + unread: _this2.state.unread.filter(function (i) { + return i !== item; + }), + selected: selectedItems + }); + } + }, + selection: this.state.selected, + unread: this.state.unread + })]; + } + }, { + key: "detailView", + value: function detailView() { + return this.state.selected.length ? this.state.selected.map(function (item) { + return _react.default.createElement("dl", { + key: item.id, + className: "slds-box slds-m-left_medium slds-m-bottom_medium slds-list_horizontal slds-wrap" + }, _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Name" + }, "Name:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.label + }, item.label), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Value" + }, "Value:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.topRightText + }, item.topRightText), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Company" + }, "Company:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.bottomLeftText + }, item.bottomLeftText), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Status" + }, "Status:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.bottomRightText + }, item.bottomRightText)); + }) : _react.default.createElement("div", null); + } + }, { + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + height: '90vh' + } + }, _react.default.createElement(_index.default, { + id: "base-multiple-example", + master: this.masterView(), + detail: this.detailView() + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'SplitViewBase'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/split-view/__examples__/base.js b/components/split-view/__examples__/base.js new file mode 100644 index 0000000000..b2e9ab772a --- /dev/null +++ b/components/split-view/__examples__/base.js @@ -0,0 +1,331 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _index = _interopRequireDefault(require("../../../../components/split-view/index")); + +var _header = _interopRequireDefault(require("../../../../components/split-view/header")); + +var _listbox = _interopRequireDefault(require("../../../../components/split-view/listbox")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +var _buttonTrigger = _interopRequireDefault(require("../../../../components/menu-dropdown/button-trigger")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var SORT_OPTIONS = { + UP: 'up', + DOWN: 'down' +}; +var listOptions = [{ + id: '001', + label: 'Riley Shultz', + topRightText: '99', + bottomLeftText: 'Biotech, Inc.', + bottomRightText: 'Nurturing' +}, { + id: '002', + label: 'Jason A. - VP of Sales', + topRightText: '92', + bottomLeftText: 'Case Management Solutions', + bottomRightText: 'Contacted' +}, { + id: '003', + label: 'Josh Smith', + topRightText: '90', + bottomLeftText: 'Acme, Inc.', + bottomRightText: 'Contacted' +}, { + id: '004', + label: 'Bobby Tree', + topRightText: '89', + bottomLeftText: 'Salesforce, Inc.', + bottomRightText: 'Closing' +}, { + id: '005', + label: 'Riley Shultz', + topRightText: '74', + bottomLeftText: 'Tesla', + bottomRightText: 'Contacted' +}, { + id: '006', + label: 'Andy Smith', + topRightText: '72', + bottomLeftText: 'Universal Technologies', + bottomRightText: 'New' +}, { + id: '007', + label: 'Jim Steele', + topRightText: '71', + bottomLeftText: 'BigList, Inc.', + bottomRightText: 'New' +}, { + id: '008', + label: 'John Gardner', + topRightText: '70', + bottomLeftText: '3C Systems', + bottomRightText: 'Contacted' +}, { + id: '009', + label: 'Sarah Loehr', + topRightText: '68', + bottomLeftText: 'MedLife, Inc.', + bottomRightText: 'New' +}]; + +var headerNavRight = _react.default.createElement("div", null, _react.default.createElement(_menuDropdown.default, { + id: "header-nav-right-more", + align: "right", + assistiveText: { + icon: 'More Options' + }, + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }] +})); + +var headerContentRight = _react.default.createElement("div", null, _react.default.createElement(_menuDropdown.default, { + id: "header-right-refresh", + buttonClassName: "slds-m-right_xx-small", + assistiveText: { + icon: 'Checkmark with right icon' + }, + buttonVariant: "icon", + checkmark: true, + iconCategory: "utility", + iconName: "side_list", + iconSize: "large", + iconVariant: "more", + align: "right", + onSelect: function onSelect(value) { + console.log('selected: ', value); + }, + options: [{ + label: 'Display As', + type: 'header' + }, { + label: 'Table View', + value: 'A0', + rightIcon: { + category: 'utility', + name: 'table' + } + }, { + label: 'List View', + value: 'B0', + rightIcon: { + category: 'utility', + name: 'side_list' + } + }], + value: "B0" +}), _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Refresh' + }, + iconCategory: "utility", + iconName: "refresh", + iconVariant: "border", + variant: "icon" +})); + +var headerTitle = _react.default.createElement("div", { + className: "slds-media__body" +}, _react.default.createElement("h1", { + className: "slds-text-heading_small slds-text-color_default slds-p-right_x-small" +}, _react.default.createElement(_menuDropdown.default, { + id: "header-title-leads", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] +}, _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + className: "slds-button_reset slds-type-focus", + iconCategory: "utility", + iconName: "down", + iconPosition: "right", + label: "My Leads", + responsive: true, + variant: "base" +}))))); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + options: listOptions, + selected: [listOptions[listOptions.length - 2]], + unread: [listOptions[0], listOptions[2]], + sortDirection: SORT_OPTIONS.DOWN + }; + _this.sortList = _this.sortList.bind(_assertThisInitialized(_this)); + return _this; + } + + _createClass(Example, [{ + key: "sortList", + value: function sortList() { + var sortDirection = this.state.sortDirection === SORT_OPTIONS.DOWN ? SORT_OPTIONS.UP : SORT_OPTIONS.DOWN; + this.setState({ + options: this.state.options.sort(function (a, b) { + return sortDirection === SORT_OPTIONS.DOWN ? a.label > b.label : b.label > a.label; + }), + sortDirection: sortDirection + }); + } // For multiple elements you need to pass an array in order for the scrolling to in the SplitViewList to work. + // React also requires a key prop on each items [React Lists and Keys](https://reactjs.org/docs/lists-and-keys.html#keys). + + }, { + key: "masterView", + value: function masterView() { + var _this2 = this; + + return [_react.default.createElement(_header.default, { + key: "1", + contentRight: headerContentRight, + navRight: headerNavRight, + iconAssistiveText: "User", + iconCategory: "standard", + iconName: "lead", + info: "42 items \u2022 Updated just now", + title: headerTitle, + truncate: true, + variant: "objectHome" + }), _react.default.createElement(_listbox.default, { + key: "2", + labels: { + header: 'Lead Score' + }, + sortDirection: this.state.sortDirection, + options: this.state.options, + events: { + onSort: this.sortList, + onSelect: function onSelect(event, _ref) { + var selectedItems = _ref.selectedItems, + item = _ref.item; + + _this2.setState({ + unread: _this2.state.unread.filter(function (i) { + return i !== item; + }), + selected: selectedItems + }); + } + }, + selection: this.state.selected, + unread: this.state.unread + })]; + } + }, { + key: "detailView", + value: function detailView() { + return this.state.selected.length ? this.state.selected.map(function (item) { + return _react.default.createElement("dl", { + key: item.id, + className: "slds-box slds-m-left_medium slds-m-bottom_medium slds-list_horizontal slds-wrap" + }, _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Name" + }, "Name:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.label + }, item.label), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Value" + }, "Value:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.topRightText + }, item.topRightText), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Company" + }, "Company:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.bottomLeftText + }, item.bottomLeftText), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Status" + }, "Status:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.bottomRightText + }, item.bottomRightText)); + }) : _react.default.createElement("div", null); + } + }, { + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + height: '90vh' + } + }, _react.default.createElement(_index.default, { + id: "base-example", + isOpen: this.props.isOpen, + master: this.masterView(), + detail: this.detailView() + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'SplitViewBase'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/split-view/__examples__/custom-Item-list.js b/components/split-view/__examples__/custom-Item-list.js new file mode 100644 index 0000000000..ed09bccc8a --- /dev/null +++ b/components/split-view/__examples__/custom-Item-list.js @@ -0,0 +1,334 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _index = _interopRequireDefault(require("../../../../components/split-view/index")); + +var _header = _interopRequireDefault(require("../../../../components/split-view/header")); + +var _listbox = _interopRequireDefault(require("../../../../components/split-view/listbox")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +var _buttonTrigger = _interopRequireDefault(require("../../../../components/menu-dropdown/button-trigger")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var SORT_OPTIONS = { + UP: 'up', + DOWN: 'down' +}; +var listOptions = [{ + id: '001', + name: 'Riley Shultz', + ranking: '99', + company: 'Biotech, Inc.', + status: 'Nurturing' +}, { + id: '002', + name: 'Jason A. - VP of Sales', + ranking: '92', + company: 'Case Management Solutions', + status: 'Contacted' +}, { + id: '003', + name: 'Josh Smith', + ranking: '90', + company: 'Acme, Inc.', + status: 'Contacted' +}, { + id: '004', + name: 'Bobby Tree', + ranking: '89', + company: 'Salesforce, Inc.', + status: 'Closing' +}, { + id: '005', + name: 'Riley Shultz', + ranking: '74', + company: 'Tesla', + status: 'Contacted' +}]; + +var headerNavRight = _react.default.createElement("div", null, _react.default.createElement(_menuDropdown.default, { + id: "header-nav-right-more", + align: "right", + assistiveText: { + icon: 'More Options' + }, + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }] +})); + +var headerContentRight = _react.default.createElement("div", null, _react.default.createElement(_menuDropdown.default, { + id: "header-right-refresh", + buttonClassName: "slds-m-right_xx-small", + assistiveText: { + icon: 'Checkmark with right icon' + }, + buttonVariant: "icon", + checkmark: true, + iconCategory: "utility", + iconName: "side_list", + iconSize: "large", + iconVariant: "more", + align: "right", + onSelect: function onSelect(value) { + console.log('selected: ', value); + }, + options: [{ + label: 'Display As', + type: 'header' + }, { + label: 'Table View', + value: 'A0', + rightIcon: { + category: 'utility', + name: 'table' + } + }, { + label: 'List View', + value: 'B0', + rightIcon: { + category: 'utility', + name: 'side_list' + } + }], + value: "B0" +}), _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Refresh' + }, + iconCategory: "utility", + iconName: "refresh", + iconVariant: "border", + variant: "icon" +})); + +var headerTitle = _react.default.createElement("div", { + className: "slds-media__body" +}, _react.default.createElement("h1", { + className: "slds-text-heading_small slds-text-color_default slds-p-right_x-small" +}, _react.default.createElement(_menuDropdown.default, { + id: "header-title-leads", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] +}, _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + className: "slds-button_reset slds-type-focus", + iconCategory: "utility", + iconName: "down", + iconPosition: "right", + label: "My Leads", + responsive: true, + variant: "base" +}))))); +/** + * Custom list item + * @param props + */ + + +var CustomListItem = function CustomListItem(props) { + return _react.default.createElement("div", null, _react.default.createElement(_icon.default, { + category: "action", + name: props.item.status === 'Contacted' ? 'check' : 'call', + size: "x-small" + }), _react.default.createElement("span", { + className: "slds-text-heading_small slds-m-left_medium" + }, props.item.name)); +}; + +CustomListItem.propsTypes = { + item: _propTypes.default.shape({ + status: _propTypes.default.string, + name: _propTypes.default.string + }) +}; +CustomListItem.displayName = 'CustomListItem'; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + options: listOptions, + selected: [listOptions[listOptions.length - 2]], + unread: [listOptions[0], listOptions[2]], + sortDirection: SORT_OPTIONS.DOWN + }; + _this.sortList = _this.sortList.bind(_assertThisInitialized(_this)); + return _this; + } + + _createClass(Example, [{ + key: "sortList", + value: function sortList() { + var sortDirection = this.state.sortDirection === SORT_OPTIONS.DOWN ? SORT_OPTIONS.UP : SORT_OPTIONS.DOWN; + this.setState({ + options: this.state.options.sort(function (a, b) { + return sortDirection === SORT_OPTIONS.DOWN ? a.name > b.name : b.name > a.name; + }), + sortDirection: sortDirection + }); + } // For multiple elements you need to pass an array in order for the scrolling to in the SplitViewList to work. + // React also requires a key prop on each items [React Lists and Keys](https://reactjs.org/docs/lists-and-keys.html#keys). + + }, { + key: "masterView", + value: function masterView() { + var _this2 = this; + + return [_react.default.createElement(_header.default, { + key: "1", + contentRight: headerContentRight, + navRight: headerNavRight, + iconAssistiveText: "User", + iconCategory: "standard", + iconName: "lead", + info: "42 items \u2022 Updated just now", + title: headerTitle, + truncate: true, + variant: "objectHome" + }), _react.default.createElement(_listbox.default, { + key: "2", + labels: { + header: 'Lead Score' + }, + sortDirection: this.state.sortDirection, + options: this.state.options, + events: { + onSort: this.sortList, + onSelect: function onSelect(event, _ref) { + var selectedItems = _ref.selectedItems, + item = _ref.item; + + _this2.setState({ + unread: _this2.state.unread.filter(function (i) { + return i !== item; + }), + selected: selectedItems + }); + } + }, + selection: this.state.selected, + unread: this.state.unread, + listItem: CustomListItem + })]; + } + }, { + key: "detailView", + value: function detailView() { + return this.state.selected.length ? this.state.selected.map(function (item) { + return _react.default.createElement("dl", { + key: item.id, + className: "slds-box slds-m-left_medium slds-m-bottom_medium slds-list_horizontal slds-wrap" + }, _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Name" + }, "Name:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.name + }, item.name), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Value" + }, "Value:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.ranking + }, item.ranking), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Company" + }, "Company:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.company + }, item.company), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Status" + }, "Status:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.status + }, item.status)); + }) : _react.default.createElement("div", null); + } + }, { + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + height: '90vh' + } + }, _react.default.createElement(_index.default, { + id: "custom-example", + master: this.masterView(), + detail: this.detailView() + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'SplitViewCustomListItem'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/split-view/__examples__/external-state.js b/components/split-view/__examples__/external-state.js new file mode 100644 index 0000000000..5e3fa499a1 --- /dev/null +++ b/components/split-view/__examples__/external-state.js @@ -0,0 +1,373 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _index = _interopRequireDefault(require("../../../../components/split-view/index")); + +var _header = _interopRequireDefault(require("../../../../components/split-view/header")); + +var _listbox = _interopRequireDefault(require("../../../../components/split-view/listbox")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +var _buttonTrigger = _interopRequireDefault(require("../../../../components/menu-dropdown/button-trigger")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var SORT_OPTIONS = { + UP: 'up', + DOWN: 'down' +}; +var listOptions = [{ + id: '001', + label: 'Riley Shultz', + topRightText: '99', + bottomLeftText: 'Biotech, Inc.', + bottomRightText: 'Nurturing' +}, { + id: '002', + label: 'Jason A. - VP of Sales', + topRightText: '92', + bottomLeftText: 'Case Management Solutions', + bottomRightText: 'Contacted' +}, { + id: '003', + label: 'Josh Smith', + topRightText: '90', + bottomLeftText: 'Acme, Inc.', + bottomRightText: 'Contacted' +}, { + id: '004', + label: 'Bobby Tree', + topRightText: '89', + bottomLeftText: 'Salesforce, Inc.', + bottomRightText: 'Closing' +}, { + id: '005', + label: 'Riley Shultz', + topRightText: '74', + bottomLeftText: 'Tesla', + bottomRightText: 'Contacted' +}, { + id: '006', + label: 'Andy Smith', + topRightText: '72', + bottomLeftText: 'Universal Technologies', + bottomRightText: 'New' +}, { + id: '007', + label: 'Jim Steele', + topRightText: '71', + bottomLeftText: 'BigList, Inc.', + bottomRightText: 'New' +}, { + id: '008', + label: 'John Gardner', + topRightText: '70', + bottomLeftText: '3C Systems', + bottomRightText: 'Contacted' +}, { + id: '009', + label: 'Sarah Loehr', + topRightText: '68', + bottomLeftText: 'MedLife, Inc.', + bottomRightText: 'New' +}]; + +var headerNavRight = _react.default.createElement("div", null, _react.default.createElement(_menuDropdown.default, { + id: "header-nav-right-more", + align: "right", + assistiveText: { + icon: 'More Options' + }, + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }] +})); + +var headerContentRight = _react.default.createElement("div", null, _react.default.createElement(_menuDropdown.default, { + id: "header-right-refresh", + buttonClassName: "slds-m-right_xx-small", + assistiveText: { + icon: 'Checkmark with right icon' + }, + buttonVariant: "icon", + checkmark: true, + iconCategory: "utility", + iconName: "side_list", + iconSize: "large", + iconVariant: "more", + align: "right", + onSelect: function onSelect(value) { + console.log('selected: ', value); + }, + options: [{ + label: 'Display As', + type: 'header' + }, { + label: 'Table View', + value: 'A0', + rightIcon: { + category: 'utility', + name: 'table' + } + }, { + label: 'List View', + value: 'B0', + rightIcon: { + category: 'utility', + name: 'side_list' + } + }], + value: "B0" +}), _react.default.createElement(_button.default, { + assistiveText: { + icon: 'Refresh' + }, + iconCategory: "utility", + iconName: "refresh", + iconVariant: "border", + variant: "icon" +})); + +var headerTitle = _react.default.createElement("div", { + className: "slds-media__body" +}, _react.default.createElement("h1", { + className: "slds-text-heading_small slds-text-color_default slds-p-right_x-small" +}, _react.default.createElement(_menuDropdown.default, { + id: "header-title-leads", + options: [{ + label: 'Menu Item One', + value: 'A0' + }, { + label: 'Menu Item Two', + value: 'B0' + }, { + label: 'Menu Item Three', + value: 'C0' + }, { + type: 'divider' + }, { + label: 'Menu Item Four', + value: 'D0' + }] +}, _react.default.createElement(_buttonTrigger.default, null, _react.default.createElement(_button.default, { + className: "slds-button_reset slds-type-focus", + iconCategory: "utility", + iconName: "down", + iconPosition: "right", + label: "My Leads", + responsive: true, + variant: "base" +}))))); + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + options: listOptions, + selected: [listOptions[listOptions.length - 2]], + unread: [listOptions[0], listOptions[2]], + sortDirection: SORT_OPTIONS.DOWN, + isOpen: true + }; + _this.sortList = _this.sortList.bind(_assertThisInitialized(_this)); + return _this; + } + + _createClass(Example, [{ + key: "onSplitViewOpen", + value: function onSplitViewOpen() { + this.setState({ + isOpen: true + }); + } + }, { + key: "onSplitViewClose", + value: function onSplitViewClose() { + this.setState({ + isOpen: false + }); + } // For multiple elements you need to pass an array in order for the scrolling to in the SplitViewList to work. + // React also requires a key prop on each items [React Lists and Keys](https://reactjs.org/docs/lists-and-keys.html#keys). + + }, { + key: "masterView", + value: function masterView() { + var _this2 = this; + + return [_react.default.createElement(_header.default, { + key: "1", + contentRight: headerContentRight, + navRight: headerNavRight, + iconAssistiveText: "User", + iconCategory: "standard", + iconName: "lead", + info: "42 items \u2022 Updated just now", + title: headerTitle, + truncate: true, + variant: "objectHome" + }), _react.default.createElement(_listbox.default, { + key: "2", + labels: { + header: 'Lead Score' + }, + sortDirection: this.state.sortDirection, + options: this.state.options, + events: { + onSort: this.sortList, + onSelect: function onSelect(event, _ref) { + var selectedItems = _ref.selectedItems, + item = _ref.item; + + _this2.setState({ + unread: _this2.state.unread.filter(function (i) { + return i !== item; + }), + selected: selectedItems + }); + } + }, + selection: this.state.selected, + unread: this.state.unread + })]; + } + }, { + key: "detailView", + value: function detailView() { + return this.state.selected.length ? this.state.selected.map(function (item) { + return _react.default.createElement("dl", { + key: item.id, + className: "slds-box slds-m-left_medium slds-m-bottom_medium slds-list_horizontal slds-wrap" + }, _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Name" + }, "Name:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.label + }, item.label), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Value" + }, "Value:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.topRightText + }, item.topRightText), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Company" + }, "Company:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.bottomLeftText + }, item.bottomLeftText), _react.default.createElement("dt", { + className: "slds-item_label slds-text-color_weak slds-truncate", + title: "Status" + }, "Status:"), _react.default.createElement("dd", { + className: "slds-item_detail slds-truncate", + title: item.bottomRightText + }, item.bottomRightText)); + }) : _react.default.createElement("div", null); + } + }, { + key: "sortList", + value: function sortList() { + var sortDirection = this.state.sortDirection === SORT_OPTIONS.DOWN ? SORT_OPTIONS.UP : SORT_OPTIONS.DOWN; + this.setState({ + options: this.state.options.sort(function (a, b) { + return sortDirection === SORT_OPTIONS.DOWN ? a.label > b.label : b.label > a.label; + }), + sortDirection: sortDirection + }); + } + }, { + key: "render", + value: function render() { + var _this3 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-box slds-m-bottom_large" + }, _react.default.createElement("div", { + className: "slds-m-bottom_small" + }, "Externally control the split view"), _react.default.createElement(_button.default, { + onClick: function onClick() { + return _this3.setState({ + isOpen: true + }); + }, + label: "Open the split view" + }), _react.default.createElement(_button.default, { + onClick: function onClick() { + return _this3.setState({ + isOpen: false + }); + }, + label: "Close the split view" + })), _react.default.createElement("div", { + style: { + height: '80vh' + } + }, _react.default.createElement(_index.default, { + events: { + onOpen: function onOpen(e) { + return _this3.onSplitViewOpen(e); + }, + onClose: function onClose(e) { + return _this3.onSplitViewClose(e); + } + }, + isOpen: this.state.isOpen, + master: this.masterView(), + detail: this.detailView() + })))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'SplitViewBase'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/split-view/docs.json b/components/split-view/docs.json new file mode 100644 index 0000000000..80ea80331d --- /dev/null +++ b/components/split-view/docs.json @@ -0,0 +1,23 @@ +{ + "component": "split-view", + "status": "prod", + "display-name": "Split View", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "last-slds-markup-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/split-view", + "dependencies": [ + { + "component": "header" + }, + { + "component": "listbox" + } + ], + "url-slug": "split-view" +} \ No newline at end of file diff --git a/components/split-view/header.js b/components/split-view/header.js new file mode 100644 index 0000000000..0c7318af73 --- /dev/null +++ b/components/split-view/header.js @@ -0,0 +1,43 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _pageHeader = _interopRequireDefault(require("../page-header")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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 propTypes = {}; +var defaultProps = {}; +/** + * The Split View Header takes the same properties as the [PageHeader](https://react.lightningdesignsystem.com/components/page-headers/) component. + */ + +var SplitViewHeader = function SplitViewHeader(_ref) { + var className = _ref.className, + rest = _objectWithoutProperties(_ref, ["className"]); + + return _react.default.createElement(_pageHeader.default, _extends({ + className: (0, _classnames.default)('slds-split-view__header slds-has-bottom-magnet', className) + }, rest)); +}; + +SplitViewHeader.displayName = _constants.SPLIT_VIEW_HEADER; +SplitViewHeader.propTypes = propTypes; +SplitViewHeader.defaultProps = defaultProps; +var _default = SplitViewHeader; +exports.default = _default; \ No newline at end of file diff --git a/components/split-view/index.js b/components/split-view/index.js new file mode 100644 index 0000000000..415b03f26a --- /dev/null +++ b/components/split-view/index.js @@ -0,0 +1,233 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _toggleButton = _interopRequireWildcard(require("./private/toggle-button")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * **Assistive text for accessibility** + * * `toggleButtonOpen`: The button used to open the split view. + * * `toggleButtonClose`: The button used to close the split view. + */ + assistiveText: _propTypes.default.shape({ + toggleButtonOpen: _propTypes.default.string, + toggleButtonClose: _propTypes.default.string + }), + + /** + * HTML Id for the component. + */ + id: _propTypes.default.string, + + /** + * CSS classes to be added to the root `div` tag. Uses `classNames` [API](https://github.com/JedWatson/classnames). + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Sets the split view to be open or closed. + */ + isOpen: _propTypes.default.bool, + + /** + * Event Callbacks + * * `onClose`: Triggered when the split view has closed. + * * `onOpen`: Triggered when the split view has opened. + */ + events: _propTypes.default.shape({ + onClose: _propTypes.default.func, + onOpen: _propTypes.default.func + }), + + /** + * The React component that is rendered in the master section. + * You need to pass in an array of elements in order for the scrolling to in the SplitViewList to work correctly. + * React requires that you also supply a unique `key` for each element [React Lists and Keys](https://reactjs.org/docs/lists-and-keys.html#keys). + */ + master: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.element), _propTypes.default.element]).isRequired, + + /** + * The width of the master section. + */ + masterWidth: _propTypes.default.string, + + /** + * The React component that is rendered in the detail section. + */ + detail: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.element), _propTypes.default.element]).isRequired +}; +var defaultProps = { + assistiveText: { + toggleButtonOpen: 'Close split view', + toggleButtonClose: 'Open split view' + }, + events: {}, + masterWidth: '20rem' +}; +/** + * Split view is used to navigate between records in a list while staying on the same screen. + */ + +var SplitView = +/*#__PURE__*/ +function (_React$Component) { + _inherits(SplitView, _React$Component); + + function SplitView(props) { + var _this; + + _classCallCheck(this, SplitView); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(SplitView).call(this, props)); + _this.state = { + isOpen: true + }; + return _this; + } + + _createClass(SplitView, [{ + key: "componentWillMount", + value: function componentWillMount() { + this.generatedId = _shortid.default.generate(); + this.setIsOpen({ + isOpen: this.props.isOpen + }); + } + }, { + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + if (nextProps.isOpen !== this.props.isOpen) { + this.setIsOpen({ + isOpen: nextProps.isOpen + }); + } + } + }, { + key: "getId", + value: function getId() { + return this.props.id || this.generatedId; + } + }, { + key: "getMasterViewId", + value: function getMasterViewId() { + return "master_view_".concat(this.getId()); + } + }, { + key: "setIsOpen", + value: function setIsOpen(_ref) { + var isOpen = _ref.isOpen; + + if (typeof this.props.isOpen === 'boolean') { + this.setState({ + isOpen: isOpen + }); + } + } + }, { + key: "toggle", + value: function toggle(event) { + this.setIsOpen({ + isOpen: !this.state.isOpen + }); + + if (this.state.isOpen && this.props.events.onClose) { + this.props.events.onClose(event); + } else if (!this.state.isOpen && this.props.events.onOpen) { + this.props.events.onOpen(event); + } + } + }, { + key: "masterContent", + value: function masterContent() { + return this.state.isOpen ? _react.default.createElement("article", { + id: this.getMasterViewId(), + className: "slds-split-view slds-grid slds-grid_vertical slds-grow slds-scrollable_none" + }, this.props.master) : null; + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement("div", { + id: this.getId(), + className: (0, _classnames.default)('slds-grid', this.props.className), + style: { + height: '100%' + } + }, _react.default.createElement("div", { + style: { + maxWidth: this.state.isOpen ? this.props.masterWidth : '0' + }, + className: (0, _classnames.default)('slds-split-view_container', { + 'slds-is-open': this.state.isOpen + }, { + 'slds-is-closed': !this.state.isOpen + }) + }, _react.default.createElement(_toggleButton.default, { + assistiveText: this.props.assistiveText, + ariaControls: this.getMasterViewId(), + isOpen: this.state.isOpen, + events: { + onClick: function onClick(event) { + return _this2.toggle(event); + } + } + }), this.masterContent()), _react.default.createElement("div", { + style: { + marginLeft: _toggleButton.TOGGLE_BUTTON_WIDTH + }, + className: "slds-grow slds-scrollable_y" + }, this.props.detail)); + } + }]); + + return SplitView; +}(_react.default.Component); + +_defineProperty(SplitView, "displayName", _constants.SPLIT_VIEW); + +_defineProperty(SplitView, "propTypes", propTypes); + +_defineProperty(SplitView, "defaultProps", defaultProps); + +var _default = SplitView; +exports.default = _default; \ No newline at end of file diff --git a/components/split-view/listbox.js b/components/split-view/listbox.js new file mode 100644 index 0000000000..224ce48243 --- /dev/null +++ b/components/split-view/listbox.js @@ -0,0 +1,451 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = exports.SORT_OPTIONS = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _event = _interopRequireDefault(require("../../utilities/event")); + +var _constants = require("../../utilities/constants"); + +var _icon = _interopRequireDefault(require("../icon")); + +var _listItemContent = _interopRequireDefault(require("./private/list-item-content")); + +var _listItemWithContent = _interopRequireDefault(require("./private/list-item-with-content")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } + +function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var SORT_OPTIONS = Object.freeze({ + UP: 'up', + DOWN: 'down' +}); +exports.SORT_OPTIONS = SORT_OPTIONS; +var propTypes = { + /** + * **Assistive text for accessibility** + * * `list`: aria label for the list + * * `sort` + * * `sortedBy`: Clickable sort header for the list. + * * `descending`: Descending sorting. + * * `ascending`: Ascending sorting. + */ + assistiveText: _propTypes.default.shape({ + list: _propTypes.default.string, + sort: _propTypes.default.shape({ + sortedBy: _propTypes.default.string, + descending: _propTypes.default.string, + ascending: _propTypes.default.string + }), + unreadItem: _propTypes.default.string + }), + + /** + * CSS classes to be added to the parent `div` tag. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Event Callbacks + * * `onSelect`: Called when a list item is selected. + * * event {object} List item click event + * * Meta {object} + * * selectedItems {array} List of selected items. + * * item {object} Last selected item. + * * `onSort`: Called when the list is sorted. + * * event {object} Sort click event + */ + events: _propTypes.default.shape({ + onSelect: _propTypes.default.func.isRequired, + onSort: _propTypes.default.func + }), + + /** + * HTML id for component. + */ + id: _propTypes.default.string, + + /** + * **Text labels for internationalization** + * * `header`: This is the header of the list. + */ + labels: _propTypes.default.shape({ + header: _propTypes.default.string + }), + + /** + * The direction of the sort arrow. Option are: + * * SORT_OPTIONS.UP: `up` + * * SORT_OPTIONS.DOWN: `down` + */ + sortDirection: _propTypes.default.oneOf([SORT_OPTIONS.UP, SORT_OPTIONS.DOWN]), + + /** + * Allows multiple item to be selection + */ + multiple: _propTypes.default.bool, + + /** + * The list of items. + * It is recommended that you have a unique `id` for each item. + */ + options: _propTypes.default.array.isRequired, + + /** + * Accepts an array of item objects. For single selection, pass in an array of one object. + */ + selection: _propTypes.default.array, + + /** + * Accepts an array of item objects. For single unread, pass in an array of one object. + */ + unread: _propTypes.default.array, + + /** + * Custom list item template for the list item content. The select and unread functionality wraps the custom list item. + * This should be a React component that accepts props. + */ + listItem: _propTypes.default.func +}; +var defaultProps = { + assistiveText: { + list: 'Select an item to open it in a new workspace tab.', + sort: { + sortedBy: 'Sorted by', + descending: 'Descending', + ascending: 'Ascending' + } + }, + events: {}, + labels: {}, + selection: [], + unread: [] +}; +/** + * The menu with the ARIA role of a listbox. + */ + +var SplitViewListbox = +/*#__PURE__*/ +function (_React$Component) { + _inherits(SplitViewListbox, _React$Component); + + function SplitViewListbox(props) { + var _this; + + _classCallCheck(this, SplitViewListbox); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(SplitViewListbox).call(this, props)); + _this.listItemComponents = {}; + _this.state = { + currentSelectedItem: null, + currentFocusedListItem: { + index: 0, + item: null + } + }; + return _this; + } + + _createClass(SplitViewListbox, [{ + key: "componentWillMount", + value: function componentWillMount() { + // Generates the list item template + this.ListItemWithContent = (0, _listItemWithContent.default)(this.props.listItem || _listItemContent.default); + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + this.focusFirstItem(); + } + }, { + key: "isListItemFocused", + value: function isListItemFocused(item) { + return this.state.currentFocusedListItem.item === item; + } + }, { + key: "isSelected", + value: function isSelected(item) { + return this.props.selection.includes(item); + } + }, { + key: "isUnread", + value: function isUnread(item) { + return this.props.unread.includes(item); + } + }, { + key: "handleKeyDown", + value: function handleKeyDown(event) { + if (this.props.multiple && event.key === 'a' && event.ctrlKey) { + // select / deselect all + _event.default.trap(event); + + if (this.props.options === this.props.selection) { + this.deselectAllListItems(event); + } else { + this.selectAllListItems(event); + } + } else if (event.key === 'ArrowUp') { + _event.default.trap(event); + + this.moveToPreviousItem(event); + } else if (event.key === 'ArrowDown') { + _event.default.trap(event); + + this.moveToNextItem(event); + } + } + }, { + key: "moveToNextItem", + value: function moveToNextItem(event) { + var nextFocusIndex = this.state.currentFocusedListItem.index === this.props.options.length - 1 ? 0 : this.state.currentFocusedListItem.index + 1; + this.moveToIndex(event, nextFocusIndex); + } + }, { + key: "moveToPreviousItem", + value: function moveToPreviousItem(event) { + var previousFocusIndex = this.state.currentFocusedListItem.index === 0 ? this.props.options.length - 1 : this.state.currentFocusedListItem.index - 1; + this.moveToIndex(event, previousFocusIndex); + } + }, { + key: "moveToIndex", + value: function moveToIndex(event, index) { + var item = this.props.options[index]; + + if (!event.metaKey && !event.ctrlKey) { + this.selectListItem(item, event); + } + + this.focusItem(item); + } + }, { + key: "focusFirstItem", + value: function focusFirstItem() { + var _this2 = this; + + var firstSelectedItem = this.props.options.find(function (item) { + return _this2.props.selection.includes(item); + }) || this.props.options[0]; + + if (firstSelectedItem) { + this.focusItem(firstSelectedItem, true); + } + } + }, { + key: "focusItem", + value: function focusItem(item, setDataOnly) { + var index = this.props.options.indexOf(item); + + if (!setDataOnly) { + this.listItemComponents[index].focus(); + } + + this.setState({ + currentFocusedListItem: { + index: index, + item: item + } + }); + } + }, { + key: "deselectAllListItems", + value: function deselectAllListItems(event) { + this.setState({ + currentSelectedItem: null + }); + this.props.events.onSelect(event, { + selectedItems: [], + item: null + }); + } + }, { + key: "selectAllListItems", + value: function selectAllListItems(event) { + this.props.events.onSelect(event, { + selectedItems: this.props.options, + item: this.state.currentSelectedItem + }); + } + }, { + key: "selectListItem", + value: function selectListItem(item, event) { + var selectedItems = [item]; + + if (this.props.multiple) { + if (event.metaKey) { + selectedItems = this.props.selection.includes(item) ? this.props.selection.filter(function (i) { + return i !== item; + }) : [item].concat(_toConsumableArray(this.props.selection)); + } else if (event.shiftKey) { + var _sort = [this.props.options.indexOf(this.state.currentSelectedItem), this.props.options.indexOf(item)].sort(), + _sort2 = _slicedToArray(_sort, 2), + begin = _sort2[0], + end = _sort2[1]; + + var addToSelection = this.props.options.slice(begin, end + 1); + selectedItems = [].concat(_toConsumableArray(addToSelection), _toConsumableArray(this.props.selection.filter(function (i) { + return !addToSelection.includes(i); + }))); + } + } + + this.setState({ + currentSelectedItem: item + }); + this.props.events.onSelect(event, { + selectedItems: selectedItems, + item: item + }); + } + }, { + key: "handleOnSelect", + value: function handleOnSelect(event, _ref) { + var item = _ref.item; + this.selectListItem(item, event); + this.focusItem(item); + } + }, { + key: "sortDirection", + value: function sortDirection() { + return this.props.sortDirection ? _react.default.createElement(_icon.default, { + category: "utility", + name: this.props.sortDirection === SORT_OPTIONS.DOWN ? 'arrowdown' : 'arrowup', + size: "xx-small", + className: "slds-align-top" + }) : null; + } + }, { + key: "headerWrapper", + value: function headerWrapper(children) { + return this.props.events.onSort ? _react.default.createElement("a", { + style: { + borderTop: '0' + }, + href: "javascript:void(0);" // eslint-disable-line no-script-url + , + role: "button", + className: "slds-split-view__list-header slds-grid slds-text-link_reset", + onClick: this.props.events.onSort + }, children) : _react.default.createElement("div", { + style: { + borderTop: '0' + }, + className: "slds-split-view__list-header slds-grid" + }, children); + } + }, { + key: "header", + value: function header() { + return this.props.labels.header ? this.headerWrapper(_react.default.createElement("span", null, _react.default.createElement("span", { + className: "slds-assistive-text" + }, this.props.assistiveText.sort.sortedBy, ":"), _react.default.createElement("span", null, this.props.labels.header, this.sortDirection()), _react.default.createElement("span", { + className: "slds-assistive-text" + }, "-", ' ', this.props.sortDirection === SORT_OPTIONS.DOWN ? this.props.assistiveText.sort.descending : this.props.assistiveText.sort.ascending))) : null; + } + }, { + key: "addListItemComponent", + value: function addListItemComponent(component, index) { + this.listItemComponents[index] = component; + } + }, { + key: "listItems", + value: function listItems() { + var _this3 = this; + + var ListItemWithContent = this.ListItemWithContent; + return this.props.options.map(function (item, index) { + return _react.default.createElement(ListItemWithContent, { + key: item.id || index, + assistiveText: { + unreadItem: _this3.props.assistiveText.unreadItem + }, + listItemRef: function listItemRef(component) { + _this3.addListItemComponent(component, index); + }, + item: item, + isFocused: _this3.isListItemFocused(item), + isSelected: _this3.isSelected(item), + isUnread: _this3.isUnread(item), + events: { + onClick: function onClick(event, meta) { + return _this3.handleOnSelect(event, meta); + } + }, + multiple: _this3.props.multiple + }); + }); + } + }, { + key: "render", + value: function render() { + var _this4 = this; + + return _react.default.createElement("div", { + id: this.props.id, + className: (0, _classnames.default)('slds-grid slds-grid_vertical slds-scrollable_none', this.props.className) + }, this.header(), _react.default.createElement("ul", { + className: "slds-scrollable_y", + "aria-label": this.props.assistiveText.list, + "aria-multiselectable": this.props.multiple, + role: "listbox", + onKeyDown: function onKeyDown(event) { + return _this4.handleKeyDown(event); + } + }, this.listItems())); + } + }]); + + return SplitViewListbox; +}(_react.default.Component); + +_defineProperty(SplitViewListbox, "displayName", _constants.SPLIT_VIEW_LISTBOX); + +_defineProperty(SplitViewListbox, "propTypes", propTypes); + +_defineProperty(SplitViewListbox, "defaultProps", defaultProps); + +var _default = SplitViewListbox; +exports.default = _default; \ No newline at end of file diff --git a/components/split-view/private/list-item-content.js b/components/split-view/private/list-item-content.js new file mode 100644 index 0000000000..f3ae215c3e --- /dev/null +++ b/components/split-view/private/list-item-content.js @@ -0,0 +1,61 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = exports.DISPLAY_NAME = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +var DISPLAY_NAME = 'SLDSSplitViewListItemContent'; +exports.DISPLAY_NAME = DISPLAY_NAME; +var propTypes = { + /** + * **Item to be displayed** + * * `label`: The main label displayed on the top left. + * * `topRightText`: The text displayed on the top right. + * * `bottomLeftText`: The text displayed on the bottom left. + * * `bottomRightText`: The text displayed on the bottom right. + */ + item: _propTypes.default.shape({ + label: _propTypes.default.string, + topRightText: _propTypes.default.string, + bottomLeftText: _propTypes.default.string, + bottomRightText: _propTypes.default.string + }) +}; +var defaultProps = {}; + +var SplitViewListItemContent = function SplitViewListItemContent(_ref) { + var item = _ref.item; + return _react.default.createElement("div", null, _react.default.createElement("div", { + className: "slds-grid slds-wrap" + }, _react.default.createElement("span", { + className: "slds-truncate slds-text-body_regular slds-text-color_default", + title: item.label + }, item.label), _react.default.createElement("span", { + className: "slds-truncate slds-col_bump-left", + title: item.topRightText + }, item.topRightText)), _react.default.createElement("div", { + className: "slds-grid slds-wrap" + }, _react.default.createElement("span", { + className: "slds-truncate", + title: item.bottomLeftText + }, item.bottomLeftText), _react.default.createElement("span", { + className: "slds-truncate slds-col_bump-left", + title: item.bottomLeftText + }, item.bottomRightText))); +}; + +SplitViewListItemContent.displayName = DISPLAY_NAME; +SplitViewListItemContent.propTypes = propTypes; +SplitViewListItemContent.defaultProps = defaultProps; +var _default = SplitViewListItemContent; +exports.default = _default; \ No newline at end of file diff --git a/components/split-view/private/list-item-with-content.js b/components/split-view/private/list-item-with-content.js new file mode 100644 index 0000000000..e795773257 --- /dev/null +++ b/components/split-view/private/list-item-with-content.js @@ -0,0 +1,172 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = exports.DISPLAY_NAME = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var DISPLAY_NAME = 'SLDSSplitViewListItemWithContent'; +exports.DISPLAY_NAME = DISPLAY_NAME; +var propsTypes = { + /** + * **Assistive text for accessibility** + * * `unreadItem`: The unread indicator. + */ + assistiveText: _propTypes.default.shape({ + unreadItem: _propTypes.default.string + }), + + /** + * Item to be displayed + */ + item: _propTypes.default.object.isRequired, + + /** + * Allows multiple item to be selection + */ + multiple: _propTypes.default.bool, + + /** + * Shows the item as `focused`. + */ + isFocused: _propTypes.default.bool.isRequired, + + /** + * Shows the item as `selected`. + */ + isSelected: _propTypes.default.bool.isRequired, + + /** + * Shows the item as `unread`. + */ + isUnread: _propTypes.default.bool, + + /** + * **Event Callbacks** + * * `onClick`: Called when the item is clicked. + * * * Event + * * * Meta data + * * * * `item`: The original item. + * * * * `isSelected`: Is the item selected. + * * * * `isUnread`: Is the item unread. + */ + events: _propTypes.default.shape({ + onClick: _propTypes.default.func.isRequired + }), + + /** + * Reference to the list item component + */ + listItemRef: _propTypes.default.func +}; +var defaultProps = { + assistiveText: { + unreadItem: 'Unread Item' + }, + events: {} +}; +/** + * HOC that wraps the list item content with selection and unread functionality. + * @param ListItemContent {node} A React component + * @returns {ListItemWithContent} A React component + */ + +var listItemWithContent = function listItemWithContent(ListItemContent) { + var ListItemWithContent = + /*#__PURE__*/ + function (_React$Component) { + _inherits(ListItemWithContent, _React$Component); + + function ListItemWithContent() { + _classCallCheck(this, ListItemWithContent); + + return _possibleConstructorReturn(this, _getPrototypeOf(ListItemWithContent).apply(this, arguments)); + } + + _createClass(ListItemWithContent, [{ + key: "onClick", + value: function onClick(event) { + this.props.events.onClick(event, { + item: this.props.item, + isSelected: this.props.isSelected, + isUnread: this.props.isUnread + }); + } + }, { + key: "unread", + value: function unread() { + return this.props.isUnread ? _react.default.createElement("abbr", { + className: "slds-indicator_unread", + title: this.props.assistiveText.unreadItem, + "aria-label": this.props.assistiveText.unreadItem + }, _react.default.createElement("span", { + className: "slds-assistive-text" + }, "\u25CF")) : null; + } + }, { + key: "render", + value: function render() { + var _this = this; + + return _react.default.createElement("li", { + className: (0, _classnames.default)('slds-split-view__list-item', { + 'slds-is-unread': this.props.isUnread + }), + role: "presentation" + }, _react.default.createElement("a", { + className: "slds-split-view__list-item-action slds-grow slds-has-flexi-truncate", + role: "option", + ref: this.props.listItemRef, + "aria-selected": this.props.multiple ? !!this.props.isSelected : this.props.isSelected, + tabIndex: this.props.isFocused ? 0 : -1, + href: "javascript:void(0);" // eslint-disable-line no-script-url + , + onClick: function onClick(e) { + return _this.onClick(e); + } + }, this.unread(), _react.default.createElement(ListItemContent, this.props))); + } + }]); + + return ListItemWithContent; + }(_react.default.Component); + + _defineProperty(ListItemWithContent, "displayName", "".concat(DISPLAY_NAME, "(").concat(ListItemContent.displayName || ListItemContent.name || 'Component', ")")); + + _defineProperty(ListItemWithContent, "propTypes", propsTypes); + + _defineProperty(ListItemWithContent, "defaultProps", defaultProps); + + return ListItemWithContent; +}; + +var _default = listItemWithContent; +exports.default = _default; \ No newline at end of file diff --git a/components/split-view/private/toggle-button.js b/components/split-view/private/toggle-button.js new file mode 100644 index 0000000000..493246d854 --- /dev/null +++ b/components/split-view/private/toggle-button.js @@ -0,0 +1,84 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = exports.TOGGLE_BUTTON_WIDTH = exports.DISPLAY_NAME = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _button = _interopRequireDefault(require("../../button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +var DISPLAY_NAME = 'SLDSSplitViewToggleButton'; +exports.DISPLAY_NAME = DISPLAY_NAME; +var TOGGLE_BUTTON_WIDTH = '0.75rem'; +exports.TOGGLE_BUTTON_WIDTH = TOGGLE_BUTTON_WIDTH; +var propsTypes = { + /** + * **Assistive text for accessibility** + * * `toggleButtonOpen`: The button used to open the split view. + * * `toggleButtonClose`: The button used to close the split view. + */ + assistiveText: _propTypes.default.shape({ + toggleButtonOpen: _propTypes.default.string.isRequired, + toggleButtonClose: _propTypes.default.string.isRequired + }), + + /** + * Unique html id placed on the button for aria-controls + */ + ariaControls: _propTypes.default.string.isRequired, + + /** + * Determines if the panel is open + */ + isOpen: _propTypes.default.bool.isRequired, + + /** + * **Event Callbacks** + * * `onClick`: Called when the button is clicked. + */ + events: _propTypes.default.shape({ + onClick: _propTypes.default.func.isRequired + }) +}; +var defaultProps = {}; + +var SplitViewToggleButton = function SplitViewToggleButton(_ref) { + var isOpen = _ref.isOpen, + assistiveText = _ref.assistiveText, + ariaControls = _ref.ariaControls, + events = _ref.events; + var toggleAssistiveText = isOpen ? assistiveText.toggleButtonOpen : assistiveText.toggleButtonClose; + return _react.default.createElement(_button.default, { + className: (0, _classnames.default)('slds-button slds-button_icon slds-split-view__toggle-button', { + 'slds-is-open': isOpen + }), + "aria-expanded": isOpen, + "aria-controls": ariaControls, + title: toggleAssistiveText, + variant: "base", + iconName: "left", + iconCategory: "utility", + iconSize: "x-small", + onClick: events.onClick, + assistiveText: { + icon: toggleAssistiveText + } + }); +}; + +SplitViewToggleButton.displayName = DISPLAY_NAME; +SplitViewToggleButton.propTypes = propsTypes; +SplitViewToggleButton.defaultProps = defaultProps; +var _default = SplitViewToggleButton; +exports.default = _default; \ No newline at end of file diff --git a/components/story-based-tests.js b/components/story-based-tests.js new file mode 100644 index 0000000000..96962c2c0b --- /dev/null +++ b/components/story-based-tests.js @@ -0,0 +1,255 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "Blank", { + enumerable: true, + get: function get() { + return _initialBlankStories.default; + } +}); +Object.defineProperty(exports, "Accordion", { + enumerable: true, + get: function get() { + return _storybookStories.default; + } +}); +Object.defineProperty(exports, "Alert", { + enumerable: true, + get: function get() { + return _storybookStories2.default; + } +}); +Object.defineProperty(exports, "Avatar", { + enumerable: true, + get: function get() { + return _storybookStories3.default; + } +}); +Object.defineProperty(exports, "BrandBand", { + enumerable: true, + get: function get() { + return _storybookStories4.default; + } +}); +Object.defineProperty(exports, "Breadcrumb", { + enumerable: true, + get: function get() { + return _storybookStories5.default; + } +}); +Object.defineProperty(exports, "Button", { + enumerable: true, + get: function get() { + return _storybookStories6.default; + } +}); +Object.defineProperty(exports, "ButtonGroup", { + enumerable: true, + get: function get() { + return _storybookStories7.default; + } +}); +Object.defineProperty(exports, "ButtonStateful", { + enumerable: true, + get: function get() { + return _storybookStories8.default; + } +}); +Object.defineProperty(exports, "Card", { + enumerable: true, + get: function get() { + return _storybookStories9.default; + } +}); +Object.defineProperty(exports, "Carousel", { + enumerable: true, + get: function get() { + return _storybookStories10.default; + } +}); +Object.defineProperty(exports, "Checkbox", { + enumerable: true, + get: function get() { + return _storybookStories11.default; + } +}); +Object.defineProperty(exports, "ColorPicker", { + enumerable: true, + get: function get() { + return _storybookStories12.default; + } +}); +Object.defineProperty(exports, "Combobox", { + enumerable: true, + get: function get() { + return _storybookStories13.default; + } +}); +Object.defineProperty(exports, "Filter", { + enumerable: true, + get: function get() { + return _storybookStories14.default; + } +}); +Object.defineProperty(exports, "DataTable", { + enumerable: true, + get: function get() { + return _storybookStories15.default; + } +}); +Object.defineProperty(exports, "DynamicIcon", { + enumerable: true, + get: function get() { + return _storybookStories16.default; + } +}); +Object.defineProperty(exports, "GlobalHeader", { + enumerable: true, + get: function get() { + return _storybookStories17.default; + } +}); +Object.defineProperty(exports, "Input", { + enumerable: true, + get: function get() { + return _storybookStories18.default; + } +}); +Object.defineProperty(exports, "Icon", { + enumerable: true, + get: function get() { + return _storybookStories19.default; + } +}); +Object.defineProperty(exports, "Illustration", { + enumerable: true, + get: function get() { + return _storybookStories20.default; + } +}); +Object.defineProperty(exports, "MediaObject", { + enumerable: true, + get: function get() { + return _storybookStories21.default; + } +}); +Object.defineProperty(exports, "PageHeader", { + enumerable: true, + get: function get() { + return _storybookStories22.default; + } +}); +Object.defineProperty(exports, "PillContainer", { + enumerable: true, + get: function get() { + return _storybookStories23.default; + } +}); +Object.defineProperty(exports, "Popover", { + enumerable: true, + get: function get() { + return _storybookStories24.default; + } +}); +Object.defineProperty(exports, "ProgressIndicator", { + enumerable: true, + get: function get() { + return _storybookStories25.default; + } +}); +Object.defineProperty(exports, "ProgressBar", { + enumerable: true, + get: function get() { + return _storybookStories26.default; + } +}); +Object.defineProperty(exports, "Spinner", { + enumerable: true, + get: function get() { + return _storybookStories27.default; + } +}); +Object.defineProperty(exports, "ScopedNotification", { + enumerable: true, + get: function get() { + return _storybookStories28.default; + } +}); +Object.defineProperty(exports, "Tooltip", { + enumerable: true, + get: function get() { + return _storybookStories29.default; + } +}); +Object.defineProperty(exports, "Tree", { + enumerable: true, + get: function get() { + return _storybookStories30.default; + } +}); + +var _initialBlankStories = _interopRequireDefault(require("../tests/initial-blank-stories")); + +var _storybookStories = _interopRequireDefault(require("../components/accordion/__docs__/storybook-stories")); + +var _storybookStories2 = _interopRequireDefault(require("../components/alert/__docs__/storybook-stories")); + +var _storybookStories3 = _interopRequireDefault(require("../components/avatar/__docs__/storybook-stories")); + +var _storybookStories4 = _interopRequireDefault(require("../components/brand-band/__docs__/storybook-stories")); + +var _storybookStories5 = _interopRequireDefault(require("../components/breadcrumb/__docs__/storybook-stories")); + +var _storybookStories6 = _interopRequireDefault(require("../components/button/__docs__/storybook-stories")); + +var _storybookStories7 = _interopRequireDefault(require("../components/button-group/__docs__/storybook-stories")); + +var _storybookStories8 = _interopRequireDefault(require("../components/button-stateful/__docs__/storybook-stories")); + +var _storybookStories9 = _interopRequireDefault(require("../components/card/__docs__/storybook-stories")); + +var _storybookStories10 = _interopRequireDefault(require("../components/carousel/__docs__/storybook-stories")); + +var _storybookStories11 = _interopRequireDefault(require("../components/checkbox/__docs__/storybook-stories")); + +var _storybookStories12 = _interopRequireDefault(require("../components/color-picker/__docs__/storybook-stories")); + +var _storybookStories13 = _interopRequireDefault(require("../components/combobox/__docs__/storybook-stories")); + +var _storybookStories14 = _interopRequireDefault(require("../components/filter/__docs__/storybook-stories")); + +var _storybookStories15 = _interopRequireDefault(require("../components/data-table/__docs__/storybook-stories")); + +var _storybookStories16 = _interopRequireDefault(require("../components/dynamic-icon/__docs__/storybook-stories")); + +var _storybookStories17 = _interopRequireDefault(require("../components/global-header/__docs__/storybook-stories")); + +var _storybookStories18 = _interopRequireDefault(require("../components/input/__docs__/storybook-stories")); + +var _storybookStories19 = _interopRequireDefault(require("../components/icon/__docs__/storybook-stories")); + +var _storybookStories20 = _interopRequireDefault(require("../components/illustration/__docs__/storybook-stories")); + +var _storybookStories21 = _interopRequireDefault(require("../components/media-object/__docs__/storybook-stories")); + +var _storybookStories22 = _interopRequireDefault(require("../components/page-header/__docs__/storybook-stories")); + +var _storybookStories23 = _interopRequireDefault(require("../components/pill-container/__docs__/storybook-stories")); + +var _storybookStories24 = _interopRequireDefault(require("../components/popover/__docs__/storybook-stories")); + +var _storybookStories25 = _interopRequireDefault(require("../components/progress-indicator/__docs__/storybook-stories")); + +var _storybookStories26 = _interopRequireDefault(require("../components/progress-bar/__docs__/storybook-stories")); + +var _storybookStories27 = _interopRequireDefault(require("../components/spinner/__docs__/storybook-stories")); + +var _storybookStories28 = _interopRequireDefault(require("../components/scoped-notification/__docs__/storybook-stories")); + +var _storybookStories29 = _interopRequireDefault(require("../components/tooltip/__docs__/storybook-stories")); + +var _storybookStories30 = _interopRequireDefault(require("../components/tree/__docs__/storybook-stories")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/components/storybook-stories.js b/components/storybook-stories.js new file mode 100644 index 0000000000..9eda79f6b9 --- /dev/null +++ b/components/storybook-stories.js @@ -0,0 +1,439 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "Accordion", { + enumerable: true, + get: function get() { + return _storybookStories.default; + } +}); +Object.defineProperty(exports, "Alert", { + enumerable: true, + get: function get() { + return _storybookStories2.default; + } +}); +Object.defineProperty(exports, "AppLauncher", { + enumerable: true, + get: function get() { + return _storybookStories3.default; + } +}); +Object.defineProperty(exports, "Avatar", { + enumerable: true, + get: function get() { + return _storybookStories4.default; + } +}); +Object.defineProperty(exports, "BrandBand", { + enumerable: true, + get: function get() { + return _storybookStories5.default; + } +}); +Object.defineProperty(exports, "Breadcrumb", { + enumerable: true, + get: function get() { + return _storybookStories6.default; + } +}); +Object.defineProperty(exports, "Button", { + enumerable: true, + get: function get() { + return _storybookStories7.default; + } +}); +Object.defineProperty(exports, "ButtonGroup", { + enumerable: true, + get: function get() { + return _storybookStories8.default; + } +}); +Object.defineProperty(exports, "ButtonStateful", { + enumerable: true, + get: function get() { + return _storybookStories9.default; + } +}); +Object.defineProperty(exports, "Card", { + enumerable: true, + get: function get() { + return _storybookStories10.default; + } +}); +Object.defineProperty(exports, "Carousel", { + enumerable: true, + get: function get() { + return _storybookStories11.default; + } +}); +Object.defineProperty(exports, "Checkbox", { + enumerable: true, + get: function get() { + return _storybookStories12.default; + } +}); +Object.defineProperty(exports, "ColorPicker", { + enumerable: true, + get: function get() { + return _storybookStories13.default; + } +}); +Object.defineProperty(exports, "Combobox", { + enumerable: true, + get: function get() { + return _storybookStories14.default; + } +}); +Object.defineProperty(exports, "Filter", { + enumerable: true, + get: function get() { + return _storybookStories15.default; + } +}); +Object.defineProperty(exports, "GlobalNavigationBar", { + enumerable: true, + get: function get() { + return _storybookStories16.default; + } +}); +Object.defineProperty(exports, "DataTable", { + enumerable: true, + get: function get() { + return _storybookStories17.default; + } +}); +Object.defineProperty(exports, "DatePicker", { + enumerable: true, + get: function get() { + return _storybookStories18.default; + } +}); +Object.defineProperty(exports, "DynamicIcon", { + enumerable: true, + get: function get() { + return _storybookStories19.default; + } +}); +Object.defineProperty(exports, "Dropdown", { + enumerable: true, + get: function get() { + return _storybookStories20.default; + } +}); +Object.defineProperty(exports, "IconSettings", { + enumerable: true, + get: function get() { + return _storybookStories21.default; + } +}); +Object.defineProperty(exports, "Input", { + enumerable: true, + get: function get() { + return _storybookStories22.default; + } +}); +Object.defineProperty(exports, "Teaxtarea", { + enumerable: true, + get: function get() { + return _storybookStories23.default; + } +}); +Object.defineProperty(exports, "InlineInput", { + enumerable: true, + get: function get() { + return _storybookStories24.default; + } +}); +Object.defineProperty(exports, "Search", { + enumerable: true, + get: function get() { + return _storybookStories25.default; + } +}); +Object.defineProperty(exports, "GlobalHeader", { + enumerable: true, + get: function get() { + return _storybookStories26.default; + } +}); +Object.defineProperty(exports, "Icon", { + enumerable: true, + get: function get() { + return _storybookStories27.default; + } +}); +Object.defineProperty(exports, "Illustration", { + enumerable: true, + get: function get() { + return _storybookStories28.default; + } +}); +Object.defineProperty(exports, "Lookup", { + enumerable: true, + get: function get() { + return _storybookStories29.default; + } +}); +Object.defineProperty(exports, "MediaObject", { + enumerable: true, + get: function get() { + return _storybookStories30.default; + } +}); +Object.defineProperty(exports, "Modal", { + enumerable: true, + get: function get() { + return _storybookStories31.default; + } +}); +Object.defineProperty(exports, "Notification", { + enumerable: true, + get: function get() { + return _storybookStories32.default; + } +}); +Object.defineProperty(exports, "PageHeader", { + enumerable: true, + get: function get() { + return _storybookStories33.default; + } +}); +Object.defineProperty(exports, "Panel", { + enumerable: true, + get: function get() { + return _storybookStories34.default; + } +}); +Object.defineProperty(exports, "Pill", { + enumerable: true, + get: function get() { + return _storybookStories35.default; + } +}); +Object.defineProperty(exports, "PillContainer", { + enumerable: true, + get: function get() { + return _storybookStories36.default; + } +}); +Object.defineProperty(exports, "Popover", { + enumerable: true, + get: function get() { + return _storybookStories37.default; + } +}); +Object.defineProperty(exports, "ProgressIndicator", { + enumerable: true, + get: function get() { + return _storybookStories38.default; + } +}); +Object.defineProperty(exports, "ProgressRing", { + enumerable: true, + get: function get() { + return _storybookStories39.default; + } +}); +Object.defineProperty(exports, "ProgressBar", { + enumerable: true, + get: function get() { + return _storybookStories40.default; + } +}); +Object.defineProperty(exports, "Picklist", { + enumerable: true, + get: function get() { + return _storybookStories41.default; + } +}); +Object.defineProperty(exports, "RadioGroup", { + enumerable: true, + get: function get() { + return _storybookStories42.default; + } +}); +Object.defineProperty(exports, "Radio", { + enumerable: true, + get: function get() { + return _storybookStories43.default; + } +}); +Object.defineProperty(exports, "RadioButtonGroup", { + enumerable: true, + get: function get() { + return _storybookStories44.default; + } +}); +Object.defineProperty(exports, "ScopedNotification", { + enumerable: true, + get: function get() { + return _storybookStories45.default; + } +}); +Object.defineProperty(exports, "Slider", { + enumerable: true, + get: function get() { + return _storybookStories46.default; + } +}); +Object.defineProperty(exports, "SplitView", { + enumerable: true, + get: function get() { + return _storybookStories47.default; + } +}); +Object.defineProperty(exports, "Spinner", { + enumerable: true, + get: function get() { + return _storybookStories48.default; + } +}); +Object.defineProperty(exports, "Tabs", { + enumerable: true, + get: function get() { + return _storybookStories49.default; + } +}); +Object.defineProperty(exports, "TimePicker", { + enumerable: true, + get: function get() { + return _storybookStories50.default; + } +}); +Object.defineProperty(exports, "Toast", { + enumerable: true, + get: function get() { + return _storybookStories51.default; + } +}); +Object.defineProperty(exports, "Tooltip", { + enumerable: true, + get: function get() { + return _storybookStories52.default; + } +}); +Object.defineProperty(exports, "Tree", { + enumerable: true, + get: function get() { + return _storybookStories53.default; + } +}); +Object.defineProperty(exports, "VerticalNavigation", { + enumerable: true, + get: function get() { + return _storybookStories54.default; + } +}); + +var _storybookStories = _interopRequireDefault(require("../components/accordion/__docs__/storybook-stories")); + +var _storybookStories2 = _interopRequireDefault(require("../components/alert/__docs__/storybook-stories")); + +var _storybookStories3 = _interopRequireDefault(require("../components/app-launcher/__docs__/storybook-stories")); + +var _storybookStories4 = _interopRequireDefault(require("../components/avatar/__docs__/storybook-stories")); + +var _storybookStories5 = _interopRequireDefault(require("../components/brand-band/__docs__/storybook-stories")); + +var _storybookStories6 = _interopRequireDefault(require("../components/breadcrumb/__docs__/storybook-stories")); + +var _storybookStories7 = _interopRequireDefault(require("../components/button/__docs__/storybook-stories")); + +var _storybookStories8 = _interopRequireDefault(require("../components/button-group/__docs__/storybook-stories")); + +var _storybookStories9 = _interopRequireDefault(require("../components/button-stateful/__docs__/storybook-stories")); + +var _storybookStories10 = _interopRequireDefault(require("../components/card/__docs__/storybook-stories")); + +var _storybookStories11 = _interopRequireDefault(require("../components/carousel/__docs__/storybook-stories")); + +var _storybookStories12 = _interopRequireDefault(require("../components/checkbox/__docs__/storybook-stories")); + +var _storybookStories13 = _interopRequireDefault(require("../components/color-picker/__docs__/storybook-stories")); + +var _storybookStories14 = _interopRequireDefault(require("../components/combobox/__docs__/storybook-stories")); + +var _storybookStories15 = _interopRequireDefault(require("../components/filter/__docs__/storybook-stories")); + +var _storybookStories16 = _interopRequireDefault(require("../components/global-navigation-bar/__docs__/storybook-stories")); + +var _storybookStories17 = _interopRequireDefault(require("../components/data-table/__docs__/storybook-stories")); + +var _storybookStories18 = _interopRequireDefault(require("../components/date-picker/__docs__/storybook-stories")); + +var _storybookStories19 = _interopRequireDefault(require("../components/dynamic-icon/__docs__/storybook-stories")); + +var _storybookStories20 = _interopRequireDefault(require("../components/menu-dropdown/__docs__/storybook-stories")); + +var _storybookStories21 = _interopRequireDefault(require("../components/icon-settings/__docs__/storybook-stories")); + +var _storybookStories22 = _interopRequireDefault(require("../components/input/__docs__/storybook-stories")); + +var _storybookStories23 = _interopRequireDefault(require("../components/textarea/__docs__/storybook-stories")); + +var _storybookStories24 = _interopRequireDefault(require("../components/forms/input/__docs__/inline/storybook-stories")); + +var _storybookStories25 = _interopRequireDefault(require("../components/input/__docs__/search/storybook-stories")); + +var _storybookStories26 = _interopRequireDefault(require("../components/global-header/__docs__/storybook-stories")); + +var _storybookStories27 = _interopRequireDefault(require("../components/icon/__docs__/storybook-stories")); + +var _storybookStories28 = _interopRequireDefault(require("../components/illustration/__docs__/storybook-stories")); + +var _storybookStories29 = _interopRequireDefault(require("../components/lookup/__docs__/storybook-stories")); + +var _storybookStories30 = _interopRequireDefault(require("../components/media-object/__docs__/storybook-stories")); + +var _storybookStories31 = _interopRequireDefault(require("../components/modal/__docs__/storybook-stories")); + +var _storybookStories32 = _interopRequireDefault(require("../components/notification/__docs__/storybook-stories")); + +var _storybookStories33 = _interopRequireDefault(require("../components/page-header/__docs__/storybook-stories")); + +var _storybookStories34 = _interopRequireDefault(require("../components/panel/__docs__/storybook-stories")); + +var _storybookStories35 = _interopRequireDefault(require("../components/pill/__docs__/storybook-stories")); + +var _storybookStories36 = _interopRequireDefault(require("../components/pill-container/__docs__/storybook-stories")); + +var _storybookStories37 = _interopRequireDefault(require("../components/popover/__docs__/storybook-stories")); + +var _storybookStories38 = _interopRequireDefault(require("../components/progress-indicator/__docs__/storybook-stories")); + +var _storybookStories39 = _interopRequireDefault(require("../components/progress-ring/__docs__/storybook-stories")); + +var _storybookStories40 = _interopRequireDefault(require("../components/progress-bar/__docs__/storybook-stories")); + +var _storybookStories41 = _interopRequireDefault(require("../components/menu-picklist/__docs__/storybook-stories")); + +var _storybookStories42 = _interopRequireDefault(require("../components/radio-group/__docs__/storybook-stories")); + +var _storybookStories43 = _interopRequireDefault(require("../components/radio/__docs__/storybook-stories")); + +var _storybookStories44 = _interopRequireDefault(require("../components/radio-button-group/__docs__/storybook-stories")); + +var _storybookStories45 = _interopRequireDefault(require("../components/scoped-notification/__docs__/storybook-stories")); + +var _storybookStories46 = _interopRequireDefault(require("../components/slider/__docs__/storybook-stories")); + +var _storybookStories47 = _interopRequireDefault(require("../components/split-view/__docs__/storybook-stories")); + +var _storybookStories48 = _interopRequireDefault(require("../components/spinner/__docs__/storybook-stories")); + +var _storybookStories49 = _interopRequireDefault(require("../components/tabs/__docs__/storybook-stories")); + +var _storybookStories50 = _interopRequireDefault(require("../components/time-picker/__docs__/storybook-stories")); + +var _storybookStories51 = _interopRequireDefault(require("../components/toast/__docs__/storybook-stories")); + +var _storybookStories52 = _interopRequireDefault(require("../components/tooltip/__docs__/storybook-stories")); + +var _storybookStories53 = _interopRequireDefault(require("../components/tree/__docs__/storybook-stories")); + +var _storybookStories54 = _interopRequireDefault(require("../components/vertical-navigation/__docs__/storybook-stories")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/components/tabs/__docs__/site-stories.js b/components/tabs/__docs__/site-stories.js new file mode 100644 index 0000000000..dd0b47f225 --- /dev/null +++ b/components/tabs/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/tabs/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/tabs/__examples__/scoped.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/tabs/__docs__/storybook-stories.js b/components/tabs/__docs__/storybook-stories.js new file mode 100644 index 0000000000..208b2e9abb --- /dev/null +++ b/components/tabs/__docs__/storybook-stories.js @@ -0,0 +1,651 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _tabs = _interopRequireDefault(require("../../tabs")); + +var _panel = _interopRequireDefault(require("../../tabs/panel")); + +var _input = _interopRequireDefault(require("../../input")); + +var _inputIcon = _interopRequireDefault(require("../../icon/input-icon")); + +var _checkbox = _interopRequireDefault(require("../../checkbox")); + +var _button = _interopRequireDefault(require("../../button")); + +var _icon = _interopRequireDefault(require("../../icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/display-name */ +var getTabs = function getTabs() { + return _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_large" + }, "Base Tabs Demo"), _react.default.createElement(_tabs.default, { + id: "main-tabs-demo", + className: "custom-class-is-custom", + foo: "baz" + }, _react.default.createElement(_panel.default, { + label: "Tab 1" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 1 contents!"), _react.default.createElement("p", null, "And they\u2019re amazing."), _react.default.createElement("p", null, "It\"s awesome."), _react.default.createElement("p", null, "You can use your ", _react.default.createElement("var", null, "TAB"), " and ", _react.default.createElement("var", null, "ARROW"), " keys to navigate around. Try it!"), _react.default.createElement("p", { + className: "slds-box slds-theme_info slds-m-top_large" + }, "(You might have to hit shift+tab to put the focus onto the tab bar ;)")), _react.default.createElement(_panel.default, { + label: "Tab 2" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 2 contents!"), _react.default.createElement("p", null, "And they\u2019re also amazing.")), _react.default.createElement(_panel.default, { + label: "Tab 3" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 3 contents!"), _react.default.createElement("p", null, "And they\u2019re quite spectacular.")))); +}; +/* eslint-enable react/display-name */ + +/* eslint-disable react/display-name */ + + +var getTabsMoreThanOneAllowGeneratedID = function getTabsMoreThanOneAllowGeneratedID() { + return _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_large" + }, "Generated Unique IDs Demo"), _react.default.createElement(_tabs.default, null, _react.default.createElement(_panel.default, { + label: "Only 1 Tab" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "About this story"), _react.default.createElement("p", null, "There should be two instances of Tabs in this story, and each should have a unique (generated) ID."))), _react.default.createElement(_tabs.default, null, _react.default.createElement(_panel.default, { + label: "Only 1 Tab" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "About this story"), _react.default.createElement("p", null, "There should be two instances of Tabs in this story, and each should have a unique (generated) ID.")))); +}; +/* eslint-enable react/display-name */ + +/* eslint-disable react/display-name */ + + +var getTabsNested = function getTabsNested() { + return _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_large" + }, "Nested Tabs Demo"), _react.default.createElement(_tabs.default, { + id: "nested-tabs-demo" + }, _react.default.createElement(_panel.default, { + label: "Tab 1" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 1 contents!"), _react.default.createElement("p", null, "And they\u2019re ", _react.default.createElement("a", { + href: "#amazing" + }, "amazing"), ".")), _react.default.createElement(_panel.default, { + label: "Tab 2" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 2 contents!"), _react.default.createElement("p", null, "And they\u2019re also amazing."), _react.default.createElement(_input.default, { + id: "unique-id-123", + name: "left-clickable-icon", + label: "Input Label", + iconLeft: _react.default.createElement(_inputIcon.default, { + name: "search", + category: "utility", + onClick: (0, _addonActions.action)('search icon clicked') + }), + placeholder: "You can tab onto this to focus it." + })), _react.default.createElement(_panel.default, { + label: "Tab 3 (has children)" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 3 contents!"), _react.default.createElement("p", null, "And they\u2019re tabceptionish."), _react.default.createElement("div", { + className: "slds-box slds-m-vertical_large" + }, _react.default.createElement(_tabs.default, { + defaultSelectedIndex: 0 + }, _react.default.createElement(_panel.default, { + label: "Tab 1" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 1 contents!"), _react.default.createElement("p", null, "And they\u2019re amazing.")), _react.default.createElement(_panel.default, { + label: "Tab 2" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 2 contents!"), _react.default.createElement("p", null, "And they\u2019re also amazing.")), _react.default.createElement(_panel.default, { + label: "Tab 3 (Also has children!)" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 3 contents!"), _react.default.createElement("p", null, "And they\u2019re even ", _react.default.createElement("em", null, "more"), " tabceptionish."), _react.default.createElement("div", { + className: "slds-box slds-m-vertical_large" + }, _react.default.createElement(_tabs.default, { + defaultSelectedIndex: 0 + }, _react.default.createElement(_panel.default, { + label: "Tab 1 (no children!)" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 1 contents!"), _react.default.createElement("p", null, "And they\u2019re amazing.")))))))))); +}; +/* eslint-enable react/display-name */ + +/* eslint-disable react/display-name */ + + +var getTabsScoped = function getTabsScoped() { + return _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_large" + }, "Scoped Tabs Demo"), _react.default.createElement(_tabs.default, { + id: "scoped-tabs-demo", + variant: "scoped" + }, _react.default.createElement(_panel.default, { + label: "Tab 1" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 1 contents!"), _react.default.createElement("p", null, "And they\u2019re amazing."), _react.default.createElement("p", null, "It\"s awesome."), _react.default.createElement("p", null, "You can use your ", _react.default.createElement("var", null, "TAB"), " and ", _react.default.createElement("var", null, "ARROW"), " keys to navigate around. Try it!"), _react.default.createElement("p", { + className: "slds-box slds-theme_info slds-m-top_large" + }, "(You might have to hit shift+tab to put the focus onto the tab bar ;)")), _react.default.createElement(_panel.default, { + label: "Tab 2" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 2 contents!"), _react.default.createElement("p", null, "And they\u2019re also amazing.")), _react.default.createElement(_panel.default, { + label: "Tab 3" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 3 contents!"), _react.default.createElement("p", null, "And they\u2019re quite spectacular.")))); +}; +/* eslint-enable react/display-name */ + + +var DemoTabsConditional = +/*#__PURE__*/ +function (_React$Component) { + _inherits(DemoTabsConditional, _React$Component); + + function DemoTabsConditional() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, DemoTabsConditional); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DemoTabsConditional)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + showA: true, + showB: true, + showC: true, + disableA: false, + disableB: true, + disableC: true + }); + + _defineProperty(_assertThisInitialized(_this), "handleCheckClicked", function (checked, event) { + var state = {}; + state[event.target.name] = checked; + + _this.setState(state); + }); + + _defineProperty(_assertThisInitialized(_this), "handleCheckClickedDisable", function (checked, event) { + var state = {}; + state[event.target.name] = checked; + + _this.setState(state); + }); + + _defineProperty(_assertThisInitialized(_this), "renderPaneA", function (disabled) { + return _react.default.createElement(_panel.default, { + label: "Tab A", + disabled: disabled + }, _react.default.createElement("p", null, "This is tab A."), _react.default.createElement("div", null, _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Disable tab B' + }, + checked: _this.state.disableB, + onChange: _this.handleCheckClickedDisable, + label: "Disable tab B", + name: "disableB" + }), _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Disable tab C' + }, + checked: _this.state.disableC, + onChange: _this.handleCheckClickedDisable, + label: "Disable tab C", + name: "disableC" + }))); + }); + + return _this; + } + + _createClass(DemoTabsConditional, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_large" + }, "Conditional Tabs Demo"), _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Show tab A' + }, + checked: this.state.showA, + onChange: this.handleCheckClicked, + label: "Show tab A", + name: "showA" + }), _react.default.createElement(_checkbox.default, { + assistiveText: { + label: 'Show tab B' + }, + checked: this.state.showB, + onChange: this.handleCheckClicked, + label: "Show tab B", + name: "showB" + }), _react.default.createElement(_checkbox.default, { + checked: this.state.showC, + onChange: this.handleCheckClicked, + assistiveText: { + label: 'Show tab C' + }, + label: "Show tab C", + name: "showC" + }), _react.default.createElement(_tabs.default, { + className: (0, _classnames.default)('slds-m-top_large', this.props.className), + onSelect: this.handleSelectNopesOnThree + }, this.state.showA && this.renderPaneA(this.state.disableA), this.state.showB && this.state.disableB ? _react.default.createElement(_panel.default, { + label: "Tab B", + disabled: true + }, _react.default.createElement("p", null, "This is tab B.")) : this.state.showB && _react.default.createElement(_panel.default, { + label: "Tab B" + }, _react.default.createElement("p", null, "This is tab B.")), this.state.showC && this.state.disableC ? _react.default.createElement(_panel.default, { + label: "Tab C", + disabled: true + }, _react.default.createElement("p", null, "This is tab C.")) : this.state.showC && _react.default.createElement(_panel.default, { + label: "Tab C" + }, _react.default.createElement("p", null, "This is tab C.")))); + } + }]); + + return DemoTabsConditional; +}(_react.default.Component); + +_defineProperty(DemoTabsConditional, "displayName", 'DemoTabsConditional'); + +_defineProperty(DemoTabsConditional, "propTypes", { + /** + * Class names to be added to the container element and is passed along to its children. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]) +}); + +var DemoTabsOutsideControl = +/*#__PURE__*/ +function (_React$Component2) { + _inherits(DemoTabsOutsideControl, _React$Component2); + + function DemoTabsOutsideControl() { + var _getPrototypeOf3; + + var _this2; + + _classCallCheck(this, DemoTabsOutsideControl); + + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + _this2 = _possibleConstructorReturn(this, (_getPrototypeOf3 = _getPrototypeOf(DemoTabsOutsideControl)).call.apply(_getPrototypeOf3, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this2), "state", { + whichOneSelectedYo: _this2.props.whichOneSelectedYo || 0, + prevOneSelectedYo: _this2.props.prevOneSelectedYo || 0 + }); + + _defineProperty(_assertThisInitialized(_this2), "handleSelect", function (index, last) { + var toReturn = true; + + if (index === _this2.state.whichOneSelectedYo && last === _this2.state.prevOneSelectedYo) { + toReturn = false; + } else { + (0, _addonActions.action)('handleSelect')(index, last); + + _this2.setState({ + whichOneSelectedYo: index, + prevOneSelectedYo: last + }); + } + + return toReturn; + }); + + _defineProperty(_assertThisInitialized(_this2), "showState", function () { + (0, _addonActions.action)('showState (current)')(_this2.state.whichOneSelectedYo); + (0, _addonActions.action)('showState (previous)')(_this2.state.prevOneSelectedYo); + }); + + _defineProperty(_assertThisInitialized(_this2), "handleButtonClicked", function (event) { + var prevOneSelected = _this2.state.prevOneSelectedYo; + var thisOneSelected = _this2.state.whichOneSelectedYo; + (0, _addonActions.action)('handleButtonClicked')(event.currentTarget.id); + + switch (event.currentTarget.id) { + case 'monday': + _this2.handleSelect(0, thisOneSelected); + + break; + + case 'tuesday': + _this2.handleSelect(1, thisOneSelected); + + break; + + case 'tuesday-alt': + _this2.handleSelect(1, thisOneSelected); + + break; + + case 'wednesday': + _this2.handleSelect(2, thisOneSelected); + + break; + + case 'thursday': + _this2.handleSelect(3, thisOneSelected); + + break; + + case 'friday': + _this2.handleSelect(4, thisOneSelected); + + break; + + case 'none': + _this2.handleSelect(undefined, thisOneSelected); + + break; + + case 'previous': + _this2.handleSelect(prevOneSelected, thisOneSelected); + + break; + + case 'show-state': + _this2.showState(); + + break; + + default: + // Statements executed when none of the values match the value of the expression + _this2.handleSelect(thisOneSelected, prevOneSelected); + + } + }); + + return _this2; + } + + _createClass(DemoTabsOutsideControl, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_large" + }, "Outside Tabs Demo"), _react.default.createElement("p", null, "Here we have several buttons, which are used to pass a new", ' ', _react.default.createElement("code", null, "selectedIndex"), " into the Tabs component."), _react.default.createElement("p", { + className: "slds-m-bottom_large" + }, "This shows that you can pass a new selected index property into the component from the outside and have it re-render."), _react.default.createElement(_button.default, { + id: "show-state", + label: "Show State", + onClick: this.showState + }), _react.default.createElement(_button.default, { + id: "monday", + label: "Monday", + onClick: this.handleButtonClicked + }), _react.default.createElement(_button.default, { + id: "tuesday", + label: "Tuesday", + onClick: this.handleButtonClicked + }), _react.default.createElement(_button.default, { + id: "wednesday", + label: "Wednesday", + onClick: this.handleButtonClicked + }), _react.default.createElement(_button.default, { + id: "thursday", + label: "Thursday", + onClick: this.handleButtonClicked + }), _react.default.createElement(_button.default, { + id: "friday", + label: "Friday", + onClick: this.handleButtonClicked + }), _react.default.createElement(_button.default, { + id: "none", + label: "None", + onClick: this.handleButtonClicked + }), _react.default.createElement(_button.default, { + id: "previous", + label: "Previous", + onClick: this.handleButtonClicked + }), _react.default.createElement(_tabs.default, { + className: (0, _classnames.default)('slds-m-top_large', this.props.className), + selectedIndex: this.state.whichOneSelectedYo, + onSelect: this.handleSelect + }, _react.default.createElement(_panel.default, { + label: "Monday" + }, _react.default.createElement("p", null, "This is Monday\"s Pane."), _react.default.createElement(_button.default, { + id: "tuesday-alt", + label: "Submit and go to next tab", + onClick: this.handleButtonClicked + })), _react.default.createElement(_panel.default, { + label: "Tuesday" + }, _react.default.createElement("p", null, "This is Tuesday\"s Pane.")), _react.default.createElement(_panel.default, { + label: "Wednesday" + }, _react.default.createElement("p", null, "This is Wednesday\"s Pane.")), _react.default.createElement(_panel.default, { + label: "Thursday" + }, _react.default.createElement("p", null, "Thursday\"s Pane has far to go.")), _react.default.createElement(_panel.default, { + label: "Friday" + }, _react.default.createElement("p", null, "This is Friday\"s Pane.")))); + } + }]); + + return DemoTabsOutsideControl; +}(_react.default.Component); +/* eslint-disable react/display-name */ + + +_defineProperty(DemoTabsOutsideControl, "displayName", 'DemoTabsOutsideControl'); + +_defineProperty(DemoTabsOutsideControl, "propTypes", { + /** + * Class names to be added to the container element and is passed along to its children. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * The Tab (and corresponding TabPanel) that is selected when the component renders. Defaults to `0`. + */ + whichOneSelectedYo: _propTypes.default.number, + prevOneSelectedYo: _propTypes.default.number +}); + +var getTabsDisabled = function getTabsDisabled() { + return _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_large" + }, "Disabled Tabs Demo"), _react.default.createElement(_tabs.default, { + id: "disabled-tabs-demo" + }, _react.default.createElement(_panel.default, { + label: "Tab 1" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 1 contents!"), _react.default.createElement("p", null, "And they\u2019re amazing."), _react.default.createElement("p", null, "It\"s awesome."), _react.default.createElement("p", null, "You can use your ", _react.default.createElement("var", null, "TAB"), " and ", _react.default.createElement("var", null, "ARROW"), " keys to navigate around. Try it!"), _react.default.createElement("p", { + className: "slds-box slds-theme_info slds-m-top_large" + }, "(You might have to hit shift+tab to put the focus onto the tab bar ;)")), _react.default.createElement(_panel.default, { + label: "Tab 2", + disabled: true + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 2 contents!"), _react.default.createElement("p", null, "And they\u2019re also amazing.")), _react.default.createElement(_panel.default, { + label: "Tab 3" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 3 contents!"), _react.default.createElement("p", null, "And they\u2019re quite spectacular.")), _react.default.createElement(_panel.default, { + label: "Tab 4" + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my tab 3 contents!"), _react.default.createElement("p", null, "Note that using your arrow keys you can loop ", _react.default.createElement("em", null, "around the tabs"), "! \uD83C\uDF89")))); +}; +/* eslint-enable react/display-name */ + +/* eslint-disable react/display-name */ + + +var getCustomContentTabs = function getCustomContentTabs() { + var tab1Label = _react.default.createElement("div", { + "aria-label": "test accessibility!" + }, _react.default.createElement(_icon.default, { + category: "utility", + name: "list", + style: { + marginRight: '.5rem' + }, + size: "x-small" + }), _react.default.createElement("span", null, "my tab")); + + var tab2Label = _react.default.createElement("span", { + style: { + color: 'red' + } + }, "my other tab"); + + return _react.default.createElement("div", null, _react.default.createElement("h2", { + className: "slds-text-heading_large" + }, "Custom Tab Contents Demo"), _react.default.createElement(_tabs.default, null, _react.default.createElement(_panel.default, { + label: tab1Label + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my first custom content tab!")), _react.default.createElement(_panel.default, { + label: tab2Label + }, _react.default.createElement("h2", { + className: "slds-text-heading_medium" + }, "This is my second custom content tab!")))); +}; +/* eslint-enable react/display-name */ + + +var DemoTabsInterceptSelect = +/*#__PURE__*/ +function (_React$Component3) { + _inherits(DemoTabsInterceptSelect, _React$Component3); + + function DemoTabsInterceptSelect() { + var _getPrototypeOf4; + + var _this3; + + _classCallCheck(this, DemoTabsInterceptSelect); + + for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + _this3 = _possibleConstructorReturn(this, (_getPrototypeOf4 = _getPrototypeOf(DemoTabsInterceptSelect)).call.apply(_getPrototypeOf4, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this3), "state", { + intercepts: 0 + }); + + _defineProperty(_assertThisInitialized(_this3), "handleTabSelect", function (next, last) { + (0, _addonActions.action)('handleTabSelect')(next, last); + var intercepts = _this3.state.intercepts + 1; + + _this3.setState({ + intercepts: intercepts + }); + + return false; + }); + + return _this3; + } + + _createClass(DemoTabsInterceptSelect, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", null, _react.default.createElement(_tabs.default, { + onSelect: this.handleTabSelect + }, _react.default.createElement(_panel.default, { + label: "Panel with intercept" + }, _react.default.createElement("p", null, "Default Panel"), this.state.intercepts > 0 && _react.default.createElement("p", null, "We've intercepted navigation ".concat(this.state.intercepts, " time(s)"))), _react.default.createElement(_panel.default, { + label: "Unreachable panel" + }, _react.default.createElement("p", null, "You should never see this message"))), _react.default.createElement("div", { + style: { + height: '20px' + } + }), _react.default.createElement(_tabs.default, null, _react.default.createElement(_panel.default, { + label: "Panel still working as intended" + }, _react.default.createElement("p", null, "Default Panel")), _react.default.createElement(_panel.default, { + label: "Destination panel" + }, _react.default.createElement("p", null, "You should be able to reach this panel")))); + } + }]); + + return DemoTabsInterceptSelect; +}(_react.default.Component); + +_defineProperty(DemoTabsInterceptSelect, "displayName", 'DemoTabsInterceptSelect'); + +(0, _react2.storiesOf)(_constants.TABS, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base', function () { + return getTabs(); +}).add('With disabled tab', function () { + return getTabsDisabled(); +}).add('Nested', function () { + return getTabsNested(); +}).add('Outside Control', function () { + return _react.default.createElement(DemoTabsOutsideControl, { + className: "controlled-yo" + }); +}).add('Conditional', function () { + return _react.default.createElement(DemoTabsConditional, { + className: "conditional-yo" + }); +}).add('Unique Generated IDs', function () { + return getTabsMoreThanOneAllowGeneratedID(); +}).add('Scoped', function () { + return getTabsScoped(); +}).add('Custom Tab Contents', function () { + return getCustomContentTabs(); +}).add('Tab Intercept Panel Select', function () { + return _react.default.createElement(DemoTabsInterceptSelect, null); +}); \ No newline at end of file diff --git a/components/tabs/__examples__/default.js b/components/tabs/__examples__/default.js new file mode 100644 index 0000000000..27c7644a7e --- /dev/null +++ b/components/tabs/__examples__/default.js @@ -0,0 +1,76 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _tabs = _interopRequireDefault(require("../../../../components/tabs")); + +var _panel = _interopRequireDefault(require("../../../../components/tabs/panel")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_tabs.default, { + id: "tabs-example-default" + }, _react.default.createElement(_panel.default, { + label: "Item One" + }, "Item One Content"), _react.default.createElement(_panel.default, { + label: "Item Two" + }, "Item Two Content"), _react.default.createElement(_panel.default, { + label: "Item Three" + }, "Item Three Content"), _react.default.createElement(_panel.default, { + disabled: true, + label: "Disabled" + }, "Disabled Content"))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'TabsExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/tabs/__examples__/scoped.js b/components/tabs/__examples__/scoped.js new file mode 100644 index 0000000000..97e6cf43c1 --- /dev/null +++ b/components/tabs/__examples__/scoped.js @@ -0,0 +1,77 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _tabs = _interopRequireDefault(require("../../../../components/tabs")); + +var _panel = _interopRequireDefault(require("../../../../components/tabs/panel")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_tabs.default, { + variant: "scoped", + id: "tabs-example-scoped" + }, _react.default.createElement(_panel.default, { + label: "Item One" + }, "Item One Content"), _react.default.createElement(_panel.default, { + label: "Item Two" + }, "Item Two Content"), _react.default.createElement(_panel.default, { + label: "Item Three" + }, "Item Three Content"), _react.default.createElement(_panel.default, { + disabled: true, + label: "Disabled" + }, "Disabled Content"))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'TabsExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/tabs/docs.json b/components/tabs/docs.json new file mode 100644 index 0000000000..0f6e55f5a9 --- /dev/null +++ b/components/tabs/docs.json @@ -0,0 +1,16 @@ +{ + "component": "tabs", + "status": "prod", + "display-name": "Tabs", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/tabs", + "dependencies": [ + { + "component": "panel" + } + ], + "url-slug": "tabss" +} \ No newline at end of file diff --git a/components/tabs/index.js b/components/tabs/index.js new file mode 100644 index 0000000000..1a23015e18 --- /dev/null +++ b/components/tabs/index.js @@ -0,0 +1,461 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _lodash = _interopRequireDefault(require("lodash.isfunction")); + +var _tabsList = _interopRequireDefault(require("./private/tabs-list")); + +var _tab3 = _interopRequireDefault(require("./private/tab")); + +var _tabPanel = _interopRequireDefault(require("./private/tab-panel")); + +var _constants = require("../../utilities/constants"); + +var _keyCode = _interopRequireDefault(require("../../utilities/key-code")); + +var _event = _interopRequireDefault(require("../../utilities/event")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// Determine if a node from event.target is a Tab element +function isTabNode(node) { + return node.nodeName === 'A' && node.getAttribute('role') === 'tab' || node.nodeName === 'LI' && node.getAttribute('role') === 'tab'; +} // Determine if a tab node is disabled + + +function isTabDisabled(node) { + if (node.getAttribute) { + return node.getAttribute('aria-disabled') === 'true'; + } + + return !!node.props.disabled; +} +/** + * Tabs keeps related content in a single container that is shown and hidden through navigation. + */ + + +var displayName = _constants.TABS; +var propTypes = { + /** + * HTML `id` attribute of primary element that has `.slds-tabs_default` on it. Optional: If one is not supplied, a `shortid` will be created. + */ + id: _propTypes.default.string, + + /** + * The `children` are the actual tabs and panels to be displayed. + * + * Note that the structure of the `` component **does not** correspond to the DOM structure that is rendered. The `` component requires one or more children of type ``, which themselves require a `label` property which will be what shows in the `` and has `children`, which end up being the _contents of the tab's corresponding panel_. + * + * The component iterates through each `` and rendering one `` and one `` for each of them. The tab(s) end up being children of the ``. + * + * ``` + * + * + *
    + *

    This is my tab 1 contents!

    + *

    They show when you click the first tab.

    + *
    + *
    + * + *
    + *

    This is my tab 2 contents!

    + *

    They show when you click the second tab.

    + *
    + *
    + *
    + * ``` + */ + children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node, _propTypes.default.element]).isRequired, + + /** + * Class names to be added to the container element and is passed along to its children. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * The Tab (and corresponding TabPanel) that is selected when the component first renders. Defaults to `0`. + */ + defaultSelectedIndex: _propTypes.default.number, + + /** + * This function triggers when a tab is selected. + */ + onSelect: _propTypes.default.func, + + /** + * If the Tabs should be scopped, defaults to false + */ + variant: _propTypes.default.oneOf(['default', 'scoped']), + + /** + * The Tab (and corresponding TabPanel) that is currently selected. + */ + selectedIndex: _propTypes.default.number +}; +var defaultProps = { + defaultSelectedIndex: 0, + variant: 'default' +}; +/** + * A tab keeps related content in a single container that is shown and hidden through navigation. + */ + +var Tabs = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Tabs, _React$Component); + + function Tabs(props) { + var _this; + + _classCallCheck(this, Tabs); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Tabs).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function (e) { + var node = e.target; + /* eslint-disable no-cond-assign */ + + do { + if (_this.isTabFromContainer(node)) { + if (isTabDisabled(node)) { + return; + } + + var index = [].slice.call(node.parentNode.children).indexOf(node); + + _this.setSelected(index); + + return; + } + } while ((node = node.parentNode) !== null); + /* eslint-enable no-cond-assign */ + + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) { + if (_this.isTabFromContainer(event.target)) { + var index = _this.getSelectedIndex(); + + var preventDefault = false; + + if (event.keyCode === _keyCode.default.LEFT || event.keyCode === _keyCode.default.UP) { + // Select next tab to the left + index = _this.getPrevTab(index); + preventDefault = true; + } else if (event.keyCode === _keyCode.default.RIGHT || event.keyCode === _keyCode.default.DOWN) { + // Select next tab to the right + index = _this.getNextTab(index); + preventDefault = true; + } // Prevent any dumn scrollbars from moving around as we type. + + + if (preventDefault) { + _event.default.trap(event); + } + + _this.setSelected(index, true); + } + }); + + _this.tabs = []; + return _this; + } + + _createClass(Tabs, [{ + key: "componentWillMount", + value: function componentWillMount() { + // If no `id` is supplied in the props we generate one. An HTML ID is _required_ for several elements in a tabs component in order to leverage ARIA attributes for accessibility. + this.generatedId = _shortid.default.generate(); + this.flavor = this.getVariant(); + this.setState({ + selectedIndex: this.props.defaultSelectedIndex + }); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this.setState({ + focus: false + }); + } + }, { + key: "getNextTab", + value: function getNextTab(index) { + var count = this.getTabsCount(); // Look for non-disabled tab from index to the last tab on the right + // eslint-disable-next-line no-plusplus + + for (var i = index + 1; i < count; i++) { + var tab = this.getTab(i); + + if (!isTabDisabled(tab)) { + return i; + } + } // If no tab found, continue searching from first on left to index + // eslint-disable-next-line no-plusplus + + + for (var _i = 0; _i < index; _i++) { + var _tab = this.getTab(_i); + + if (!isTabDisabled(_tab)) { + return _i; + } + } // No tabs are disabled, return index + + + return index; + } + }, { + key: "getPanelsCount", + value: function getPanelsCount() { + return this.props.children ? _react.default.Children.count(this.props.children) : 0; + } + }, { + key: "getPrevTab", + value: function getPrevTab(index) { + var i = index; // Look for non-disabled tab from index to first tab on the left + // eslint-disable-next-line no-plusplus + + while (i--) { + var tab = this.getTab(i); + + if (!isTabDisabled(tab)) { + return i; + } + } // If no tab found, continue searching from last tab on right to index + + + i = this.getTabsCount(); // eslint-disable-next-line no-plusplus + + while (i-- > index) { + var _tab2 = this.getTab(i); + + if (!isTabDisabled(_tab2)) { + return i; + } + } // No tabs are disabled, return index + + + return index; + } + }, { + key: "getSelectedIndex", + value: function getSelectedIndex() { + return Number.isInteger(this.props.selectedIndex) ? this.props.selectedIndex : this.state.selectedIndex; + } + }, { + key: "getTab", + value: function getTab(index) { + return this.tabs[index].tab; + } + }, { + key: "getTabNode", + value: function getTabNode(index) { + return this.tabs[index].node; + } + }, { + key: "getTabsCount", + value: function getTabsCount() { + return this.props.children ? _react.default.Children.count(this.props.children) : 0; + } + }, { + key: "getVariant", + value: function getVariant() { + return this.props.variant === 'scoped' ? 'scoped' : 'default'; + } + }, { + key: "setSelected", + value: function setSelected(index, focus) { + // Check index boundary + if (index < 0 || index >= this.getTabsCount()) { + return; + } // Keep reference to last index for event handler + + + var last = this.getSelectedIndex(); + /** + * This is a temporary solution that could be broken in the future without notification, + * since this component is not a controlled component and only relies on internal state. + * If this breaks in the future an alternative way to control the state from outside the + * component should be present. + * */ + + var shouldContinue; // Call change event handler + + if ((0, _lodash.default)(this.props.onSelect)) { + shouldContinue = this.props.onSelect(index, last); + } // Don't update the state if nothing has changed + + + if (shouldContinue !== false && index !== this.state.selectedIndex) { + this.setState({ + selectedIndex: index, + focus: focus === true + }); + } + } + }, { + key: "isTabFromContainer", + + /** + * Determine if a node from event.target is a Tab element for the current Tabs container. + * If the clicked element is not a Tab, it returns false. + * If it finds another Tabs container between the Tab and `this`, it returns false. + */ + value: function isTabFromContainer(node) { + // Return immediately if the clicked element is not a Tab. This prevents tab panel content from selecting a tab. + if (!isTabNode(node)) { + return false; + } // Check if the first occurrence of a Tabs container is `this` one. + + + var nodeAncestor = node.parentElement; + + do { + if (nodeAncestor === this.tabsNode) return true;else if (nodeAncestor.getAttribute('data-tabs')) break; + nodeAncestor = nodeAncestor.parentElement; + } while (nodeAncestor); + + return false; + } + }, { + key: "renderTabPanels", + value: function renderTabPanels(parentId) { + var _this2 = this; + + var children = _react.default.Children.toArray(this.props.children); + + var selectedIndex = this.getSelectedIndex(); + var result = null; + result = children.map(function (child, index) { + var tabId = "".concat(parentId, "-slds-tabs_tab-").concat(index); + var id = "".concat(parentId, "-slds-tabs_panel-").concat(index); + var selected = selectedIndex === index; + + var variant = _this2.getVariant(); + + return _react.default.createElement(_tabPanel.default, { + key: child.key, + selected: selected, + id: id, + tabId: tabId, + variant: variant + }, children[index]); + }); + return result; + } + }, { + key: "renderTabsList", + value: function renderTabsList(parentId) { + var _this3 = this; + + var children = _react.default.Children.toArray(this.props.children); + + return (// `parentId` gets consumed by TabsList, adding a suffix of `-tabs__nav` + _react.default.createElement(_tabsList.default, { + id: parentId, + variant: this.getVariant() + }, children.map(function (child, index) { + var id = "".concat(parentId, "-slds-tabs_tab-").concat(index); + var panelId = "".concat(parentId, "-slds-tabs_panel-").concat(index); + var selected = _this3.getSelectedIndex() === index; + var focus = selected && _this3.state.focus; + + var variant = _this3.getVariant(); + + return _react.default.createElement(_tab3.default, { + key: child.key, + ref: function ref(node) { + _this3.tabs[index] = { + tab: child, + node: node + }; + + if (_this3.state.focus) { + _this3.setState({ + focus: false + }); + } + }, + focus: focus, + selected: selected, + id: id, + panelId: panelId, + disabled: child.props.disabled, + variant: variant + }, child.props.label); + })) + ); + } + }, { + key: "render", + value: function render() { + var _this4 = this; + + var _this$props = this.props, + className = _this$props.className, + _this$props$id = _this$props.id, + id = _this$props$id === void 0 ? this.generatedId : _this$props$id, + _this$props$variant = _this$props.variant, + variant = _this$props$variant === void 0 ? this.getVariant : _this$props$variant; + return ( + /* eslint-disable jsx-a11y/no-static-element-interactions */ + _react.default.createElement("div", { + id: id, + className: (0, _classnames.default)({ + 'slds-tabs_default': variant === 'default', + 'slds-tabs_scoped': variant === 'scoped' + }, className), + onClick: this.handleClick, + onKeyDown: this.handleKeyDown, + "data-tabs": true, + ref: function ref(node) { + _this4.tabsNode = node; + } + }, this.renderTabsList(id), this.renderTabPanels(id)) + ); + } + }]); + + return Tabs; +}(_react.default.Component); + +Tabs.displayName = displayName; +Tabs.propTypes = propTypes; +Tabs.defaultProps = defaultProps; +var _default = Tabs; +exports.default = _default; \ No newline at end of file diff --git a/components/tabs/pane.js b/components/tabs/pane.js new file mode 100644 index 0000000000..8859dadf31 --- /dev/null +++ b/components/tabs/pane.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _panel = _interopRequireDefault(require("./panel")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// This is just an alias, Sydney Bristow. Remove at next breaking release. +var _default = _panel.default; +exports.default = _default; \ No newline at end of file diff --git a/components/tabs/panel.js b/components/tabs/panel.js new file mode 100644 index 0000000000..4ae34768fc --- /dev/null +++ b/components/tabs/panel.js @@ -0,0 +1,56 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/** + * The `` component allows us to simplify the structure of the `` component. + + * Rather than require different (deeply nested) children for tabslist, with its tab(s) as well as tabpanel(s), we provide this `TabsPanel` component which takes a `label` property that will become what is shown on the `` that will be associated with it. + + * The `children` of the Panel will be fed to the `` component, while its `label` is handled in ``, via ``. + * + * ``` + * + *
    + *

    This is my tab 1 contents!

    + *

    They show when you click the first tab.

    + *
    + *
    + * ``` + */ +var Panel = function Panel(_ref) { + var children = _ref.children; + return _react.default.createElement("div", null, _react.default.Children.toArray(children)); +}; + +Panel.displayName = _constants.TABS_PANEL; +Panel.propTypes = { + /** + * The string or element that is handed off to the `` component, ends up being the title and the label for the tab associated with its tab panel. + */ + label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]).isRequired, + + /** + * The `children` are the actual tab panels to be rendered. They get created by [tabs/index.jsx](./index.jsx) in the `renderTabPanels` function. + * + * Note that the `` component inserts a `div` element around the children, because React requires exactly one "parent" element returned. The `` component simply dips down into `children` to get the children of this wrapping `div` so that it does not get rendered in the DOM. + */ + children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node, _propTypes.default.element]).isRequired +}; +var _default = Panel; +exports.default = _default; \ No newline at end of file diff --git a/components/tabs/private/tab-panel.js b/components/tabs/private/tab-panel.js new file mode 100644 index 0000000000..d340b77fd8 --- /dev/null +++ b/components/tabs/private/tab-panel.js @@ -0,0 +1,104 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +/** + * The containers of content that are shown and hidden by `Tabs`. + */ +var TabPanel = function TabPanel(_ref) { + var className = _ref.className, + children = _ref.children, + variant = _ref.variant, + selected = _ref.selected, + id = _ref.id, + tabId = _ref.tabId, + attributes = _objectWithoutProperties(_ref, ["className", "children", "variant", "selected", "id", "tabId"]); + + return _react.default.createElement("div", { + "aria-labelledby": tabId, + className: (0, _classnames.default)(className, { + 'slds-show': selected, + 'slds-hide': !selected, + 'slds-tabs_default__content': variant === 'default', + 'slds-tabs_scoped__content': variant === 'scoped' + }), + id: id, + role: "tabpanel" + }, children.props.children); +}; + +TabPanel.displayName = _constants.TAB_PANEL; +TabPanel.propTypes = { + /** + * The `children` are the contents of the tab panel. + * + * Note that the structure of the `` component **does not** correspond to the DOM structure that is rendered. The `` component requires one or more children of type ``, which themselves require a `label` property which will be what shows in the `` and has `children`, which end up being the _contents of the tab's corresponding panel_. + * + * The component iterates through each `` and rendering one `` and one `` for each of them. The tab(s) end up being children of the ``. + * + * The tab panel component actually returns the _children_ of the _children_ which were provided by the `` component. + * + * Due to React's nature, the `` component wraps its children in a `div` element which we don't need nor want in our rendered DOM structure, so we just bypass it and get its kids via `{children.props.children}` in the render method below. + * ``` + * + * + *

    This is my tab 1 contents!

    + *

    They show when you click the first tab.

    + *
    + * + *

    This is my tab 2 contents!

    + *

    They show when you click the second tab.

    + *
    + *
    + * ``` + */ + children: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * CSS classes to be added to the tab panel. + */ + className: _propTypes.default.string, + + /** + * The HTML ID of this tab panel. Also used by the ``that controls it as `panelId`. + */ + id: _propTypes.default.string, + + /** + * Whether this panel is hidden or shown. Uses the `.slds-show` and `.slds-hide` classes. + */ + selected: _propTypes.default.bool, + + /** + * If the Tabs should be scopped, defaults to false + */ + variant: _propTypes.default.oneOf(['default', 'scoped']), + + /** + * The HTML ID of the `` that controls this panel. + */ + tabId: _propTypes.default.string +}; +TabPanel.defaultProps = { + variant: 'default', + selected: false +}; +var _default = TabPanel; +exports.default = _default; \ No newline at end of file diff --git a/components/tabs/private/tab.js b/components/tabs/private/tab.js new file mode 100644 index 0000000000..dbd530d2b8 --- /dev/null +++ b/components/tabs/private/tab.js @@ -0,0 +1,195 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* + * Disabled Tab CSS has been removed. If you'd like to use the styling, please import it in your module bundler. + */ +// import '!style-loader!css-loader!../../../styles/tabs/tab.css'; // eslint-disable-line import/no-unresolved +var Tab = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Tab, _React$Component); + + function Tab() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Tab); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Tab)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "checkFocus", function () { + if (_this.props.selected && _this.props.focus && _this.node) { + _this.node.focus(); + } + }); + + return _this; + } + + _createClass(Tab, [{ + key: "componentDidMount", + value: function componentDidMount() { + this.checkFocus(); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate() { + this.checkFocus(); + } + }, { + key: "render", + value: function render() { + var _classNames, + _this2 = this, + _classNames2; + + var _this$props = this.props, + selected = _this$props.selected, + disabled = _this$props.disabled, + panelId = _this$props.panelId, + activeTabClassName = _this$props.activeTabClassName, + disabledTabClassName = _this$props.disabledTabClassName, + className = _this$props.className, + children = _this$props.children, + id = _this$props.id, + variant = _this$props.variant; + var tabIndex; + + if (selected) { + tabIndex = '0'; + } else if (disabled) { + tabIndex = '-1'; + } else { + tabIndex = null; + } + + return _react.default.createElement("li", { + className: (0, _classnames.default)('slds-text-title_caps', className, (_classNames = {}, _defineProperty(_classNames, activeTabClassName, selected), _defineProperty(_classNames, disabledTabClassName, disabled), _defineProperty(_classNames, 'slds-tabs_default__item', variant === 'default'), _defineProperty(_classNames, 'slds-tabs_scoped__item', variant === 'scoped'), _classNames)), + role: "tab", + ref: function ref(node) { + _this2.node = node; + }, + "aria-selected": selected ? 'true' : 'false', + "aria-disabled": disabled, + "aria-controls": panelId, + tabIndex: tabIndex, + id: id, + title: typeof children === 'string' ? children : null + }, _react.default.createElement("a", { + className: (0, _classnames.default)((_classNames2 = {}, _defineProperty(_classNames2, activeTabClassName, selected), _defineProperty(_classNames2, disabledTabClassName, disabled), _defineProperty(_classNames2, 'slds-tabs_default__link', variant === 'default'), _defineProperty(_classNames2, 'slds-tabs_scoped__link', variant === 'scoped'), _classNames2)), + href: "javascript:void(0);" // eslint-disable-line no-script-url + , + role: "presentation", + tabIndex: "-1", + "aria-disabled": disabled + }, children)); + } + }]); + + return Tab; +}(_react.default.Component); + +_defineProperty(Tab, "displayName", _constants.TAB); + +_defineProperty(Tab, "propTypes", { + /** + * CSS classes to be added to the tab. + */ + className: _propTypes.default.string, + + /** + * The HTML ID of this tab. Also used by the `` it controls as `tabId`. + */ + id: _propTypes.default.string, + + /** + * Whether to apply focus to this tab. + */ + focus: _propTypes.default.bool, + + /** + * When `true`, the class `.slds-active` is applied. + */ + selected: _propTypes.default.bool, + + /** + * When `true`, the HTML attribute `aria-disabled` will be applied. Disabled Tab CSS has been removed. If you'd like to use the styling, please import it in your module bundler. `import 'css-loader!/node_modules/design-system-react/styles/tabs/tab.css';` This feature may be removed in the future due to disabled tabs being inaccessible. + */ + disabled: _propTypes.default.bool, + + /** + * The CSS class to be applied when this tab is selected. Defaults to `.slds-active`. If another class is desired, it should be passed in _along with_ `.slds-active`, not _instead_ of it. + */ + activeTabClassName: _propTypes.default.string, + + /** + * The CSS class to be applied when this tab is disabled. Defaults to `.slds-disabled`. If another class is desired, it should be passed in _along with_ `.slds-disabled`, not _instead_ of it. + */ + disabledTabClassName: _propTypes.default.string, + + /** + * The HTML ID of `` this tab controls. + */ + panelId: _propTypes.default.string, + + /** + * The string or element that is shown as both the title and the label for this tab. + */ + children: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]), + + /** + * If the Tabs should be scopped, defaults to false + */ + variant: _propTypes.default.oneOf(['default', 'scoped']) +}); + +_defineProperty(Tab, "defaultProps", { + focus: false, + selected: false, + activeTabClassName: 'slds-active', + disabledTabClassName: 'slds-disabled', + variant: 'default' +}); + +var _default = Tab; +exports.default = _default; \ No newline at end of file diff --git a/components/tabs/private/tabs-list.js b/components/tabs/private/tabs-list.js new file mode 100644 index 0000000000..95ebb581e4 --- /dev/null +++ b/components/tabs/private/tabs-list.js @@ -0,0 +1,64 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// # Tabs Component +// Implements the [Tabs design pattern](https://www.lightningdesignsystem.com/components/tabs/) in React. +// ## Dependencies +// ### React +// ### classNames +var TabsList = function TabsList(_ref) { + var id = _ref.id, + className = _ref.className, + children = _ref.children, + variant = _ref.variant; + return _react.default.createElement("ul", { + id: "".concat(id, "-slds-tabs__nav"), + className: (0, _classnames.default)(className, { + 'slds-tabs_default__nav': variant === 'default', + 'slds-tabs_scoped__nav': variant === 'scoped' + }), + role: "tablist" + }, children); +}; + +TabsList.displayName = _constants.TABS_LIST; +TabsList.propTypes = { + /** + * Inherits the `id` from the parent `` component and appends `-tabs__nav`. Becomes the HTML `id` attribute of UL element that has the class `.slds-tabs_default__nav` on it. + */ + id: _propTypes.default.string, + + /** + * Class names to be added to the tabs list element. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * The `children` are the actual tabs to be rendered as `li` elements. They get created by [tabs/index.jsx](./index.jsx) in the `renderTabsList` function. + */ + children: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.array]), + + /** + * If the Tabs should be scopped, defaults to false + */ + variant: _propTypes.default.oneOf(['default', 'scoped']) +}; +var _default = TabsList; +exports.default = _default; \ No newline at end of file diff --git a/components/textarea/__docs__/site-stories.js b/components/textarea/__docs__/site-stories.js new file mode 100644 index 0000000000..8f6361cb08 --- /dev/null +++ b/components/textarea/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/textarea/__examples__/default.jsx'), require('raw-loader!@salesforce/design-system-react/components/textarea/__examples__/error.jsx'), require('raw-loader!@salesforce/design-system-react/components/textarea/__examples__/disabled.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/textarea/__docs__/storybook-stories.js b/components/textarea/__docs__/storybook-stories.js new file mode 100644 index 0000000000..b65fd3c7f3 --- /dev/null +++ b/components/textarea/__docs__/storybook-stories.js @@ -0,0 +1,65 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _ = _interopRequireDefault(require("../")); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _disabled = _interopRequireDefault(require("../__examples__/disabled")); + +var _error = _interopRequireDefault(require("../__examples__/error")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.TEXTAREA, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Standard', function () { + return _react.default.createElement(_.default, { + label: "Textarea Label", + name: "standard-textarea", + placeholder: "Placeholder Text" + }); +}).add('Disabled', function () { + return _react.default.createElement(_.default, { + name: "disabled", + label: "Textarea Label", + disabled: true, + placeholder: "Placeholder Text" + }); +}).add('Required', function () { + return _react.default.createElement(_.default, { + "aria-describedby": "required-1", + name: "required-textarea", + assistiveText: { + label: 'Textarea Label' + }, + required: true, + placeholder: "Placeholder Text" + }); +}).add('Error', function () { + return _react.default.createElement(_.default, { + "aria-describedby": "error-1", + name: "required-textarea-error", + label: "Textarea Label", + required: true, + errorText: "Error Message", + placeholder: "Placeholder Text" + }); +}).add('Docs site Default', function () { + return _react.default.createElement(_default.default, null); +}).add('Docs site Disabled', function () { + return _react.default.createElement(_disabled.default, null); +}).add('Docs site Error', function () { + return _react.default.createElement(_error.default, null); +}); \ No newline at end of file diff --git a/components/textarea/__examples__/default.js b/components/textarea/__examples__/default.js new file mode 100644 index 0000000000..85ed22027d --- /dev/null +++ b/components/textarea/__examples__/default.js @@ -0,0 +1,67 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _textarea = _interopRequireDefault(require("../../../../components/textarea")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_textarea.default, { + id: "unique-id-1", + label: "Textarea Label" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'TextareaExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/textarea/__examples__/disabled.js b/components/textarea/__examples__/disabled.js new file mode 100644 index 0000000000..1a38d8fe9a --- /dev/null +++ b/components/textarea/__examples__/disabled.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _textarea = _interopRequireDefault(require("../../../../components/textarea")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_textarea.default, { + name: "disabled", + label: "Textarea Label", + disabled: true, + placeholder: "Placeholder Text" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'TextareaExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/textarea/__examples__/error.js b/components/textarea/__examples__/error.js new file mode 100644 index 0000000000..19b6eb20ca --- /dev/null +++ b/components/textarea/__examples__/error.js @@ -0,0 +1,71 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _textarea = _interopRequireDefault(require("../../../../components/textarea")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_textarea.default, { + "aria-describedby": "error-1", + name: "required-textarea-error", + label: "Textarea Label", + required: true, + errorText: "Error Message", + placeholder: "Placeholder Text" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'TextareaExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/textarea/check-props.js b/components/textarea/check-props.js new file mode 100644 index 0000000000..aa1455784e --- /dev/null +++ b/components/textarea/check-props.js @@ -0,0 +1,40 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _onlyOneOfProperties = _interopRequireDefault(require("../../utilities/warning/only-one-of-properties")); + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ + +/* eslint-disable max-len */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + (0, _onlyOneOfProperties.default)(COMPONENT, { + assistiveText: props.assistiveText, + label: props.label + }, createDocUrl()); + + if (typeof props.assistiveText === 'string') { + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', "`assistiveText` as a string has been deprecated and is now an object to allow for multiple uses in the component. Please use `assistiveText.label` instead. ".concat(createDocUrl('assistiveText'))); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/textarea/docs.json b/components/textarea/docs.json new file mode 100644 index 0000000000..ee791c4a56 --- /dev/null +++ b/components/textarea/docs.json @@ -0,0 +1,7 @@ +{ + "component": "textarea", + "status": "prod", + "display-name": "Textareas", + "SLDS-component-path": "/components/forms#flavor-textarea", + "url-slug": "textareas" +} \ No newline at end of file diff --git a/components/textarea/index.js b/components/textarea/index.js new file mode 100644 index 0000000000..fa4d017084 --- /dev/null +++ b/components/textarea/index.js @@ -0,0 +1,378 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _constants = require("../../utilities/constants"); + +var _docs = _interopRequireDefault(require("./docs.json")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * A multi-line plain-text editing control. + */ +var Textarea = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Textarea, _React$Component); + + function Textarea() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Textarea); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Textarea)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "getId", function () { + return _this.props.id || _this.generatedId; + }); + + _defineProperty(_assertThisInitialized(_this), "getErrorId", function () { + return _this.props['aria-describedby'] || _this.generatedErrorId; + }); + + return _this; + } + + _createClass(Textarea, [{ + key: "componentWillMount", + value: function componentWillMount() { + // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + (0, _checkProps.default)(_constants.TEXTAREA, this.props, _docs.default); + this.generatedId = _shortid.default.generate(); + + if (this.props.errorText) { + this.generatedErrorId = _shortid.default.generate(); + } + } + }, { + key: "render", + // ### Render + value: function render() { + var _this$props = this.props, + autoFocus = _this$props.autoFocus, + children = _this$props.children, + className = _this$props.className, + classNameContainer = _this$props.classNameContainer, + disabled = _this$props.disabled, + errorText = _this$props.errorText, + textareaRef = _this$props.textareaRef, + label = _this$props.label, + onBlur = _this$props.onBlur, + onChange = _this$props.onChange, + onClick = _this$props.onClick, + onFocus = _this$props.onFocus, + onInput = _this$props.onInput, + onInvalid = _this$props.onInvalid, + onKeyDown = _this$props.onKeyDown, + onKeyPress = _this$props.onKeyPress, + onKeyUp = _this$props.onKeyUp, + onSelect = _this$props.onSelect, + onSubmit = _this$props.onSubmit, + maxLength = _this$props.maxLength, + name = _this$props.name, + placeholder = _this$props.placeholder, + required = _this$props.required, + role = _this$props.role, + value = _this$props.value, + defaultValue = _this$props.defaultValue, + wrap = _this$props.wrap; + var assistiveText = typeof this.props.assistiveText === 'string' ? this.props.assistiveText : _objectSpread({}, this.props.assistiveText).label; + var labelText = label || assistiveText; // One of these is required to pass accessibility tests + + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-form-element', { + 'slds-has-error': errorText + }, classNameContainer) + }, labelText && _react.default.createElement("label", { + className: (0, _classnames.default)('slds-form-element__label', { + 'slds-assistive-text': assistiveText && !label + }), + htmlFor: this.getId() + }, required && _react.default.createElement("abbr", { + className: "slds-required", + title: "required" + }, "*"), labelText), _react.default.createElement("div", { + className: (0, _classnames.default)('slds-form-element__control') + }, _react.default.createElement("textarea", { + "aria-activedescendant": this.props['aria-activedescendant'], + "aria-controls": this.props['aria-controls'], + "aria-labelledby": this.props['aria-labelledby'], + "aria-describedby": this.getErrorId(), + "aria-expanded": this.props['aria-expanded'], + "aria-owns": this.props['aria-owns'], + "aria-required": this.props['aria-required'], + className: (0, _classnames.default)('slds-textarea', className), + autoFocus: autoFocus, + disabled: disabled, + id: this.getId(), + maxLength: maxLength, + name: name, + onBlur: onBlur, + onChange: onChange, + onClick: onClick, + onFocus: onFocus, + onInput: onInput, + onInvalid: onInvalid, + onKeyDown: onKeyDown, + onKeyPress: onKeyPress, + onKeyUp: onKeyUp, + onSelect: onSelect, + onSubmit: onSubmit, + placeholder: placeholder, + ref: textareaRef, + role: role, + required: required, + wrap: wrap, + value: value, + defaultValue: defaultValue + })), errorText && _react.default.createElement("div", { + id: this.getErrorId(), + className: "slds-form-element__help" + }, errorText), children); + } + }]); + + return Textarea; +}(_react.default.Component); + +_defineProperty(Textarea, "displayName", _constants.TEXTAREA); + +_defineProperty(Textarea, "propTypes", { + /** + * The aria-activedescendant attribute contains the ID of the currently active child object that is part of a composite widget within the Document Object Model. It makes do with the overhead of having all or more than one child focusable. As the name specifies, it helps in managing the current active child of the composite widget. + */ + 'aria-activedescendant': _propTypes.default.string, + + /** + * Indicates if the suggestions in a composite widget are values that complete the current textbox input. + */ + 'aria-autocomplete': _propTypes.default.string, + + /** + * An HTML ID that is shared with ARIA-supported devices with the + * `aria-controls` attribute in order to relate the input with + * another region of the page. An example would be a select box + * that shows or hides a panel. + */ + 'aria-controls': _propTypes.default.string, + + /** + * The `aria-describedby` attribute is used to indicate the IDs of the elements that describe the object. It is used to establish a relationship between widgets or groups and text that described them. This is very similar to aria-labelledby: a label describes the essence of an object, while a description provides more information that the user might need. + */ + 'aria-describedby': _propTypes.default.string, + + /** + * Use the `aria-expanded` state to indicate whether regions of the content are collapsible, and to expose whether a region is currently expanded or collapsed. + */ + 'aria-expanded': _propTypes.default.bool, + + /** + * Indicates that the element has a popup context menu or sub-level menu. + */ + 'aria-haspopup': _propTypes.default.bool, + + /** + * The aria-labelledby attribute contains the element IDs of labels in objects such as input elements, widgets, and groups. The attribute establishes relationships between objects and their labels. Assistive technology, such as screen readers, use this attribute to catalog the objects in a document so that users can navigate between them. Without an element ID, the assistive technology cannot catalog the object. + */ + 'aria-labelledby': _propTypes.default.string, + + /** + * An HTML ID that is shared with ARIA-supported devices with the + * `aria-controls` attribute in order to relate the input with + * another region of the page. An example would be a search field + * that shows search results. + */ + 'aria-owns': _propTypes.default.string, + + /** + * The `aria-required` attribute is used to indicate that user input is required on an element before a form can be submitted. + */ + 'aria-required': _propTypes.default.bool, + + /** + * Specifies is the textarea should automatically get focus when the page loads. This is typically a poor user experience. + */ + autoFocus: _propTypes.default.bool, + + /** + * **Assistive text for accessibility.** + * * `label`: If present, the label associated with this `textarea` is overwritten by this text and is visually not shown. + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string + }), + + /** + * Elements are added after the `textarea`. + */ + children: _propTypes.default.node, + + /** + * Class names to be added to the textarea component. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** Allows for ability to apply classNames to outer textarea div. + */ + classNameContainer: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Disables the textarea and prevents editing the contents. + */ + disabled: _propTypes.default.bool, + + /** + * Message to display when the textarea is in an error state. When this is present, also visually highlights the component as in error. + */ + errorText: _propTypes.default.string, + + /** + * Every textarea must have a unique ID in order to support keyboard navigation and ARIA support. + */ + id: _propTypes.default.string, + + /** + * This callback exposes the textarea reference / DOM node to parent components. ` this.textarea = textareaComponent} /> + */ + textareaRef: _propTypes.default.func, + + /** + * This label appears above the textarea. + */ + label: _propTypes.default.string, + + /** + * Triggered when focus is removed. + */ + onBlur: _propTypes.default.func, + + /** + * This callback fires when the textarea changes. The synthetic React event will be the first parameter to the callback. You will probably want to reference `event.target.value` in your callback. No custom data object is provided. + */ + onChange: _propTypes.default.func, + + /** + * This event fires when the textarea is clicked. + */ + onClick: _propTypes.default.func, + + /** + * Triggered when component is focused. + */ + onFocus: _propTypes.default.func, + + /** + * Similar to `onchange`. Triggered when an element gets user input. + */ + onInput: _propTypes.default.func, + + /** + * Triggered when a submittable element is invalid. + */ + onInvalid: _propTypes.default.func, + + /** + * Triggered when a key is pressed down + */ + onKeyDown: _propTypes.default.func, + + /** + * Triggered when a key is pressed and released + */ + onKeyPress: _propTypes.default.func, + + /** + * Triggered when a key is released + */ + onKeyUp: _propTypes.default.func, + + /** + * Triggered after some text has been selected in an element. + */ + onSelect: _propTypes.default.func, + + /** + * Fires when a form is submitted. + */ + onSubmit: _propTypes.default.func, + + /** + * Maximum number of characters allowed. + */ + maxLength: _propTypes.default.string, + + /** + * Name of the submitted form parameter. + */ + name: _propTypes.default.string, + + /** + * Text that will appear in an empty textarea. + */ + placeholder: _propTypes.default.string, + + /** + * Highlights the textarea as a required field (does not perform any validation). + */ + required: _propTypes.default.bool, + + /** + * The textarea is a controlled component, and will always display this value. + */ + value: _propTypes.default.string, + + /** + * The textarea is a uncontrolled component, and this will be the initial value. + */ + defaultValue: _propTypes.default.string, + + /** + * Specifies how the text in a text area is to be wrapped when submitted in a form. + */ + wrap: _propTypes.default.oneOf(['soft', 'hard']) +}); + +var _default = Textarea; +exports.default = _default; \ No newline at end of file diff --git a/components/time-picker/__docs__/site-stories.js b/components/time-picker/__docs__/site-stories.js new file mode 100644 index 0000000000..d52138c4b6 --- /dev/null +++ b/components/time-picker/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/time-picker/__examples__/default.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/time-picker/__docs__/storybook-stories.js b/components/time-picker/__docs__/storybook-stories.js new file mode 100644 index 0000000000..a5ddc34528 --- /dev/null +++ b/components/time-picker/__docs__/storybook-stories.js @@ -0,0 +1,39 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _timePicker = _interopRequireDefault(require("../../time-picker")); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* eslint-disable indent */ +var getTimepicker = function getTimepicker(props) { + return _react.default.createElement(_timePicker.default, props); +}; + +(0, _react2.storiesOf)(_constants.TIME_PICKER, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base', function () { + return getTimepicker({ + label: 'Time', + required: true, + stepInMinutes: 30, + onDateChange: (0, _addonActions.action)('onDateChange') + }); +}).add('Docs site Default', function () { + return _react.default.createElement(_default.default, null); +}); \ No newline at end of file diff --git a/components/time-picker/__examples__/default.js b/components/time-picker/__examples__/default.js new file mode 100644 index 0000000000..68f37a03dc --- /dev/null +++ b/components/time-picker/__examples__/default.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _timePicker = _interopRequireDefault(require("../../../../components/time-picker")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_timePicker.default, { + placeholder: "Select a time", + stepInMinutes: 30, + onDateChange: function onDateChange(date, inputStr) { + console.log('onDateChange ', date, ' inputStr: ', inputStr); + } + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'TimepickerExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/time-picker/check-props.js b/components/time-picker/check-props.js new file mode 100644 index 0000000000..36beed0ff4 --- /dev/null +++ b/components/time-picker/check-props.js @@ -0,0 +1,29 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _deprecatedProperty = _interopRequireDefault(require("../../utilities/warning/deprecated-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + (0, _deprecatedProperty.default)(COMPONENT, props.isInline, 'isInline', 'menuPosition="relative"', createDocUrl('menuPosition')); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/time-picker/docs.json b/components/time-picker/docs.json new file mode 100644 index 0000000000..6a390d572d --- /dev/null +++ b/components/time-picker/docs.json @@ -0,0 +1,7 @@ +{ + "component": "time-picker", + "status": "prod", + "display-name": "Timepickers", + "SLDS-component-path": "/components/timepicker", + "url-slug": "timepickers" +} \ No newline at end of file diff --git a/components/time-picker/index.js b/components/time-picker/index.js new file mode 100644 index 0000000000..6913cdf8f1 --- /dev/null +++ b/components/time-picker/index.js @@ -0,0 +1,308 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.isdate")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _inputIcon = _interopRequireDefault(require("../icon/input-icon")); + +var _menuDropdown = _interopRequireDefault(require("../menu-dropdown")); + +var _dropdownTrigger = _interopRequireDefault(require("./private/dropdown-trigger")); + +var _constants = require("../../utilities/constants"); + +var _docs = _interopRequireDefault(require("./docs.json")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var getOptions = function getOptions(_ref) { + var props = _ref.props; + var baseDate = new Date(); + var options = []; + baseDate.setHours(0); + baseDate.setMinutes(0); + baseDate.setSeconds(0); + baseDate.setMilliseconds(0); + var curDate = new Date(baseDate); + + while (baseDate.getDate() === curDate.getDate()) { + var formatted = props.formatter(curDate); + options.push({ + label: formatted, + value: new Date(curDate) + }); + curDate.setMinutes(curDate.getMinutes() + props.stepInMinutes); + } + + return options; +}; +/** + * Component description. + */ + + +var Timepicker = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Timepicker, _React$Component); + + function Timepicker() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Timepicker); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Timepicker)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + value: _this.props.value, + strValue: _this.props.strValue, + options: getOptions({ + props: _this.props + }) + }); + + _defineProperty(_assertThisInitialized(_this), "parseDate", function (strValue) { + var newDate = _this.props.parser(strValue); + + if ((0, _lodash.default)(newDate)) { + if (!isNaN(newDate.getTime())) { + return newDate; + } + } + + return new Date(); + }); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (date, strValue) { + _this.setState({ + value: date, + strValue: strValue + }); + + if (_this.props.onDateChange) { + _this.props.onDateChange(date, strValue); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleSelect", function (val) { + if (val && val.value) { + _this.handleChange(val.value, val.label); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event) { + var strValue = event.target.value; + + _this.setState({ + strValue: strValue + }); + + if (_this.props.onDateChange) { + var parsedDate = _this.props.parser(strValue); + + _this.props.onDateChange(parsedDate, strValue); + } + }); + + return _this; + } + + _createClass(Timepicker, [{ + key: "componentWillMount", + value: function componentWillMount() { + // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + (0, _checkProps.default)(_constants.TIME_PICKER, this.props, _docs.default); + } + }, { + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + if (nextProps.value && this.props.value) { + var currentTime = this.props.value.getTime(); + var nextTime = nextProps.value.getTime(); + + if (currentTime !== nextTime) { + this.setState({ + value: nextProps.value, + strValue: this.props.formatter(nextProps.value) + }); + } + } + } + }, { + key: "render", + // ### Render + value: function render() { + return _react.default.createElement(_menuDropdown.default, { + checkmark: false, + constrainToScrollParent: this.props.constrainToScrollParent, + disabled: this.props.disabled, + inheritTargetWidth: this.props.inheritTargetWidth, + label: this.props.label, + listItemRenderer: this.props.listItemRenderer // inline style override + , + menuStyle: { + maxHeight: '20em', + overflowX: 'hidden', + minWidth: '100%' + }, + menuPosition: this.props.menuPosition, + onSelect: this.handleSelect, + options: this.state.options + }, _react.default.createElement(_dropdownTrigger.default, { + iconRight: _react.default.createElement(_inputIcon.default, { + category: "utility", + name: "clock" + }), + onChange: this.handleInputChange, + placeholder: this.props.placeholder, + required: this.props.required, + type: "text", + value: this.state.strValue + })); + } + }]); + + return Timepicker; +}(_react.default.Component); + +_defineProperty(Timepicker, "displayName", _constants.TIME_PICKER); + +_defineProperty(Timepicker, "propTypes", { + /** + * If true, constrains the menu to the scroll parent. See `Dropdown`. + */ + constrainToScrollParent: _propTypes.default.bool, + + /** + * Disables the input and prevents editing the contents. + */ + disabled: _propTypes.default.bool, + + /** + * Time formatting function + */ + formatter: _propTypes.default.func, + + /** + * Sets the dialog width to the width of the target. Menus attached to `input` typically follow this UX pattern. + */ + inheritTargetWidth: _propTypes.default.bool, + + /** + * This label appears above the input. + */ + label: _propTypes.default.string, + + /** + * Custom element that overrides the default Menu Item component. + */ + listItemRenderer: _propTypes.default.func, + + /** + * Please select one of the following: + * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog. + * * `overflowBoundaryElement` - The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree. + * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing. + */ + menuPosition: _propTypes.default.oneOf(['absolute', 'overflowBoundaryElement', 'relative']), + + /** + * Receives the props `(dateValue, stringValue)` + */ + onDateChange: _propTypes.default.func, + + /** + * Parsing date string into Date + */ + parser: _propTypes.default.func, + + /** + * Text that will appear in an empty input. + */ + placeholder: _propTypes.default.string, + + /** + * If true, adds asterisk next to input label to indicate it is a required field. + */ + required: _propTypes.default.bool, + + /** + * Frequency of options + */ + stepInMinutes: _propTypes.default.number, + + /** + * Value for input that is parsed to create an internal state in the `date` format. + */ + strValue: _propTypes.default.string, + + /** + * Instance an internal state in the `date` format. + */ + value: _propTypes.default.instanceOf(Date) +}); + +_defineProperty(Timepicker, "defaultProps", { + formatter: function formatter(date) { + if (date) { + return date.toLocaleTimeString(navigator.language, { + hour: '2-digit', + minute: '2-digit' + }); + } + + return null; + }, + parser: function parser(timeStr) { + var date = new Date(); + var dateStr = date.toLocaleString(navigator.language, { + year: 'numeric', + month: 'numeric', + day: 'numeric' + }); + return new Date("".concat(dateStr, " ").concat(timeStr)); + }, + menuPosition: 'absolute', + placeholder: 'Pick Time', + value: null, + stepInMinutes: 30 +}); + +var _default = Timepicker; +exports.default = _default; \ No newline at end of file diff --git a/components/time-picker/private/dropdown-trigger.js b/components/time-picker/private/dropdown-trigger.js new file mode 100644 index 0000000000..6006da062d --- /dev/null +++ b/components/time-picker/private/dropdown-trigger.js @@ -0,0 +1,171 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _input = _interopRequireDefault(require("../../input")); + +var _keyCode = _interopRequireDefault(require("../../../utilities/key-code")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Component description. + */ +var TimepickerDropdownTrigger = +/*#__PURE__*/ +function (_React$Component) { + _inherits(TimepickerDropdownTrigger, _React$Component); + + function TimepickerDropdownTrigger() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, TimepickerDropdownTrigger); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TimepickerDropdownTrigger)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) { + if (_this.props.onKeyDown && event.keyCode) { + if (event.keyCode === _keyCode.default.ENTER || event.keyCode === _keyCode.default.DOWN || event.keyCode === _keyCode.default.UP || event.keyCode === _keyCode.default.ESCAPE) { + _this.props.onKeyDown(event); + } + } + }); + + return _this; + } + + _createClass(TimepickerDropdownTrigger, [{ + key: "render", + // ### Render + value: function render() { + var _this$props = this.props, + iconRight = _this$props.iconRight, + menu = _this$props.menu, + onBlur = _this$props.onBlur, + onFocus = _this$props.onFocus, + onKeyDown = _this$props.onKeyDown, + onMouseDown = _this$props.onMouseDown, + triggerRef = _this$props.triggerRef, + props = _objectWithoutProperties(_this$props, ["iconRight", "menu", "onBlur", "onFocus", "onKeyDown", "onMouseDown", "triggerRef"]); + + return ( + /* eslint-disable jsx-a11y/no-static-element-interactions */ + _react.default.createElement("div", { + onBlur: onBlur, + onFocus: onFocus, + onKeyDown: this.handleKeyDown, + onMouseDown: onMouseDown + }, _react.default.createElement(_input.default, _extends({ + iconRight: iconRight + }, props, { + inputRef: triggerRef + }), menu)) + ); + } + }]); + + return TimepickerDropdownTrigger; +}(_react.default.Component); + +_defineProperty(TimepickerDropdownTrigger, "displayName", _constants.MENU_DROPDOWN_TRIGGER); + +_defineProperty(TimepickerDropdownTrigger, "propTypes", { + /** + * Icon for right side of trigger + */ + iconRight: _propTypes.default.node, + + /** + * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the dropdown to the triggering input. + */ + id: _propTypes.default.string, + + /** + * This label appears above the input. + */ + label: _propTypes.default.string, + + /** + * The dropdown menu. + */ + menu: _propTypes.default.node, + + /** + * Is only called when `openOn` is set to `hover` and when the triggering input loses focus. + */ + onBlur: _propTypes.default.func, + + /** + * This prop is passed onto the triggering `Input`. Triggered when the trigger input is clicked. + */ + onClick: _propTypes.default.func, + + /** + * Is only called when `openOn` is set to `hover` and when the triggering input gains focus. + */ + onFocus: _propTypes.default.func, + + /** + * Called when a key pressed. + */ + onKeyDown: _propTypes.default.func, + + /** + * Called when mouse clicks down on the trigger input. + */ + onMouseDown: _propTypes.default.func, + + /** + * The ref of the actual triggering input. + */ + triggerRef: _propTypes.default.func, + + /** + * Date + */ + value: _propTypes.default.string +}); + +var _default = TimepickerDropdownTrigger; +exports.default = _default; \ No newline at end of file diff --git a/components/toast/__docs__/site-stories.js b/components/toast/__docs__/site-stories.js new file mode 100644 index 0000000000..672c7b9da1 --- /dev/null +++ b/components/toast/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/toast/__examples__/info.jsx'), require('raw-loader!@salesforce/design-system-react/components/toast/__examples__/success.jsx'), require('raw-loader!@salesforce/design-system-react/components/toast/__examples__/warning.jsx'), require('raw-loader!@salesforce/design-system-react/components/toast/__examples__/error.jsx'), require('raw-loader!@salesforce/design-system-react/components/toast/__examples__/error-with-details.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/toast/__docs__/storybook-stories.js b/components/toast/__docs__/storybook-stories.js new file mode 100644 index 0000000000..be6dc4ea6d --- /dev/null +++ b/components/toast/__docs__/storybook-stories.js @@ -0,0 +1,52 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _constants = require("../../../utilities/constants"); + +var _info = _interopRequireDefault(require("../__examples__/info")); + +var _success = _interopRequireDefault(require("../__examples__/success")); + +var _warning = _interopRequireDefault(require("../__examples__/warning")); + +var _error = _interopRequireDefault(require("../__examples__/error")); + +var _errorWithDetails = _interopRequireDefault(require("../__examples__/error-with-details")); + +var _closeToast = _interopRequireDefault(require("../__examples__/close-toast")); + +var _durationToast = _interopRequireDefault(require("../__examples__/duration-toast")); + +var _customClassName = _interopRequireDefault(require("../__examples__/custom-class-name")); + +var _customStyle = _interopRequireDefault(require("../__examples__/custom-style")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* eslint-disable react/display-name */ +(0, _react2.storiesOf)(_constants.TOAST, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Info', function () { + return _react.default.createElement(_info.default, null); +}).add('Success', function () { + return _react.default.createElement(_success.default, null); +}).add('Warning', function () { + return _react.default.createElement(_warning.default, null); +}).add('Error', function () { + return _react.default.createElement(_error.default, null); +}).add('Error With Details', function () { + return _react.default.createElement(_errorWithDetails.default, null); +}).add('Close Toast', function () { + return _react.default.createElement(_closeToast.default, null); +}).add('Duration Toast', function () { + return _react.default.createElement(_durationToast.default, null); +}).add('Custom Class Names', function () { + return _react.default.createElement(_customClassName.default, null); +}).add('Custom Style', function () { + return _react.default.createElement(_customStyle.default, null); +}); \ No newline at end of file diff --git a/components/toast/__examples__/close-toast.js b/components/toast/__examples__/close-toast.js new file mode 100644 index 0000000000..e5e147522a --- /dev/null +++ b/components/toast/__examples__/close-toast.js @@ -0,0 +1,96 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _toast = _interopRequireDefault(require("../../../../components/toast")); + +var _container = _interopRequireDefault(require("../../../../components/toast/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + isOpen: false + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement(_container.default, null, this.state.isOpen ? _react.default.createElement(_toast.default, { + labels: { + heading: '26 potential duplicate leads were found.', + headingLink: 'Select Leads to Merge' + }, + onClickHeadingLink: function onClickHeadingLink() { + console.log('Link clicked.'); + }, + onRequestClose: function onRequestClose() { + _this2.setState({ + isOpen: false + }); + } + }) : null), _react.default.createElement(_button.default, { + label: "Toggle toast", + onClick: function onClick() { + _this2.setState(function (prevState) { + return { + isOpen: !prevState.isOpen + }; + }); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ToastExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/toast/__examples__/custom-class-name.js b/components/toast/__examples__/custom-class-name.js new file mode 100644 index 0000000000..b5a4435ef1 --- /dev/null +++ b/components/toast/__examples__/custom-class-name.js @@ -0,0 +1,72 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _toast = _interopRequireDefault(require("../../../../components/toast")); + +var _container = _interopRequireDefault(require("../../../../components/toast/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, { + className: "this-is-the-container" + }, _react.default.createElement(_toast.default, { + className: "this-is-the-alert", + labels: { + heading: '26 potential duplicate leads were found.', + headingLink: 'Select Leads to Merge' + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ToastExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/toast/__examples__/custom-style.js b/components/toast/__examples__/custom-style.js new file mode 100644 index 0000000000..68dd2ae2d6 --- /dev/null +++ b/components/toast/__examples__/custom-style.js @@ -0,0 +1,74 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _toast = _interopRequireDefault(require("../../../../components/toast")); + +var _container = _interopRequireDefault(require("../../../../components/toast/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, { + className: "this-is-the-container" + }, _react.default.createElement(_toast.default, { + labels: { + heading: '26 potential duplicate leads were found.', + headingLink: 'Select Leads to Merge' + }, + style: { + backgroundColor: 'rgb(18, 49, 35)' + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ToastExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/toast/__examples__/duration-toast.js b/components/toast/__examples__/duration-toast.js new file mode 100644 index 0000000000..b316e4e8c4 --- /dev/null +++ b/components/toast/__examples__/duration-toast.js @@ -0,0 +1,97 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _toast = _interopRequireDefault(require("../../../../components/toast")); + +var _container = _interopRequireDefault(require("../../../../components/toast/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example(props) { + var _this; + + _classCallCheck(this, Example); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Example).call(this, props)); + _this.state = { + isOpen: true + }; + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, _react.default.createElement(_container.default, null, this.state.isOpen ? _react.default.createElement(_toast.default, { + duration: 1000, + labels: { + heading: '26 potential duplicate leads were found.', + headingLink: 'Select Leads to Merge' + }, + onClickHeadingLink: function onClickHeadingLink() { + console.log('Link clicked.'); + }, + onRequestClose: function onRequestClose() { + _this2.setState({ + isOpen: false + }); + } + }) : null), _react.default.createElement(_button.default, { + label: "Toggle toast", + onClick: function onClick() { + _this2.setState(function (prevState) { + return { + isOpen: !prevState.isOpen + }; + }); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ToastExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/toast/__examples__/error-with-details.js b/components/toast/__examples__/error-with-details.js new file mode 100644 index 0000000000..58e03d06c6 --- /dev/null +++ b/components/toast/__examples__/error-with-details.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _toast = _interopRequireDefault(require("../../../../components/toast")); + +var _container = _interopRequireDefault(require("../../../../components/toast/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, null, _react.default.createElement(_toast.default, { + labels: { + heading: "You've encountered some errors when trying to save edits to Samuel Smith.", + details: "Here's some detail of what happened, being very descriptive and transparent." + }, + variant: "error" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ToastExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/toast/__examples__/error.js b/components/toast/__examples__/error.js new file mode 100644 index 0000000000..ba1dc1b73f --- /dev/null +++ b/components/toast/__examples__/error.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _toast = _interopRequireDefault(require("../../../../components/toast")); + +var _container = _interopRequireDefault(require("../../../../components/toast/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, null, _react.default.createElement(_toast.default, { + labels: { + heading: 'Can’t save lead “Sally Wong” because another lead has the same name.' + }, + variant: "error" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ToastExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/toast/__examples__/info.js b/components/toast/__examples__/info.js new file mode 100644 index 0000000000..cffe5bd298 --- /dev/null +++ b/components/toast/__examples__/info.js @@ -0,0 +1,72 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _toast = _interopRequireDefault(require("../../../../components/toast")); + +var _container = _interopRequireDefault(require("../../../../components/toast/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, null, _react.default.createElement(_toast.default, { + labels: { + heading: '26 potential duplicate leads were found.', + headingLink: 'Select Leads to Merge' + }, + onClickHeadingLink: function onClickHeadingLink() { + console.log('Link clicked.'); + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ToastExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/toast/__examples__/success.js b/components/toast/__examples__/success.js new file mode 100644 index 0000000000..05a5ab5451 --- /dev/null +++ b/components/toast/__examples__/success.js @@ -0,0 +1,72 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _toast = _interopRequireDefault(require("../../../../components/toast")); + +var _container = _interopRequireDefault(require("../../../../components/toast/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, null, _react.default.createElement(_toast.default, { + labels: { + heading: ['Account ', _react.default.createElement("a", { + key: "acme-100", + href: "javascript:void(0);" + }, "ACME - 100"), ' widgets was created.'] + }, + variant: "success" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ToastExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/toast/__examples__/warning.js b/components/toast/__examples__/warning.js new file mode 100644 index 0000000000..2d29c277a5 --- /dev/null +++ b/components/toast/__examples__/warning.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _toast = _interopRequireDefault(require("../../../../components/toast")); + +var _container = _interopRequireDefault(require("../../../../components/toast/container")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_container.default, null, _react.default.createElement(_toast.default, { + labels: { + heading: 'Can’t share file “report-q3.pdf” with the selected users.' + }, + variant: "warning" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'ToastExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/toast/check-props.js b/components/toast/check-props.js new file mode 100644 index 0000000000..297b8e796a --- /dev/null +++ b/components/toast/check-props.js @@ -0,0 +1,37 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + /* eslint-disable max-len */ + + (0, _sunsetProperty.default)(COMPONENT, props.iconCategory, 'iconCategory', "Use `Icon` instead. ".concat(createDocUrl('icon'))); + (0, _sunsetProperty.default)(COMPONENT, props.iconName, 'iconName', "Use `Icon` instead. ".concat(createDocUrl('icon'))); + (0, _sunsetProperty.default)(COMPONENT, props.content, 'content', "Use `labels.heading` and `labels.headingLink` instead. ".concat(createDocUrl('labels'))); + (0, _sunsetProperty.default)(COMPONENT, props.isOpen, 'isOpen', "Use a conditional outside of alert. ".concat(createDocUrl())); + (0, _sunsetProperty.default)(COMPONENT, props.isOpen, 'onDismiss', "Use `onRequestClose` instead. ".concat(createDocUrl('onRequestClose'))); + (0, _sunsetProperty.default)(COMPONENT, props.texture, 'texture', createDocUrl()); + (0, _sunsetProperty.default)(COMPONENT, props.theme, 'theme', "Use `variant` instead. ".concat(createDocUrl('variant'))); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/toast/container.js b/components/toast/container.js new file mode 100644 index 0000000000..a1c7ea5012 --- /dev/null +++ b/components/toast/container.js @@ -0,0 +1,77 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classNames = _interopRequireDefault(require("../../utilities/class-names")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var propTypes = { + /** + * CSS classes to be added to tag with `.slds-notify-container`. Uses `classNames` [API](https://github.com/JedWatson/classnames). + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Toast components + */ + children: _propTypes.default.node +}; +/** + * A fixed container for toast banners. + */ + +var ToastContainer = +/*#__PURE__*/ +function (_React$Component) { + _inherits(ToastContainer, _React$Component); + + function ToastContainer() { + _classCallCheck(this, ToastContainer); + + return _possibleConstructorReturn(this, _getPrototypeOf(ToastContainer).apply(this, arguments)); + } + + _createClass(ToastContainer, [{ + key: "render", + value: function render() { + return _react.default.createElement("div", { + className: (0, _classNames.default)('slds-notify-container', this.props.className) + }, this.props.children); + } + }]); + + return ToastContainer; +}(_react.default.Component); + +ToastContainer.displayName = _constants.TOAST_CONTAINER; +ToastContainer.propTypes = propTypes; +var _default = ToastContainer; +exports.default = _default; \ No newline at end of file diff --git a/components/toast/docs.json b/components/toast/docs.json new file mode 100644 index 0000000000..8103ed6361 --- /dev/null +++ b/components/toast/docs.json @@ -0,0 +1,16 @@ +{ + "component": "toast", + "status": "prod", + "display-name": "Toasts", + "last-accessibility-review": { + "date-iso-8601": "2018/01/18", + "commit-sha": "ad6b6c6523ee21cada11be5f7ea4d99abc530726" + }, + "SLDS-component-path": "/components/toast", + "dependencies": [ + { + "component": "container" + } + ], + "url-slug": "toasts" +} \ No newline at end of file diff --git a/components/toast/index.js b/components/toast/index.js new file mode 100644 index 0000000000..79ad680188 --- /dev/null +++ b/components/toast/index.js @@ -0,0 +1,286 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _classNames = _interopRequireDefault(require("../../utilities/class-names")); + +var _button = _interopRequireDefault(require("../button")); + +var _icon = _interopRequireDefault(require("../icon")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _constants = require("../../utilities/constants"); + +var _domElementFocus = _interopRequireDefault(require("../../utilities/dom-element-focus")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * **Assistive text for accessibility** + * This object is merged with the default props object on every render. + * * `closeButton`: This is a visually hidden label for the close button. + * _Tested with snapshot testing._ + */ + assistiveText: _propTypes.default.shape({ + closeButton: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]) + }), + + /** + * CSS classes to be added to tag with `.slds-notify_toast`. Uses `classNames` [API](https://github.com/JedWatson/classnames). + * _Tested with snapshot testing._ + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * If duration exists, the Toast will disappear after that amount of time. Time in milliseconds. _Tested with Mocha testing._ + */ + duration: _propTypes.default.number, + + /** + * **Text labels for internationalization** + * This object is merged with the default props object on every render. + * * `details`: Secondary text below heading + * * `heading`: text within heading tag + * * `headingLink`: Text of link that triggers `onClickHeadingLink`. Inline links should pass a keyed array of React components into `labels.heading`. + * + * _Tested with snapshot testing._ + */ + labels: _propTypes.default.shape({ + details: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]), + heading: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]), + headingLink: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]) + }), + + /** + * Triggered by link. _Tested with Mocha testing._ + */ + onClickHeadingLink: _propTypes.default.func, + + /** + * Icon of type `~/components/icon`. This icon will be cloned and additional props appended. The default icons are: + * * info variant: `utility:info` + * * error variant: `utility:error` + * * success variant: `utility:success` + * * warning variant: `utility:warning` + * + * _Tested with snapshot testing._ + */ + icon: _propTypes.default.node, + + /** + * Triggered by close button. _Tested with Mocha testing._ + */ + onRequestClose: _propTypes.default.func, + + /** + * Custom styles to be passed to the component. _Tested with Mocha testing._ + */ + style: _propTypes.default.object, + + /** + * The type of Toast. _Tested with snapshot testing._ + */ + variant: _propTypes.default.oneOf(['error', 'info', 'success', 'warning']).isRequired +}; +var defaultProps = { + assistiveText: { + closeButton: 'Close' + }, + variant: 'info' +}; +/** + * Toast serves as a feedback & confirmation mechanism after the user takes an action. View [banner guidelines](https://www.lightningdesignsystem.com/guidelines/messaging/components/banners/). + */ + +var Toast = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Toast, _React$Component); + + function Toast(props) { + var _this; + + _classCallCheck(this, Toast); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Toast).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "onClose", function () { + _this.clearTimeout(); + + if (_this.props.onRequestClose) { + _this.props.onRequestClose(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "clearTimeout", function () { + if (_this.timeout) { + clearTimeout(_this.timeout); + _this.timeout = null; + } + }); + + _defineProperty(_assertThisInitialized(_this), "saveButtonRef", function (component) { + _this.closeButton = component; + + if (_this.state.isInitialRender) { + _domElementFocus.default.storeActiveElement(); + + if (_this.closeButton) { + _this.closeButton.focus(); + } + + _this.setState({ + isInitialRender: false + }); + } + }); + + _this.state = { + isInitialRender: true + }; + _this.timeout = null; + return _this; + } + + _createClass(Toast, [{ + key: "componentWillMount", + value: function componentWillMount() { + // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + (0, _checkProps.default)(_constants.TOAST, this.props, _docs.default); + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + var _this2 = this; + + if (this.props.duration) { + this.timeout = setTimeout(function () { + _this2.onClose(); + }, this.props.duration); + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this.clearTimeout(); + + _domElementFocus.default.returnFocusToStoredElement(); + } + }, { + key: "render", + value: function render() { + // Merge objects of strings with their default object + var assistiveText = (0, _lodash.default)({}, defaultProps.assistiveText, this.props.assistiveText); + var labels = (0, _lodash.default)({}, defaultProps.labels, this.props.labels); + var heading = labels.heading || this.props.content; // eslint-disable-line react/prop-types + + var assistiveTextVariant = { + info: 'info', + success: 'success', + warning: 'warning', + error: 'error' + }; + var defaultIcons = { + info: _react.default.createElement(_icon.default, { + category: "utility", + name: "info" + }), + success: _react.default.createElement(_icon.default, { + category: "utility", + name: "success" + }), + warning: _react.default.createElement(_icon.default, { + category: "utility", + name: "warning" + }), + error: _react.default.createElement(_icon.default, { + category: "utility", + name: "error" + }) + }; + var icon = this.props.icon ? this.props.icon : defaultIcons[this.props.variant]; + + var clonedIcon = _react.default.cloneElement(icon, { + containerClassName: 'slds-m-right_small slds-no-flex slds-align-top', + inverse: true, + size: 'small' + }); + /* eslint-disable no-script-url */ + + + return _react.default.createElement("div", { + className: (0, _classNames.default)('slds-notify slds-notify_toast', { + 'slds-theme_info': this.props.variant === 'info', + 'slds-theme_success': this.props.variant === 'success', + 'slds-theme_warning': this.props.variant === 'warning', + 'slds-theme_error': this.props.variant === 'error' + }, this.props.className), + role: "status", + style: this.props.style + }, _react.default.createElement("span", { + className: "slds-assistive-text" + }, assistiveTextVariant[this.props.variant]), clonedIcon, _react.default.createElement("div", { + className: "slds-notify__content" + }, _react.default.createElement("h2", { + className: "slds-text-heading_small" + }, heading, ' ', labels.headingLink ? _react.default.createElement("a", { + onClick: this.props.onClickHeadingLink, + href: "javascript:void(0);" + }, labels.headingLink) : null), labels.details ? _react.default.createElement("p", null, labels.details) : null), _react.default.createElement(_button.default, { + assistiveText: { + icon: assistiveText.closeButton + }, + buttonRef: this.saveButtonRef, + className: "slds-notify__close", + iconCategory: "utility", + iconName: "close", + iconSize: "large", + inverse: true, + onClick: this.props.onRequestClose, + title: assistiveText.closeButton, + variant: "icon" + })); + } + }]); + + return Toast; +}(_react.default.Component); + +Toast.defaultProps = defaultProps; +Toast.displayName = _constants.TOAST; +Toast.propTypes = propTypes; +var _default = Toast; +exports.default = _default; \ No newline at end of file diff --git a/components/tooltip/__docs__/__snapshots__/storybook-stories.storyshot b/components/tooltip/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..bf7b2870f0 --- /dev/null +++ b/components/tooltip/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,2133 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSPopoverTooltip Alignment (Button) 1`] = ` +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopoverTooltip Alignment (icon) 1`] = ` +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    + + + + Case Icon + + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopoverTooltip Alignment (span) 1`] = ` +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    + + Trigger Tooltip + + +
    +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopoverTooltip Base 1`] = ` +
    +
    + + +
    +
    +`; + +exports[`DOM snapshots SLDSPopoverTooltip Button 1`] = ` +
    +
    + + +
    +
    +`; + +exports[`DOM snapshots SLDSPopoverTooltip Button Group 1`] = ` +
    +
    +
    + + +
    +
    + + +
    +
    + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSPopoverTooltip Learn More 1`] = ` + +`; + +exports[`DOM snapshots SLDSPopoverTooltip Open 1`] = ` +
    +
    + + +
    +
    +`; diff --git a/components/tooltip/__docs__/site-stories.js b/components/tooltip/__docs__/site-stories.js new file mode 100644 index 0000000000..7fa884ed3b --- /dev/null +++ b/components/tooltip/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/tooltip/__examples__/base.jsx'), require('raw-loader!@salesforce/design-system-react/components/tooltip/__examples__/button.jsx'), require('raw-loader!@salesforce/design-system-react/components/tooltip/__examples__/button-group.jsx'), require('raw-loader!@salesforce/design-system-react/components/tooltip/__examples__/learn-more.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/tooltip/__docs__/storybook-stories.js b/components/tooltip/__docs__/storybook-stories.js new file mode 100644 index 0000000000..aee23c862f --- /dev/null +++ b/components/tooltip/__docs__/storybook-stories.js @@ -0,0 +1,116 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _tooltip = _interopRequireDefault(require("../../tooltip")); + +var _base = _interopRequireDefault(require("../__examples__/base")); + +var _buttonGroup = _interopRequireDefault(require("../__examples__/button-group")); + +var _button = _interopRequireDefault(require("../__examples__/button")); + +var _learnMore = _interopRequireDefault(require("../__examples__/learn-more")); + +var _icon = _interopRequireDefault(require("../../icon")); + +var _button2 = _interopRequireDefault(require("../../button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +var getPopoverTooltip = function getPopoverTooltip(props) { + return _react.default.createElement(_tooltip.default, props, _react.default.createElement(_button2.default, { + label: "Trigger Tooltip" + })); +}; + +var getPopoverTooltipAlign = function getPopoverTooltipAlign(props) { + /* eslint-disable react/prop-types */ + var children = []; + var align = ['top', 'top left', 'top right', 'right', 'right top', 'right bottom', 'bottom', 'bottom left', 'bottom right', 'left', 'left top', 'left bottom']; + align.forEach(function (value) { + children.push(_react.default.createElement("div", { + key: value, + style: { + margin: '100px auto' + } + }, _react.default.createElement(_tooltip.default, _extends({}, props, { + align: value + }), props.trigger))); + }); + return _react.default.createElement("div", { + key: "container" + }, children); +}; + +var content = 'Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi.'; +(0, _react2.storiesOf)(_constants.POPOVER_TOOLTIP, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium slds-m-horizontal_x-large", + style: { + margin: '150px auto', + width: '500px' + } + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Base', function () { + return _react.default.createElement(_base.default, null); +}).add('Learn More', function () { + return _react.default.createElement(_learnMore.default, null); +}).add('Button Group', function () { + return _react.default.createElement(_buttonGroup.default, null); +}).add('Button', function () { + return _react.default.createElement(_button.default, null); +}).add('Open', function () { + return getPopoverTooltip({ + align: 'bottom', + isOpen: true, + id: 'myPopoverId', + dialogClassName: 'dialog-classname', + content: content + }); +}).add('Alignment (Button)', function () { + return getPopoverTooltipAlign({ + id: 'myPopoverId', + isOpen: true, + content: content, + trigger: _react.default.createElement(_button2.default, { + label: "Trigger Tooltip" + }) + }); +}).add('Alignment (span)', function () { + return getPopoverTooltipAlign({ + id: 'myPopoverId', + isOpen: true, + content: content, + trigger: _react.default.createElement("span", { + tabIndex: "0", + key: "trigger" + }, "Trigger Tooltip") + }); +}).add('Alignment (icon)', function () { + return getPopoverTooltipAlign({ + id: 'myPopoverId', + isOpen: true, + content: _react.default.createElement("span", null, content), + // react/no-unescaped-entities + trigger: _react.default.createElement(_icon.default, { + assistiveText: { + label: 'Case Icon' + }, + category: "standard", + name: "case", + size: "small", + tabIndex: "0" + }) + }); +}); \ No newline at end of file diff --git a/components/tooltip/__examples__/base.js b/components/tooltip/__examples__/base.js new file mode 100644 index 0000000000..830b2eda60 --- /dev/null +++ b/components/tooltip/__examples__/base.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _tooltip = _interopRequireDefault(require("../../../../components/tooltip")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// `~` is replaced with design-system-react at runtime +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_tooltip.default, { + id: "base", + align: "top left", + content: "Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi.", + variant: "learnMore", + dialogClassName: "dialog-classname" + })); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'TooltipExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/tooltip/__examples__/button-group.js b/components/tooltip/__examples__/button-group.js new file mode 100644 index 0000000000..14b8d3f620 --- /dev/null +++ b/components/tooltip/__examples__/button-group.js @@ -0,0 +1,107 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _tooltip = _interopRequireDefault(require("../../../../components/tooltip")); + +var _buttonGroup = _interopRequireDefault(require("../../../../components/button-group")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +var _menuDropdown = _interopRequireDefault(require("../../../../components/menu-dropdown")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_buttonGroup.default, { + className: "slds-p-bottom_medium" + }, _react.default.createElement(_tooltip.default, { + id: "refresh-tooltip", + align: "bottom", + content: "Buttonbar Tooltip" + }, _react.default.createElement(_button.default, { + id: "refresh-button", + label: "Refresh" + })), _react.default.createElement(_tooltip.default, { + id: "edit-tooltip", + align: "bottom right", + content: "Buttonbar Tooltip" + }, _react.default.createElement(_button.default, { + label: "Edit", + id: "edit-button" + })), _react.default.createElement(_menuDropdown.default, { + id: "options", + assistiveText: { + icon: 'More Options' + }, + buttonVariant: "icon", + iconCategory: "utility", + iconName: "down", + iconVariant: "border-filled", + onSelect: function onSelect(item) { + return console.log('selected', item); + }, + options: [{ + label: 'A Option', + value: 'A0' + }, { + label: 'B Option', + value: 'B0' + }, { + label: 'C Option', + value: 'C0' + }] + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'TooltipExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/tooltip/__examples__/button.js b/components/tooltip/__examples__/button.js new file mode 100644 index 0000000000..04828eb2d9 --- /dev/null +++ b/components/tooltip/__examples__/button.js @@ -0,0 +1,72 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _tooltip = _interopRequireDefault(require("../../../../components/tooltip")); + +var _button = _interopRequireDefault(require("../../../../components/button")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_tooltip.default, { + id: "tooltip", + align: "right", + content: "Tooltip with right alignment" + }, _react.default.createElement(_button.default, { + id: "button", + label: "Hover or focus to Open" + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'TooltipExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/tooltip/__examples__/learn-more.js b/components/tooltip/__examples__/learn-more.js new file mode 100644 index 0000000000..00c2046a36 --- /dev/null +++ b/components/tooltip/__examples__/learn-more.js @@ -0,0 +1,84 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _tooltip = _interopRequireDefault(require("../../../../components/tooltip")); + +var _icon = _interopRequireDefault(require("../../../../components/icon")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function (event) { + console.log(event, 'clicked'); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_tooltip.default, { + id: "tooltip", + align: "top left", + content: "This is the exciting content of this tooltip. The content is so exciting that we cannot contain all we need to say within this tooltip.", + onClickTrigger: this.handleClick, + variant: "learnMore" + })); + } + }]); + + return Example; +}(_react.default.Component); + +Example.displayName = 'TooltipExample'; +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/tooltip/check-props.js b/components/tooltip/check-props.js new file mode 100644 index 0000000000..4abf958aa0 --- /dev/null +++ b/components/tooltip/check-props.js @@ -0,0 +1,58 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _deprecatedProperty = _interopRequireDefault(require("../../utilities/warning/deprecated-property")); + +var _deprecatedPropertyValue = _interopRequireDefault(require("../../utilities/warning/deprecated-property-value")); + +var _isTriggerTabbable = _interopRequireDefault(require("../../utilities/warning/is-trigger-tabbable")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + + if (props.variant === 'base' && _react.default.Children.count(props.children) !== 0) { + (0, _isTriggerTabbable.default)(COMPONENT, props.children, createDocUrl()); + } // Deprecated and changed to another property + + + (0, _deprecatedPropertyValue.default)(COMPONENT, { + propAsString: 'variant', + propValue: props.variant, + deprecatedPropValue: 'info', + replacementPropAsString: 'theme', + replacementPropAsValue: 'info' + }, createDocUrl('theme')); + (0, _deprecatedPropertyValue.default)(COMPONENT, { + propAsString: 'variant', + propValue: props.variant, + deprecatedPropValue: 'error', + replacementPropAsString: 'theme', + replacementPropAsValue: 'error' + }, createDocUrl('theme')); + (0, _deprecatedProperty.default)(COMPONENT, props.openByDefault, 'openByDefault', 'isOpen', createDocUrl('isOpen')); + (0, _deprecatedProperty.default)(COMPONENT, props.target, 'target', undefined, "A new positioning library is being implmented under the hood. Please trigger tooltips to appear on their triggers with `isOpen` and not on other DOM elements. ".concat(createDocUrl('isOpen')) // eslint-disable-line max-len + ); + (0, _deprecatedProperty.default)(COMPONENT, props.isInline, 'isInline', 'position="relative"', createDocUrl('position')); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/tooltip/docs.json b/components/tooltip/docs.json new file mode 100644 index 0000000000..ccfaa709da --- /dev/null +++ b/components/tooltip/docs.json @@ -0,0 +1,7 @@ +{ + "component": "tooltip", + "status": "prod", + "display-name": "Tooltips", + "SLDS-component-path": "/components/tooltips", + "url-slug": "tooltips" +} \ No newline at end of file diff --git a/components/tooltip/index.js b/components/tooltip/index.js new file mode 100644 index 0000000000..316fac3a6f --- /dev/null +++ b/components/tooltip/index.js @@ -0,0 +1,368 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _constants = require("../../utilities/constants"); + +var _dialog = _interopRequireDefault(require("../utilities/dialog")); + +var _icon = _interopRequireDefault(require("../icon")); + +var _button = _interopRequireDefault(require("../button")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// ### Display Name +// Always use the canonical component name as the React display name. +var displayName = _constants.POPOVER_TOOLTIP; +var propTypes = { + /** + * Alignment of the Tooltip relative to the element that triggers it. + */ + align: _propTypes.default.oneOf(['top', 'top left', 'top right', 'right', 'right top', 'right bottom', 'bottom', 'bottom left', 'bottom right', 'left', 'left top', 'left bottom']).isRequired, + + /** + * **Assistive text for accessibility** + * This object is merged with the default props object on every render. + * * `tooltipTipLearnMoreIcon`: This text is inside the info icon within the tooltip content and exists to "complete the sentence" for assistive tech users. + * * `triggerLearnMoreIcon`: This text is inside the info icon that triggers the tooltip in order to have text within the link. + */ + assistiveText: _propTypes.default.shape({ + tooltipTipLearnMoreIcon: _propTypes.default.string, + triggerLearnMoreIcon: _propTypes.default.string + }), + + /** + * Pass the one element that triggers the Tooltip as a child. It must be an element with `tabIndex` or an element that already has a `tabIndex` set such as an anchor or a button, so that keyboard users can tab to it. + */ + children: _propTypes.default.node, + + /** + * Content inside Tooltip. + */ + content: _propTypes.default.node.isRequired, + + /** + * CSS classes to be added to the popover dialog. That is the element with `.slds-popover` on it. + */ + dialogClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * By default, dialogs will flip their alignment (such as bottom to top) if they extend beyond a boundary element such as a scrolling parent or a window/viewpoint. `hasStaticAlignment` disables this behavior and allows this component to extend beyond boundary elements. _Not tested._ + */ + hasStaticAlignment: _propTypes.default.bool, + + /** + * Delay on Tooltip closing. + */ + hoverCloseDelay: _propTypes.default.number, + + /** + * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the popover to the triggering element. + */ + id: _propTypes.default.string, + + /** + * **Text labels for internationalization** + * This object is merged with the default props object on every render. + * * `learnMoreAfter`: This label appears in the tooltip after the info icon. + * * `learnMoreBefore`: This label appears in the tooltip before the info icon. + */ + labels: _propTypes.default.shape({ + learnMoreAfter: _propTypes.default.string, + learnMoreBefore: _propTypes.default.string + }), + + /** + * Forces tooltip to be open. A value of `false` will disable any interaction with the tooltip. + */ + isOpen: _propTypes.default.bool, + + /** + * CSS classes to be added to tag with `slds-tooltip-trigger`. + */ + triggerClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Please select one of the following: + * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog. + * * `overflowBoundaryElement` - The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree. + * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing. + */ + position: _propTypes.default.oneOf(['absolute', 'overflowBoundaryElement', 'relative']), + + /** + * Custom styles to be added to wrapping triggering `div`. + */ + triggerStyle: _propTypes.default.object, + + /** + * Determines the theme of tooltip: for informative purpose (blue background) or warning purpose (red background). This used to be `variant`. + */ + theme: _propTypes.default.oneOf(['info', 'error']), + + /** + * Determines the type of the tooltip. + */ + variant: _propTypes.default.oneOf(['base', 'learnMore']) +}; +var defaultProps = { + assistiveText: { + tooltipTipLearnMoreIcon: 'this link', + triggerLearnMoreIcon: 'Help' + }, + align: 'top', + content: _react.default.createElement("span", null, "Tooltip"), + labels: { + learnMoreAfter: 'to learn more.', + learnMoreBefore: 'Click' + }, + hoverCloseDelay: 50, + position: 'absolute', + theme: 'info', + variant: 'base' +}; +/** + * The PopoverTooltip component is variant of the Lightning Design System Popover component. This component wraps an element that triggers it to open. It must be a focusable child element (either a button or an anchor), so that keyboard users can navigate to it. + */ + +var Tooltip = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Tooltip, _React$Component); + + function Tooltip(props) { + var _this; + + _classCallCheck(this, Tooltip); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Tooltip).call(this, props)); + + _defineProperty(_assertThisInitialized(_this), "handleCancel", function () { + _this.setState({ + isOpen: false, + isClosing: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function () { + _this.setState({ + isOpen: true, + isClosing: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleMouseLeave", function () { + _this.setState({ + isClosing: true + }); + + setTimeout(function () { + if (!_this.isUnmounting && _this.state.isClosing) { + _this.setState({ + isOpen: false, + isClosing: false + }); + } + }, _this.props.hoverCloseDelay); + }); + + _defineProperty(_assertThisInitialized(_this), "saveTriggerRef", function (component) { + _this.trigger = component; // yes, this is a re-render triggered by a render. + // Dialog/Popper.js cannot place the popover until + // the trigger/target DOM node is mounted. This + // way `findDOMNode` is not called and parent + // DOM nodes are not queried. + + if (!_this.state.triggerRendered) { + _this.setState({ + triggerRendered: true + }); + } + }); + + _this.state = { + isClosing: false, + isOpen: false + }; + return _this; + } + + _createClass(Tooltip, [{ + key: "componentWillMount", + value: function componentWillMount() { + // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + (0, _checkProps.default)(_constants.POPOVER_TOOLTIP, this.props, _docs.default); + this.generatedId = _shortid.default.generate(); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this.isUnmounting = true; + } + }, { + key: "getContent", + value: function getContent() { + var _this2 = this; + + var children; + var noChildrenProvided = _react.default.Children.count(this.props.children) === 0; + + if (noChildrenProvided && this.props.onClickTrigger) { + children = [_react.default.createElement("a", { + href: "javascript:void(0)", + onClick: this.props.onClickTrigger + }, _react.default.createElement(_icon.default, { + category: "utility", + name: "info", + assistiveText: { + label: this.props.assistiveText.triggerLearnMoreIcon + }, + size: "x-small" + }))]; + } else if (noChildrenProvided) { + children = [_react.default.createElement(_button.default, { + "aria-disabled": true, + assistiveText: { + icon: this.props.assistiveText.triggerLearnMoreIcon + }, + iconCategory: "utility", + iconName: "info", + variant: "icon" + })]; + } else { + children = this.props.children; + } + + return _react.default.Children.map(children, function (child, i) { + return _react.default.cloneElement(child, { + key: i, + // eslint-disable-line react/no-array-index-key + 'aria-describedby': _this2.getId(), + onBlur: _this2.handleMouseLeave, + onFocus: _this2.handleMouseEnter, + onMouseEnter: _this2.handleMouseEnter, + onMouseLeave: _this2.handleMouseLeave + }); + }); + } + }, { + key: "getId", + value: function getId() { + return this.props.id || this.generatedId; + } + }, { + key: "getTooltip", + value: function getTooltip() { + var _this3 = this; + + var isOpen = this.props.isOpen === undefined ? this.state.isOpen : this.props.isOpen; + var align = this.props.align; // REMOVE AT NEXT BREAKING CHANGE (v1.0 or v0.9) + + var deprecatedWay = this.props.variant === 'error'; + return isOpen ? _react.default.createElement(_dialog.default, { + closeOnTabKey: true, + hasNubbin: true, + contentsClassName: (0, _classnames.default)('slds-popover', 'slds-popover_tooltip', { + 'slds-theme_error': this.props.theme === 'error' || deprecatedWay + }, this.props.dialogClassName), + align: align, + context: this.context, + hasStaticAlignment: this.props.hasStaticAlignment, + onClose: this.handleCancel, + onRequestTargetElement: function onRequestTargetElement() { + return _this3.getTooltipTarget(); + }, + position: this.props.position, + variant: "tooltip", + containerProps: { + id: this.getId() + } + }, this.getTooltipContent()) : _react.default.createElement("span", null); + } + }, { + key: "getTooltipContent", + value: function getTooltipContent() { + return _react.default.createElement("div", { + className: "slds-popover__body" + }, this.props.content, this.props.variant === 'learnMore' && this.props.onClickTrigger ? _react.default.createElement("div", { + className: "slds-m-top_x-small", + "aria-hidden": "true" + }, this.props.labels.learnMoreBefore, ' ', _react.default.createElement(_icon.default, { + assistiveText: { + label: this.props.assistiveText.tooltipTipLearnMoreIcon + }, + category: "utility", + inverse: true, + name: "info", + size: "x-small" + }), ' ', this.props.labels.learnMoreAfter, ' ') : null); + } + }, { + key: "getTooltipTarget", + value: function getTooltipTarget() { + return this.props.target ? this.props.target : this.trigger; + } + }, { + key: "render", + value: function render() { + var containerStyles = _objectSpread({ + display: 'inline-block' + }, this.props.triggerStyle); + + return _react.default.createElement("div", { + className: (0, _classnames.default)('slds-tooltip-trigger', this.props.triggerClassName), + style: containerStyles, + ref: this.saveTriggerRef + }, this.getContent(), this.getTooltip()); + } + }]); + + return Tooltip; +}(_react.default.Component); + +Tooltip.contextTypes = { + iconPath: _propTypes.default.string +}; +Tooltip.displayName = displayName; +Tooltip.propTypes = propTypes; +Tooltip.defaultProps = defaultProps; +var _default = Tooltip; +exports.default = _default; \ No newline at end of file diff --git a/components/tooltip/private/field-level-help-tooltip.js b/components/tooltip/private/field-level-help-tooltip.js new file mode 100644 index 0000000000..b744603a57 --- /dev/null +++ b/components/tooltip/private/field-level-help-tooltip.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _index = _interopRequireDefault(require("../index")); + +var _object = _interopRequireDefault(require("../../../utilities/object")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /* + * Assistive Text object from parent component such as Input, Combobox, etc. + */ + assistiveText: _propTypes.default.shape({ + triggerLearnMoreIcon: _propTypes.default.string + }), + + /* + * Tooltip from external prop + */ + fieldLevelHelpTooltip: _propTypes.default.node.isRequired +}; +var defaultProps = { + triggerClassName: 'slds-form-element__icon', + // This allows `position: absolute` Tooltips to align properly. + // If not present, tooltip will always be below the info icon // instead of above it. + triggerStyle: { + position: 'static' + }, + variant: 'learnMore' +}; + +var FieldLevelHelpTooltip = function FieldLevelHelpTooltip(_ref) { + var fieldLevelHelpTooltip = _ref.fieldLevelHelpTooltip, + _ref$assistiveText = _ref.assistiveText, + assistiveText = _ref$assistiveText === void 0 ? {} : _ref$assistiveText; + return fieldLevelHelpTooltip ? _react.default.createElement(_index.default, _objectSpread({}, defaultProps, fieldLevelHelpTooltip.props, { + // allow backwards compatibility with Input's + // assistiveText.fieldLevelHelpButton + // `Input` used to have an `assistiveText.fieldLevelHelpButton` + // prop and that prop needs to override the default Tooltip + // "Help" string. + assistiveText: _objectSpread({}, fieldLevelHelpTooltip.props.assistiveText, _object.default.removeUndefined(assistiveText)) + })) : null; +}; + +FieldLevelHelpTooltip.propTypes = propTypes; +FieldLevelHelpTooltip.displayName = 'FieldLevelHelpTooltip'; +var _default = FieldLevelHelpTooltip; +exports.default = _default; \ No newline at end of file diff --git a/components/tree/__docs__/__snapshots__/storybook-stories.storyshot b/components/tree/__docs__/__snapshots__/storybook-stories.storyshot new file mode 100644 index 0000000000..bbc7ed96ae --- /dev/null +++ b/components/tree/__docs__/__snapshots__/storybook-stories.storyshot @@ -0,0 +1,18798 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DOM snapshots SLDSTree Assistive Heading 1`] = ` +
    +
    +
    +

    + Miscellaneous Foods +

    +
      +
    • +
      + + + + Grains + + +
      +
    • +
    +
    +
    +`; + +exports[`DOM snapshots SLDSTree Base 1`] = ` +
    +
    +
    +

    + Miscellaneous Foods +

    +
      +
    • +
      + + + + Grains + + +
      +
    • +
    +
    +
    +`; + +exports[`DOM snapshots SLDSTree Base with stencil 1`] = ` +
    +
    +
    +

    + Miscellaneous Foods +

    +
      +
    • +
      + + + + Grains + + +
      +
    • +
    +
    +
    +`; + +exports[`DOM snapshots SLDSTree Highlighted Search 1`] = ` +
    +
    +
    +
    + +
    + + + + +
    +
    +
    +
    +
    +

    + Miscellaneous Foods +

    +
      +
    • +
      + + + + + + Grains + + + + +
      +
    • +
    +
    +
    +`; + +exports[`DOM snapshots SLDSTree Initial Expanded/Selected 1`] = ` +
    +
    +
    +

    + Miscellaneous Foods +

    +
      +
    • +
      + + + + Grains + + +
      +
    • +
    • +
      + + + + Fruits + + +
      +
        +
      • +
        + + + + Ground Fruits + + +
        +
          +
        • +
          + + + + Watermelon + + +
          +
        • +
        • +
          + + + + Canteloupe + + +
          +
        • +
        • +
          + + + + Strawberries + + +
          +
        • +
        +
      • + +
    +
    +
    +`; + +exports[`DOM snapshots SLDSTree Multiple Selection 1`] = ` +
    +
    +
    +

    + Miscellaneous Foods +

    +
      +
    • +
      + + + + Grains + + +
      +
    • +
    +
    +
    +`; + +exports[`DOM snapshots SLDSTree No Branch Select 1`] = ` +
    +
    +
    +

    + Miscellaneous Foods +

    +
      +
    • +
      + + + + Grains + + +
      +
    • +
    +
    +
    +`; + +exports[`DOM snapshots SLDSTree Overflow Hidden 1`] = ` +
    +
    +
    +

    + Miscellaneous Foods +

    +
      +
    +
    +
    +`; diff --git a/components/tree/__docs__/dynamic-hashmap.js b/components/tree/__docs__/dynamic-hashmap.js new file mode 100644 index 0000000000..bec376e582 --- /dev/null +++ b/components/tree/__docs__/dynamic-hashmap.js @@ -0,0 +1,41 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _normalizr = require("normalizr"); + +var _tree = _interopRequireDefault(require("../../../utilities/sample-data/tree")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* + [Normalizr](https://github.com/paularmstrong/normalizr) Many APIs, public or not, return JSON data that has deeply nested objects. Using data in this kind of structure is often very difficult for JavaScript applications, especially those using Flux or Redux. + + Normalizr is a small, but powerful utility for taking JSON with a schema definition and returning nested entities with their IDs, gathered in dictionaries. + + Hashmaps or hash tables more easily allow immutability because only one hash entry needs to be overwritten by changes. This prevents anti-patterns like `_.deepClone` or `forceUpdate` renders which update the whole tree instead of limiting the re-render to only the node that changed. React is cool like that. + */ +// Define Normalzr schema +var nodeEntity = new _normalizr.schema.Entity('nodes'); +var nodes = new _normalizr.schema.Array(nodeEntity); +nodeEntity.define({ + nodes: nodes +}); // Convert nested objects to a hashmap + +var base = (0, _normalizr.normalize)(_tree.default.base, nodeEntity).entities.nodes; +var initialExpandedSelected = (0, _normalizr.normalize)(_tree.default.initialState, nodeEntity).entities.nodes; +var large = (0, _normalizr.normalize)(_tree.default.large, nodeEntity).entities.nodes; +var hashmap = { + base: base, + large: large, + initialExpandedSelected: initialExpandedSelected +}; +var _default = hashmap; +exports.default = _default; \ No newline at end of file diff --git a/components/tree/__docs__/site-stories.js b/components/tree/__docs__/site-stories.js new file mode 100644 index 0000000000..c60abb366d --- /dev/null +++ b/components/tree/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/tree/__examples__/default.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/tree/__docs__/storybook-stories.js b/components/tree/__docs__/storybook-stories.js new file mode 100644 index 0000000000..b052094bff --- /dev/null +++ b/components/tree/__docs__/storybook-stories.js @@ -0,0 +1,90 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _normalizr = require("normalizr"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _dynamicHashmap = _interopRequireDefault(require("./dynamic-hashmap")); + +var _tree = _interopRequireDefault(require("../../tree")); + +var _search = _interopRequireDefault(require("../../input/search")); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// View the generated hash map +// console.log(JSON.stringify(sampleNodesDynamicHashMap.base)); +// console.log(JSON.stringify(sampleNodesDynamicHashMap.initialExpandedSelected)); +// console.log(JSON.stringify(sampleNodesDynamicHashMap.large)); +(0, _react2.storiesOf)(_constants.TREE, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, getStory()); +}).add('Base', function () { + return _react.default.createElement(_default.default, { + nodes: _dynamicHashmap.default.base, + action: _addonActions.action + }); +}).add('Base with stencil', function () { + return _react.default.createElement(_default.default, { + action: _addonActions.action, + loadingStencil: true + }); +}).add('Initial Expanded/Selected', function () { + return _react.default.createElement(_default.default, { + action: _addonActions.action, + nodes: _dynamicHashmap.default.initialExpandedSelected + }); +}).add('No Branch Select', function () { + return _react.default.createElement(_default.default, { + action: _addonActions.action, + noBranchSelection: true + }); +}).add('Multiple Selection', function () { + return _react.default.createElement(_default.default, { + action: _addonActions.action, + multipleSelection: true + }); +}).add('Assistive Heading', function () { + return _react.default.createElement(_default.default, { + action: _addonActions.action, + noHeading: true, + assistiveText: { + label: 'Miscellaneous Foods' + } + }); +}).add('Overflow Hidden', function () { + return _react.default.createElement(_default.default, { + action: _addonActions.action, + listStyle: { + height: '300px', + overflowY: 'auto' + }, + nodes: _dynamicHashmap.default.large + }); +}).add('Large dataset (300+) NoTest', function () { + return _react.default.createElement(_default.default, { + action: _addonActions.action, + nodes: _dynamicHashmap.default.large + }); +}).add('Highlighted Search', function () { + return _react.default.createElement(_default.default, { + action: _addonActions.action, + searchable: true + }); +}); \ No newline at end of file diff --git a/components/tree/__examples__/default.js b/components/tree/__examples__/default.js new file mode 100644 index 0000000000..f5e94ad8ee --- /dev/null +++ b/components/tree/__examples__/default.js @@ -0,0 +1,450 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _normalizr = require("normalizr"); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _tree = _interopRequireDefault(require("../../../../components/tree")); + +var _log = _interopRequireDefault(require("../../../../utilities/log")); + +var _search = _interopRequireDefault(require("../../forms/input/search")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var sampleNodes = { + 0: { + id: 0, + nodes: [1, 2, 3, 7] + }, + 1: { + label: 'Grains', + type: 'item', + id: 1 + }, + 2: { + label: 'Fruits', + type: 'branch', + id: 2, + nodes: [4, 5] + }, + 3: { + label: 'Nuts', + type: 'branch', + _iconClass: 'glyphicon-file', + id: 3, + nodes: [8, 9, 10, 11] + }, + 4: { + assistiveText: 'Ground Fruits', + label: 'Ground Fruits', + type: 'branch', + id: 4, + nodes: [12, 13, 14] + }, + 5: { + label: 'Tree Fruits', + type: 'branch', + id: 5, + nodes: [15, 16, 17, 18, 19, 6] + }, + 6: { + label: 'Raspberries', + type: 'item', + id: 6 + }, + 7: { + label: 'Empty folder', + type: 'branch', + id: 7 + }, + 8: { + label: 'Almonds', + type: 'item', + id: 8 + }, + 9: { + label: 'Cashews', + type: 'item', + id: 9 + }, + 10: { + label: 'Pecans', + type: 'item', + id: 10 + }, + 11: { + label: 'Walnuts', + type: 'item', + id: 11 + }, + 12: { + label: 'Watermelon', + type: 'item', + id: 12 + }, + 13: { + label: 'Canteloupe', + type: 'item', + _iconClass: 'glyphicon-file', + id: 13 + }, + 14: { + label: 'Strawberries', + type: 'item', + id: 14 + }, + 15: { + label: 'Peaches', + type: 'item', + id: 15 + }, + 16: { + label: 'Pears', + type: 'item', + _iconClass: 'glyphicon-file', + id: 16 + }, + 17: { + label: 'Citrus', + type: 'branch', + id: 17, + nodes: [20, 21, 22, 23] + }, + 18: { + label: 'Apples', + type: 'branch', + id: 18, + nodes: [24, 25, 26, 27] + }, + 19: { + label: 'Cherries', + type: 'branch', + id: 19, + nodes: [28, 29, 30, 31, 32, 33] + }, + 20: { + label: 'Orange', + type: 'item', + id: 20 + }, + 21: { + label: 'Grapefruit', + type: 'item', + id: 21 + }, + 22: { + label: 'Lemon', + type: 'item', + id: 22 + }, + 23: { + label: 'Lime', + type: 'item', + id: 23 + }, + 24: { + label: 'Granny Smith', + type: 'item', + id: 24 + }, + 25: { + label: 'Pinklady', + type: 'item', + _iconClass: 'glyphicon-file', + id: 25 + }, + 26: { + label: 'Rotten', + type: 'item', + id: 26 + }, + 27: { + label: 'Jonathan', + type: 'item', + id: 27 + }, + 28: { + label: 'Balaton', + type: 'item', + id: 28 + }, + 29: { + label: 'Erdi Botermo', + type: 'item', + id: 29 + }, + 30: { + label: 'Montmorency', + type: 'item', + id: 30 + }, + 31: { + label: 'Queen Ann', + type: 'item', + id: 31 + }, + 32: { + label: 'Ulster', + type: 'item', + id: 32 + }, + 33: { + label: 'Viva', + type: 'item', + id: 33 + } +}; +/* +Sample of normalized hash table created +{ + "0":{ + "id":0, + "nodes":[ + 1, + 2, + 3, + 7 + ] + }, + "1":{ + "label":"Grains", + "type":"item", + "id":1 + }, + "2":{ + "label":"Fruits", + "type":"branch", + "id":2, + "nodes":[ + 4, + 5 + ] + }, + "3":{ + "label":"Nuts", + "type":"branch", + "_iconClass":"glyphicon-file", + "id":3, + "nodes":[ + 8, + 9, + 10, + 11 + ] + }, + "4":{ + "assistiveText":"Ground Fruits", + "label":{ + "type":"span", + "key":null, + "ref":null, + "props":{ + "children":"Ground Fruits" + }, + "_owner":null, + "_store":{ + + } + }, + "type":"branch", + "id":4, + "nodes":[ + 12, + 13, + 14 + ] + } +} + */ + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + nodes: _this.props.nodes || sampleNodes, + searchTerm: _this.props.searchable ? 'fruit' : undefined + }); + + _defineProperty(_assertThisInitialized(_this), "getNodes", function (node) { + return node.nodes ? node.nodes.map(function (id) { + return _this.state.nodes[id]; + }) : []; + }); + + _defineProperty(_assertThisInitialized(_this), "handleExpandClick", function (event, data) { + (0, _log.default)({ + action: _this.props.action, + customLog: _this.props.log, + event: event, + eventName: 'Expand Branch', + data: data + }); + var selected = data.select ? true : data.node.selected; + + _this.setState(function (prevState) { + return _objectSpread({}, prevState, { + nodes: _objectSpread({}, prevState.nodes, _defineProperty({}, data.node.id, _objectSpread({}, data.node, { + expanded: data.expand, + selected: selected + }))) + }); + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function (event, data) { + (0, _log.default)({ + action: _this.props.action, + customLog: _this.props.log, + event: event, + eventName: 'Node Selected', + data: data + }); + + if (_this.props.multipleSelection) { + if (!_this.props.noBranchSelection || _this.props.noBranchSelection && data.node.type !== 'branch') { + // Take the previous state, expand it, overwrite the `nodes` key with the previous state's `nodes` key expanded with the id of the node just clicked selected + _this.setState(function (prevState) { + return _objectSpread({}, prevState, { + nodes: _objectSpread({}, prevState.nodes, _defineProperty({}, data.node.id, _objectSpread({}, data.node, { + selected: data.select + }))) + }); + }); + } + } else if (_this.props.noBranchSelection && data.node.type === 'branch') { + // OPEN BRANCH/FOLDER WHEN CLICKED + // Although not codified in SLDS, this takes the click callback and turns it into the expand callback, and should be used for item only selection. + _this.setState(function (prevState) { + return _objectSpread({}, prevState, { + nodes: _objectSpread({}, prevState.nodes, _defineProperty({}, data.node.id, _objectSpread({}, data.node, { + expanded: !data.node.expanded + }))) + }); + }); + } else { + // SINGLE SELECTION + // Take the previous state, expand it, overwrite the `nodes` key with the previous state's `nodes` key expanded with the id of the node just clicked selected and the previously selected node unselected. + _this.setState(function (prevState) { + // Gaurd against no selection with the following. `selectedNode` + // is the previously selected "current state" that is about to + // be updated + var selectedNode = prevState.selectedNode ? _defineProperty({}, prevState.selectedNode.id, _objectSpread({}, prevState.nodes[prevState.selectedNode.id], { + selected: false + })) : {}; + return _objectSpread({}, prevState, { + nodes: _objectSpread({}, prevState.nodes, _objectSpread(_defineProperty({}, data.node.id, _objectSpread({}, data.node, { + selected: data.select + })), selectedNode)), + selectedNode: data.node + }); + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleScroll", function (event, data) { + (0, _log.default)({ + action: _this.props.action, + event: event, + eventName: 'Tree scrolled', + data: data + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleSearchChange", function (event) { + _this.setState({ + searchTerm: event.target.value + }); + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", null, this.props.searchable ? _react.default.createElement("div", null, _react.default.createElement(_search.default, { + assistiveText: { + label: 'Search Tree' + }, + id: "example-search", + value: this.state.searchTerm, + onChange: this.handleSearchChange + }), _react.default.createElement("br", null)) : null, _react.default.createElement(_tree.default, { + assistiveText: this.props.assistiveText, + className: this.props.className, + getNodes: this.props.getNodes || this.getNodes, + heading: !this.props.noHeading && this.props.heading, + id: this.props.id, + listStyle: this.props.listStyle, + listClassName: this.props.listClassName, + nodes: this.state.nodes['0'].nodes, + onExpandClick: this.props.onExpandClick || this.handleExpandClick, + onClick: this.props.onClick || this.handleClick, + onScroll: this.props.onScroll || this.handleScroll, + searchTerm: this.props.searchTerm || this.state.searchTerm + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'DemoTree'); + +_defineProperty(Example, "defaultProps", { + heading: 'Miscellaneous Foods', + id: 'example-tree' +}); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/tree/check-props.js b/components/tree/check-props.js new file mode 100644 index 0000000000..0da516528e --- /dev/null +++ b/components/tree/check-props.js @@ -0,0 +1,41 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _oneOfRequiredProperty = _interopRequireDefault(require("../../utilities/warning/one-of-required-property")); + +var _sunsetProperty = _interopRequireDefault(require("../../utilities/warning/sunset-property")); + +var _getComponentDoc = _interopRequireDefault(require("../../utilities/get-component-doc")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props, jsonDoc) { + var createDocUrl = (0, _getComponentDoc.default)(jsonDoc); + /* eslint-disable max-len */ + + (0, _oneOfRequiredProperty.default)(COMPONENT, { + assistiveText: props.assistiveText, + heading: props.heading + }, createDocUrl()); + /* eslint-enable max-len */ + + if (typeof props.assistiveText === 'string') { + (0, _sunsetProperty.default)(COMPONENT, props.assistiveText, 'assistiveText', "`assistiveText` as a string has been deprecated and is now an object to allow for multiple uses in the component. Please use `assistiveText.label` instead. ".concat(createDocUrl('assistiveText'))); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/tree/docs.json b/components/tree/docs.json new file mode 100644 index 0000000000..acf5cc175c --- /dev/null +++ b/components/tree/docs.json @@ -0,0 +1,15 @@ +{ + "component": "tree", + "status": "prod", + "display-name": "Tree", + "last-accessibility-review": { + "date-iso-8601": "2018/05/04", + "commit-sha": "5fdeb31982a42cbd37a70d96d6257142cd7eec72" + }, + "last-slds-markup-review": { + "date-iso-8601": "2018/05/04", + "commit-sha": "5fdeb31982a42cbd37a70d96d6257142cd7eec72" + }, + "SLDS-component-path": "/components/trees", + "url-slug": "tree" +} \ No newline at end of file diff --git a/components/tree/index.js b/components/tree/index.js new file mode 100644 index 0000000000..bdf2220365 --- /dev/null +++ b/components/tree/index.js @@ -0,0 +1,337 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _lodash = _interopRequireDefault(require("lodash.find")); + +var _branch = _interopRequireDefault(require("./private/branch")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _constants = require("../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// ### Prop Types +var propTypes = { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `label`: For users of assistive technology, if set the heading will be hidden. One of `heading` or `assistiveText.label` must be set in order to label the tree. + */ + assistiveText: _propTypes.default.shape({ + label: _propTypes.default.string + }), + + /** + * Class names to be added to the container element which has the heading and the `ul.slds-tree` element as children. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Class names to be added to the top-level `ul` element of the tree. + */ + listClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * A function that will be called by every branch to receive its child nodes. The parent `node` object with the branch data is passed into this function: `getNodes(node)`. If your state engine is Flux or Redux, then your tree data structure will probably be flattened or normalized within the store. This will allow you to build out your tree without transversing an actual tree of data and may be more performant. + */ + getNodes: _propTypes.default.func, + + /** + * This is the tree's heading and describes its contents. It can be hidden, see `assistiveText`. + * */ + heading: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * HTML `id` of primary element that has `.slds-tree` on it. This component has a wrapping container element outside of `.slds-tree`. + */ + id: _propTypes.default.string.isRequired, + + /** + * Array of items starting at the top of the tree. The shape each node in the array is: + * ``` + * { + * expanded: string, + * id: string, + * label: string or node, + * selected: string, + * type: string, + * nodes: array + * } + * ``` + * `assistiveText: string` is optional and helpful if the label is not a string. Only `id` and `label` are required. Use `type: 'branch'` for folder and categories. + */ + nodes: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string, _propTypes.default.shape({ + id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired, + label: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]).isRequired, + type: _propTypes.default.string.isRequired + })])).isRequired, + + /** + * Function that will run whenever an item or branch is selected due to click or keyboard navigation. + */ + onClick: _propTypes.default.func.isRequired, + + /** + * This function triggers when the expand or collapse icon is clicked or due to keyboard navigation. + */ + onExpandClick: _propTypes.default.func.isRequired, + + /** + * This function triggers when the top-level `ul` element scrolls. This can be used to implement an "infinite scroll" pattern and update the `nodes` prop accordingly. + */ + onScroll: _propTypes.default.func, + + /** + * Highlights term if found in node label. This does not auto-expand branches. + */ + searchTerm: _propTypes.default.string, + + /** + * Styles to be added to the top-level `ul` element. Useful for `overflow:hidden`. + */ + listStyle: _propTypes.default.object +}; +var defaultProps = { + assistiveText: {}, + getNodes: function getNodes(node) { + return node.nodes; + } +}; +/** + * A tree is visualization of a structure hierarchy. A branch can be expanded or collapsed. This is a controlled component, since visual state is present in the `nodes` data. + */ + +var Tree = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Tree, _React$Component); + + function Tree(props) { + var _this; + + _classCallCheck(this, Tree); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Tree).call(this, props)); // Find the first selected node and initialize it properly so that can be tabbed to. If no node is selected, it will be selected upon first focus. + + _defineProperty(_assertThisInitialized(_this), "flattenTree", function (root) { + var treeIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; + var firstLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; + + if (!root.nodes) { + return [{ + node: root, + treeIndex: treeIndex + }]; + } + + var nodes = [{ + node: root, + treeIndex: treeIndex + }]; + + if (root.expanded) { + for (var index = 0; index < root.nodes.length; index++) { + var curNode = firstLevel ? root.nodes[index] : _this.props.getNodes(root)[index]; + nodes = nodes.concat(_this.flattenTree(curNode, treeIndex ? "".concat(treeIndex, "-").concat(index) : "".concat(index), false)); + } + } + + return nodes; + }); + + _defineProperty(_assertThisInitialized(_this), "handleSelect", function (_ref) { + var event = _ref.event, + data = _ref.data, + clearSelectedNodes = _ref.clearSelectedNodes, + fromFocus = _ref.fromFocus; + + // When triggered by a key event, other nodes should be deselected. + if (clearSelectedNodes) { + _this.state.flattenedNodes.forEach(function (flattenedNode) { + if (flattenedNode.node.selected) { + flattenedNode.node.selected = false; + } + }); + } // Prevent firing twice on first click, due to the handleSelect + // triggered by a focus event + + + if (!fromFocus) { + _this.props.onClick(event, data); + } // Keep track of the currently selected and focused nodes. + + + var selectedNodeIndexes; + + if (data.select) { + selectedNodeIndexes = _this.state.selectedNodeIndexes.concat([data.treeIndex]); + } else { + selectedNodeIndexes = _this.state.selectedNodeIndexes.filter(function (treeIndex) { + return treeIndex !== data.treeIndex; + }); + } + + _this.treeHasFocus = true; + + _this.setState({ + focusedNodeIndex: data.treeIndex, + selectedNodeIndexes: selectedNodeIndexes + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleNodeBlur", function () { + // There is no need to render when blurring a node because focus is either: + // - outside of the tree, or + // - focused on another node in the tree, which triggers its own render + _this.treeHasFocus = false; + }); + + _defineProperty(_assertThisInitialized(_this), "handleExpand", function (_ref2) { + var event = _ref2.event, + data = _ref2.data; + _this.treeHasFocus = true; + + _this.props.onExpandClick(event, data); + + if (data.select) { + _this.setState({ + focusedNodeIndex: data.treeIndex + }); + } + }); + + var flattenedNodes = _this.flattenTree({ + nodes: _this.props.getNodes({ + nodes: _this.props.nodes + }), + expanded: true + }).slice(1); + + var selectedNode = (0, _lodash.default)(flattenedNodes, function (curNode) { + return curNode.node.selected; + }); + var _selectedNodeIndexes = []; + var focusedNodeIndex; + + if (selectedNode) { + _selectedNodeIndexes.push(selectedNode.treeIndex); + + focusedNodeIndex = selectedNode.treeIndex; + } + + _this.state = { + flattenedNodes: flattenedNodes, + selectedNodeIndexes: _selectedNodeIndexes, + focusedNodeIndex: focusedNodeIndex + }; + return _this; + } + + _createClass(Tree, [{ + key: "componentWillMount", + value: function componentWillMount() { + (0, _checkProps.default)(_constants.TREE, this.props, _docs.default); + } + }, { + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + this.setState({ + flattenedNodes: this.flattenTree({ + nodes: this.props.getNodes({ + nodes: nextProps.nodes + }), + expanded: true + }).slice(1) + }); + } + /* Flattens hierarchical tree structure into a flat array. The + * first item in the array is the whole tree and therefore should be + * removed with `slice(1)`.` This means that root cannot call `getNodes()` + * and should directly reference the `nodes` key. All level after that + * should use `getNodes()` to access the correct nodes. + */ + + }, { + key: "render", + value: function render() { + // One of these is required to pass accessibility tests + var assistiveText = typeof this.props.assistiveText === 'string' ? this.props.assistiveText : _objectSpread({}, defaultProps.assistiveText, this.props.assistiveText).label; + var headingText = assistiveText || this.props.heading; // Start the zero level branch--that is the tree root. There is no label for + // the tree root, but is required by all other nodes + + return _react.default.createElement("div", { + id: this.props.id, + className: (0, _classnames.default)('slds-tree_container', this.props.className) + /* role="application" */ + + }, _react.default.createElement("h4", { + className: (0, _classnames.default)('slds-tree__group-header', { + 'slds-assistive-text': assistiveText + }), + id: "".concat(this.props.id, "__heading") + }, headingText), _react.default.createElement(_branch.default, { + getNodes: this.props.getNodes, + initalClassName: this.props.listClassName, + htmlId: this.props.id, + initialStyle: this.props.listStyle, + level: 0, + node: { + nodes: this.props.nodes + }, + flattenedNodes: this.state.flattenedNodes, + selectedNodeIndexes: this.state.selectedNodeIndexes, + focusedNodeIndex: this.state.focusedNodeIndex, + treeHasFocus: this.treeHasFocus, + onNodeBlur: this.handleNodeBlur, + onSelect: this.handleSelect, + onExpand: this.handleExpand, + onScroll: this.props.onScroll, + searchTerm: this.props.searchTerm, + treeId: this.props.id + })); + } + }]); + + return Tree; +}(_react.default.Component); + +Tree.displayName = _constants.TREE; +Tree.propTypes = propTypes; +Tree.defaultProps = defaultProps; +var _default = Tree; +exports.default = _default; \ No newline at end of file diff --git a/components/tree/private/branch.js b/components/tree/private/branch.js new file mode 100644 index 0000000000..70aa1d9165 --- /dev/null +++ b/components/tree/private/branch.js @@ -0,0 +1,209 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _item = _interopRequireDefault(require("./item")); + +var _renderInitialBranch = _interopRequireDefault(require("./render-initial-branch")); + +var _renderBranch = _interopRequireDefault(require("./render-branch")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// # Tree Branch Component +// Child components + +/** + * A Tree Item is a non-branching node in a hierarchical list. + */ +var Branch = function Branch(props) { + var treeIndex = ''; + var children; + var treeId = props.treeId, + level = props.level, + onExpand = props.onExpand, + searchTerm = props.searchTerm; + + if (Array.isArray(props.getNodes(props.node))) { + children = props.getNodes(props.node).map(function (node, index) { + var child; + var htmlId = "".concat(props.treeId, "-").concat(node.id); + treeIndex = "".concat(index); + + if (props.treeIndex) { + treeIndex = "".concat(props.treeIndex, "-").concat(treeIndex); + } + + if (node.type === 'branch') { + child = _react.default.createElement(Branch, { + getNodes: props.getNodes, + htmlId: htmlId, + key: node.id, + label: node.label, + level: level + 1, + node: node, + flattenedNodes: props.flattenedNodes, + selectedNodeIndexes: props.selectedNodeIndexes, + focusedNodeIndex: props.focusedNodeIndex, + treeHasFocus: props.treeHasFocus, + onNodeBlur: props.onNodeBlur, + nodes: node.nodes, + onSelect: props.onSelect, + onExpand: onExpand, + searchTerm: searchTerm, + treeId: treeId, + treeIndex: treeIndex, + parent: props.node + }); + } else { + child = _react.default.createElement(_item.default, { + label: node.label, + htmlId: htmlId, + key: _shortid.default.generate(), + level: level + 1, + node: node, + flattenedNodes: props.flattenedNodes, + selectedNodeIndexes: props.selectedNodeIndexes, + focusedNodeIndex: props.focusedNodeIndex, + treeHasFocus: props.treeHasFocus, + onNodeBlur: props.onNodeBlur, + onSelect: props.onSelect, + onExpand: onExpand, + searchTerm: searchTerm, + treeIndex: treeIndex, + treeId: treeId, + parent: props.node + }); + } + + return child; + }); + } + + var branch = props.level === 0 ? (0, _renderInitialBranch.default)(children, props) : (0, _renderBranch.default)(children, props); + return branch; +}; // ### Display Name +// Always use the canonical component name as the React display name. + + +Branch.displayName = _constants.TREE_BRANCH; // ### Prop Types + +Branch.propTypes = { + /** + * A function that will be called by every branch to receive its child nodes. The parent `node` object with the branch data is passed into this function: `getNodes(node)`. If your state engine is Flux or Redux, then your tree data structure will probably be flattened or normalized within the store. This will allow you to build out your tree without transversing an actual tree of data and may be more performant. + */ + getNodes: _propTypes.default.func, + + /** + * HTML `id` of the wrapping container element joined with the `id` of the node. This will recursively increase as the tree depth increases. + */ + htmlId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired, + + /** + * All tree nodes must have a unique HTML `id` for users of assistive technology. If no `id` key is present in the is provided, one will be generated. + */ + index: _propTypes.default.number, + + /** + * Determines if nodes in the top-level of the tree. + */ + initial: _propTypes.default.bool, + + /* + * Class names to be added to the top-level `ul` element. + */ + initalClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + initialStyle: _propTypes.default.object, + + /** + * The text of the tree item. + */ + label: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * The number of nestings. Determines the ARIA level and style alignment. + */ + level: _propTypes.default.number.isRequired, + + /** + * The current node that is being rendered. + */ + node: _propTypes.default.object.isRequired, + + /** + * Function that will run whenever an item or branch is selected (click or keyboard). + */ + onSelect: _propTypes.default.func, + + /** + * This function triggers when the expand or collapse icon is clicked. + */ + onExpand: _propTypes.default.func.isRequired, + + /** + * Highlights term if found in node label + */ + searchTerm: _propTypes.default.string, + + /** + * Unique id used for a prefix of all tree nodes. This is the prefix for subsequent `htmlId` props. + */ + treeId: _propTypes.default.string, + + /** + * Location of node (zero index). First node is `0`. It's first child is `0-0`. This can be used to modify your nodes without searching for the node. This index is only valid if the `nodes` prop is the same as at the time of the event. + */ + treeIndex: _propTypes.default.string, + + /** + * Flattened tree structure. + */ + flattenedNodes: _propTypes.default.arrayOf(_propTypes.default.object), + + /** + * Tree indexes of nodes that are currently selected. + */ + selectedNodeIndexes: _propTypes.default.arrayOf(_propTypes.default.string), + + /** + * Tree index of the node that is currently focused. + */ + focusedNodeIndex: _propTypes.default.string, + + /** + * Callback for when a node is blurred. + */ + onNodeBlur: _propTypes.default.func, + + /** + * Sets focus on render. + */ + treeHasFocus: _propTypes.default.bool, + + /** + * This node's parent. + */ + parent: _propTypes.default.object +}; +Branch.defaultProps = { + level: 0, + label: '', + treeIndex: '', + selectedNodeIndexes: [] +}; +var _default = Branch; +exports.default = _default; \ No newline at end of file diff --git a/components/tree/private/item.js b/components/tree/private/item.js new file mode 100644 index 0000000000..303ec3a017 --- /dev/null +++ b/components/tree/private/item.js @@ -0,0 +1,318 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _lodash = _interopRequireDefault(require("lodash.findindex")); + +var _lodash2 = _interopRequireDefault(require("lodash.isfunction")); + +var _button = _interopRequireDefault(require("../../button")); + +var _highlighter = _interopRequireDefault(require("../../utilities/highlighter")); + +var _event = _interopRequireDefault(require("../../../utilities/event")); + +var _keyCode = _interopRequireDefault(require("../../../utilities/key-code")); + +var _keyCallbacks = _interopRequireDefault(require("../../../utilities/key-callbacks")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var handleSelect = function handleSelect(_ref) { + var event = _ref.event, + props = _ref.props, + fromFocus = _ref.fromFocus; + + _event.default.trap(event); + + if ((0, _lodash2.default)(props.onSelect)) { + props.onSelect({ + event: event, + data: { + node: props.node, + select: !props.node.selected, + treeIndex: props.treeIndex + }, + fromFocus: fromFocus + }); + } +}; + +var findNextNode = function findNextNode(flattenedNodes, node) { + var nodes = flattenedNodes.map(function (flattenedNode) { + return flattenedNode.node; + }); + var index = (0, _lodash.default)(nodes, { + id: node.id + }); + return flattenedNodes[(index + 1) % flattenedNodes.length]; +}; + +var findPreviousNode = function findPreviousNode(flattenedNodes, node) { + var nodes = flattenedNodes.map(function (flattenedNode) { + return flattenedNode.node; + }); + var index = (0, _lodash.default)(nodes, { + id: node.id + }) - 1; + + if (index < 0) { + index += flattenedNodes.length; + } + + return flattenedNodes[index]; +}; + +var handleKeyDownDown = function handleKeyDownDown(event, props) { + if (props.focusedNodeIndex === props.treeIndex) { + // Select the next visible node + var flattenedNode = findNextNode(props.flattenedNodes, props.node); + props.onSelect({ + event: event, + data: { + node: flattenedNode.node, + select: true, + treeIndex: flattenedNode.treeIndex + }, + clearSelectedNodes: true + }); + } +}; + +var handleKeyDownUp = function handleKeyDownUp(event, props) { + if (props.focusedNodeIndex === props.treeIndex) { + // Go to the previous visible node + var flattenedNode = findPreviousNode(props.flattenedNodes, props.node); + props.onSelect({ + event: event, + data: { + node: flattenedNode.node, + select: true, + treeIndex: flattenedNode.treeIndex + }, + clearSelectedNodes: true + }); + } +}; + +var handleKeyDownLeft = function handleKeyDownLeft(event, props) { + var nodes = props.flattenedNodes.map(function (flattenedNode) { + return flattenedNode.node; + }); + var index = (0, _lodash.default)(nodes, { + id: props.parent.id + }); + + if (index !== -1) { + props.onExpand({ + event: event, + data: { + node: props.parent, + select: true, + expand: !props.parent.expanded, + treeIndex: props.flattenedNodes[index].treeIndex + } + }); + } +}; + +var handleKeyDownEnter = function handleKeyDownEnter(event, props) { + handleSelect({ + event: event, + props: props + }); +}; + +var handleKeyDown = function handleKeyDown(event, props) { + var _callbacks; + + (0, _keyCallbacks.default)(event, { + callbacks: (_callbacks = {}, _defineProperty(_callbacks, _keyCode.default.DOWN, { + callback: function callback(evt) { + return handleKeyDownDown(evt, props); + } + }), _defineProperty(_callbacks, _keyCode.default.UP, { + callback: function callback(evt) { + return handleKeyDownUp(evt, props); + } + }), _defineProperty(_callbacks, _keyCode.default.LEFT, { + callback: function callback(evt) { + return handleKeyDownLeft(evt, props); + } + }), _defineProperty(_callbacks, _keyCode.default.ENTER, { + callback: function callback(evt) { + return handleKeyDownEnter(evt, props); + } + }), _callbacks) + }); +}; + +var handleFocus = function handleFocus(event, props) { + if (!props.treeHasFocus && !props.focusedNodeIndex && event.target === event.currentTarget) { + handleSelect({ + event: event, + props: props + }); + } +}; + +var getTabIndex = function getTabIndex(props) { + var initialFocus = props.selectedNodeIndexes.length === 0 && props.treeIndex === props.flattenedNodes[0].treeIndex; + return props.treeIndex === props.focusedNodeIndex || initialFocus ? 0 : -1; +}; +/** + * A Tree Item is a non-branching node in a hierarchical list. + */ + + +var Item = function Item(props) { + var isSelected = props.node.selected; + var isFocused = props.treeIndex === props.focusedNodeIndex; + return _react.default.createElement("li", { + id: "".concat(props.treeId, "-").concat(props.node.id), + role: "treeitem", + "aria-level": props.level, + "aria-selected": isSelected ? 'true' : 'false', + tabIndex: getTabIndex(props), + onKeyDown: function onKeyDown(event) { + return handleKeyDown(event, props); + }, + onFocus: function onFocus(event) { + return handleFocus(event, props); + }, + onBlur: props.onNodeBlur, + ref: function ref(component) { + if (props.treeHasFocus && component && isFocused) { + component.focus(); + } + } + }, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-tree__item', { + 'slds-is-selected': isSelected + }), + onClick: function onClick(event) { + handleSelect({ + event: event, + props: props + }); + } + }, _react.default.createElement(_button.default, { + tabIndex: "-1", + "aria-hidden": true, + assistiveText: { + icon: '' + }, + role: "presentation", + iconCategory: "utility", + iconName: "chevronright", + iconSize: "small", + variant: "icon", + className: "slds-m-right_small slds-is-disabled", + disabled: true + }), _react.default.createElement("span", { + className: "slds-size_1-of-1" + }, _react.default.createElement(_highlighter.default, { + search: props.searchTerm, + className: "slds-tree__item-label slds-truncate" + }, props.label)))); +}; // ### Display Name +// Always use the canonical component name as the React display name. + + +Item.displayName = _constants.TREE_ITEM; // ### Prop Types + +Item.propTypes = { + /** + * HTML `id` of the wrapping container element joined with the `id` of the node. This will recursively increase as the tree depth increases. + */ + htmlId: _propTypes.default.string.isRequired, + + /** + * The text of the tree item. + */ + label: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]).isRequired, + + /** + * The number of nestings. Determines the ARIA level and style alignment. + */ + level: _propTypes.default.number.isRequired, + + /** + * The current node that is being rendered. + */ + node: _propTypes.default.object.isRequired, + + /** + * This function triggers when the expand or collapse icon is clicked or due to keyboard navigation. + */ + onExpand: _propTypes.default.func.isRequired, + + /** + * Function that will run whenever an item or branch is selected (click or keyboard). + */ + onSelect: _propTypes.default.func, + + /** + * Highlights term if found in node label + */ + searchTerm: _propTypes.default.string, + + /** + * Unique id used for a prefix of all tree nodes + */ + treeId: _propTypes.default.string, + + /** + * Location of node (zero index). First node is `0`. It's first child is `0-0`. This can be used to modify your nodes without searching for the node. This index is only valid if the `nodes` prop is the same as at the time of the event. + */ + treeIndex: _propTypes.default.string, + + /** + * Flattened tree structure. + */ + flattenedNodes: _propTypes.default.arrayOf(_propTypes.default.object), + + /** + * Tree indexes of nodes that are currently selected. + */ + selectedNodeIndexes: _propTypes.default.arrayOf(_propTypes.default.string), + + /** + * Tree index of the node that is currently focused. + */ + focusedNodeIndex: _propTypes.default.string, + + /** + * Callback for when a node is blurred. + */ + onNodeBlur: _propTypes.default.func, + + /** + * Sets focus on render. + */ + treeHasFocus: _propTypes.default.bool, + + /** + * This node's parent. + */ + parent: _propTypes.default.object +}; +Item.defaultProps = { + selected: false, + selectedNodeIndexes: [] +}; +var _default = Item; +exports.default = _default; \ No newline at end of file diff --git a/components/tree/private/render-branch.js b/components/tree/private/render-branch.js new file mode 100644 index 0000000000..85538f7d62 --- /dev/null +++ b/components/tree/private/render-branch.js @@ -0,0 +1,389 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.findindex")); + +var _lodash2 = _interopRequireDefault(require("lodash.isfunction")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _button = _interopRequireDefault(require("../../button")); + +var _highlighter = _interopRequireDefault(require("../../utilities/highlighter")); + +var _event = _interopRequireDefault(require("../../../utilities/event")); + +var _keyCode = _interopRequireDefault(require("../../../utilities/key-code")); + +var _keyCallbacks = _interopRequireDefault(require("../../../utilities/key-callbacks")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * HTML `id` of primary element that has `.slds-tree` on it. This component has a wrapping container element outside of `.slds-tree`. + */ + htmlId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired, + + /** + * The text of the tree item. + */ + label: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), + + /** + * The number of nestings. Determines the ARIA level and style alignment. + */ + level: _propTypes.default.number.isRequired, + + /** + * The current node that is being rendered. + */ + node: _propTypes.default.object.isRequired, + + /** + * This function triggers when the expand or collapse icon is clicked or due to keyboard navigation. + */ + onExpand: _propTypes.default.func.isRequired, + + /** + * Function that will run whenever an item or branch is clicked. + */ + onSelect: _propTypes.default.func, + + /** + * Highlights term if found in node label + */ + searchTerm: _propTypes.default.string, + + /** + * Location of node (zero index). First node is `0`. It's first child is `0-0`. This can be used to modify your nodes without searching for the node. This index is only valid if the `nodes` prop is the same as at the time of the event. + */ + treeIndex: _propTypes.default.string, + + /** + * Flattened tree structure. + */ + flattenedNodes: _propTypes.default.arrayOf(_propTypes.default.object), + + /** + * Tree indexes of nodes that are currently selected. + */ + selectedNodeIndexes: _propTypes.default.arrayOf(_propTypes.default.string), + + /** + * Tree index of the node that is currently focused. + */ + focusedNodeIndex: _propTypes.default.string, + + /** + * Callback for when a node is blurred. + */ + onNodeBlur: _propTypes.default.func, + + /** + * Sets focus on render. + */ + treeHasFocus: _propTypes.default.bool, + + /** + * This node's parent. + */ + parent: _propTypes.default.object +}; + +var handleExpand = function handleExpand(event, props) { + _event.default.trap(event); + + if ((0, _lodash2.default)(props.onExpand)) { + props.onExpand({ + event: event, + data: { + node: props.node, + expand: !props.node.expanded, + treeIndex: props.treeIndex + } + }); + } +}; + +var handleSelect = function handleSelect(_ref) { + var event = _ref.event, + props = _ref.props, + fromFocus = _ref.fromFocus; + + _event.default.trap(event); + + if ((0, _lodash2.default)(props.onSelect)) { + props.onSelect({ + event: event, + data: { + node: props.node, + select: !props.node.selected, + treeIndex: props.treeIndex + }, + fromFocus: fromFocus + }); + } +}; + +var findNextNode = function findNextNode(flattenedNodes, node) { + var nodes = flattenedNodes.map(function (flattenedNode) { + return flattenedNode.node; + }); + var index = (0, _lodash.default)(nodes, { + id: node.id + }); + return flattenedNodes[(index + 1) % flattenedNodes.length]; +}; + +var findPreviousNode = function findPreviousNode(flattenedNodes, node) { + var nodes = flattenedNodes.map(function (flattenedNode) { + return flattenedNode.node; + }); + var index = (0, _lodash.default)(nodes, { + id: node.id + }) - 1; + + if (index < 0) { + index += flattenedNodes.length; + } + + return flattenedNodes[index]; +}; + +var handleKeyDownDown = function handleKeyDownDown(event, props) { + if (props.focusedNodeIndex === props.treeIndex) { + // Select the next visible node + var flattenedNode = findNextNode(props.flattenedNodes, props.node); + props.onSelect({ + event: event, + data: { + node: flattenedNode.node, + select: true, + treeIndex: flattenedNode.treeIndex + }, + clearSelectedNodes: true + }); + } +}; + +var handleKeyDownUp = function handleKeyDownUp(event, props) { + if (props.focusedNodeIndex === props.treeIndex) { + // Go to the previous visible node + var flattenedNode = findPreviousNode(props.flattenedNodes, props.node); + props.onSelect({ + event: event, + data: { + node: flattenedNode.node, + select: true, + treeIndex: flattenedNode.treeIndex + }, + clearSelectedNodes: true + }); + } +}; + +var handleKeyDownRight = function handleKeyDownRight(event, props) { + if (props.node.expanded) { + if (props.getNodes(props.node) && props.getNodes(props.node).length > 0) { + handleKeyDownDown(event, props); + } + } else { + handleExpand(event, props); + } +}; + +var handleKeyDownLeft = function handleKeyDownLeft(event, props) { + if (props.node.expanded) { + handleExpand(event, props); + } else { + var nodes = props.flattenedNodes.map(function (flattenedNode) { + return flattenedNode.node; + }); + var index = (0, _lodash.default)(nodes, { + id: props.parent.id + }); + + if (index !== -1) { + props.onExpand({ + event: event, + data: { + node: props.parent, + select: true, + expand: !props.parent.expanded, + treeIndex: props.flattenedNodes[index].treeIndex + } + }); + } + } +}; + +var handleKeyDownEnter = function handleKeyDownEnter(event, props) { + handleSelect({ + event: event, + props: props + }); +}; + +var handleKeyDown = function handleKeyDown(event, props) { + var _callbacks; + + (0, _keyCallbacks.default)(event, { + callbacks: (_callbacks = {}, _defineProperty(_callbacks, _keyCode.default.DOWN, { + callback: function callback(evt) { + return handleKeyDownDown(evt, props); + } + }), _defineProperty(_callbacks, _keyCode.default.UP, { + callback: function callback(evt) { + return handleKeyDownUp(evt, props); + } + }), _defineProperty(_callbacks, _keyCode.default.RIGHT, { + callback: function callback(evt) { + return handleKeyDownRight(evt, props); + } + }), _defineProperty(_callbacks, _keyCode.default.LEFT, { + callback: function callback(evt) { + return handleKeyDownLeft(evt, props); + } + }), _defineProperty(_callbacks, _keyCode.default.ENTER, { + callback: function callback(evt) { + return handleKeyDownEnter(evt, props); + } + }), _callbacks) + }); +}; + +var handleFocus = function handleFocus(event, props) { + if (!props.treeHasFocus && !props.focusedNodeIndex && event.target === event.currentTarget) { + // did it happen by mouse? + handleSelect({ + event: event, + props: props, + fromFocus: true + }); + } +}; + +var getTabIndex = function getTabIndex(props) { + var initialFocus = props.selectedNodeIndexes.length === 0 && props.treeIndex === props.flattenedNodes[0].treeIndex; + return props.treeIndex === props.focusedNodeIndex || initialFocus ? 0 : -1; +}; // Most of these props come from the nodes array, not from the Tree props + + +var RenderBranch = function RenderBranch(children, props) { + var isExpanded = props.node.expanded; + var isSelected = props.node.selected; + var isFocused = props.treeIndex === props.focusedNodeIndex; + var isLoading = props.node.loading; + + var loader = _react.default.createElement("div", { + style: { + display: 'block', + paddingLeft: "".concat(1.5 * props.level + 1.5, "rem"), + marginTop: '.5rem' + } + }, _react.default.createElement("div", { + style: { + borderRadius: '15rem', + display: 'block', + marginBottom: '.75rem', + height: '.5rem', + backgroundColor: 'rgb(224, 229, 238)', + width: '40%' + } + }), _react.default.createElement("div", { + style: { + borderRadius: '15rem', + display: 'block', + marginBottom: '.75rem', + height: '.5rem', + backgroundColor: 'rgb(224, 229, 238)', + width: '80%' + } + }), _react.default.createElement("div", { + style: { + borderRadius: '15rem', + display: 'block', + marginBottom: '.75rem', + height: '.5rem', + backgroundColor: 'rgb(224, 229, 238)', + width: '60%' + } + })); + + var label = props.node.assistiveText || (typeof props.node.label === 'string' ? props.node.label : null); + return _react.default.createElement("li", { + id: props.htmlId, + role: "treeitem", + "aria-level": props.level, + "aria-expanded": isExpanded ? 'true' : 'false', + "aria-label": props.node.nodes && props.node.nodes.length > 0 ? label : null, + tabIndex: getTabIndex(props), + onKeyDown: function onKeyDown(event) { + return handleKeyDown(event, props); + }, + onFocus: function onFocus(event) { + return handleFocus(event, props); + }, + onBlur: props.onNodeBlur, + ref: function ref(component) { + if (props.treeHasFocus && component && isFocused) { + component.focus(); + } + } + }, _react.default.createElement("div", { + className: (0, _classnames.default)('slds-tree__item', { + 'slds-is-selected': isSelected + }), + onClick: function onClick(event) { + handleSelect({ + event: event, + props: props + }); + } + }, _react.default.createElement(_button.default, { + "aria-hidden": true, + assistiveText: { + icon: 'Expand Tree Branch' + }, + iconCategory: "utility", + iconName: "chevronright", + iconSize: "small", + variant: "icon", + className: "slds-m-right_small", + role: "presentation", + "aria-controls": props.htmlId, + onClick: function onClick(event) { + handleExpand(event, props); + }, + tabIndex: "-1" + }), _react.default.createElement("span", { + className: "slds-size_1-of-1", + id: "".concat(props.htmlId, "__label") + }, _react.default.createElement(_highlighter.default, { + search: props.searchTerm, + className: "slds-tree__item-label slds-truncate" + }, props.label))), isLoading ? loader : null, _react.default.createElement("ul", { + className: (0, _classnames.default)({ + 'slds-is-expanded': isExpanded, + 'slds-is-collapsed': !isExpanded + }), + role: "group", + "aria-labelledby": "".concat(props.htmlId, "__label") + }, isExpanded && !isLoading ? children : null)); +}; + +RenderBranch.displayName = 'Branch'; +RenderBranch.propTypes = propTypes; +var _default = RenderBranch; +exports.default = _default; \ No newline at end of file diff --git a/components/tree/private/render-initial-branch.js b/components/tree/private/render-initial-branch.js new file mode 100644 index 0000000000..bbf2391711 --- /dev/null +++ b/components/tree/private/render-initial-branch.js @@ -0,0 +1,67 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.isfunction")); + +var _classnames = _interopRequireDefault(require("classnames")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// # Tree Initial Branch +var propTypes = { + /** + * HTML `id` of the wrapping container element. + */ + htmlId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired, + + /* + * Class names to be added to the top-level `ul` element. + */ + initalClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /* + * Styles to be added to the top-level `ul` element. Useful for `overflow:hidden`. + */ + initialStyle: _propTypes.default.object +}; + +var handleScroll = function handleScroll(event, props) { + var percentage = event.target.scrollTop / (event.target.scrollHeight - event.target.clientHeight) * 100; + + if ((0, _lodash.default)(props.onScroll)) { + props.onScroll(event, { + percentage: percentage + }); + } +}; + +var renderInitialNode = function renderInitialNode(children, props) { + return (// id intentionally not rendered here, and is present on + // container that includes the header + _react.default.createElement("ul", { + "aria-labelledby": "".concat(props.htmlId, "__heading"), + className: (0, _classnames.default)('slds-tree', props.initalClassName), + onScroll: function onScroll(event) { + handleScroll(event, props); + }, + role: "tree", + style: props.initialStyle + }, children) + ); +}; + +renderInitialNode.displayName = 'TreeInitialNode'; +renderInitialNode.propTypes = propTypes; +var _default = renderInitialNode; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/README.md b/components/utilities/README.md new file mode 100644 index 0000000000..acf9bbe383 --- /dev/null +++ b/components/utilities/README.md @@ -0,0 +1,3 @@ +# Utility Components + +This folder contains shared child components used by official SLDS components. Components in this folder are not official SLDS components in their own right. diff --git a/components/utilities/deprecated-warning/index.js b/components/utilities/deprecated-warning/index.js new file mode 100644 index 0000000000..67ed0c28b7 --- /dev/null +++ b/components/utilities/deprecated-warning/index.js @@ -0,0 +1,41 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _constants = require("../../../utilities/constants"); + +var _alert = _interopRequireDefault(require("../../alert")); + +var _container = _interopRequireDefault(require("../../alert/container")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// ### React +// ## Constants + +/** + * A utility component that is used to highlight a deprecated component. + */ +var DeprecatedWarning = function DeprecatedWarning() { + return _react.default.createElement("div", { + className: "slds-p-top_x-large" + }, _react.default.createElement(_container.default, null, _react.default.createElement(_alert.default, { + labels: { + heading: _react.default.createElement("span", null, _react.default.createElement("strong", null, "Deprecated component."), " No fit and finish bug fixes will be accepted for this component.") + }, + variant: "error" + }))); +}; // ### Display Name + + +DeprecatedWarning.displayName = _constants.DEPRECATED_WARNING; +var _default = DeprecatedWarning; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/dialog/__docs__/storybook-stories.js b/components/utilities/dialog/__docs__/storybook-stories.js new file mode 100644 index 0000000000..964b35811a --- /dev/null +++ b/components/utilities/dialog/__docs__/storybook-stories.js @@ -0,0 +1,32 @@ +// TODO - we should make stories to see everything on one page +// import React from 'react'; +// import { storiesOf } from '@storybook/react'; +// import { action } from '@storybook/addon-actions'; +// import IconSettings from '../../../icon-settings'; +// +// // import { POPOVER } from '../../../utilities/constants'; +// // import Header from '../__examples__/header'; +// // import AlternativeHeader from '../__examples__/alternative-header'; +// // import ControlledWithFooter from '../__examples__/controlled-with-footer'; +// +// import Popover from '../../../popover'; +// import Tooltip from '../../../tooltip'; +// import Button from '../../../button'; +// +// +// let stories = storiesOf('Dialog', module) +// .addDecorator((getStory) => ( +//
    +// {getStory()} +//
    +// )); +// +// stories = stories.add('Header', () =>
    ); +"use strict"; \ No newline at end of file diff --git a/components/utilities/dialog/index.js b/components/utilities/dialog/index.js new file mode 100644 index 0000000000..0f5685372d --- /dev/null +++ b/components/utilities/dialog/index.js @@ -0,0 +1,519 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _popper = _interopRequireDefault(require("popper.js")); + +var _lodash = _interopRequireDefault(require("lodash.isequal")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _portal = _interopRequireDefault(require("./portal")); + +var _event = _interopRequireDefault(require("../../../utilities/event")); + +var _keyCode = _interopRequireDefault(require("../../../utilities/key-code")); + +var _domElementFocus = _interopRequireDefault(require("../../../utilities/dom-element-focus")); + +var _dialogHelpers = require("../../../utilities/dialog-helpers"); + +var _constants = require("../../../utilities/constants"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* + * A Dialog is content that is separate from the typical flow of a page. It typically overlays other elements in the document flow. This is achieved with elevation (`z-index`) and one of the following: relative position, absolute position, or a new top-level React render tree (portal). A boundary element is a scrolling ancestor element or the edge of the browser (window/viewport). This element typically has an overflow (overflow-y/overflow-x) style that is scroll, hidden, or auto. Inverted placement is the flipping of the overlay element from top to bottom or left to right in order stay within a boundary element. + * + * * Dropdown menu (Combobox, DatePicker, et al.) placement is typically bottom-aligned and should be allowed to invert its placement when inside a boundary element this often happens within a modal. Dropdowns should not overflow boundary elements , since most boundary elements scroll vertically and have space for the menu. + * + * * If they are hidden, left and right placed overlay elements (such as Popover and Tooltip) should be placed within a portal element attached to the DOM , but styled to align to its target/trigger. Since scrolling typically occurs on the vertical axis, this allows them to overflow boundary elements and still allow scrolling of content, yet still invert placement for the browser viewport. Portal elements are only necessary if an original ancestor boundary element exists. **No portals are created by default.** + * + * * Nubbins/arrows should be repositioned for any new placement/alignment. + * + * Allow Overflowing of Boundary Element: Allow applications to create a portal element attached to the DOM to be outside of boundary elements if manual testing shows confusing alignment/poor usability/readability. This should be exception and not the default. + * + * Allow Inverted placement: Allow applications to prevent inverted placement if manual testing shows confusing alignment/poor usability/readability. + * + * ### How this new Dialog component works + * * There is no longer an inline render within components. All overlays should go through `Dialog`. `position: relative` just passes on the markup with some additional event listeners. No positional library is used. + * * The default `position: absolute` will run through three renders. It will first render the overlay at `0px/0px` offset of its parent. It will then store the target DOM node, once the DOM node is set, a state change will occur and tell a PopperJS instance to be created on update, once it is created, a third render is done to update the styles created by PopperJS. + * * `position: overflowBoundaryElement` will do the same three renders as `absolute` except that the initial render will create a disconnected render tree (portal) on the `body`. Then, the position will change once the target is stored. The portal itself will be rendered multiple times. The first will result in `onOpen` executing. Each update will result in a re-render of the disconnected render-tree. + * + * This component is private. + */ +var Dialog = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Dialog, _React$Component); + + function Dialog() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Dialog); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Dialog)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + triggerPopperJS: false, + isOpen: false + }); + + _defineProperty(_assertThisInitialized(_this), "getPropOffsetsInPixels", function (offsetString) { + var offsetArray = offsetString.split(' '); + return { + vertical: parseInt(offsetArray[0], 10), + horizontal: parseInt(offsetArray[1], 10) + }; + }); + + _defineProperty(_assertThisInitialized(_this), "getPopperStyles", function () { + var popperData = _this.state.popperData; + + if (!_this.popper || !popperData) { + return { + position: 'absolute', + pointerEvents: 'none' + }; + } + + var position = popperData.offsets.popper.position; + + var propOffsets = _this.getPropOffsetsInPixels(_this.props.offset); // FIXME before merge - gotta rename from margin to offset + + + var nubbinOffsets = _this.props.hasNubbin ? (0, _dialogHelpers.getNubbinMargins)(_this.state.popperData) : { + left: 0, + top: 0 + }; + var left = popperData.offsets.popper.left + nubbinOffsets.left + propOffsets.horizontal; + var top = popperData.offsets.popper.top + nubbinOffsets.top + propOffsets.vertical; // A Dropdown with overflowBoundaryElement position and 'align=right' uses max-width instead of inherited children width + + var right = 'inherit'; + return _objectSpread({}, popperData.style, { + left: left, + top: top, + right: right, + position: position + }); + }); + + _defineProperty(_assertThisInitialized(_this), "setDialogContent", function (component) { + _this.dialogContent = component; + + if (!_this.state.triggerPopperJS) { + _this.setState({ + triggerPopperJS: true + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleClickOutside", function () { + _this.handleClose(); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClose", function (event, data) { + _this.setState({ + triggerPopperJS: true + }); + + if (_this.props.onClose) { + _this.props.onClose(event, data); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function (event) { + if (event.nativeEvent) { + event.nativeEvent.preventDefault(); + event.nativeEvent.stopPropagation(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) { + if (event.keyCode === _keyCode.default.TAB) { + if (_this.props.closeOnTabKey) { + _event.default.trap(event); + + _this.handleClose(event); + } + } + + if (_this.props.onKeyDown) { + _this.props.onKeyDown(event); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleOpen", function () { + if (_this.props.variant === 'popover' && _this.dialogContent) { + _domElementFocus.default.storeActiveElement(); + + _domElementFocus.default.setupScopedFocus({ + ancestorElement: _this.dialogContent + }); // eslint-disable-line react/no-find-dom-node + // Don't steal focus from inner elements + + + if (!_domElementFocus.default.hasOrAncestorHasFocus()) { + _domElementFocus.default.focusAncestor({ + isPortal: _this.props.position === 'overflowBoundaryElement' + }); + } + } + + if (_this.props.onOpen) { + _this.props.onOpen(undefined, { + portal: _this.dialogContent + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "createPopper", function () { + var reference = _this.props.onRequestTargetElement(); // eslint-disable-line react/no-find-dom-node + + + var popper = _this.dialogContent; + var placement = (0, _dialogHelpers.mapPropToPopperPlacement)(_this.props.align); + var eventsEnabled = true; // Lets popper listen to events (resize, scroll, etc.) + + var modifiers = { + applyStyle: { + enabled: false + }, + // moves dialog in order to not extend a boundary element such as a scrolling parent or a window/viewpoint. + preventOverflow: { + enabled: !_this.props.hasStaticAlignment, + boundariesElement: _this.props.position === 'absolute' ? 'scrollParent' : 'viewport' + }, + hide: { + enabled: false + }, + // By default, dialogs will flip their alignment if they extend beyond a boundary element such as a scrolling parent or a window/viewpoint + flip: { + enabled: !_this.props.hasStaticAlignment + }, + removeOnDestroy: true, + updateState: { + enabled: true, + order: 900, + fn: function fn(popperData) { + if (_this.state.popperData && !(0, _lodash.default)(popperData.offsets, _this.state.popperData.offsets) || !_this.state.popperData) { + _this.setState({ + popperData: popperData + }); + } + + return popperData; + } + } // arrow property can also point to an element + + }; + + if (!reference) { + console.error('Target node not found!', reference); // eslint-disable-line no-console + } + + if (!popper) { + console.error('Popper node not found!', popper); // eslint-disable-line no-console + } + + _this.popper = new _popper.default(reference, popper, { + placement: placement, + eventsEnabled: eventsEnabled, + modifiers: modifiers + }); + + _this.popper.scheduleUpdate(); + }); + + _defineProperty(_assertThisInitialized(_this), "destroyPopper", function () { + if (_this.popper) { + _this.popper.destroy(); + } + }); + + return _this; + } + + _createClass(Dialog, [{ + key: "componentDidMount", + value: function componentDidMount() { + if (this.props.position === 'absolute' || this.props.position === 'relative') { + this.handleOpen(); + } + } + }, { + key: "componentWillUpdate", + value: function componentWillUpdate() { + if (this.popper) { + this.popper.scheduleUpdate(); + } + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps, prevState) { + if (this.state.triggerPopperJS === true && prevState.triggerPopperJS === false && (this.props.position === 'absolute' || this.props.position === 'overflowBoundaryElement') && this.dialogContent && this.props.onRequestTargetElement()) { + this.createPopper(); + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + if (this.props.variant === 'popover') { + _domElementFocus.default.teardownScopedFocus(); + + _domElementFocus.default.returnFocusToStoredElement(); + } + + if (this.props.position === 'absolute' || this.props.position === 'overflowBoundaryElement') { + this.destroyPopper(); + } + + this.handleClose(undefined, { + componentWillUnmount: true + }); + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var style = {}; + var role = this.props.variant === 'popover' ? 'dialog' : this.props.variant; + + if (this.props.position === 'absolute' || this.props.position === 'overflowBoundaryElement') { + style = _objectSpread({}, style, { + outline: 0 + }, this.getPopperStyles()); + } + + if (this.props.inheritWidthOf === 'target' && this.props.onRequestTargetElement()) { + style.width = this.props.onRequestTargetElement().getBoundingClientRect().width; + } else if (this.props.inheritWidthOf === 'menu' && this.dialogContent && this.dialogContent.querySelector('.slds-listbox')) { + // inherit menu renderer width + style.width = this.dialogContent.querySelector('.slds-listbox').getBoundingClientRect().width; + } + + style = _objectSpread({}, style, this.props.style); + + var contents = _react.default.createElement("section", _extends({ + // eslint-disable-line jsx-a11y/no-static-element-interactions, jsx-a11y/no-noninteractive-element-interactions + className: (0, _classnames.default)(_defineProperty({ + 'absolute-positioned': this.props.position === 'absolute', + 'portal-positioned': this.props.position === 'overflowBoundaryElement' + }, "".concat(this.props.outsideClickIgnoreClass), this.props.position === 'overflowBoundaryElement'), this.props.hasNubbin && (0, _dialogHelpers.getNubbinClassName)(this.props.align, this.state.popperData), this.props.contentsClassName) || undefined, + style: style, + onMouseDown: this.props.onMouseDown, + onKeyDown: this.handleKeyDown, + onMouseEnter: this.props.onMouseEnter, + onMouseLeave: this.props.onMouseLeave, + ref: this.setDialogContent, + role: role, + tabIndex: this.props.variant === 'popover' ? '-1' : undefined + }, this.props.containerProps), this.props.children); + + var subRenders = { + absolute: function absolute() { + return contents; + }, + relative: function relative() { + return contents; + }, + overflowBoundaryElement: function overflowBoundaryElement() { + // Cycle through current context, create object of + // truthy values, and pass into Portal's context. + // TODO: Add test when switched to `ReactDOM.createPortal` + var truthyIconSettingsContext = Object.keys(_iconSettings.default.childContextTypes).filter(function (key) { + return Boolean(_this2.context[key]); + }).reduce(function (accumulatedContext, key) { + return _objectSpread({}, accumulatedContext, _defineProperty({}, key, _this2.context[key])); + }, {}); + return _react.default.createElement(_portal.default, { + onOpen: _this2.handleOpen, + portalMount: _this2.props.portalMount + }, _react.default.createElement(_iconSettings.default, truthyIconSettingsContext, contents)); + } + }; + return subRenders[this.props.position] && subRenders[this.props.position](); + } + }]); + + return Dialog; +}(_react.default.Component); + +_defineProperty(Dialog, "displayName", _constants.DIALOG); + +_defineProperty(Dialog, "propTypes", { + /** + * Aligns the right or left side of the dialog with the respective side of the target. + */ + align: _propTypes.default.oneOf(['top', 'top left', 'top right', 'right', 'right top', 'right bottom', 'bottom', 'bottom left', 'bottom right', 'left', 'left top', 'left bottom']), + + /** + * CSS classes to be added to the absolutely positioned element. + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * CSS classes to be added to the wrapping `div` of the contents of the dialog. + */ + contentsClassName: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Contents of dialog + */ + children: _propTypes.default.node.isRequired, + + /** + * Closes dialog when tab key is pressed + */ + closeOnTabKey: _propTypes.default.bool, + + /** + * Props passed along to wrapping div. This allows one less wrapping `div` to be in the markup. dialog children are expected to be wrapper in a single `div`. + */ + containerProps: _propTypes.default.object, + + /** + * Will show the nubbin pointing from the dialog to the reference element. Positioning and offsets will be handled. + */ + hasNubbin: _propTypes.default.bool, + + /** + * By default, dialogs will flip their alignment (such as bottom to top) if they extend beyond a boundary element such as a scrolling parent or a window/viewpoint. `hasStaticAlignment` disables this behavior and allows this component to extend beyond boundary elements. + */ + hasStaticAlignment: _propTypes.default.bool, + + /** + * Sets the dialog width to the width of either 'target' (Menus attached to `input` typically follow this UX pattern), 'menu' or 'none. + */ + inheritWidthOf: _propTypes.default.oneOf(['target', 'menu', 'none']), + + /** + * DEPRECATED - do not add checkProp deprecation message at this level. It is handled at higher level components. + * TODO - to be removed. + * Offset adds pixels to the absolutely positioned dropdown menu in the format: ([vertical]px [horizontal]px). SHOULD BE OBJECT ----------- + */ + offset: _propTypes.default.string, + + /** + * Called when dialog closes and unmounts. + */ + onClose: _propTypes.default.func, + + /** + * Called when a key pressed. + */ + onKeyDown: _propTypes.default.func, + + /** + * Called when mouse hovers over the trigger button. This is only called if `this.props.openOn` is set to `hover`. + */ + onMouseEnter: _propTypes.default.func, + + /** + * Called when mouse hover leaves the trigger button. This is only called if `this.props.openOn` is set to `hover`. + */ + onMouseLeave: _propTypes.default.func, + + /** + * Called when dialog opens (that is mounts). The parameters are `undefined, { portal: this.portal }`. + */ + onOpen: _propTypes.default.func, + + /** + * React component to be aligned with. Function should return a DOM `ref` from the parent component. + */ + onRequestTargetElement: _propTypes.default.func.isRequired, + + /** + * Triggered when an item in the menu is clicked. + */ + outsideClickIgnoreClass: _propTypes.default.string, + + /** + * If a dialog is `positione="overflowBoundaryElement"`, it will be rendered in a portal or separate render tree. This `portalMount` callback will be triggered instead of the the default `ReactDOM.unstable_renderSubtreeIntoContainer` and the function will mount the portal itself. Consider the following code that bypasses the internal mount and uses an Enzyme wrapper to mount the React root tree to the DOM. + * + * ``` + * { + * portalWrapper = Enzyme.mount(reactElement, { attachTo: domContainerNode }); + * }} + * onOpen={() => { + * expect(portalWrapper.find(`#my-heading`)).to.exist; + * done(); + * }} + * /> + * ``` + */ + portalMount: _propTypes.default.func, + + /** + * Please select one of the following: + * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog. + * * `overflowBoundaryElement` - The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree. + * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing. + */ + position: _propTypes.default.oneOf(['absolute', 'overflowBoundaryElement', 'relative']).isRequired, + + /** + * An object of CSS styles that are applied to the immediate parent `div` of the contents. Use this instead of margin props. + */ + style: _propTypes.default.object, + + /** + * Sets which focus UX pattern to follow. For instance, popovers trap focus and must be exited to regain focus. Dropdowns and Tooltips never have focus. + */ + variant: _propTypes.default.oneOf(['dropdown', 'popover', 'tooltip']) +}); + +_defineProperty(Dialog, "defaultProps", { + align: 'bottom left', + offset: '0px 0px', + outsideClickIgnoreClass: 'ignore-react-onclickoutside' +}); + +Dialog.contextTypes = { + iconPath: _propTypes.default.string +}; +var _default = Dialog; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/dialog/portal.js b/components/utilities/dialog/portal.js new file mode 100644 index 0000000000..562ee86f07 --- /dev/null +++ b/components/utilities/dialog/portal.js @@ -0,0 +1,277 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = require("react"); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _reactDom = _interopRequireDefault(require("react-dom")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +/* + * This component mounts its children within a disconnected render tree (portal). + */ +var documentDefined = typeof document !== 'undefined'; + +var Portal = +/*#__PURE__*/ +function (_Component) { + _inherits(Portal, _Component); + + function Portal(props) { + var _this; + + _classCallCheck(this, Portal); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Portal).call(this, props)); + _this.portalNode = null; + _this.state = { + isOpen: false + }; + return _this; + } + + _createClass(Portal, [{ + key: "componentDidMount", + value: function componentDidMount() { + this.renderPortal(); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate() { + this.renderPortal(); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this.unmountPortal(); + } + }, { + key: "getChildren", + value: function getChildren() { + return _react.Children.only(this.props.children); + } + }, { + key: "getPortalParentNode", + value: function getPortalParentNode() { + var element; + + if (typeof this.props.renderTo === 'string') { + element = document.querySelector(this.props.renderTo); + } else { + element = this.props.renderTo || documentDefined && document.body; + } + + return element; + } + }, { + key: "setupPortalNode", + value: function setupPortalNode() { + var parentParentNode = this.getPortalParentNode(); + this.portalNode = {}; + + if (documentDefined) { + this.portalNode = document.createElement(this.props.renderTag); + this.portalNode.setAttribute('style', 'display: block; height: 0px; width: 0px;'); + this.portalNode.setAttribute('className', 'design-system-react-portal'); + parentParentNode.appendChild(this.portalNode); + this.portalNodeInstance = this.props.onMount ? this.props.onMount(undefined, { + portal: this.portalNode + }) : this.portalNode; + } + } + }, { + key: "unmountPortal", + value: function unmountPortal() { + if (this.portalNode) { + _reactDom.default.unmountComponentAtNode(this.portalNode); + + this.portalNode.parentNode.removeChild(this.portalNode); + } + + this.portalNode = null; + } + }, { + key: "updatePortal", + value: function updatePortal() { + var _this2 = this; + + if (this.props.id) { + this.portalNode.id = this.props.id; + } + + if (this.props.className) { + this.portalNode.className = this.props.className; + } + + if (this.props.style) { + Object.keys(this.props.style).forEach(function (key) { + _this2.portalNode.style[key] = _this2.props.style[key]; + }); + } + + if (this.props.onUpdate) { + this.portalNodeInstance = this.props.onUpdate(this.portalNodeInstance); + } + } + }, { + key: "renderPortal", + value: function renderPortal() { + var _this3 = this; + + // if no portal contents, then unmount + if (!this.getChildren() || !documentDefined) { + this.unmountPortal(); + return; + } + + if (!this.portalNode) { + this.setupPortalNode(); + } + + if (this.props.portalMount) { + this.props.portalMount({ + instance: this, + reactElement: this.getChildren(), + domContainerNode: this.portalNode, + updateCallback: function updateCallback() { + _this3.updatePortal(); // update after subtree renders + + } + }); + } else { + // actual render + _reactDom.default.unstable_renderSubtreeIntoContainer(this, this.getChildren(), this.portalNode, function () { + _this3.updatePortal(); // update after subtree renders + + + if (_this3.state.isOpen === false) { + if (_this3.props.onOpen) { + _this3.props.onOpen(undefined, { + portal: _this3.getChildren() + }); + } + + _this3.setState({ + isOpen: true + }); + } + }); + } + } + }, { + key: "render", + value: function render() { + return null; + } + }]); + + return Portal; +}(_react.Component); + +Portal.displayName = 'Portal'; +Portal.propTypes = { + /* + * What tag to use for the portal, defaults to `div`. + */ + renderTag: _propTypes.default.string, + + /* + * What node the portal is rendered to, defaults to `document.body`. + */ + renderTo: _propTypes.default.any, + + /* + * React id prop. + */ + id: _propTypes.default.string, + + /* + * Accepts a _single_ element or component. + */ + children: _propTypes.default.node, + + /* + * ClassName added to . + */ + className: _propTypes.default.any, + + /* + * An object of styles that are applied to the portal. + */ + style: _propTypes.default.object, + + /* + * Triggers when Portal render tree mounts. Pass in an undefined event and `{ portal: [node] }`` + */ + onMount: _propTypes.default.func, + + /* + * Triggers when the portal is mounted. + */ + onOpen: _propTypes.default.func, + + /* + * Triggers when Portal re-renders its tree. + */ + onUpdate: _propTypes.default.func, + + /** + * If a dialog is `positione="overflowBoundaryElement"`, it will be rendered in a portal or separate render tree. This `portalMount` callback will be triggered instead of the the default `ReactDOM.unstable_renderSubtreeIntoContainer` and the function will mount the portal itself. Consider the following code that bypasses the internal mount and uses an Enzyme wrapper to mount the React root tree to the DOM. + * + * ``` + * { + * portalWrapper = Enzyme.mount(reactElement, { attachTo: domContainerNode }); + * }} + * onOpen={() => { + * expect(portalWrapper.find(`#my-heading`)).to.exist; + * done(); + * }} + * /> + * ``` + */ + portalMount: _propTypes.default.func +}; +Portal.defaultProps = { + renderTag: 'span', + renderTo: null, + onMount: function onMount() { + return null; + }, + onOpen: function onOpen() { + return null; + }, + onUpdate: function onUpdate() { + return null; + }, + onUnmount: function onUnmount() { + return null; + } +}; +var _default = Portal; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/highlighter/index.js b/components/utilities/highlighter/index.js new file mode 100644 index 0000000000..a30c8966b2 --- /dev/null +++ b/components/utilities/highlighter/index.js @@ -0,0 +1,99 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _reactHighlighter = _interopRequireDefault(require("react-highlighter")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// ### React +// ### ReactHighlighter +// ## Constants + +/** + * A utility component that highlights occurrences of a particular pattern in its contents. + */ +var Highlighter = function Highlighter(props) { + if (props.search) { + var children; + + if (typeof props.children === 'string') { + children = _react.default.createElement(_reactHighlighter.default, { + className: props.className, + matchClass: null, + matchElement: "mark", + search: props.search, + title: props.children + }, props.children); + } else { + var findString = function findString(nodeArr) { + return nodeArr.map(function (element) { + var newElement; + + if (typeof element === 'string') { + newElement = _react.default.createElement(_reactHighlighter.default, { + key: element, + className: props.className, + matchClass: null, + matchElement: "mark", + search: props.search, + title: element + }, element); + } else { + newElement = element; + } + + return newElement; + }); + }; + + if (props.children.props) { + var node = props.children.props.children; + children = node instanceof Array ? findString(node) : node; + } + } + + return _react.default.createElement("span", null, children); + } + + if (typeof props.children === 'string') { + return _react.default.createElement("span", { + className: props.className, + title: props.children + }, props.children); + } + + return _react.default.createElement("span", { + className: props.className + }, props.children); +}; // ### Display Name + + +Highlighter.displayName = _constants.HIGHLIGHTER; // ### Prop Types + +Highlighter.propTypes = { + /** + * The full string to display. + */ + children: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.bool, _propTypes.default.node]), + className: _propTypes.default.string, + + /** + * The string of text (or Regular Expression) to highlight. + */ + search: _propTypes.default.any +}; +var _default = Highlighter; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/label/index.js b/components/utilities/label/index.js new file mode 100644 index 0000000000..9aa6919aef --- /dev/null +++ b/components/utilities/label/index.js @@ -0,0 +1,81 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +var propTypes = { + /* + * Assistive Text to use instead of a visible label + */ + assistiveText: _propTypes.default.object, + + /** + * Class names to be added to the label + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /* + * Id of the input associated with this label + */ + htmlFor: _propTypes.default.string, + + /* + * Input Label + */ + label: _propTypes.default.string, + + /* + * Applies label styling for a required form element + */ + required: _propTypes.default.bool, + + /** + * Changes markup of label. + */ + variant: _propTypes.default.oneOf(['base', 'static']) +}; +var defaultProps = { + variant: 'base' +}; +/* + * Form label. This returns null if there is no label text (hidden or shown) + */ + +var Label = function Label(props) { + var labelText = props.label || props.assistiveText && props.assistiveText.label; // One of these is required to pass accessibility tests + + var subRenders = { + base: _react.default.createElement("label", { + className: (0, _classnames.default)('slds-form-element__label', { + 'slds-assistive-text': props.assistiveText && !props.label + }, props.className), + htmlFor: props.htmlFor + }, props.required && _react.default.createElement("abbr", { + className: "slds-required", + title: "required" + }, "*"), labelText), + static: _react.default.createElement("span", { + className: (0, _classnames.default)('slds-form-element__label', props.className) + }, labelText) + }; + return labelText ? subRenders[props.variant] : null; +}; + +Label.displayName = 'Label'; +Label.propTypes = propTypes; +Label.defaultProps = defaultProps; +var _default = Label; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/menu-list/index.js b/components/utilities/menu-list/index.js new file mode 100644 index 0000000000..dbed060150 --- /dev/null +++ b/components/utilities/menu-list/index.js @@ -0,0 +1,158 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _item = _interopRequireDefault(require("./item")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Component description. + */ +var List = +/*#__PURE__*/ +function (_React$Component) { + _inherits(List, _React$Component); + + function List() { + _classCallCheck(this, List); + + return _possibleConstructorReturn(this, _getPrototypeOf(List).apply(this, arguments)); + } + + _createClass(List, [{ + key: "render", + value: function render() { + var _this = this; + + var lengthClassName; + + if (this.props.length) { + lengthClassName = "slds-dropdown_length-".concat(this.props.length); + } + + return _react.default.createElement("ul", { + "aria-labelledby": this.props.triggerId, + className: (0, _classnames.default)('dropdown__list', lengthClassName, this.props.className), + role: "menu" + }, this.props.options.map(function (option, index) { + var id = _this.props.getListItemId(index); + + var isSingleSelected = index === _this.props.selectedIndex; + var isMultipleSelected = !!_this.props.selectedIndices && _this.props.selectedIndices.indexOf(index) !== -1; + return _react.default.createElement(_item.default, _extends({}, option, { + "aria-disabled": option.disabled, + checkmark: _this.props.checkmark && (isSingleSelected || isMultipleSelected), + data: option, + id: id, + index: index, + isSelected: isSingleSelected || isMultipleSelected, + key: "".concat(id, "-").concat(option.value), + labelRenderer: _this.props.itemRenderer, + onSelect: _this.props.onSelect, + ref: function ref(listItem) { + return _this.props.itemRefs(listItem, index); + } + })); + })); + } + }]); + + return List; +}(_react.default.Component); + +_defineProperty(List, "displayName", _constants.LIST); + +_defineProperty(List, "propTypes", { + /** + * Determines whether or not to show a checkmark for selected items. + */ + checkmark: _propTypes.default.bool, + + /** + * CSS classes to be added to `
      `. + */ + className: _propTypes.default.string, + + /** + * Used internally to determine the id that will be used for list items. + */ + getListItemId: _propTypes.default.func, + + /** + * Used internally to pass references to the individual menu items back up for focusing / scrolling. + */ + itemRefs: _propTypes.default.func, + + /** + * If provided, this function will be used to render the contents of each menu item. + */ + itemRenderer: _propTypes.default.func, + + /** + * Sets the height of the list based on the numeber of items. + */ + length: _propTypes.default.oneOf([null, '5', '7', '10', 5, 7, 10]), + + /** + * Triggered when a list item is selected (via mouse or keyboard). + */ + onSelect: _propTypes.default.func, + + /** + * An array of items to render in the list. + */ + options: _propTypes.default.array, + + /** + * The index of the currently selected item in the list. + */ + selectedIndex: _propTypes.default.number, + + /** + * The id of the element which triggered this list (in a menu context). + */ + triggerId: _propTypes.default.string +}); + +_defineProperty(List, "defaultProps", { + length: '5', + options: [], + selectedIndex: -1 +}); + +var _default = List; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/menu-list/item-label.js b/components/utilities/menu-list/item-label.js new file mode 100644 index 0000000000..8e2c55783f --- /dev/null +++ b/components/utilities/menu-list/item-label.js @@ -0,0 +1,52 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// # List Item Label Component +// ## Dependencies +// ### React +// ## Constants + +/** + * Component description. + */ +var ListItemLabel = function ListItemLabel(props) { + return _react.default.createElement("span", { + className: "slds-truncate" + }, props.icon, props.label); +}; + +ListItemLabel.displayName = _constants.LIST_ITEM_LABEL; +ListItemLabel.propTypes = { + data: _propTypes.default.object, + icon: _propTypes.default.node, + index: _propTypes.default.number, + inverted: _propTypes.default.bool, + isSelected: _propTypes.default.bool, + label: _propTypes.default.string, + value: _propTypes.default.any +}; +ListItemLabel.defaultProps = { + data: {}, + index: 0, + inverted: false, + isSelected: false, + label: '', + value: null +}; +var _default = ListItemLabel; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/menu-list/item.js b/components/utilities/menu-list/item.js new file mode 100644 index 0000000000..d382bbccc8 --- /dev/null +++ b/components/utilities/menu-list/item.js @@ -0,0 +1,230 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _icon = _interopRequireDefault(require("../../icon")); + +var _itemLabel = _interopRequireDefault(require("./item-label")); + +var _event = _interopRequireDefault(require("../../../utilities/event")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Component description. + */ +var ListItem = +/*#__PURE__*/ +function (_React$Component) { + _inherits(ListItem, _React$Component); + + function ListItem() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, ListItem); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(ListItem)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "getLabel", function () { + var Label = _this.props.labelRenderer; + return _react.default.createElement(Label, { + checkmark: _this.props.checkmark, + data: _this.props.data, + icon: _this.getIcon('left'), + index: _this.props.index, + inverted: _this.props.inverted, + isSelected: _this.props.isSelected, + label: _this.props.label, + value: _this.props.value + }); + }); + + _defineProperty(_assertThisInitialized(_this), "getIcon", function (position) { + var classnames = ['slds-icon-text-default']; + + var iconProps = _this.props["".concat(position, "Icon")]; + + if (position === 'left') { + if (_this.props.checkmark) { + classnames.push('slds-icon_selected'); + iconProps = { + category: 'utility', + name: 'check' + }; + } + + classnames.push('slds-m-right_x-small'); + } else { + classnames.push('slds-m-left_small'); + } + + if (iconProps) { + return _react.default.createElement(_icon.default, _extends({ + className: (0, _classnames.default)(classnames), + position: position, + size: "x-small" + }, iconProps)); + } + + return null; + }); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function (event) { + if (_this.props.type !== 'link' || _this.props.href === 'javascript:void(0);' // eslint-disable-line no-script-url + ) { + // eslint-disable-line no-script-url + _event.default.trapImmediate(event); + } + + if (_this.props.onSelect) { + _this.props.onSelect(_this.props.index); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleMouseDown", function (event) { + _event.default.trapImmediate(event); + }); + + return _this; + } + + _createClass(ListItem, [{ + key: "render", + value: function render() { + switch (this.props.type) { + case 'header': + { + return _react.default.createElement("li", { + className: (0, _classnames.default)('slds-dropdown__header', { + 'slds-has-divider_top-space': this.props.divider === 'top', + 'slds-has-divider_bottom-space': this.props.divider === 'bottom' + }, this.props.className), + onMouseDown: this.handleMouseDown, + role: "separator" + }, _react.default.createElement("span", { + className: "slds-text-title_caps" + }, this.props.label)); + } + + case 'divider': + { + return _react.default.createElement("li", { + className: (0, _classnames.default)('slds-has-divider', this.props.className), + onMouseDown: this.handleMouseDown, + role: "separator" + }); + } + + case 'link': + case 'item': + default: + { + return ( + /* eslint-disable jsx-a11y/role-supports-aria-props */ + // disabled eslint, but using aria-selected on presentation role seems suspicious... + _react.default.createElement("li", { + "aria-selected": this.props.checkmark === null ? this.props.isSelected : null, + className: (0, _classnames.default)('slds-dropdown__item', { + 'slds-is-selected': this.props.isSelected + }, this.props.className), + id: this.props.id, + onMouseDown: this.handleMouseDown, + role: "presentation" + }, _react.default.createElement("a", { + "aria-checked": this.props.checkmark && this.props.isSelected, + "aria-disabled": this.props['aria-disabled'], + href: this.props.href, + "data-index": this.props.index, + onClick: this.handleClick, + role: this.props.checkmark ? 'menuitemcheckbox' : 'menuitem', + tabIndex: "-1" + }, this.getLabel(), this.getIcon('right'))) + ); + } + } + } + }]); + + return ListItem; +}(_react.default.Component); + +_defineProperty(ListItem, "displayName", _constants.LIST_ITEM); + +_defineProperty(ListItem, "propTypes", { + 'aria-disabled': _propTypes.default.bool, + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + checkmark: _propTypes.default.bool, + data: _propTypes.default.object, + divider: _propTypes.default.oneOf(['top', 'bottom']), + href: _propTypes.default.string, + id: _propTypes.default.string.isRequired, + index: _propTypes.default.number.isRequired, + inverted: _propTypes.default.bool, + isSelected: _propTypes.default.bool, + label: _propTypes.default.string, + labelRenderer: _propTypes.default.func, + leftIcon: _propTypes.default.shape({ + category: _propTypes.default.string, + name: _propTypes.default.string + }), + onSelect: _propTypes.default.func.isRequired, + rightIcon: _propTypes.default.shape({ + category: _propTypes.default.string, + name: _propTypes.default.string + }), + type: _propTypes.default.string, + value: _propTypes.default.any +}); + +_defineProperty(ListItem, "defaultProps", { + data: {}, + href: 'javascript:void(0);', + // eslint-disable-line no-script-url + inverted: false, + isSelected: false, + label: '', + labelRenderer: _itemLabel.default, + value: null +}); + +var _default = ListItem; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/pill/index.js b/components/utilities/pill/index.js new file mode 100644 index 0000000000..8a4a55d7df --- /dev/null +++ b/components/utilities/pill/index.js @@ -0,0 +1,206 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.assign")); + +var _keyCode = _interopRequireDefault(require("../../../utilities/key-code")); + +var _keyCallbacks = _interopRequireDefault(require("../../../utilities/key-callbacks")); + +var _event = _interopRequireDefault(require("../../../utilities/event")); + +var _pill = _interopRequireDefault(require("../../../components/pill")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var propTypes = { + /** + * Pill is the actively focused pill within a pill container. This will request focus on the DOM node. + */ + active: _propTypes.default.bool, + + /** + * **Assistive text for accessibility** + * This object is merged with the default props object on every render. + * * `pressDeleteOrBackspace`: Informs user of keyboard keys to press in order to remove a pill + */ + assistiveText: _propTypes.default.shape({ + remove: _propTypes.default.string + }), + + /** + * SLDSAvatar component to show on the left of the pill. + * _Tested with Mocha framework._ + */ + avatar: _propTypes.default.element, + + /** + * Applies the bare style to the component. + * _Tested with Mocha framework._ + */ + bare: _propTypes.default.bool, + + /* + * Pills are often used for selection of a type of entity such as days in a daypicker. This prop allows you to pass in data that will be passed back to the event handler. + */ + eventData: _propTypes.default.object, + + /* + * Callbacks for various pill events such as click, focus, etc + */ + events: _propTypes.default.shape({ + onClick: _propTypes.default.func, + onFocus: _propTypes.default.func, + onRequestFocus: _propTypes.default.func.isRequired, + onRequestFocusOnNextPill: _propTypes.default.func.isRequired, + onRequestFocusOnPreviousPill: _propTypes.default.func.isRequired, + onRequestRemove: _propTypes.default.func.isRequired + }), + + /** + * Applies the error style to the component. + * _Tested with Mocha framework._ + */ + hasError: _propTypes.default.bool, + + /* + * The icon next to the pill label. + */ + icon: _propTypes.default.element, + + /* + * Pill Label + */ + labels: _propTypes.default.shape({ + label: _propTypes.default.string.isRequired, + removeTitle: _propTypes.default.string + }), + + /* + * If true and is active pill in listbox, will trigger `events.onRequestFocus` + */ + requestFocus: _propTypes.default.bool, + + /* + * Pill Title + */ + title: _propTypes.default.string, + + /* + * Allows the user to tab to the node + */ + tabIndex: _propTypes.default.number +}; +var defaultProps = { + assistiveText: _propTypes.default.shape({ + remove: ', Press delete or backspace to remove' + }), + labels: { + remove: 'Remove' + }, + events: {} +}; + +var handleKeyDown = function handleKeyDown(event, _ref) { + var _callbacks; + + var events = _ref.events, + data = _ref.data; + // Helper function that takes an object literal of callbacks that are triggered with a key event + (0, _keyCallbacks.default)(event, { + callbacks: (_callbacks = {}, _defineProperty(_callbacks, _keyCode.default.BACKSPACE, { + callback: events.onRequestRemove, + data: data + }), _defineProperty(_callbacks, _keyCode.default.DELETE, { + callback: events.onRequestRemove, + data: data + }), _defineProperty(_callbacks, _keyCode.default.LEFT, { + callback: events.onRequestFocusOnPreviousPill, + data: _objectSpread({}, data, { + direction: 'previous' + }) + }), _defineProperty(_callbacks, _keyCode.default.RIGHT, { + callback: events.onRequestFocusOnNextPill, + data: _objectSpread({}, data, { + direction: 'next' + }) + }), _callbacks) + }); +}; + +var handleClickRemove = function handleClickRemove(event, _ref2) { + var events = _ref2.events, + data = _ref2.data; + + _event.default.trap(event); + + events.onRequestRemove(event, data); +}; + +var Pill = function Pill(props) { + var assistiveText = (0, _lodash.default)({}, defaultProps.assistiveText, props.assistiveText); + var labels = (0, _lodash.default)({}, defaultProps.labels, props.labels); + return _react.default.createElement(_pill.default, { + avatar: props.avatar, + bare: props.bare, + hasError: props.hasError, + tabIndex: props.tabIndex || '0', + icon: props.icon, + variant: "option", + labels: labels, + assistiveText: { + remove: assistiveText.remove + }, + "aria-selected": "true", + onBlur: props.events.onBlur, + onClick: typeof props.events.onClick === 'function' ? function (event) { + if (props.events.onClick) { + props.events.onClick(event, _objectSpread({}, props.eventData)); + } + } : null, + onFocus: function onFocus(event) { + if (props.events.onFocus) { + props.events.onFocus(event); + } + }, + onRemove: function onRemove(event) { + _event.default.trap(event); + + handleClickRemove(event, { + events: props.events, + data: props.eventData + }); + }, + onKeyDown: function onKeyDown(event) { + handleKeyDown(event, { + events: props.events, + data: props.eventData + }); + }, + ref: function ref(component) { + if (props.requestFocus && props.active) { + props.events.onRequestFocus(undefined, { + ref: component + }); + } + } + }); +}; + +Pill.displayName = 'Pill'; +Pill.propTypes = propTypes; +Pill.defaultProps = defaultProps; +var _default = Pill; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/text-content.js b/components/utilities/text-content.js new file mode 100644 index 0000000000..f906c67d9a --- /dev/null +++ b/components/utilities/text-content.js @@ -0,0 +1,25 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = textContent; + +function textContentArray(child) { + var text = []; + + if (typeof child === 'string' || typeof child === 'number') { + text.push(child); + } else if (Array.isArray(child)) { + text.push(child.forEach(textContentArray)); + } else if (child && child.props) { + var children = child.props.children; + text.push(textContentArray(children)); + } + + return text; +} + +function textContent(child) { + return textContentArray(child).join(''); +} \ No newline at end of file diff --git a/components/utilities/truncate/by-length.js b/components/utilities/truncate/by-length.js new file mode 100644 index 0000000000..001ea41669 --- /dev/null +++ b/components/utilities/truncate/by-length.js @@ -0,0 +1,40 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = truncateByLength; + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +function truncateByLength(_ref) { + var _ref$inputString = _ref.inputString, + inputString = _ref$inputString === void 0 ? '' : _ref$inputString, + _ref$maxLength = _ref.maxLength, + maxLength = _ref$maxLength === void 0 ? 140 : _ref$maxLength, + _ref$truncationChars = _ref.truncationChars, + truncationChars = _ref$truncationChars === void 0 ? '...' : _ref$truncationChars, + _ref$startingLength = _ref.startingLength, + startingLength = _ref$startingLength === void 0 ? 0 : _ref$startingLength; + var outputString; + + if (inputString.length <= maxLength) { + outputString = inputString; + } else { + var words = inputString.split(' '); + var length = startingLength + truncationChars.length - 1; + outputString = words.reduce(function (combined, word) { + length += word.length + 1; + + if (length <= maxLength) { + combined.push(word); + } + + return combined; + }, []).join(' '); + outputString += truncationChars; + } + + return outputString; +} \ No newline at end of file diff --git a/components/utilities/truncate/index.js b/components/utilities/truncate/index.js new file mode 100644 index 0000000000..64fa8172a4 --- /dev/null +++ b/components/utilities/truncate/index.js @@ -0,0 +1,289 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _lodash = _interopRequireDefault(require("lodash.memoize")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +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; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var documentDefined = typeof document !== 'undefined'; +var canvas; +var docFragment; +var canvasContext; + +var measureWidth = function measureWidth() {}; + +if (documentDefined) { + canvas = document.createElement('canvas'); + docFragment = document.createDocumentFragment(); + docFragment.appendChild(canvas); + canvasContext = canvas.getContext('2d'); + measureWidth = (0, _lodash.default)(function (text, font) { + canvasContext.font = font; + return canvasContext.measureText(text).width; + }); +} + +var TextTruncate = +/*#__PURE__*/ +function (_React$Component) { + _inherits(TextTruncate, _React$Component); + + function TextTruncate() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, TextTruncate); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TextTruncate)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", {}); + + _defineProperty(_assertThisInitialized(_this), "onResize", function () { + _this.update(_this.props); + }); + + _defineProperty(_assertThisInitialized(_this), "getRenderText", function (ref, nextProps) { + if (!ref) { + return; + } + + _this.scope = ref; // nextProps will be undefined for resize events, but will change if search or other props are changed + + var propsToRender; + + if (nextProps) { + propsToRender = nextProps; + } else { + propsToRender = _this.props; + } + + var _propsToRender = propsToRender, + containerClassName = _propsToRender.containerClassName, + line = _propsToRender.line, + prefix = _propsToRender.prefix, + suffix = _propsToRender.suffix, + text = _propsToRender.text, + textTruncateChild = _propsToRender.textTruncateChild, + truncateText = _propsToRender.truncateText, + wrapper = _propsToRender.wrapper, + props = _objectWithoutProperties(_propsToRender, ["containerClassName", "line", "prefix", "suffix", "text", "textTruncateChild", "truncateText", "wrapper"]); + + var scopeWidth = _this.scope.getBoundingClientRect().width; + + var style = window.getComputedStyle(_this.scope); + var font = [style['font-weight'], style['font-style'], style['font-size'], style['font-family']].join(' '); // return if display:none + + if (scopeWidth === 0) { + _this.setState({ + renderText: null + }); + + return; + } + + var child; + var outputText = text; // return if all of text can be displayed + + if (scopeWidth < measureWidth(text, font)) { + var currentPos = 1; + var maxTextLength = text.length; + var truncatedText = ''; + var splitPos = 0; + var startPos = 0; + var displayLine = line; + var width = 0; + var lastIsEng = false; + var lastSpaceIndex = -1; + + while (displayLine !== 0) { + var ext = ''; + var extraWidthDueToPrefixStyle = 0; + + if (prefix && displayLine === line - 1) { + ext += " ".concat(prefix); // MAGIC NUMBER: (width at letter-spacing of 0.25rems - width at normal) / number of letters + + extraWidthDueToPrefixStyle = prefix.length * 0.66; + } + + if (!displayLine) { + ext += truncateText; + + if (suffix) { + ext += " ".concat(suffix); + } + } + + while (currentPos <= maxTextLength) { + truncatedText = text.substr(startPos, currentPos); + width = measureWidth(truncatedText + ext, font) + extraWidthDueToPrefixStyle; + + if (width < scopeWidth) { + splitPos = text.indexOf(' ', currentPos + 1); + + if (splitPos === -1) { + currentPos += 1; + lastIsEng = false; + } else { + lastIsEng = true; + currentPos = splitPos; + } + } else { + var lastWidth = 0; + + do { + currentPos -= 1; + truncatedText = text.substr(startPos, currentPos); + + if (truncatedText[truncatedText.length - 1] === ' ') { + truncatedText = text.substr(startPos, currentPos - 1); + } + + if (lastIsEng) { + lastSpaceIndex = truncatedText.lastIndexOf(' '); + + if (lastSpaceIndex > -1) { + currentPos = lastSpaceIndex; + truncatedText = text.substr(startPos, currentPos); + } + } + + width = measureWidth(truncatedText + ext, font) + extraWidthDueToPrefixStyle; + + if (width === lastWidth) { + currentPos = 0; + break; + } else { + lastWidth = width; + } + } while (width >= scopeWidth); + + startPos += currentPos; + break; + } + } + + if (currentPos >= maxTextLength) { + startPos = maxTextLength; + break; + } + + displayLine -= 1; // iterate + } + + if (startPos !== maxTextLength) { + outputText = "".concat(text.substr(0, startPos)).concat(truncateText, " "); + child = textTruncateChild; + } + } + + var renderText; + + if (wrapper) { + renderText = wrapper(outputText, child); + } else { + renderText = _react.default.createElement("div", props, outputText, child); + } + + _this.setState({ + renderText: renderText + }); + }); + + _defineProperty(_assertThisInitialized(_this), "update", function (nextProps) { + _this.getRenderText(_this.scope, nextProps); + }); + + return _this; + } + + _createClass(TextTruncate, [{ + key: "componentDidMount", + value: function componentDidMount() { + window.addEventListener('resize', this.onResize, false); + } + }, { + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + this.update(nextProps); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + window.removeEventListener('resize', this.onResize, false); + } + }, { + key: "render", + value: function render() { + var containerClassName = this.props.containerClassName; // inline style override + + return _react.default.createElement("div", { + ref: this.getRenderText, + className: containerClassName, + style: { + overflow: 'hidden' + } + }, this.state.renderText); + } + }]); + + return TextTruncate; +}(_react.default.Component); + +_defineProperty(TextTruncate, "displayName", 'TextTruncate'); + +_defineProperty(TextTruncate, "propTypes", { + containerClassName: _propTypes.default.string, + line: _propTypes.default.number, + prefix: _propTypes.default.string, + suffix: _propTypes.default.string, + text: _propTypes.default.string, + textTruncateChild: _propTypes.default.node, + truncateText: _propTypes.default.string, + wrapper: _propTypes.default.func +}); + +_defineProperty(TextTruncate, "defaultProps", { + line: 1, + text: '', + truncateText: '…' +}); + +var _default = TextTruncate; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/utility-icon/check-props.js b/components/utilities/utility-icon/check-props.js new file mode 100644 index 0000000000..184246056b --- /dev/null +++ b/components/utilities/utility-icon/check-props.js @@ -0,0 +1,29 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _urlExists = _interopRequireDefault(require("../../../utilities/warning/url-exists")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props) { + if (!props.context["".concat(props.category, "Sprite")] && !props.context.onRequestIconPath) { + var modifiedPath = props.path || props.context.iconPath; + (0, _urlExists.default)(COMPONENT, "".concat(modifiedPath, "/").concat(props.category, "-sprite/svg/symbols.svg#").concat(props.name)); + } + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/utility-icon/index.js b/components/utilities/utility-icon/index.js new file mode 100644 index 0000000000..84c6427056 --- /dev/null +++ b/components/utilities/utility-icon/index.js @@ -0,0 +1,131 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _svg = _interopRequireDefault(require("./svg")); + +var _utility = _interopRequireDefault(require("../../../icons/utility")); + +var _action = _interopRequireDefault(require("../../../icons/action")); + +var _custom = _interopRequireDefault(require("../../../icons/custom")); + +var _doctype = _interopRequireDefault(require("../../../icons/doctype")); + +var _standard = _interopRequireDefault(require("../../../icons/standard")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +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; } + +/* + * If inline icons are present and icon bundle imports are not just an empty object, then inline icons will be used instead of external icons that require HTTP access. + */ +var UtilityIcon = function UtilityIcon(_ref, context) { + var _ref$name = _ref.name, + name = _ref$name === void 0 ? '' : _ref$name, + assistiveText = _ref.assistiveText, + category = _ref.category, + icon = _ref.icon, + path = _ref.path, + rest = _objectWithoutProperties(_ref, ["name", "assistiveText", "category", "icon", "path"]); + + (0, _checkProps.default)('UtilityIcon', { + name: name, + category: category, + path: path, + context: context + }); + var inlineIcons = { + action: _action.default, + custom: _custom.default, + doctype: _doctype.default, + standard: _standard.default, + utility: _utility.default + }; + var inlineData; + + if (icon) { + // Use SVG data passed in with `icon` prop + inlineData = icon; + } else if (Object.keys(inlineIcons[category]).length) { + // Use inline icon data if it exists. ENV variables will have to set to allow this. + inlineData = inlineIcons[category][name.toLowerCase()]; + inlineData.viewBox = inlineIcons[category].viewBox; + } + + var modifiedPath; + + if (path) { + // Use `path` prop of Icon if present + modifiedPath = path; + } else if (context.onRequestIconPath) { + modifiedPath = context.onRequestIconPath({ + category: category, + name: name + }); + } else if (context["".concat(category, "Sprite")]) { + // Use category sprite file from IconSettings if present + modifiedPath = "".concat(context["".concat(category, "Sprite")], "#").concat(name); + } else { + // Otherwise, use external URLs for icons + modifiedPath = context.iconPath && "".concat(context.iconPath, "/").concat(category, "-sprite/svg/symbols.svg#").concat(name); + } + + return inlineData ? _react.default.createElement(_svg.default, _extends({ + data: inlineData, + name: name + }, rest)) : _react.default.createElement("svg", _extends({ + key: "".concat(name, "_").concat(category) + }, rest), _react.default.createElement("use", { + xlinkHref: modifiedPath + })); +}; + +UtilityIcon.displayName = 'UtilityIcon'; +UtilityIcon.propTypes = { + assistiveText: _propTypes.default.object, + category: _propTypes.default.oneOf(['action', 'custom', 'doctype', 'standard', 'utility']), + + /** + * An SVG object to use instead of name / category, look in `design-system-react/icons` for examples + */ + icon: _propTypes.default.object, + + /** + * Name of the icon. Visit Lightning Design System Icons to reference icon names. + */ + name: _propTypes.default.string, + + /** + * Path to the icon. This will override any global icon settings. + */ + path: _propTypes.default.string +}; +UtilityIcon.defaultProps = { + category: 'utility' +}; +UtilityIcon.contextTypes = { + iconPath: _propTypes.default.string, + onRequestIconPath: _propTypes.default.func, + actionSprite: _propTypes.default.string, + customSprite: _propTypes.default.string, + doctypeSprite: _propTypes.default.string, + standardSprite: _propTypes.default.string, + utilitySprite: _propTypes.default.string +}; +var _default = UtilityIcon; +exports.default = _default; \ No newline at end of file diff --git a/components/utilities/utility-icon/svg.js b/components/utilities/utility-icon/svg.js new file mode 100644 index 0000000000..2983ddf478 --- /dev/null +++ b/components/utilities/utility-icon/svg.js @@ -0,0 +1,161 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +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; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Svg = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Svg, _React$Component); + + function Svg() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Svg); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Svg)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "getPaths", function (paths) { + if (paths instanceof Array) { + return paths.map(function (item) { + return _react.default.createElement("path", item); + }); + } + + return _react.default.createElement("path", _extends({ + key: "pathSVG" + }, paths)); + }); + + _defineProperty(_assertThisInitialized(_this), "getCircles", function (circles) { + if (circles instanceof Array) { + return circles.map(function (item) { + return _react.default.createElement("circle", item); + }); + } + + return _react.default.createElement("circle", _extends({ + key: "circleSVG" + }, circles)); + }); + + _defineProperty(_assertThisInitialized(_this), "getEllipses", function (ellipses) { + if (ellipses instanceof Array) { + return ellipses.map(function (item) { + return _react.default.createElement("ellipse", item); + }); + } + + return _react.default.createElement("ellipse", _extends({ + key: "ellipseSVG" + }, ellipses)); + }); + + _defineProperty(_assertThisInitialized(_this), "getGroups", function (groups) { + if (groups instanceof Array) { + return groups.map(function (item) { + return _react.default.createElement("g", null, _this.getShapes(item)); + }); + } + + return _react.default.createElement("g", { + key: "groupsSVG" + }, _this.getShapes(groups)); + }); + + _defineProperty(_assertThisInitialized(_this), "getShapes", function (data) { + var shapes = []; + + if (data) { + if (data.g) { + shapes.push(_this.getGroups(data.g)); + } + + if (data.ellipse) { + shapes.push(_this.getEllipses(data.ellipse)); + } + + if (data.circle) { + shapes.push(_this.getCircles(data.circle)); + } + + if (data.path) { + shapes.push(_this.getPaths(data.path)); + } + } + + return shapes; + }); + + _defineProperty(_assertThisInitialized(_this), "getSVG", function (_ref, props) { + var viewBox = _ref.viewBox, + rest = _objectWithoutProperties(_ref, ["viewBox"]); + + return _react.default.createElement("svg", { + "aria-hidden": props['aria-hidden'], + className: props.className, + viewBox: viewBox, + name: props.name, + style: props.style + }, _this.getShapes(rest)); + }); + + return _this; + } + + _createClass(Svg, [{ + key: "render", + value: function render() { + var _this$props = this.props, + data = _this$props.data, + props = _objectWithoutProperties(_this$props, ["data"]); + + return data ? this.getSVG(data, props) : null; + } + }]); + + return Svg; +}(_react.default.Component); + +_defineProperty(Svg, "displayName", 'Svg'); + +var _default = Svg; +exports.default = _default; \ No newline at end of file diff --git a/components/vertical-navigation/__docs__/site-stories.js b/components/vertical-navigation/__docs__/site-stories.js new file mode 100644 index 0000000000..cd92a6eccd --- /dev/null +++ b/components/vertical-navigation/__docs__/site-stories.js @@ -0,0 +1,9 @@ +"use strict"; + +// This object is imported into the documentation site. An example for the documentation site should be part of the pull request for the component. The object key is the kabob case of the "URL folder". In the case of `http://localhost:8080/components/app-launcher/`, `app-launcher` is the `key`. The folder name is created by `components.component` value in `package.json`. The following uses webpack's raw-loader plugin to get "text files" that will be eval()'d by CodeMirror within the documentation site on page load. + +/* eslint-env node */ + +/* eslint-disable global-require */ +var siteStories = [require('raw-loader!@salesforce/design-system-react/components/vertical-navigation/__examples__/default.jsx')]; +module.exports = siteStories; \ No newline at end of file diff --git a/components/vertical-navigation/__docs__/storybook-stories.js b/components/vertical-navigation/__docs__/storybook-stories.js new file mode 100644 index 0000000000..1dbdfcef9f --- /dev/null +++ b/components/vertical-navigation/__docs__/storybook-stories.js @@ -0,0 +1,31 @@ +"use strict"; + +var _react = _interopRequireDefault(require("react")); + +var _react2 = require("@storybook/react"); + +var _addonActions = require("@storybook/addon-actions"); + +var _iconSettings = _interopRequireDefault(require("../../icon-settings")); + +var _constants = require("../../../utilities/constants"); + +var _default = _interopRequireDefault(require("../__examples__/default")); + +var _snapshotDefault = _interopRequireDefault(require("../__examples__/snapshot-default")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _react2.storiesOf)(_constants.VERTICAL_NAVIGATION, module).addDecorator(function (getStory) { + return _react.default.createElement("div", { + className: "slds-p-around_medium" + }, _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, getStory())); +}).add('Default', function () { + return _react.default.createElement(_default.default, { + action: _addonActions.action + }); +}).add('DOM Snapshot', function () { + return _react.default.createElement(_snapshotDefault.default, null); +}); \ No newline at end of file diff --git a/components/vertical-navigation/__examples__/default.js b/components/vertical-navigation/__examples__/default.js new file mode 100644 index 0000000000..5c7ac8a5c5 --- /dev/null +++ b/components/vertical-navigation/__examples__/default.js @@ -0,0 +1,144 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _verticalNavigation = _interopRequireDefault(require("../../../../components/vertical-navigation")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var sampleReportCategories = [{ + id: 'reports', + label: 'Reports', + items: [{ + id: 'recent_reports', + label: 'Recent' + }, { + id: 'my_reports', + label: 'Created by Me' + }, { + id: 'private_reports', + label: 'Private Reports' + }, { + id: 'public_reports', + label: 'Public Reports' + }, { + id: 'all_reports', + label: 'All Reports' + }] +}, { + id: 'folders', + label: 'Folders', + items: [{ + id: 'my_folders', + label: 'Created by Me' + }, { + id: 'shared_folders', + label: 'Shared with Me' + }, { + id: 'all_folders', + label: 'All Folders' + }] +}]; + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Example); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Example)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "state", { + selectedId: 'recent_reports' + }); + + return _this; + } + + _createClass(Example, [{ + key: "render", + value: function render() { + var _this2 = this; + + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement("div", { + style: { + width: '320px' + } + }, _react.default.createElement(_verticalNavigation.default, { + id: "sample-navigation", + categories: sampleReportCategories, + selectedId: this.state.selectedId, + onSelect: function onSelect(event, data) { + _this2.setState({ + selectedId: data.item.id + }); + + if (_this2.props.action) { + var dataAsArray = Object.keys(data).map(function (key) { + return data[key]; + }); + + _this2.props.action('onSelect').apply(void 0, [event, data].concat(_toConsumableArray(dataAsArray))); + } else if (console) { + console.log('[onSelect] (event, data)', event, data); + } + } + }))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'NavigationExample'); + +var _default = Example; // export is replaced with `ReactDOM.render(, mountNode);` at runtime + +exports.default = _default; \ No newline at end of file diff --git a/components/vertical-navigation/__examples__/snapshot-default.js b/components/vertical-navigation/__examples__/snapshot-default.js new file mode 100644 index 0000000000..da923ba00d --- /dev/null +++ b/components/vertical-navigation/__examples__/snapshot-default.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _verticalNavigation = _interopRequireDefault(require("../../../../components/vertical-navigation")); + +var _iconSettings = _interopRequireDefault(require("../../../../components/icon-settings")); + +var _verticalNavigation2 = require("../../../../utilities/sample-data/vertical-navigation"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var Example = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Example, _React$Component); + + function Example() { + _classCallCheck(this, Example); + + return _possibleConstructorReturn(this, _getPrototypeOf(Example).apply(this, arguments)); + } + + _createClass(Example, [{ + key: "render", + value: function render() { + return _react.default.createElement(_iconSettings.default, { + iconPath: "/assets/icons" + }, _react.default.createElement(_verticalNavigation.default, _extends({ + id: "sample-navigation", + categories: _verticalNavigation2.sampleReportCategories + }, this.props))); + } + }]); + + return Example; +}(_react.default.Component); + +_defineProperty(Example, "displayName", 'NavigationExample'); + +var _default = Example; +exports.default = _default; \ No newline at end of file diff --git a/components/vertical-navigation/check-props.js b/components/vertical-navigation/check-props.js new file mode 100644 index 0000000000..ab61afbb1a --- /dev/null +++ b/components/vertical-navigation/check-props.js @@ -0,0 +1,26 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _deprecatedProperty = _interopRequireDefault(require("../../utilities/warning/deprecated-property")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ + +/* eslint-disable import/no-mutable-exports */ +var checkProps = function checkProps() {}; + +if (process.env.NODE_ENV !== 'production') { + checkProps = function checkProps(COMPONENT, props) { + (0, _deprecatedProperty.default)(COMPONENT, props.variant, 'variant', undefined, 'Shade variant is deprecated as there is no background supported currently. Vertical Navigation now uses a default shade.'); + }; +} + +var _default = checkProps; +exports.default = _default; \ No newline at end of file diff --git a/components/vertical-navigation/docs.json b/components/vertical-navigation/docs.json new file mode 100644 index 0000000000..bb2dcc47bb --- /dev/null +++ b/components/vertical-navigation/docs.json @@ -0,0 +1,7 @@ +{ + "component": "vertical-navigation", + "status": "prod", + "display-name": "Vertical Navigation", + "SLDS-component-path": "/components/vertical-navigation", + "url-slug": "vertical-navigation" +} \ No newline at end of file diff --git a/components/vertical-navigation/index.js b/components/vertical-navigation/index.js new file mode 100644 index 0000000000..2f2486fd01 --- /dev/null +++ b/components/vertical-navigation/index.js @@ -0,0 +1,163 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _shortid = _interopRequireDefault(require("shortid")); + +var _docs = _interopRequireDefault(require("./docs.json")); + +var _checkProps = _interopRequireDefault(require("./check-props")); + +var _constants = require("../../utilities/constants"); + +var _item = _interopRequireDefault(require("./private/item")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Vertical Navigation represents a list of links that either take the user to another page or parts of the page the user is in. + */ +var VerticalNavigation = +/*#__PURE__*/ +function (_React$Component) { + _inherits(VerticalNavigation, _React$Component); + + function VerticalNavigation() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, VerticalNavigation); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(VerticalNavigation)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "getId", function () { + return _this.props.id || _this.generatedId; + }); + + _defineProperty(_assertThisInitialized(_this), "getSelectedId", function () { + var categories = _this.props.categories; + var selectedId; + + if (_this.props.selectedId) { + selectedId = _this.props.selectedId; + } else if (categories.length > 0 && categories[0].items && categories[0].items.length > 0) { + selectedId = categories[0].items[0].id; + } + + return selectedId; + }); + + return _this; + } + + _createClass(VerticalNavigation, [{ + key: "componentWillMount", + value: function componentWillMount() { + this.generatedId = _shortid.default.generate(); + (0, _checkProps.default)(_constants.VERTICAL_NAVIGATION, this.props, _docs.default); + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var rootId = this.getId(); + return _react.default.createElement("nav", { + id: rootId, + className: (0, _classnames.default)('slds-nav-vertical', this.props.className) + }, this.props.categories.map(function (category) { + var categoryId = "".concat(rootId, "-").concat(category.id); + + var selectedId = _this2.getSelectedId(); + + return _react.default.createElement("div", { + key: "".concat(categoryId, "-header"), + className: "slds-nav-vertical__section" + }, _react.default.createElement("h2", { + id: categoryId, + className: "slds-nav-vertical__title" + }, category.label), _react.default.createElement("ul", { + key: categoryId + }, category.items.map(function (item) { + return _react.default.createElement(_item.default, { + key: item.id, + item: item, + isSelected: item.id === selectedId, + categoryId: categoryId, + onSelect: _this2.props.onSelect + }); + }))); + })); + } + }]); + + return VerticalNavigation; +}(_react.default.Component); + +_defineProperty(VerticalNavigation, "displayName", _constants.VERTICAL_NAVIGATION); + +_defineProperty(VerticalNavigation, "propTypes", { + /** + * HTML id for component. _Tested with snapshot testing._ + */ + id: _propTypes.default.string, + + /** + * CSS class names to be added to the container element. _Tested with snapshot testing._ + */ + className: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.string]), + + /** + * Array of categories. The required shape is: `{id: string, label: string, items: array}`. The required shape of an item is `{id: string, label: string, url: string}`. All item ids are expected to be unique. _Tested with snapshot testing._ + */ + categories: _propTypes.default.array, + + /** + * The ID of the item that is currently selected. Defaults to the ID of the first item. _Tested with Mocha framework._ + */ + selectedId: _propTypes.default.string, + + /** + * Triggered when the selection changes. It receives an event and an item object in the shape: `event, {item: [object] }`. _Tested with Mocha framework._ + */ + onSelect: _propTypes.default.func +}); + +_defineProperty(VerticalNavigation, "defaultProps", {}); + +var _default = VerticalNavigation; +exports.default = _default; \ No newline at end of file diff --git a/components/vertical-navigation/private/item.js b/components/vertical-navigation/private/item.js new file mode 100644 index 0000000000..dcb4613fb6 --- /dev/null +++ b/components/vertical-navigation/private/item.js @@ -0,0 +1,86 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _propTypes = _interopRequireDefault(require("prop-types")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _lodash = _interopRequireDefault(require("lodash.isfunction")); + +var _constants = require("../../../utilities/constants"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// ### classNames +// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames) +// This project uses `classnames`, 'a simple javascript utility for conditionally +// joining classNames together.' +// ### isFunction +var handleClick = function handleClick(event, props) { + if ((0, _lodash.default)(props.onSelect)) { + props.onSelect(event, { + item: props.item + }); + } +}; + +var Item = function Item(props) { + return _react.default.createElement("li", { + className: (0, _classnames.default)('slds-nav-vertical__item', { + 'slds-is-active': props.isSelected + }) + }, _react.default.createElement("a", { + "data-id": props.item.id, + href: props.item.url || 'javascript:void(0);' // eslint-disable-line no-script-url + , + className: "slds-nav-vertical__action", + "aria-describedby": props.categoryId, + onClick: function onClick(event) { + handleClick(event, props); + } + }, props.item.label)); +}; // ### Display Name +// Always use the canonical component name as the React display name. + + +Item.displayName = _constants.VERTICAL_NAVIGATION_ITEM; // ### Prop Types + +Item.propTypes = { + /** + * Item to be rendered. + */ + item: _propTypes.default.shape({ + id: _propTypes.default.string.isRequired, + label: _propTypes.default.string.isRequired, + url: _propTypes.default.string + }), + + /** + * Whether item is selected or not. + */ + isSelected: _propTypes.default.bool, + + /** + * ID of the category this item belongs to. + */ + categoryId: _propTypes.default.string.isRequired, + + /** + * Function that will run whenever an item is selected. + */ + onSelect: _propTypes.default.func +}; +Item.defaultProps = { + isSelected: false +}; +var _default = Item; +exports.default = _default; \ No newline at end of file diff --git a/design-system-react-components.js b/design-system-react-components.js new file mode 100644 index 0000000000..5629785a69 --- /dev/null +++ b/design-system-react-components.js @@ -0,0 +1,64004 @@ +/*! + * design-system-react + * v0.10.3 + * Copyright (c) 2015-present, Salesforce.com, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Salesforce.com nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("react"), require("react-dom")); + else if(typeof define === 'function' && define.amd) + define(["react", "react-dom"], factory); + else if(typeof exports === 'object') + exports["design-system-react"] = factory(require("react"), require("react-dom")); + else + root["design-system-react"] = factory(root["React"], root["ReactDOM"]); +})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_17__) { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = "/"; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 163); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +module.exports = __WEBPACK_EXTERNAL_MODULE_0__; + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +if (false) { + var ReactIs = require('react-is'); + + // By explicitly using `prop-types` you are opting into new development behavior. + // http://fb.me/prop-types-in-prod + var throwOnDirectAccess = true; + module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess); +} else { + // By explicitly using `prop-types` you are opting into new production behavior. + // http://fb.me/prop-types-in-prod + module.exports = __webpack_require__(166)(); +} + + +/***/ }), +/* 2 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ACCORDION; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return ACCORDION_PANEL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return ALERT; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return ALERT_CONTAINER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return APP_LAUNCHER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return APP_LAUNCHER_SECTION; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return APP_LAUNCHER_TILE; }); +/* unused harmony export APP_LAUNCHER_HEADER */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return AVATAR; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return BRAND_BAND; }); +/* unused harmony export BREAD_CRUMB */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return BREADCRUMB; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return BUTTON; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return BUTTON_GROUP; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return BUTTON_STATEFUL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return BUTTON_ICON; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return CARD; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return CARD_BODY; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return CARD_EMPTY; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return CARD_FILTER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return CARD_FOOTER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return CARD_HEADER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return CAROUSEL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return CAROUSEL_INDICATORS; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return CAROUSEL_ITEM; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return CAROUSEL_NAVIGATORS; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return CAROUSEL_AUTOPLAY_BUTTON; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return COLOR_PICKER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return COMBOBOX; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return DATA_TABLE; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return DATA_TABLE_CELL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return DATA_TABLE_COLUMN; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return DATA_TABLE_HEAD; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "G", function() { return DATA_TABLE_HEADER_CELL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I", function() { return DATA_TABLE_ROW_ACTIONS; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return DATA_TABLE_ROW; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "J", function() { return DATE_PICKER; }); +/* unused harmony export DEPRECATED_WARNING */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "L", function() { return DYNAMIC_ICON; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "K", function() { return DIALOG; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "M", function() { return FILTER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return CHECKBOX; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "N", function() { return FORMS_INLINE_EDIT; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_8", function() { return INPUT; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_49", function() { return TEXTAREA; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_38", function() { return SEARCH; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "O", function() { return GLOBAL_HEADER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "P", function() { return GLOBAL_HEADER_BUTTON; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Q", function() { return GLOBAL_HEADER_DROPDOWN; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R", function() { return GLOBAL_HEADER_FAVORITES; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "S", function() { return GLOBAL_HEADER_HELP; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "T", function() { return GLOBAL_HEADER_NOTIFICATIONS; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "U", function() { return GLOBAL_HEADER_PROFILE; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "V", function() { return GLOBAL_HEADER_SEARCH; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return GLOBAL_HEADER_SETUP; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return GLOBAL_HEADER_TASK; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Y", function() { return GLOBAL_HEADER_TOOL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Z", function() { return GLOBAL_NAVIGATION_BAR; }); +/* unused harmony export GLOBAL_NAVIGATION_BAR_BUTTON */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_0", function() { return GLOBAL_NAVIGATION_BAR_DROPDOWN; }); +/* unused harmony export GLOBAL_NAVIGATION_BAR_LABEL */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_1", function() { return GLOBAL_NAVIGATION_BAR_LINK; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_2", function() { return GLOBAL_NAVIGATION_BAR_REGION; }); +/* unused harmony export GLOBAL_NAVIGATION_BAR_APP_LAUNCHER */ +/* unused harmony export GRID */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_3", function() { return HIGHLIGHTER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_4", function() { return ICON; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_6", function() { return ICON_SETTINGS; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_5", function() { return ICON_INPUT; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_7", function() { return ILLUSTRATION; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_9", function() { return LIST; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_10", function() { return LIST_ITEM; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_11", function() { return LIST_ITEM_LABEL; }); +/* unused harmony export LISTBOX_OF_PILL_OPTIONS */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_12", function() { return LOOKUP; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_13", function() { return MEDIA_OBJECT; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_14", function() { return MENU_DROPDOWN; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_15", function() { return MENU_DROPDOWN_TRIGGER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_16", function() { return MENU_PICKLIST; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_17", function() { return MODAL; }); +/* unused harmony export NOTIFICATION */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_19", function() { return PANEL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_20", function() { return PANEL_FILTER_GROUP; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_21", function() { return PANEL_FILTER_LIST; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_22", function() { return PANEL_FILTER_LIST_HEADING; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_18", function() { return PAGE_HEADER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_23", function() { return PILL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_24", function() { return PILL_CONTAINER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_25", function() { return POPOVER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_26", function() { return POPOVER_EDIT_DIALOG; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_27", function() { return POPOVER_TOOLTIP; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_29", function() { return PROGRESS_INDICATOR; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_30", function() { return PROGRESS_INDICATOR_PROGRESS; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_31", function() { return PROGRESS_INDICATOR_STEP; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_32", function() { return PROGRESS_INDICATOR_STEP_VERTICAL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_33", function() { return PROGRESS_RING; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_28", function() { return PROGRESS_BAR; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_37", function() { return SCOPED_NOTIFICATION; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_39", function() { return SLIDER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_40", function() { return SPINNER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_41", function() { return SPLIT_VIEW; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_42", function() { return SPLIT_VIEW_HEADER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_43", function() { return SPLIT_VIEW_LISTBOX; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_34", function() { return RADIO; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_36", function() { return RADIO_GROUP; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_35", function() { return RADIO_BUTTON_GROUP; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_44", function() { return TAB; }); +/* unused harmony export TAB_ITEM */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_48", function() { return TAB_PANEL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_45", function() { return TABS; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_46", function() { return TABS_LIST; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_47", function() { return TABS_PANEL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_50", function() { return TIME_PICKER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_51", function() { return TOAST; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_52", function() { return TOAST_CONTAINER; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_53", function() { return TREE; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_54", function() { return TREE_BRANCH; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_55", function() { return TREE_ITEM; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_56", function() { return VERTICAL_NAVIGATION; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_57", function() { return VERTICAL_NAVIGATION_ITEM; }); +// ## Components +var ACCORDION = 'SLDSAccordion'; +var ACCORDION_PANEL = 'SLDSAccordionPanel'; +var ALERT = 'SLDSAlert'; +var ALERT_CONTAINER = 'SLDSAlertContainer'; +var APP_LAUNCHER = 'SLDSAppLauncher'; +var APP_LAUNCHER_SECTION = 'SLDSAppLauncherSection'; +var APP_LAUNCHER_TILE = 'SLDSAppLauncherTile'; +var APP_LAUNCHER_HEADER = 'SLDSAppLauncherHeader'; +var AVATAR = 'SLDSAvatar'; +var BRAND_BAND = 'SLDSBrandBand'; +/* Remove at next breaking change */ + +var BREAD_CRUMB = 'SLDSBreadcrumb'; +var BREADCRUMB = 'SLDSBreadcrumb'; +var BUTTON = 'SLDSButton'; +var BUTTON_GROUP = 'SLDSButtonGroup'; +var BUTTON_STATEFUL = 'SLDSButtonStateful'; +var BUTTON_ICON = 'SLDSButtonIcon'; // a non-interctive icon wrapper for SLDSUtilityIcon + +var CARD = 'SLDSCard'; +var CARD_BODY = 'SLDSCardBody'; +var CARD_EMPTY = 'SLDSCardEmpty'; +var CARD_FILTER = 'SLDSCardFilter'; +var CARD_FOOTER = 'SLDSCardFooter'; +var CARD_HEADER = 'SLDSCardHeader'; +var CAROUSEL = 'SLDSCarousel'; +var CAROUSEL_INDICATORS = 'SLDSCarouselIndicators'; +var CAROUSEL_ITEM = 'SLDSCarouselItem'; +var CAROUSEL_NAVIGATORS = 'SLDSCarouselNavigators'; +var CAROUSEL_AUTOPLAY_BUTTON = 'SLDSCarouselAutoPlayButton'; +var COLOR_PICKER = 'SLDSColorPicker'; +var COMBOBOX = 'SLDSCombobox'; +var DATA_TABLE = 'SLDSDataTable'; +var DATA_TABLE_CELL = 'SLDSDataTableCell'; +var DATA_TABLE_COLUMN = 'SLDSDataTableColumn'; +var DATA_TABLE_HEAD = 'SLDSDataTableHead'; +var DATA_TABLE_HEADER_CELL = 'SLDSDataTableHeaderCell'; +var DATA_TABLE_ROW_ACTIONS = 'SLDSDataTableRowActions'; +var DATA_TABLE_ROW = 'SLDSDataTableRow'; +var DATE_PICKER = 'SLDSDatePicker'; +var DEPRECATED_WARNING = 'SLDSDeprecatedWarning'; +var DYNAMIC_ICON = 'SLDSDynamicIcon'; +var DIALOG = 'SLDSDialog'; +var FILTER = 'SLDSFilter'; +var CHECKBOX = 'SLDSCheckbox'; +var FORMS_INLINE_EDIT = 'SLDSInlineEdit'; +var INPUT = 'SLDSInput'; +var TEXTAREA = 'SLDSTextarea'; +var SEARCH = 'SLDSSearch'; +var GLOBAL_HEADER = 'SLDSGlobalHeader'; +var GLOBAL_HEADER_BUTTON = 'SLDSGlobalHeaderButton'; +var GLOBAL_HEADER_DROPDOWN = 'SLDSGlobalHeaderDropdown'; +var GLOBAL_HEADER_FAVORITES = 'SLDSGlobalHeaderFavorites'; +var GLOBAL_HEADER_HELP = 'SLDSGlobalHeaderHelp'; +var GLOBAL_HEADER_NOTIFICATIONS = 'SLDSGlobalHeaderNotifications'; +var GLOBAL_HEADER_PROFILE = 'SLDSGlobalHeaderProfile'; +var GLOBAL_HEADER_SEARCH = 'SLDSGlobalHeaderSearch'; +var GLOBAL_HEADER_SETUP = 'SLDSGlobalHeaderSetup'; +var GLOBAL_HEADER_TASK = 'SLDSGlobalHeaderTask'; +var GLOBAL_HEADER_TOOL = 'SLDSGlobalHeaderTool'; +var GLOBAL_NAVIGATION_BAR = 'SLDSGlobalNavigationBar'; +var GLOBAL_NAVIGATION_BAR_BUTTON = 'SLDSGlobalNavigationBarButton'; +var GLOBAL_NAVIGATION_BAR_DROPDOWN = 'SLDSGlobalNavigationBarDropdown'; +var GLOBAL_NAVIGATION_BAR_LABEL = 'SLDSGlobalNavigationBarLabel'; +var GLOBAL_NAVIGATION_BAR_LINK = 'SLDSGlobalNavigationBarLink'; +var GLOBAL_NAVIGATION_BAR_REGION = 'SLDSGlobalNavigationBarRegion'; +var GLOBAL_NAVIGATION_BAR_APP_LAUNCHER = 'SLDSGlobalNavigationBarAppLauncher'; +var GRID = 'SLDSGrid'; +var HIGHLIGHTER = 'SLDSHighlighter'; +var ICON = 'SLDSIcon'; +var ICON_SETTINGS = 'SLDSIconSettings'; +var ICON_INPUT = 'SLDSIconInput'; +var ILLUSTRATION = 'SLDSIllustration'; +var LIST = 'SLDSList'; +var LIST_ITEM = 'SLDSListItem'; +var LIST_ITEM_LABEL = 'SLDSListItemLabel'; +var LISTBOX_OF_PILL_OPTIONS = 'SLDSListboxOfPillOptions'; +var LOOKUP = 'SLDSLookup'; +var MEDIA_OBJECT = 'SLDSMediaObject'; +var MENU_DROPDOWN = 'SLDSMenuDropdown'; +var MENU_DROPDOWN_TRIGGER = 'SLDSMenuDropdownTrigger'; +var MENU_PICKLIST = 'SLDSMenuPicklist'; +var MODAL = 'SLDSModal'; +var NOTIFICATION = 'SLDSNotification'; +var PANEL = 'SLDSPanel'; +var PANEL_FILTER_GROUP = 'SLDSFilterGroup'; +var PANEL_FILTER_LIST = 'SLDSFilterList'; +var PANEL_FILTER_LIST_HEADING = 'SLDSPanelFilterListHeading'; +var PAGE_HEADER = 'SLDSPageHeader'; +var PILL = 'SLDSPill'; +var PILL_CONTAINER = 'SLDSPillContainer'; +var POPOVER = 'SLDSPopover'; +var POPOVER_EDIT_DIALOG = 'SLDSPopoverEditDialog'; +var POPOVER_TOOLTIP = 'SLDSPopoverTooltip'; +var PROGRESS_INDICATOR = 'SLDSProgressIndicator'; +var PROGRESS_INDICATOR_PROGRESS = 'SLDSProgressIndicatorProgress'; +var PROGRESS_INDICATOR_STEP = 'SLDSProgressIndicatorStep'; +var PROGRESS_INDICATOR_STEP_VERTICAL = 'SLDSProgressIndicatorStepVertical'; +var PROGRESS_RING = 'SLDSProgressRing'; +var PROGRESS_BAR = 'SLDSProgressBar'; +var SCOPED_NOTIFICATION = 'SLDSScopedNotification'; +var SLIDER = 'SLDSSlider'; +var SPINNER = 'SLDSSpinner'; +var SPLIT_VIEW = 'SLDSSplitView'; +var SPLIT_VIEW_HEADER = 'SLDSSplitViewHeader'; +var SPLIT_VIEW_LISTBOX = 'SLDSSplitViewListbox'; +var RADIO = 'SLDSRadio'; +var RADIO_GROUP = 'SLDSRadioGroup'; +var RADIO_BUTTON_GROUP = 'SLDSRadioButtonGroup'; +var TAB = 'SLDSTab'; +var TAB_ITEM = 'SLDSTabItem'; +var TAB_PANEL = 'SLDSTabPanel'; +var TABS = 'SLDSTabs'; +var TABS_LIST = 'SLDSTabsList'; +var TABS_PANEL = 'SLDSTabsPanel'; +var TIME_PICKER = 'SLDSTimepicker'; +var TOAST = 'SLDSToast'; +var TOAST_CONTAINER = 'SLDSToastContainer'; +var TREE = 'SLDSTree'; +var TREE_BRANCH = 'SLDSTreeBranch'; +var TREE_ITEM = 'SLDSTreeItem'; +var VERTICAL_NAVIGATION = 'SLDSVerticalNavigation'; +var VERTICAL_NAVIGATION_ITEM = 'SLDSVerticalNavigationItem'; + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! + Copyright (c) 2017 Jed Watson. + Licensed under the MIT License (MIT), see + http://jedwatson.github.io/classnames +*/ +/* global define */ + +(function () { + 'use strict'; + + var hasOwn = {}.hasOwnProperty; + + function classNames () { + var classes = []; + + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + if (!arg) continue; + + var argType = typeof arg; + + if (argType === 'string' || argType === 'number') { + classes.push(arg); + } else if (Array.isArray(arg) && arg.length) { + var inner = classNames.apply(null, arg); + if (inner) { + classes.push(inner); + } + } else if (argType === 'object') { + for (var key in arg) { + if (hasOwn.call(arg, key) && arg[key]) { + classes.push(key); + } + } + } + } + + return classes.join(' '); + } + + if (typeof module !== 'undefined' && module.exports) { + classNames.default = classNames; + module.exports = classNames; + } else if (true) { + // register as 'classnames', consistent with npm package name + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { + return classNames; + }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else { + window.classNames = classNames; + } +}()); + + +/***/ }), +/* 4 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_required_if__ = __webpack_require__(78); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_required_if___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_react_required_if__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_prop_types__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_prop_types__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_classnames__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_classnames___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_classnames__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__icon_button_icon__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__check_props__ = __webpack_require__(190); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__docs_json__ = __webpack_require__(191); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__docs_json___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6__docs_json__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__tooltip__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utilities_get_aria_props__ = __webpack_require__(201); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utilities_constants__ = __webpack_require__(2); +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */ + +/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */ +// Implements the [Button design pattern](https://lightningdesignsystem.com/components/buttons/) in React. +// Based on SLDS v2.2.1 + + + + + + + + + + +var defaultProps = { + assistiveText: { + icon: '' + }, + disabled: false, + hint: false, + iconSize: 'medium', + responsive: false, + type: 'button', + variant: 'neutral' +}; +/** + * The Button component is the Lightning Design System Button component. The Button should be used for label buttons, icon buttons, or buttons that have both labels and icons. + * Either a label or assistiveText.icon is required; see the Prop Details table below. For buttons that maintain selected/unselected states, use the ButtonStateful component. + * Although not listed in the prop table, all `aria-*` props will be added to the `button` element if passed in. + */ + +var Button = +/*#__PURE__*/ +function (_React$Component) { + _inherits(Button, _React$Component); + + function Button() { + var _getPrototypeOf2; + + var _this; + + _classCallCheck(this, Button); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Button)).call.apply(_getPrototypeOf2, [this].concat(args))); + + _defineProperty(_assertThisInitialized(_this), "getClassName", function () { + var _classNames; + + var isIcon = _this.props.variant === 'icon'; + var iconVariant = _this.props.iconVariant; + var iconMore = iconVariant === 'more'; + var iconBorder = iconVariant === 'border'; + var iconGlobalHeader = iconVariant === 'global-header'; + var showButtonVariant = _this.props.variant !== 'base' && !iconVariant && !_this.props.inverse && _this.props.variant !== 'link' || iconVariant === 'bare'; + var plainInverseBtn = _this.props.inverse && !isIcon; + var plainInverseIcon = _this.props.inverse && isIcon && !iconMore && !iconBorder; + var moreInverseIcon = _this.props.inverse && iconMore; + var borderInverseIcon = _this.props.inverse && iconBorder; // After hijacking `iconVariant` to let `Button` know it's in the header, we reset to container style for the actual button CSS. + + if (iconVariant === 'global-header') { + iconVariant = 'container'; + } + + return __WEBPACK_IMPORTED_MODULE_3_classnames___default()((_classNames = { + 'slds-button': _this.props.variant !== 'link' + }, _defineProperty(_classNames, "slds-button_".concat(_this.props.variant), showButtonVariant), _defineProperty(_classNames, 'slds-button_inverse', plainInverseBtn), _defineProperty(_classNames, 'slds-button_icon-inverse', plainInverseIcon || moreInverseIcon), _defineProperty(_classNames, 'slds-button_icon-border-inverse', borderInverseIcon), _defineProperty(_classNames, "slds-button_icon-".concat(iconVariant), iconVariant && !borderInverseIcon), _defineProperty(_classNames, 'slds-global-header__button_icon', iconGlobalHeader), _defineProperty(_classNames, "slds-button_icon-".concat(_this.props.iconSize), iconVariant && _this.props.iconSize !== 'medium'), _defineProperty(_classNames, 'slds-button_reset', _this.props.variant === 'link'), _defineProperty(_classNames, 'slds-text-link', _this.props.variant === 'link'), _classNames), _this.props.className); + }); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function (event) { + if (_this.props.onClick) { + _this.props.onClick(event, {}); + } + }); + + _defineProperty(_assertThisInitialized(_this), "renderIcon", function (name) { + var iconSize = _this.props.iconSize === '' || _this.props.iconVariant ? null : _this.props.iconSize; + return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_4__icon_button_icon__["a" /* default */], { + category: _this.props.iconCategory || 'utility' // BREAKING CHANGE we will introduce in 1.0. For the moment, set default prop here if none specified. + , + className: __WEBPACK_IMPORTED_MODULE_3_classnames___default()({ + 'slds-global-header__icon': _this.props.iconVariant === 'global-header' + }, _this.props.iconClassName), + hint: _this.props.hint, + inverse: _this.props.inverse, + name: name, + path: _this.props.iconPath, + position: _this.props.iconPosition, + size: iconSize + }); + }); + + _defineProperty(_assertThisInitialized(_this), "renderLabel", function () { + var iconOnly = _this.props.iconName || _this.props.iconPath; + var assistiveTextIcon = typeof _this.props.assistiveText === 'string' ? _this.props.assistiveText : _objectSpread({}, defaultProps.assistiveText, _this.props.assistiveText).icon; + return iconOnly && assistiveTextIcon ? __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("span", { + className: "slds-assistive-text" + }, assistiveTextIcon) : _this.props.label; + }); + + _defineProperty(_assertThisInitialized(_this), "renderButton", function () { + var ariaProps = Object(__WEBPACK_IMPORTED_MODULE_8__utilities_get_aria_props__["a" /* default */])(_this.props); + return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("button", _extends({ + className: _this.getClassName(), + disabled: _this.props.disabled, + id: _this.props.id, + onBlur: _this.props.onBlur, + onClick: _this.handleClick, + onFocus: _this.props.onFocus, + onKeyDown: _this.props.onKeyDown, + onKeyPress: _this.props.onKeyPress, + onKeyUp: _this.props.onKeyUp, + onMouseDown: _this.props.onMouseDown, + onMouseEnter: _this.props.onMouseEnter, + onMouseLeave: _this.props.onMouseLeave, + onMouseUp: _this.props.onMouseUp, + ref: function ref(component) { + if (_this.props.buttonRef) { + _this.props.buttonRef(component); + } + }, + tabIndex: _this.props.tabIndex, + title: _this.props.title, + type: _this.props.type, + style: _this.props.style + }, ariaProps), _this.props.iconPosition === 'right' ? _this.renderLabel() : null, _this.props.iconName || _this.props.iconPath ? _this.renderIcon(_this.props.iconName) : null, _this.props.iconVariant === 'more' ? __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_4__icon_button_icon__["a" /* default */], { + category: "utility", + name: "down", + size: "x-small", + className: _this.props.iconClassName + }) : null, _this.props.iconPosition === 'left' || !_this.props.iconPosition ? _this.renderLabel() : null, _this.props.children // eslint-disable-line react/prop-types + ); + }); + + _defineProperty(_assertThisInitialized(_this), "renderTooltip", function () { + return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_7__tooltip__["a" /* default */], { + content: _this.props.tooltip + }, _this.renderButton); + }); + + return _this; + } + + _createClass(Button, [{ + key: "componentWillMount", + value: function componentWillMount() { + // `checkProps` issues warnings to developers about properties (similar to React's built in development tools) + Object(__WEBPACK_IMPORTED_MODULE_5__check_props__["a" /* default */])(__WEBPACK_IMPORTED_MODULE_9__utilities_constants__["k" /* BUTTON */], this.props, __WEBPACK_IMPORTED_MODULE_6__docs_json___default.a); + } + }, { + key: "render", + value: function render() { + return this.props.tooltip ? this.renderTooltip() : this.renderButton(); + } + }]); + + return Button; +}(__WEBPACK_IMPORTED_MODULE_0_react___default.a.Component); + +_defineProperty(Button, "displayName", __WEBPACK_IMPORTED_MODULE_9__utilities_constants__["k" /* BUTTON */]); + +_defineProperty(Button, "propTypes", { + /** + * **Assistive text for accessibility.** + * This object is merged with the default props object on every render. + * * `icon`: Text that is visually hidden but read aloud by screenreaders to tell the user what the icon means. If the button has an icon and a visible label, you can omit the assistiveText.icon prop and use the label prop. + */ + assistiveText: __WEBPACK_IMPORTED_MODULE_2_prop_types___default.a.shape({ + icon: __WEBPACK_IMPORTED_MODULE_2_prop_types___default.a.string + }), + + /** + * Callback that passes in the DOM reference of the `\n\t\t);\n\t};\n\n\t// This is present for backwards compatibility and should be removed at a future breaking change release. Please wrap a `Button` in a `PopoverTooltip` to achieve the same result. There will be an extra trigger `div` wrapping the `Button` though.\n\trenderTooltip = () => (\n\t\t{this.renderButton}\n\t);\n\n\trender() {\n\t\treturn this.props.tooltip ? this.renderTooltip() : this.renderButton();\n\t}\n}\n\nexport default Button;\n\n\n\n// WEBPACK FOOTER //\n// ./components/button/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n/* eslint-disable import/no-mutable-exports */\n\nlet getComponentDocFn = function() {};\n\nconst baseURL = 'https://react.lightningdesignsystem.com';\n\nif (process.env.NODE_ENV !== 'production') {\n\tgetComponentDocFn = function(jsonDoc) {\n\t\tconst componentUrl = `${baseURL +\n\t\t\t(jsonDoc && jsonDoc['url-slug']\n\t\t\t\t? `/components/${jsonDoc['url-slug']}`\n\t\t\t\t: '')}`;\n\t\treturn (propName) =>\n\t\t\t`Please check the current documentation at: ${\n\t\t\t\tpropName ? `${componentUrl}#prop-${propName}` : componentUrl\n\t\t\t}`;\n\t};\n}\n\nexport default getComponentDocFn;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/get-component-doc.js","'use strict';\nmodule.exports = require('./lib/index');\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/shortid/index.js\n// module id = 6\n// module chunks = 0","const keys = {\n\tENTER: 13,\n\tESCAPE: 27,\n\tSPACE: 32,\n\tLEFT: 37,\n\tUP: 38,\n\tRIGHT: 39,\n\tDOWN: 40,\n\tTAB: 9,\n\tDELETE: 46,\n\tBACKSPACE: 8,\n};\n\n// Helpful for interaction/event tests. Use with simulate:\n// `nodes.input.simulate('keyDown', keyObjects.DOWN);`\nconst keyObjects = {\n\tENTER: { key: 'Enter', keyCode: keys.ENTER, which: keys.ENTER },\n\tESCAPE: { key: 'Escape', keyCode: keys.ESCAPE, which: keys.ESCAPE },\n\tSPACE: { key: 'Space', keyCode: keys.SPACE, which: keys.SPACE },\n\tLEFT: { key: 'Left', keyCode: keys.LEFT, which: keys.LEFT },\n\tUP: { key: 'Up', keyCode: keys.UP, which: keys.ESCAPE },\n\tRIGHT: { key: 'Right', keyCode: keys.RIGHT, which: keys.RIGHT },\n\tDOWN: { key: 'Down', keyCode: keys.DOWN, which: keys.DOWN },\n\tTAB: { key: 'Tab', keyCode: keys.TAB, which: keys.TAB },\n\tDELETE: { key: 'Delete', keyCode: keys.DELETE, which: keys.DELETE },\n\tBACKSPACE: {\n\t\tkey: 'Backspace',\n\t\tkeyCode: keys.BACKSPACE,\n\t\twhich: keys.BACKSPACE,\n\t},\n};\n\nexport default keys;\nexport { keyObjects };\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/key-code.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nconst EventUtil = {\n\ttrapEvent: (event) => {\n\t\tif (!event) return;\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\t\tif (event.nativeEvent && event.nativeEvent.preventDefault) {\n\t\t\tevent.nativeEvent.preventDefault();\n\t\t}\n\n\t\tif (event.nativeEvent && event.nativeEvent.stopPropagation) {\n\t\t\tevent.nativeEvent.stopPropagation();\n\t\t}\n\t},\n\n\ttrap: (event) => EventUtil.trapEvent(event),\n\n\ttrapImmediate: (event) => {\n\t\tif (event.stopImmediatePropagation) {\n\t\t\tevent.stopImmediatePropagation();\n\t\t}\n\n\t\tif (event.nativeEvent && event.nativeEvent.stopImmediatePropagation) {\n\t\t\tevent.nativeEvent.stopImmediatePropagation();\n\t\t}\n\n\t\tEventUtil.trap(event);\n\t},\n};\n\nexport default EventUtil;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/event.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Icon Component\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nimport checkProps from './check-props';\nimport componentDoc from './docs.json';\n\n// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames)\n// A simple javascript utility for conditionally joining classNames together.\nimport classNames from '../../utilities/class-names';\n\n// ## Children\nimport UtilityIcon from '../utilities/utility-icon';\n\nimport { ICON } from '../../utilities/constants';\n\nconst defaultProps = {\n\tassistiveText: {},\n\tcategory: 'standard',\n\tcolorVariant: 'default',\n\tsize: 'medium',\n};\n\n/**\n * The Icon component is the Lightning Design System Icon component and should be used for naked icons. For icons that are buttons, use the Button component component with variant='icon'.\n */\nconst Icon = (props) => {\n\tcheckProps(ICON, props, componentDoc);\n\tconst {\n\t\tcategory,\n\t\tclassName,\n\t\tcolorVariant,\n\t\tcontainerClassName,\n\t\ticon,\n\t\tinverse,\n\t\tname,\n\t\tpath,\n\t\tsize,\n\t\tstyle,\n\t\ttitle,\n\t} = props;\n\tconst assistiveText =\n\t\ttypeof props.assistiveText === 'string'\n\t\t\t? props.assistiveText\n\t\t\t: {\n\t\t\t\t\t...defaultProps.assistiveText,\n\t\t\t\t\t...props.assistiveText,\n\t\t\t\t}.label;\n\n\tconst kababCaseName = name ? name.replace(/_/g, '-') : '';\n\n\treturn (\n\t\t\n\t\t\t\n\t\t\t{assistiveText ? (\n\t\t\t\t{assistiveText}\n\t\t\t) : (\n\t\t\t\t''\n\t\t\t)}\n\t\t\n\t);\n};\n\n// ### Display Name\n// Always use the canonical component name as the React display name.\nIcon.displayName = ICON;\n\n// ### Prop Types\nIcon.propTypes = {\n\t/**\n\t * **Assistive text for accessibility.**\n\t * This object is merged with the default props object on every render.\n\t * * `label`: Text that is visually hidden but read aloud by screenreaders to tell the user what the icon means. Naked icons must have assistive text, however, if you also have visible descriptive text with the icon, declare this prop as assistiveText=''.\n\t */\n\tassistiveText: PropTypes.shape({\n\t\tlabel: PropTypes.string,\n\t}),\n\t/**\n\t * Icon category from [lightningdesignsystem.com/icons/](https://www.lightningdesignsystem.com/icons/)\n\t */\n\tcategory: PropTypes.oneOf([\n\t\t'action',\n\t\t'custom',\n\t\t'doctype',\n\t\t'standard',\n\t\t'utility',\n\t]).isRequired,\n\t/**\n\t * CSS classes that are applied to the SVG.\n\t */\n\tclassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * CSS classes that are applied to the span.\n\t */\n\tcontainerClassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * Icon color variants\n\t */\n\tcolorVariant: PropTypes.oneOf([\n\t\t'base',\n\t\t'default',\n\t\t'error',\n\t\t'light',\n\t\t'warning',\n\t]),\n\t/**\n\t * A custom SVG object to use instead of the supplied SLDS icons, look in `design-system-react/icons` for examples and syntax.\n\t */\n\ticon: PropTypes.object,\n\t/**\n\t * Setting `inverse` to true will switch the color of the icon: light to dark, dark to light.\n\t */\n\tinverse: PropTypes.bool,\n\t/**\n\t * Name of the icon. Visit Lightning Design System Icons to reference icon names.\n\t */\n\tname: PropTypes.string,\n\t/**\n\t * Path to the icon. This will override any global icon settings\n\t */\n\tpath: PropTypes.string,\n\t/**\n\t * Size of the icon. Visit [lightningdesignsystem.com/components/icons/#flavor-sizes](https://www.lightningdesignsystem.com/components/icons/#flavor-sizes)\n\t */\n\tsize: PropTypes.oneOf(['xx-small', 'x-small', 'small', 'medium', 'large']),\n\t/**\n\t * Custom styles to be passed to the SVG. Could be used to change icon or background color.\n\t */\n\tstyle: PropTypes.object,\n\t/**\n\t * Title attribute for the icon container\n\t */\n\ttitle: PropTypes.string,\n};\n\nIcon.defaultProps = defaultProps;\n\nexport default Icon;\n\n\n\n// WEBPACK FOOTER //\n// ./components/icon/index.jsx","/**\n * lodash (Custom Build) \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]';\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/**\n * A faster alternative to `Function#apply`, this function invokes `func`\n * with the `this` binding of `thisArg` and the arguments of `args`.\n *\n * @private\n * @param {Function} func The function to invoke.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} args The arguments to invoke `func` with.\n * @returns {*} Returns the result of `func`.\n */\nfunction apply(func, thisArg, args) {\n switch (args.length) {\n case 0: return func.call(thisArg);\n case 1: return func.call(thisArg, args[0]);\n case 2: return func.call(thisArg, args[0], args[1]);\n case 3: return func.call(thisArg, args[0], args[1], args[2]);\n }\n return func.apply(thisArg, args);\n}\n\n/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\n/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeKeys = overArg(Object.keys, Object),\n nativeMax = Math.max;\n\n/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */\nvar nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n // Safari 8.1 makes `arguments.callee` enumerable in strict mode.\n // Safari 9 makes `arguments.length` enumerable in strict mode.\n var result = (isArray(value) || isArguments(value))\n ? baseTimes(value.length, String)\n : [];\n\n var length = result.length,\n skipIndexes = !!length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (key == 'length' || isIndex(key, length)))) {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * Assigns `value` to `key` of `object` if the existing value is not equivalent\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction assignValue(object, key, value) {\n var objValue = object[key];\n if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||\n (value === undefined && !(key in object))) {\n object[key] = value;\n }\n}\n\n/**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * The base implementation of `_.rest` which doesn't validate or coerce arguments.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n */\nfunction baseRest(func, start) {\n start = nativeMax(start === undefined ? (func.length - 1) : start, 0);\n return function() {\n var args = arguments,\n index = -1,\n length = nativeMax(args.length - start, 0),\n array = Array(length);\n\n while (++index < length) {\n array[index] = args[start + index];\n }\n index = -1;\n var otherArgs = Array(start + 1);\n while (++index < start) {\n otherArgs[index] = args[index];\n }\n otherArgs[start] = array;\n return apply(func, this, otherArgs);\n };\n}\n\n/**\n * Copies properties of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy properties from.\n * @param {Array} props The property identifiers to copy.\n * @param {Object} [object={}] The object to copy properties to.\n * @param {Function} [customizer] The function to customize copied values.\n * @returns {Object} Returns `object`.\n */\nfunction copyObject(source, props, object, customizer) {\n object || (object = {});\n\n var index = -1,\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n\n var newValue = customizer\n ? customizer(object[key], source[key], key, object, source)\n : undefined;\n\n assignValue(object, key, newValue === undefined ? source[key] : newValue);\n }\n return object;\n}\n\n/**\n * Creates a function like `_.assign`.\n *\n * @private\n * @param {Function} assigner The function to assign values.\n * @returns {Function} Returns the new assigner function.\n */\nfunction createAssigner(assigner) {\n return baseRest(function(object, sources) {\n var index = -1,\n length = sources.length,\n customizer = length > 1 ? sources[length - 1] : undefined,\n guard = length > 2 ? sources[2] : undefined;\n\n customizer = (assigner.length > 3 && typeof customizer == 'function')\n ? (length--, customizer)\n : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n customizer = length < 3 ? undefined : customizer;\n length = 1;\n }\n object = Object(object);\n while (++index < length) {\n var source = sources[index];\n if (source) {\n assigner(object, source, index, customizer);\n }\n }\n return object;\n });\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nfunction isArguments(value) {\n // Safari 8.1 makes `arguments.callee` enumerable in strict mode.\n return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&\n (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);\n}\n\n/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * This method is like `_.isArrayLike` except that it also checks if `value`\n * is an object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array-like object,\n * else `false`.\n * @example\n *\n * _.isArrayLikeObject([1, 2, 3]);\n * // => true\n *\n * _.isArrayLikeObject(document.body.children);\n * // => true\n *\n * _.isArrayLikeObject('abc');\n * // => false\n *\n * _.isArrayLikeObject(_.noop);\n * // => false\n */\nfunction isArrayLikeObject(value) {\n return isObjectLike(value) && isArrayLike(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Assigns own enumerable string keyed properties of source objects to the\n * destination object. Source objects are applied from left to right.\n * Subsequent sources overwrite property assignments of previous sources.\n *\n * **Note:** This method mutates `object` and is loosely based on\n * [`Object.assign`](https://mdn.io/Object/assign).\n *\n * @static\n * @memberOf _\n * @since 0.10.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @see _.assignIn\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * function Bar() {\n * this.c = 3;\n * }\n *\n * Foo.prototype.b = 2;\n * Bar.prototype.d = 4;\n *\n * _.assign({ 'a': 0 }, new Foo, new Bar);\n * // => { 'a': 1, 'c': 3 }\n */\nvar assign = createAssigner(function(object, source) {\n if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {\n copyObject(source, keys(source), object);\n return;\n }\n for (var key in source) {\n if (hasOwnProperty.call(source, key)) {\n assignValue(object, key, source[key]);\n }\n }\n});\n\n/**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\nfunction keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n}\n\nmodule.exports = assign;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/lodash.assign/index.js\n// module id = 10\n// module chunks = 0","/**\n * Lodash (Custom Build) \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright JS Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** `Object#toString` result references. */\nvar asyncTag = '[object AsyncFunction]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n nullTag = '[object Null]',\n proxyTag = '[object Proxy]',\n undefinedTag = '[object Undefined]';\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar Symbol = root.Symbol,\n symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nmodule.exports = isFunction;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/lodash.isfunction/index.js\n// module id = 11\n// module chunks = 0","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n/* eslint-disable import/no-mutable-exports */\n\n// This function will deliver an error message to the browser console about the removal of a property.\nimport warning from 'warning';\n\nlet sunset = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\tconst hasWarned = {};\n\n\tsunset = function(control, propValue, oldProp, comment) {\n\t\tconst additionalComment = comment ? ` ${comment}` : '';\n\t\tif (!hasWarned[control + oldProp]) {\n\t\t\t/* eslint-disable max-len */\n\t\t\twarning(\n\t\t\t\t!propValue,\n\t\t\t\t`[Design System React] \\`${oldProp}\\` has reached End-of-Life and has been removed from the API of ${control}. Please update your API.${additionalComment}`\n\t\t\t);\n\t\t\t/* eslint-enable max-len */\n\t\t\thasWarned[control + oldProp] = !!propValue;\n\t\t}\n\t};\n}\n\nexport default sunset;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/warning/sunset-property.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n/* eslint-disable import/no-mutable-exports */\n\n// This function will deliver an error message to the browser console about the removal of a property.\nimport warning from 'warning';\n\nlet deprecated = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\tconst hasWarned = {};\n\n\tdeprecated = function(control, propValue, oldProp, newProp, comment) {\n\t\tconst additionalComment = comment ? ` ${comment}` : '';\n\t\tconst newProperty = newProp ? `Use \\`${newProp}\\`` : '';\n\t\tconst newPropertySentence = newProp ? ` ${newProperty} instead.` : '';\n\t\tif (!hasWarned[control + oldProp]) {\n\t\t\t/* eslint-disable max-len */\n\t\t\twarning(\n\t\t\t\tpropValue === undefined,\n\t\t\t\t`[Design System React] \\`${oldProp}\\` will be removed in the next major version of ${control}.${newPropertySentence}${additionalComment}`\n\t\t\t);\n\t\t\t/* eslint-enable max-len */\n\t\t\thasWarned[control + oldProp] = propValue !== undefined;\n\t\t}\n\t};\n}\n\nexport default deprecated;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/warning/deprecated-property.js","/**\n * Copyright 2014-2015, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n'use strict';\n\n/**\n * Similar to invariant but only logs a warning if the condition is not met.\n * This can be used to log issues in development environments in critical\n * paths. Removing the logging code for production environments will keep the\n * same logic and follow the same code paths.\n */\n\nvar warning = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n warning = function(condition, format, args) {\n var len = arguments.length;\n args = new Array(len > 2 ? len - 2 : 0);\n for (var key = 2; key < len; key++) {\n args[key - 2] = arguments[key];\n }\n if (format === undefined) {\n throw new Error(\n '`warning(condition, format, ...args)` requires a warning ' +\n 'message argument'\n );\n }\n\n if (format.length < 10 || (/^[s\\W]*$/).test(format)) {\n throw new Error(\n 'The warning format should be able to uniquely identify this ' +\n 'warning. Please, use a more descriptive format than: ' + format\n );\n }\n\n if (!condition) {\n var argIndex = 0;\n var message = 'Warning: ' +\n format.replace(/%s/g, function() {\n return args[argIndex++];\n });\n if (typeof console !== 'undefined') {\n console.error(message);\n }\n try {\n // This error was thrown as a convenience so that you can use this stack\n // to find the callsite that caused this warning to fire.\n throw new Error(message);\n } catch(x) {}\n }\n };\n}\n\nmodule.exports = warning;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/warning/browser.js\n// module id = 14\n// module chunks = 0","/* eslint-disable max-lines */\n/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Input Component\n\n// Implements the [Input design pattern](https://lightningdesignsystem.com/components/forms/#flavor-input) in React. Does not yet implement [fixed text](https://lightningdesignsystem.com/components/forms/#flavor-input-input-fixed-text).\n// Based on SLDS v2.2.1\n//\n\n// ### React\nimport React from 'react';\n\nimport PropTypes from 'prop-types';\n\n// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames)\n// This project uses `classnames`, \"a simple javascript utility for conditionally\n// joining classNames together.\"\nimport classNames from 'classnames';\n\n// ### shortid\n// [npmjs.com/package/shortid](https://www.npmjs.com/package/shortid)\n// shortid is a short, non-sequential, url-friendly, unique id generator\nimport shortid from 'shortid';\n\nimport Button from '../button';\n\n// ## Children\nimport InputIcon from '../icon/input-icon';\nimport InnerInput from './private/inner-input';\nimport Label from '../utilities/label';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode (similar to React's built in development tools)\nimport checkProps from './check-props';\n\nimport { INPUT } from '../../utilities/constants';\nimport componentDoc from './docs.json';\nimport FieldLevelHelpTooltip from '../tooltip/private/field-level-help-tooltip';\n\nconst COUNTER = 'counter';\nconst DECREMENT = 'Decrement';\nconst INCREMENT = 'Increment';\n\nconst defaultProps = {\n\tassistiveText: {\n\t\tdecrement: `${DECREMENT} ${COUNTER}`,\n\t\tincrement: `${INCREMENT} ${COUNTER}`,\n\t},\n\ttype: 'text',\n};\n\n/**\n * The HTML `input` with a label and error messaging.\n */\nclass Input extends React.Component {\n\tstatic displayName = INPUT;\n\n\tstatic propTypes = {\n\t\t/**\n\t\t * The aria-activedescendant attribute contains the ID of the currently active child object that is part of a composite widget within the Document Object Model. It makes do with the overhead of having all or more than one child focusable. As the name specifies, it helps in managing the current active child of the composite widget.\n\t\t */\n\t\t'aria-activedescendant': PropTypes.string,\n\t\t/**\n\t\t * Indicates if the suggestions in a composite widget are values that complete the current textbox input.\n\t\t */\n\t\t'aria-autocomplete': PropTypes.string,\n\t\t/**\n\t\t * An HTML ID that is shared with ARIA-supported devices with the\n\t\t * `aria-controls` attribute in order to relate the input with\n\t\t * another region of the page. An example would be a select box\n\t\t * that shows or hides a panel.\n\t\t */\n\t\t'aria-controls': PropTypes.string,\n\t\t/**\n\t\t * The `aria-describedby` attribute is used to indicate the IDs of the elements that describe the object. It is used to establish a relationship between widgets or groups and text that described them. This is very similar to aria-labelledby: a label describes the essence of an object, while a description provides more information that the user might need.\n\t\t */\n\t\t'aria-describedby': PropTypes.string,\n\t\t/**\n\t\t * Use the `aria-expanded` state to indicate whether regions of the content are collapsible, and to expose whether a region is currently expanded or collapsed.\n\t\t */\n\t\t'aria-expanded': PropTypes.bool,\n\t\t/**\n\t\t * Indicates that the element has a popup context menu or sub-level menu.\n\t\t */\n\t\t'aria-haspopup': PropTypes.bool,\n\t\t/**\n\t\t * The aria-labelledby attribute contains the element IDs of labels in objects such as input elements, widgets, and groups. The attribute establishes relationships between objects and their labels. Assistive technology, such as screen readers, use this attribute to catalog the objects in a document so that users can navigate between them. Without an element ID, the assistive technology cannot catalog the object.\n\t\t */\n\t\t'aria-labelledby': PropTypes.string,\n\t\t/**\n\t\t * An HTML ID that is shared with ARIA-supported devices with the\n\t\t * `aria-controls` attribute in order to relate the input with\n\t\t * another region of the page. An example would be a search field\n\t\t * that shows search results.\n\t\t */\n\t\t'aria-owns': PropTypes.string,\n\t\t/**\n\t\t * The `aria-required` attribute is used to indicate that user input is required on an element before a form can be submitted.\n\t\t */\n\t\t'aria-required': PropTypes.bool,\n\t\t/**\n\t\t * **Assistive text for accessibility**\n\t\t * * `label`: Visually hidden label but read out loud by screen readers.\n\t\t * * `spinner`: Text for loading spinner icon.\n\t\t */\n\t\tassistiveText: PropTypes.shape({\n\t\t\tlabel: PropTypes.string,\n\t\t\tspinner: PropTypes.string,\n\t\t}),\n\t\t/**\n\t\t * Disabled brower's autocomplete when \"off\" is used.\n\t\t */\n\t\tautoComplete: PropTypes.string,\n\t\t/**\n\t\t * Elements are added after the `input`.\n\t\t */\n\t\tchildren: PropTypes.node,\n\t\t/**\n\t\t * Class names to be added to the outer container of the input.\n\t\t */\n\t\tclassName: PropTypes.oneOfType([\n\t\t\tPropTypes.array,\n\t\t\tPropTypes.object,\n\t\t\tPropTypes.string,\n\t\t]),\n\t\t/**\n\t\t * This is the initial value of an uncontrolled form element and\n\t\t * is present only to provide compatibility with hybrid framework\n\t\t * applications that are not entirely React. It should only be used\n\t\t * in an application without centralized state (Redux, Flux).\n\t\t * \"Controlled components\" with centralized state is highly recommended.\n\t\t * See [Code Overview](https://github.com/salesforce/design-system-react/blob/master/docs/codebase-overview.md#controlled-and-uncontrolled-components) for more information.\n\t\t */\n\t\tdefaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n\t\t/**\n\t\t * Disables the input and prevents editing the contents.\n\t\t */\n\t\tdisabled: PropTypes.bool,\n\t\t/**\n\t\t * Message to display when the input is in an error state. When this is present, also visually highlights the component as in error.\n\t\t */\n\t\terrorText: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),\n\t\t/**\n\t\t * A [Tooltip](https://react.lightningdesignsystem.com/components/tooltips/) component that is displayed next to the label.\n\t\t */\n\t\tfieldLevelHelpTooltip: PropTypes.node,\n\t\t/**\n\t\t * Displays text or node to the left of the input. This follows the fixed text input UX pattern.\n\t\t */\n\t\tfixedTextLeft: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),\n\t\t/**\n\t\t * Displays text or node to the right of the input. This follows the fixed text input UX pattern.\n\t\t */\n\t\tfixedTextRight: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),\n\t\t/**\n\t\t * If true, loading spinner appears inside input on right hand side.\n\t\t */\n\t\thasSpinner: PropTypes.bool,\n\t\t/**\n\t\t * Left aligned icon, must be instace of `design-system-react/components/icon/input-icon`\n\t\t */\n\t\ticonLeft: PropTypes.node,\n\t\t/**\n\t\t * Right aligned icon, must be instace of `design-system-react/components/icon/input-icon`\n\t\t */\n\t\ticonRight: PropTypes.node,\n\t\t/**\n\t\t * Every input must have a unique ID in order to support keyboard navigation and ARIA support.\n\t\t */\n\t\tid: PropTypes.string,\n\t\t/**\n\t\t * Displays help text under the input.\n\t\t */\n\t\tinlineHelpText: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),\n\t\t/**\n\t\t * This callback exposes the input reference / DOM node to parent components. ` this.input = inputComponent} />\n\t\t */\n\t\tinputRef: PropTypes.func,\n\t\t/**\n\t\t * Displays the value of the input statically. This follows the static input UX pattern.\n\t\t */\n\t\tisStatic: PropTypes.bool,\n\t\t/**\n\t\t * This label appears above the input.\n\t\t */\n\t\tlabel: PropTypes.string,\n\t\t/**\n\t\t * Triggered when focus is removed.\n\t\t */\n\t\tonBlur: PropTypes.func,\n\t\t/**\n\t\t * This callback fires when the input changes. Passes in `event, { value }`.\n\t\t */\n\t\tonChange: PropTypes.func,\n\t\t/**\n\t\t * This event fires when the input is clicked.\n\t\t */\n\t\tonClick: PropTypes.func,\n\t\t/**\n\t\t * Triggered when component is focused.\n\t\t */\n\t\tonFocus: PropTypes.func,\n\t\t/**\n\t\t * Similar to `onchange`. Triggered when an element gets user input.\n\t\t */\n\t\tonInput: PropTypes.func,\n\t\t/**\n\t\t * Triggered when a submittable `` element is invalid.\n\t\t */\n\t\tonInvalid: PropTypes.func,\n\t\t/**\n\t\t * Triggered when a key is pressed down\n\t\t */\n\t\tonKeyDown: PropTypes.func,\n\t\t/**\n\t\t * Triggered when a key is pressed and released\n\t\t */\n\t\tonKeyPress: PropTypes.func,\n\t\t/**\n\t\t * Triggered when a key is released\n\t\t */\n\t\tonKeyUp: PropTypes.func,\n\t\t/**\n\t\t * Triggered after some text has been selected in an element.\n\t\t */\n\t\tonSelect: PropTypes.func,\n\t\t/**\n\t\t * Fires when a form is submitted.\n\t\t */\n\t\tonSubmit: PropTypes.func,\n\t\t/**\n\t\t * Text that will appear in an empty input.\n\t\t */\n\t\tplaceholder: PropTypes.string,\n\t\t/**\n\t\t * Sets the minimum number of characters that an `` can accept.\n\t\t */\n\t\tminLength: PropTypes.string,\n\t\t/**\n\t\t * Specifies minimum accepted value for a counter input\n\t\t */\n\t\tminValue: PropTypes.number,\n\t\t/**\n\t\t * Sets the maximum number of characters that an `` can accept.\n\t\t */\n\t\tmaxLength: PropTypes.string,\n\t\t/**\n\t\t * Specifies maximum accepted value for a counter input\n\t\t */\n\t\tmaxValue: PropTypes.number,\n\t\t/**\n\t\t * Name of the submitted form parameter.\n\t\t */\n\t\tname: PropTypes.string,\n\t\t/**\n\t\t * Displays the value of the input as read-only. This is used in the inline edit UX pattern.\n\t\t */\n\t\treadOnly: PropTypes.bool,\n\t\t/**\n\t\t * Highlights the input as a required field (does not perform any validation).\n\t\t */\n\t\trequired: PropTypes.bool,\n\t\t/**\n\t\t * ARIA role\n\t\t */\n\t\trole: PropTypes.string,\n\t\t/**\n\t\t * Determines the step size upon increment or decrement. Can be set to decimal values.\n\t\t */\n\t\tstep: PropTypes.number,\n\t\t/**\n\t\t * styles to be added to input\n\t\t */\n\t\tstyleInput: PropTypes.object,\n\t\t/**\n\t\t * Custom styles to be passed to the component container\n\t\t */\n\t\tstyleContainer: PropTypes.object,\n\t\t/**\n\t\t * The `` element includes support for all HTML5 types.\n\t\t */\n\t\ttype: PropTypes.oneOf([\n\t\t\t'text',\n\t\t\t'password',\n\t\t\t'datetime',\n\t\t\t'datetime-local',\n\t\t\t'date',\n\t\t\t'month',\n\t\t\t'time',\n\t\t\t'week',\n\t\t\t'number',\n\t\t\t'email',\n\t\t\t'url',\n\t\t\t'search',\n\t\t\t'tel',\n\t\t\t'color',\n\t\t]),\n\t\t/**\n\t\t * The input is a controlled component, and will always display this value.\n\t\t */\n\t\tvalue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n\t\t/**\n\t\t * Which UX pattern of input? The default is `base` while other option is `counter`\n\t\t */\n\t\tvariant: PropTypes.oneOf(['base', COUNTER]),\n\t};\n\n\tstatic defaultProps = defaultProps;\n\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.inputRef = null;\n\t\tthis.stepping = {\n\t\t\tcurrentDelay: 500,\n\t\t\tinitialDelay: 500,\n\t\t\tspeedDelay: 75,\n\t\t\ttimeout: {},\n\t\t};\n\t}\n\n\tcomponentWillMount() {\n\t\t// `checkProps` issues warnings to developers about properties (similar to React's built in development tools)\n\t\tcheckProps(INPUT, this.props, componentDoc);\n\n\t\tthis.generatedId = shortid.generate();\n\t\tif (this.props.errorText) {\n\t\t\tthis.generatedErrorId = shortid.generate();\n\t\t}\n\t}\n\n\tgetId = () => this.props.id || this.generatedId;\n\n\tgetErrorId = () => this.props['aria-describedby'] || this.generatedErrorId;\n\n\tgetValueAsNumber = () => {\n\t\tlet value = 0;\n\n\t\tif (this.props.value !== undefined) {\n\t\t\tvalue = Number(this.props.value);\n\t\t} else if (this.inputRef) {\n\t\t\tvalue = Number(this.inputRef.value);\n\t\t}\n\n\t\treturn value;\n\t};\n\n\tgetCounterButtonIcon = (direction) => {\n\t\tconst value = this.getValueAsNumber();\n\t\tlet disabled = false;\n\n\t\tif (\n\t\t\tthis.props.disabled ||\n\t\t\t(direction === INCREMENT &&\n\t\t\t\tthis.props.maxValue !== undefined &&\n\t\t\t\tvalue >= this.props.maxValue) ||\n\t\t\t(direction === DECREMENT &&\n\t\t\t\tthis.props.minValue !== undefined &&\n\t\t\t\tvalue <= this.props.minValue)\n\t\t) {\n\t\t\tdisabled = true;\n\t\t}\n\n\t\treturn (\n\t\t\t {\n\t\t\t\t\tif (event.keyCode === 13) {\n\t\t\t\t\t\tthis.performStep(direction, event);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tonKeyUp={this.stopStepping}\n\t\t\t\tonMouseDown={(event) => {\n\t\t\t\t\tthis.performStep(direction, event);\n\t\t\t\t}}\n\t\t\t\tonMouseLeave={this.stopStepping}\n\t\t\t\tonMouseUp={this.stopStepping}\n\t\t\t\tvariant=\"icon\"\n\t\t\t/>\n\t\t);\n\t};\n\n\t// This is convoluted to maintain backwards compatibility. Please remove deprecatedProps on next breaking change.\n\tgetIconRender = (position, iconPositionProp) => {\n\t\tlet icon;\n\n\t\t// Remove at next breaking change\n\t\t/* eslint-disable react/prop-types */\n\t\tconst deprecatedProps = {\n\t\t\tassistiveText: {\n\t\t\t\ticon:\n\t\t\t\t\t(this.props[iconPositionProp] &&\n\t\t\t\t\t\tthis.props[iconPositionProp].props.assistiveText) ||\n\t\t\t\t\tthis.props.iconAssistiveText,\n\t\t\t},\n\t\t\tcategory:\n\t\t\t\t(this.props[iconPositionProp] &&\n\t\t\t\t\tthis.props[iconPositionProp].props.category) ||\n\t\t\t\tthis.props.iconCategory,\n\t\t\tname:\n\t\t\t\t(this.props[iconPositionProp] &&\n\t\t\t\t\tthis.props[iconPositionProp].props.name) ||\n\t\t\t\tthis.props.iconName,\n\t\t\tonClick:\n\t\t\t\t(this.props[iconPositionProp] &&\n\t\t\t\t\tthis.props[iconPositionProp].props.onClick) ||\n\t\t\t\tthis.props.onIconClick,\n\t\t};\n\t\t/* eslint-enable react/prop-types */\n\n\t\tif (\n\t\t\tthis.props[iconPositionProp] &&\n\t\t\tposition &&\n\t\t\tthis.props[iconPositionProp]\n\t\t) {\n\t\t\ticon = React.cloneElement(this.props[iconPositionProp], {\n\t\t\t\ticonPosition: `${position}`,\n\t\t\t});\n\t\t} else if (deprecatedProps.name) {\n\t\t\ticon = ;\n\t\t}\n\n\t\treturn icon;\n\t};\n\n\tsetInputRef = (ref) => {\n\t\tthis.inputRef = ref;\n\t\tif (this.props.inputRef) {\n\t\t\tthis.props.inputRef(ref);\n\t\t}\n\t};\n\n\thandleChange = (event) => {\n\t\tif (this.props.onChange) {\n\t\t\tconst data = {\n\t\t\t\tvalue: event.target.value,\n\t\t\t};\n\n\t\t\tif (this.props.variant === COUNTER) {\n\t\t\t\tdata.number = Number(data.value);\n\t\t\t}\n\n\t\t\tthis.props.onChange(event, data);\n\t\t}\n\t};\n\n\tperformStep = (direction, event) => {\n\t\tclearTimeout(this.stepping.timeout);\n\n\t\tconst maxValue = this.props.maxValue;\n\t\tconst minValue = this.props.minValue;\n\t\tconst step = this.props.step !== undefined ? Number(this.props.step) : 1;\n\t\tlet value = this.getValueAsNumber();\n\t\tlet valueChanged = false;\n\n\t\tif (direction === DECREMENT && maxValue !== undefined && value > maxValue) {\n\t\t\tvalue = Number(maxValue);\n\t\t\tvalueChanged = true;\n\t\t} else if (\n\t\t\tdirection === INCREMENT &&\n\t\t\tminValue !== undefined &&\n\t\t\tvalue < minValue\n\t\t) {\n\t\t\tvalue = Number(minValue);\n\t\t\tvalueChanged = true;\n\t\t} else {\n\t\t\tconst decimalPlaces =\n\t\t\t\tString(step).search(/\\./) >= 0 ? String(step).split('.')[1].length : 0;\n\t\t\tlet minOverflow = 0;\n\n\t\t\tif (minValue !== undefined) {\n\t\t\t\tminOverflow = (value - minValue) % step;\n\t\t\t}\n\n\t\t\tif (minOverflow > 0) {\n\t\t\t\t// Default browser inputs of type number with a min attribute alter the value upon change as needed so\n\t\t\t\t// that with enough decrements it can reach the exact min value. This behavior is reflected here\n\t\t\t\tvalue =\n\t\t\t\t\tdirection === DECREMENT\n\t\t\t\t\t\t? value - minOverflow\n\t\t\t\t\t\t: value + (step - minOverflow);\n\t\t\t} else {\n\t\t\t\tvalue = direction === DECREMENT ? value - step : value + step;\n\t\t\t}\n\n\t\t\tvalue = Number(value.toFixed(decimalPlaces));\n\n\t\t\tif (\n\t\t\t\t!(maxValue !== undefined && value > maxValue) &&\n\t\t\t\t!(minValue !== undefined && value < minValue)\n\t\t\t) {\n\t\t\t\tvalueChanged = true;\n\t\t\t}\n\t\t}\n\n\t\tif (valueChanged) {\n\t\t\t/*\n\t\t\t* Use of `this.forceUpdate` is an anti-pattern. This code only executes if this `input` element is uncontrolled which this library believes is an anti-pattern, also. This code is only present to allow for the edge case of uncontrolled use of an `input`.\n\t\t\t*/\n\t\t\tif (this.props.value === undefined && this.inputRef) {\n\t\t\t\tthis.inputRef.value = String(value);\n\t\t\t\tthis.forceUpdate();\n\t\t\t} else if (this.props.onChange) {\n\t\t\t\tthis.props.onChange(event, {\n\t\t\t\t\tnumber: value,\n\t\t\t\t\tvalue: String(value),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\t(direction === INCREMENT &&\n\t\t\t\tmaxValue !== undefined &&\n\t\t\t\tvalue >= maxValue) ||\n\t\t\t(direction === DECREMENT && minValue !== undefined && value <= minValue)\n\t\t) {\n\t\t\tthis.stopStepping();\n\t\t} else {\n\t\t\tthis.stepping.timeout = setTimeout(() => {\n\t\t\t\tthis.stepping.currentDelay = this.stepping.speedDelay;\n\t\t\t\tthis.performStep(direction);\n\t\t\t}, this.stepping.currentDelay);\n\t\t}\n\t};\n\n\tstopStepping = () => {\n\t\tclearTimeout(this.stepping.timeout);\n\t\tthis.stepping.currentDelay = this.stepping.initialDelay;\n\t};\n\n\trender() {\n\t\tconst assistiveText = {\n\t\t\t...defaultProps.assistiveText,\n\t\t\t...this.props.assistiveText,\n\t\t};\n\t\tconst inputRef =\n\t\t\tthis.props.variant === COUNTER ? this.setInputRef : this.props.inputRef;\n\t\tlet iconLeft = null;\n\t\tlet iconRight = null;\n\n\t\tconst hasRenderedLabel =\n\t\t\tthis.props.label || (assistiveText && assistiveText.label);\n\n\t\t// Remove at next breaking change\n\t\t// this is a hack to make left the default prop unless overwritten by `iconPosition=\"right\"`\n\t\tif (\n\t\t\t!!this.props.iconLeft ||\n\t\t\t((this.props.iconPosition === 'left' ||\n\t\t\t\tthis.props.iconPosition === undefined) &&\n\t\t\t\t!!this.props.iconName)\n\t\t) {\n\t\t\ticonLeft = this.getIconRender('left', 'iconLeft');\n\t\t} else if (\n\t\t\tthis.props.variant === COUNTER &&\n\t\t\t!this.props.isStatic &&\n\t\t\t!this.props.readOnly\n\t\t) {\n\t\t\ticonLeft = this.getCounterButtonIcon(DECREMENT);\n\t\t}\n\n\t\tif (\n\t\t\t!!this.props.iconRight ||\n\t\t\t(this.props.iconPosition === 'right' && !!this.props.iconName)\n\t\t) {\n\t\t\ticonRight = this.getIconRender('right', 'iconRight');\n\t\t} else if (\n\t\t\tthis.props.variant === COUNTER &&\n\t\t\t!this.props.isStatic &&\n\t\t\t!this.props.readOnly\n\t\t) {\n\t\t\ticonRight = this.getCounterButtonIcon(INCREMENT);\n\t\t}\n\n\t\treturn (\n\t\t\t\n\t\t\t\t\n\t\t\t\t{this.props.fieldLevelHelpTooltip && hasRenderedLabel ? (\n\t\t\t\t\t\n\t\t\t\t) : null}\n\t\t\t\t\n\t\t\t\t{this.props.errorText && (\n\t\t\t\t\t
      \n\t\t\t\t\t\t{this.props.errorText}\n\t\t\t\t\t
      \n\t\t\t\t)}\n\t\t\t\t{this.props.children}\n\t\t\t
    \n\t\t);\n\t}\n}\n\nexport default Input;\n\n\n\n// WEBPACK FOOTER //\n// ./components/input/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### React\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\n// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames)\n// A simple javascript utility for conditionally joining classNames together.\nimport classNames from 'classnames';\n\n// ### isFunction\nimport isFunction from 'lodash.isfunction';\n\n// ## Children\nimport UtilityIcon from '../../utilities/utility-icon';\nimport Button from '../../button';\n\n// ## Constants\nimport { ICON_INPUT } from '../../../utilities/constants';\n\n/**\n * A wrapper for icons that will be rendered inside of an Input\n *\n * If the `onClick` function prop is provided, the `design-system-react/components/button` component is used.\n * If not, the icon will be an instance of `design-system-react/components/utilities/utility-icon`.\n * Checkout out the appropriate component to see what props can be passed along via the `{...props}` rest operator\n */\nconst InputIcon = (props) => {\n\tconst {\n\t\tcategory,\n\t\ticonPosition,\n\t\tname,\n\t\tpath,\n\t\tonClick,\n\t\tvariant,\n\t\t...rest\n\t} = props;\n\n\t// need to pass click event up on SVG\n\n\tconst variants = {\n\t\tcombobox: (\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t),\n\t\tbase: (\n\t\t\t\n\t\t),\n\t};\n\n\treturn isFunction(onClick) ? (\n\t\t\n\t) : (\n\t\tvariants[variant]\n\t);\n};\n\nInputIcon.displayName = ICON_INPUT;\n\nInputIcon.propTypes = {\n\t/**\n\t * Icon category from [lightningdesignsystem.com/icons/](https://www.lightningdesignsystem.com/icons/)\n\t */\n\tcategory: PropTypes.string,\n\t/**\n\t * This is only needed if an input contains two icons, the Input component handles this prop for you.\n\t */\n\ticonPosition: PropTypes.oneOf(['left', 'right']),\n\t/**\n\t * Name of the icon. Visit Lightning Design System Icons to reference icon names.\n\t */\n\tname: PropTypes.string,\n\t/**\n\t * Path to the icon. This will override any global icon settings.\n\t */\n\tpath: PropTypes.string,\n\t/**\n\t * This event fires when the icon is clicked.\n\t */\n\tonClick: PropTypes.func,\n\t/**\n\t * Changes styles of the InputIcon.\n\t */\n\tvariant: PropTypes.oneOf(['base', 'combobox']),\n};\n\nInputIcon.defaultProps = {\n\tcategory: 'utility',\n\tvariant: 'base',\n};\n\nexport default InputIcon;\n\n\n\n// WEBPACK FOOTER //\n// ./components/icon/input-icon/index.jsx","module.exports = __WEBPACK_EXTERNAL_MODULE_17__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"amd\":\"react-dom\",\"commonjs\":\"react-dom\",\"commonjs2\":\"react-dom\",\"root\":\"ReactDOM\"}\n// module id = 17\n// module chunks = 0","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Tooltip\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nimport classNames from 'classnames';\n\n// ### shortid\n// [npmjs.com/package/shortid](https://www.npmjs.com/package/shortid)\n// shortid is a short, non-sequential, url-friendly, unique id generator\nimport shortid from 'shortid';\n\nimport { POPOVER_TOOLTIP } from '../../utilities/constants';\n\nimport Dialog from '../utilities/dialog';\nimport Icon from '../icon';\nimport Button from '../button';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode (similar to React's built in development tools)\nimport checkProps from './check-props';\nimport componentDoc from './docs.json';\n\n// ### Display Name\n// Always use the canonical component name as the React display name.\nconst displayName = POPOVER_TOOLTIP;\n\nconst propTypes = {\n\t/**\n\t * Alignment of the Tooltip relative to the element that triggers it.\n\t */\n\talign: PropTypes.oneOf([\n\t\t'top',\n\t\t'top left',\n\t\t'top right',\n\t\t'right',\n\t\t'right top',\n\t\t'right bottom',\n\t\t'bottom',\n\t\t'bottom left',\n\t\t'bottom right',\n\t\t'left',\n\t\t'left top',\n\t\t'left bottom',\n\t]).isRequired,\n\t/**\n\t * **Assistive text for accessibility**\n\t * This object is merged with the default props object on every render.\n\t * * `tooltipTipLearnMoreIcon`: This text is inside the info icon within the tooltip content and exists to \"complete the sentence\" for assistive tech users.\n\t * * `triggerLearnMoreIcon`: This text is inside the info icon that triggers the tooltip in order to have text within the link.\n\t */\n\tassistiveText: PropTypes.shape({\n\t\ttooltipTipLearnMoreIcon: PropTypes.string,\n\t\ttriggerLearnMoreIcon: PropTypes.string,\n\t}),\n\t/**\n\t * Pass the one element that triggers the Tooltip as a child. It must be an element with `tabIndex` or an element that already has a `tabIndex` set such as an anchor or a button, so that keyboard users can tab to it.\n\t */\n\tchildren: PropTypes.node,\n\t/**\n\t * Content inside Tooltip.\n\t */\n\tcontent: PropTypes.node.isRequired,\n\t/**\n\t * CSS classes to be added to the popover dialog. That is the element with `.slds-popover` on it.\n\t */\n\tdialogClassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * By default, dialogs will flip their alignment (such as bottom to top) if they extend beyond a boundary element such as a scrolling parent or a window/viewpoint. `hasStaticAlignment` disables this behavior and allows this component to extend beyond boundary elements. _Not tested._\n\t */\n\thasStaticAlignment: PropTypes.bool,\n\t/**\n\t * Delay on Tooltip closing.\n\t */\n\thoverCloseDelay: PropTypes.number,\n\t/**\n\t * A unique ID is needed in order to support keyboard navigation, ARIA support, and connect the popover to the triggering element.\n\t */\n\tid: PropTypes.string,\n\t/**\n\t * **Text labels for internationalization**\n\t * This object is merged with the default props object on every render.\n\t * * `learnMoreAfter`: This label appears in the tooltip after the info icon.\n\t * * `learnMoreBefore`: This label appears in the tooltip before the info icon.\n\t */\n\tlabels: PropTypes.shape({\n\t\tlearnMoreAfter: PropTypes.string,\n\t\tlearnMoreBefore: PropTypes.string,\n\t}),\n\t/**\n\t * Forces tooltip to be open. A value of `false` will disable any interaction with the tooltip.\n\t */\n\tisOpen: PropTypes.bool,\n\t/**\n\t * CSS classes to be added to tag with `slds-tooltip-trigger`.\n\t */\n\ttriggerClassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * Please select one of the following:\n\t * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog.\n\t * * `overflowBoundaryElement` - The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree.\n\t * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing.\n\t */\n\tposition: PropTypes.oneOf([\n\t\t'absolute',\n\t\t'overflowBoundaryElement',\n\t\t'relative',\n\t]),\n\t/**\n\t * Custom styles to be added to wrapping triggering `div`.\n\t */\n\ttriggerStyle: PropTypes.object,\n\t/**\n\t * Determines the theme of tooltip: for informative purpose (blue background) or warning purpose (red background). This used to be `variant`.\n\t */\n\ttheme: PropTypes.oneOf(['info', 'error']),\n\t/**\n\t * Determines the type of the tooltip.\n\t */\n\tvariant: PropTypes.oneOf(['base', 'learnMore']),\n};\n\nconst defaultProps = {\n\tassistiveText: {\n\t\ttooltipTipLearnMoreIcon: 'this link',\n\t\ttriggerLearnMoreIcon: 'Help',\n\t},\n\talign: 'top',\n\tcontent: Tooltip,\n\tlabels: {\n\t\tlearnMoreAfter: 'to learn more.',\n\t\tlearnMoreBefore: 'Click',\n\t},\n\thoverCloseDelay: 50,\n\tposition: 'absolute',\n\ttheme: 'info',\n\tvariant: 'base',\n};\n\n/**\n * The PopoverTooltip component is variant of the Lightning Design System Popover component. This component wraps an element that triggers it to open. It must be a focusable child element (either a button or an anchor), so that keyboard users can navigate to it.\n */\nclass Tooltip extends React.Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\n\t\tthis.state = {\n\t\t\tisClosing: false,\n\t\t\tisOpen: false,\n\t\t};\n\t}\n\n\tcomponentWillMount() {\n\t\t// `checkProps` issues warnings to developers about properties (similar to React's built in development tools)\n\t\tcheckProps(POPOVER_TOOLTIP, this.props, componentDoc);\n\n\t\tthis.generatedId = shortid.generate();\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.isUnmounting = true;\n\t}\n\n\tgetContent() {\n\t\tlet children;\n\t\tconst noChildrenProvided = React.Children.count(this.props.children) === 0;\n\n\t\tif (noChildrenProvided && this.props.onClickTrigger) {\n\t\t\tchildren = [\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t,\n\t\t\t];\n\t\t} else if (noChildrenProvided) {\n\t\t\tchildren = [\n\t\t\t\t,\n\t\t\t];\n\t\t} else {\n\t\t\tchildren = this.props.children;\n\t\t}\n\n\t\treturn React.Children.map(children, (child, i) =>\n\t\t\tReact.cloneElement(child, {\n\t\t\t\tkey: i, // eslint-disable-line react/no-array-index-key\n\t\t\t\t'aria-describedby': this.getId(),\n\t\t\t\tonBlur: this.handleMouseLeave,\n\t\t\t\tonFocus: this.handleMouseEnter,\n\t\t\t\tonMouseEnter: this.handleMouseEnter,\n\t\t\t\tonMouseLeave: this.handleMouseLeave,\n\t\t\t})\n\t\t);\n\t}\n\n\tgetId() {\n\t\treturn this.props.id || this.generatedId;\n\t}\n\n\tgetTooltip() {\n\t\tconst isOpen =\n\t\t\tthis.props.isOpen === undefined ? this.state.isOpen : this.props.isOpen;\n\t\tconst align = this.props.align;\n\n\t\t// REMOVE AT NEXT BREAKING CHANGE (v1.0 or v0.9)\n\t\tconst deprecatedWay = this.props.variant === 'error';\n\n\t\treturn isOpen ? (\n\t\t\t this.getTooltipTarget()}\n\t\t\t\tposition={this.props.position}\n\t\t\t\tvariant=\"tooltip\"\n\t\t\t\tcontainerProps={{\n\t\t\t\t\tid: this.getId(),\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{this.getTooltipContent()}\n\t\t\t\n\t\t) : (\n\t\t\t\n\t\t);\n\t}\n\n\tgetTooltipContent() {\n\t\treturn (\n\t\t\t
    \n\t\t\t\t{this.props.content}\n\t\t\t\t{this.props.variant === 'learnMore' && this.props.onClickTrigger ? (\n\t\t\t\t\t
    \n\t\t\t\t\t\t{this.props.labels.learnMoreBefore}{' '}\n\t\t\t\t\t\t{' '}\n\t\t\t\t\t\t{this.props.labels.learnMoreAfter}{' '}\n\t\t\t\t\t
    \n\t\t\t\t) : null}\n\t\t\t
    \n\t\t);\n\t}\n\n\tgetTooltipTarget() {\n\t\treturn this.props.target ? this.props.target : this.trigger;\n\t}\n\n\thandleCancel = () => {\n\t\tthis.setState({\n\t\t\tisOpen: false,\n\t\t\tisClosing: false,\n\t\t});\n\t};\n\n\thandleMouseEnter = () => {\n\t\tthis.setState({\n\t\t\tisOpen: true,\n\t\t\tisClosing: false,\n\t\t});\n\t};\n\n\thandleMouseLeave = () => {\n\t\tthis.setState({ isClosing: true });\n\n\t\tsetTimeout(() => {\n\t\t\tif (!this.isUnmounting && this.state.isClosing) {\n\t\t\t\tthis.setState({\n\t\t\t\t\tisOpen: false,\n\t\t\t\t\tisClosing: false,\n\t\t\t\t});\n\t\t\t}\n\t\t}, this.props.hoverCloseDelay);\n\t};\n\n\tsaveTriggerRef = (component) => {\n\t\tthis.trigger = component;\n\t\t// yes, this is a re-render triggered by a render.\n\t\t// Dialog/Popper.js cannot place the popover until\n\t\t// the trigger/target DOM node is mounted. This\n\t\t// way `findDOMNode` is not called and parent\n\t\t// DOM nodes are not queried.\n\t\tif (!this.state.triggerRendered) {\n\t\t\tthis.setState({ triggerRendered: true });\n\t\t}\n\t};\n\n\trender() {\n\t\tconst containerStyles = {\n\t\t\tdisplay: 'inline-block',\n\t\t\t...this.props.triggerStyle,\n\t\t};\n\n\t\treturn (\n\t\t\t\n\t\t\t\t{this.getContent()}\n\t\t\t\t{this.getTooltip()}\n\t\t\t
    \n\t\t);\n\t}\n}\n\nTooltip.contextTypes = {\n\ticonPath: PropTypes.string,\n};\n\nTooltip.displayName = displayName;\nTooltip.propTypes = propTypes;\nTooltip.defaultProps = defaultProps;\n\nexport default Tooltip;\n\n\n\n// WEBPACK FOOTER //\n// ./components/tooltip/index.jsx","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1,eval)(\"this\");\r\n} catch(e) {\r\n\t// This works if the window reference is available\r\n\tif(typeof window === \"object\")\r\n\t\tg = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/global.js\n// module id = 19\n// module chunks = 0","// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames)\n// This project uses `classnames`, \"a simple javascript utility for conditionally\n// joining classNames together.\"\nimport classNames from 'classnames';\n\nconst classNamesWrapper = (...rest) => {\n\tconst string = classNames(...rest);\n\treturn string === '' ? undefined : string;\n};\n\nexport default classNamesWrapper;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/class-names.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### onClickOutside\n// Listen for clicks that occur somewhere in the document, outside of the element itself\nimport onClickOutside from 'react-onclickoutside';\nimport Popover from './popover';\n\nexport default onClickOutside(Popover);\n\n\n\n// WEBPACK FOOTER //\n// ./components/popover/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### onClickOutside\n// Listen for clicks that occur somewhere in the document, outside of the element itself\nimport onClickOutside from 'react-onclickoutside';\nimport MenuDropdown from './menu-dropdown';\n\nexport default onClickOutside(MenuDropdown);\n\n\n\n// WEBPACK FOOTER //\n// ./components/menu-dropdown/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\nimport React from 'react';\n\nimport PropTypes from 'prop-types';\n\nimport Popper from 'popper.js';\nimport isEqual from 'lodash.isequal';\n\n// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames)\n// This project uses `classnames`, \"a simple javascript utility for conditionally\n// joining classNames together.\"\nimport classNames from 'classnames';\n\nimport Portal from './portal';\nimport EventUtil from '../../../utilities/event';\nimport KEYS from '../../../utilities/key-code';\nimport DOMElementFocus from '../../../utilities/dom-element-focus';\nimport {\n\tgetNubbinMargins,\n\tgetNubbinClassName,\n\tmapPropToPopperPlacement,\n} from '../../../utilities/dialog-helpers';\n\nimport { DIALOG } from '../../../utilities/constants';\n\n// #### Dialog doesn't pass down context so repassing it here.\nimport IconSettings from '../../icon-settings';\n\n/*\n * A Dialog is content that is separate from the typical flow of a page. It typically overlays other elements in the document flow. This is achieved with elevation (`z-index`) and one of the following: relative position, absolute position, or a new top-level React render tree (portal). A boundary element is a scrolling ancestor element or the edge of the browser (window/viewport). This element typically has an overflow (overflow-y/overflow-x) style that is scroll, hidden, or auto. Inverted placement is the flipping of the overlay element from top to bottom or left to right in order stay within a boundary element.\n *\n * * Dropdown menu (Combobox, DatePicker, et al.) placement is typically bottom-aligned and should be allowed to invert its placement when inside a boundary element this often happens within a modal. Dropdowns should not overflow boundary elements , since most boundary elements scroll vertically and have space for the menu.\n *\n * * If they are hidden, left and right placed overlay elements (such as Popover and Tooltip) should be placed within a portal element attached to the DOM , but styled to align to its target/trigger. Since scrolling typically occurs on the vertical axis, this allows them to overflow boundary elements and still allow scrolling of content, yet still invert placement for the browser viewport. Portal elements are only necessary if an original ancestor boundary element exists. **No portals are created by default.**\n *\n * * Nubbins/arrows should be repositioned for any new placement/alignment.\n *\n * Allow Overflowing of Boundary Element: Allow applications to create a portal element attached to the DOM to be outside of boundary elements if manual testing shows confusing alignment/poor usability/readability. This should be exception and not the default.\n *\n * Allow Inverted placement: Allow applications to prevent inverted placement if manual testing shows confusing alignment/poor usability/readability.\n *\n * ### How this new Dialog component works\n * * There is no longer an inline render within components. All overlays should go through `Dialog`. `position: relative` just passes on the markup with some additional event listeners. No positional library is used.\n * * The default `position: absolute` will run through three renders. It will first render the overlay at `0px/0px` offset of its parent. It will then store the target DOM node, once the DOM node is set, a state change will occur and tell a PopperJS instance to be created on update, once it is created, a third render is done to update the styles created by PopperJS.\n * * `position: overflowBoundaryElement` will do the same three renders as `absolute` except that the initial render will create a disconnected render tree (portal) on the `body`. Then, the position will change once the target is stored. The portal itself will be rendered multiple times. The first will result in `onOpen` executing. Each update will result in a re-render of the disconnected render-tree.\n *\n * This component is private.\n */\nclass Dialog extends React.Component {\n\tstatic displayName = DIALOG;\n\n\tstatic propTypes = {\n\t\t/**\n\t\t * Aligns the right or left side of the dialog with the respective side of the target.\n\t\t */\n\t\talign: PropTypes.oneOf([\n\t\t\t'top',\n\t\t\t'top left',\n\t\t\t'top right',\n\t\t\t'right',\n\t\t\t'right top',\n\t\t\t'right bottom',\n\t\t\t'bottom',\n\t\t\t'bottom left',\n\t\t\t'bottom right',\n\t\t\t'left',\n\t\t\t'left top',\n\t\t\t'left bottom',\n\t\t]),\n\t\t/**\n\t\t * CSS classes to be added to the absolutely positioned element.\n\t\t */\n\t\tclassName: PropTypes.oneOfType([\n\t\t\tPropTypes.array,\n\t\t\tPropTypes.object,\n\t\t\tPropTypes.string,\n\t\t]),\n\t\t/**\n\t\t * CSS classes to be added to the wrapping `div` of the contents of the dialog.\n\t\t */\n\t\tcontentsClassName: PropTypes.oneOfType([\n\t\t\tPropTypes.array,\n\t\t\tPropTypes.object,\n\t\t\tPropTypes.string,\n\t\t]),\n\t\t/**\n\t\t * Contents of dialog\n\t\t */\n\t\tchildren: PropTypes.node.isRequired,\n\t\t/**\n\t\t * Closes dialog when tab key is pressed\n\t\t */\n\t\tcloseOnTabKey: PropTypes.bool,\n\t\t/**\n\t\t * Props passed along to wrapping div. This allows one less wrapping `div` to be in the markup. dialog children are expected to be wrapper in a single `div`.\n\t\t */\n\t\tcontainerProps: PropTypes.object,\n\t\t/**\n\t\t * Will show the nubbin pointing from the dialog to the reference element. Positioning and offsets will be handled.\n\t\t */\n\t\thasNubbin: PropTypes.bool,\n\t\t/**\n\t\t * By default, dialogs will flip their alignment (such as bottom to top) if they extend beyond a boundary element such as a scrolling parent or a window/viewpoint. `hasStaticAlignment` disables this behavior and allows this component to extend beyond boundary elements.\n\t\t */\n\t\thasStaticAlignment: PropTypes.bool,\n\t\t/**\n\t\t * Sets the dialog width to the width of either 'target' (Menus attached to `input` typically follow this UX pattern), 'menu' or 'none.\n\t\t */\n\t\tinheritWidthOf: PropTypes.oneOf(['target', 'menu', 'none']),\n\t\t/**\n\t\t * DEPRECATED - do not add checkProp deprecation message at this level. It is handled at higher level components.\n\t\t * TODO - to be removed.\n\t\t * Offset adds pixels to the absolutely positioned dropdown menu in the format: ([vertical]px [horizontal]px). SHOULD BE OBJECT -----------\n\t\t */\n\t\toffset: PropTypes.string,\n\t\t/**\n\t\t * Called when dialog closes and unmounts.\n\t\t */\n\t\tonClose: PropTypes.func,\n\t\t/**\n\t\t * Called when a key pressed.\n\t\t */\n\t\tonKeyDown: PropTypes.func,\n\t\t/**\n\t\t * Called when mouse hovers over the trigger button. This is only called if `this.props.openOn` is set to `hover`.\n\t\t */\n\t\tonMouseEnter: PropTypes.func,\n\t\t/**\n\t\t * Called when mouse hover leaves the trigger button. This is only called if `this.props.openOn` is set to `hover`.\n\t\t */\n\t\tonMouseLeave: PropTypes.func,\n\t\t/**\n\t\t * Called when dialog opens (that is mounts). The parameters are `undefined, { portal: this.portal }`.\n\t\t */\n\t\tonOpen: PropTypes.func,\n\t\t/**\n\t\t * React component to be aligned with. Function should return a DOM `ref` from the parent component.\n\t\t */\n\t\tonRequestTargetElement: PropTypes.func.isRequired,\n\t\t/**\n\t\t * Triggered when an item in the menu is clicked.\n\t\t */\n\t\toutsideClickIgnoreClass: PropTypes.string,\n\t\t/**\n\t\t * If a dialog is `positione=\"overflowBoundaryElement\"`, it will be rendered in a portal or separate render tree. This `portalMount` callback will be triggered instead of the the default `ReactDOM.unstable_renderSubtreeIntoContainer` and the function will mount the portal itself. Consider the following code that bypasses the internal mount and uses an Enzyme wrapper to mount the React root tree to the DOM.\n\t\t *\n\t\t * ```\n\t\t * {\n\t\t * portalWrapper = Enzyme.mount(reactElement, { attachTo: domContainerNode });\n\t\t * }}\n\t\t * onOpen={() => {\n\t\t * expect(portalWrapper.find(`#my-heading`)).to.exist;\n\t\t * done();\n\t\t * }}\n\t\t * />\n\t\t * ```\n\t\t */\n\t\tportalMount: PropTypes.func,\n\t\t/**\n\t\t * Please select one of the following:\n\t\t * * `absolute` - (default) The dialog will use `position: absolute` and style attributes to position itself. This allows inverted placement or flipping of the dialog.\n\t\t * * `overflowBoundaryElement` - The dialog will overflow scrolling parents. Use on elements that are aligned to the left or right of their target and don't care about the target being within a scrolling parent. Typically this is a popover or tooltip. Dropdown menus can usually open up and down if no room exists. In order to achieve this a portal element will be created and attached to `body`. This element will render into that detached render tree.\n\t\t * * `relative` - No styling or portals will be used. Menus will be positioned relative to their triggers. This is a great choice for HTML snapshot testing.\n\t\t */\n\t\tposition: PropTypes.oneOf([\n\t\t\t'absolute',\n\t\t\t'overflowBoundaryElement',\n\t\t\t'relative',\n\t\t]).isRequired,\n\t\t/**\n\t\t * An object of CSS styles that are applied to the immediate parent `div` of the contents. Use this instead of margin props.\n\t\t */\n\t\tstyle: PropTypes.object,\n\n\t\t/**\n\t\t * Sets which focus UX pattern to follow. For instance, popovers trap focus and must be exited to regain focus. Dropdowns and Tooltips never have focus.\n\t\t */\n\t\tvariant: PropTypes.oneOf(['dropdown', 'popover', 'tooltip']),\n\t};\n\n\tstatic defaultProps = {\n\t\talign: 'bottom left',\n\t\toffset: '0px 0px',\n\t\toutsideClickIgnoreClass: 'ignore-react-onclickoutside',\n\t};\n\n\tstate = {\n\t\ttriggerPopperJS: false,\n\t\tisOpen: false,\n\t};\n\n\tcomponentDidMount() {\n\t\tif (\n\t\t\tthis.props.position === 'absolute' ||\n\t\t\tthis.props.position === 'relative'\n\t\t) {\n\t\t\tthis.handleOpen();\n\t\t}\n\t}\n\n\tcomponentWillUpdate() {\n\t\tif (this.popper) {\n\t\t\tthis.popper.scheduleUpdate();\n\t\t}\n\t}\n\n\tcomponentDidUpdate(prevProps, prevState) {\n\t\tif (\n\t\t\tthis.state.triggerPopperJS === true &&\n\t\t\tprevState.triggerPopperJS === false &&\n\t\t\t(this.props.position === 'absolute' ||\n\t\t\t\tthis.props.position === 'overflowBoundaryElement') &&\n\t\t\tthis.dialogContent &&\n\t\t\tthis.props.onRequestTargetElement()\n\t\t) {\n\t\t\tthis.createPopper();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif (this.props.variant === 'popover') {\n\t\t\tDOMElementFocus.teardownScopedFocus();\n\t\t\tDOMElementFocus.returnFocusToStoredElement();\n\t\t}\n\n\t\tif (\n\t\t\tthis.props.position === 'absolute' ||\n\t\t\tthis.props.position === 'overflowBoundaryElement'\n\t\t) {\n\t\t\tthis.destroyPopper();\n\t\t}\n\n\t\tthis.handleClose(undefined, { componentWillUnmount: true });\n\t}\n\n\tgetPropOffsetsInPixels = (offsetString) => {\n\t\tconst offsetArray = offsetString.split(' ');\n\t\treturn {\n\t\t\tvertical: parseInt(offsetArray[0], 10),\n\t\t\thorizontal: parseInt(offsetArray[1], 10),\n\t\t};\n\t};\n\n\tgetPopperStyles = () => {\n\t\tconst { popperData } = this.state;\n\t\tif (!this.popper || !popperData) {\n\t\t\treturn {\n\t\t\t\tposition: 'absolute',\n\t\t\t\tpointerEvents: 'none',\n\t\t\t};\n\t\t}\n\n\t\tconst { position } = popperData.offsets.popper;\n\t\tconst propOffsets = this.getPropOffsetsInPixels(this.props.offset);\n\n\t\t// FIXME before merge - gotta rename from margin to offset\n\t\tconst nubbinOffsets = this.props.hasNubbin\n\t\t\t? getNubbinMargins(this.state.popperData)\n\t\t\t: { left: 0, top: 0 };\n\n\t\tconst left =\n\t\t\tpopperData.offsets.popper.left +\n\t\t\tnubbinOffsets.left +\n\t\t\tpropOffsets.horizontal;\n\t\tconst top =\n\t\t\tpopperData.offsets.popper.top + nubbinOffsets.top + propOffsets.vertical;\n\n\t\t// A Dropdown with overflowBoundaryElement position and 'align=right' uses max-width instead of inherited children width\n\t\tconst right = 'inherit';\n\t\treturn {\n\t\t\t...popperData.style,\n\t\t\tleft,\n\t\t\ttop,\n\t\t\tright,\n\t\t\tposition,\n\t\t};\n\t};\n\n\t// Render\n\tsetDialogContent = (component) => {\n\t\tthis.dialogContent = component;\n\t\tif (!this.state.triggerPopperJS) {\n\t\t\tthis.setState({ triggerPopperJS: true });\n\t\t}\n\t};\n\n\t/**\n\t * Events\n\t */\n\thandleClickOutside = () => {\n\t\tthis.handleClose();\n\t};\n\n\thandleClose = (event, data) => {\n\t\tthis.setState({ triggerPopperJS: true });\n\t\tif (this.props.onClose) {\n\t\t\tthis.props.onClose(event, data);\n\t\t}\n\t};\n\n\thandleClick = (event) => {\n\t\tif (event.nativeEvent) {\n\t\t\tevent.nativeEvent.preventDefault();\n\t\t\tevent.nativeEvent.stopPropagation();\n\t\t}\n\t};\n\n\thandleKeyDown = (event) => {\n\t\tif (event.keyCode === KEYS.TAB) {\n\t\t\tif (this.props.closeOnTabKey) {\n\t\t\t\tEventUtil.trap(event);\n\t\t\t\tthis.handleClose(event);\n\t\t\t}\n\t\t}\n\n\t\tif (this.props.onKeyDown) {\n\t\t\tthis.props.onKeyDown(event);\n\t\t}\n\t};\n\n\thandleOpen = () => {\n\t\tif (this.props.variant === 'popover' && this.dialogContent) {\n\t\t\tDOMElementFocus.storeActiveElement();\n\t\t\tDOMElementFocus.setupScopedFocus({\n\t\t\t\tancestorElement: this.dialogContent,\n\t\t\t}); // eslint-disable-line react/no-find-dom-node\n\t\t\t// Don't steal focus from inner elements\n\t\t\tif (!DOMElementFocus.hasOrAncestorHasFocus()) {\n\t\t\t\tDOMElementFocus.focusAncestor({\n\t\t\t\t\tisPortal: this.props.position === 'overflowBoundaryElement',\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (this.props.onOpen) {\n\t\t\tthis.props.onOpen(undefined, { portal: this.dialogContent });\n\t\t}\n\t};\n\n\t/**\n\t * Popper API and helper functions\n\t */\n\n\tcreatePopper = () => {\n\t\tconst reference = this.props.onRequestTargetElement(); // eslint-disable-line react/no-find-dom-node\n\t\tconst popper = this.dialogContent;\n\t\tconst placement = mapPropToPopperPlacement(this.props.align);\n\t\tconst eventsEnabled = true; // Lets popper listen to events (resize, scroll, etc.)\n\t\tconst modifiers = {\n\t\t\tapplyStyle: { enabled: false },\n\t\t\t// moves dialog in order to not extend a boundary element such as a scrolling parent or a window/viewpoint.\n\t\t\tpreventOverflow: {\n\t\t\t\tenabled: !this.props.hasStaticAlignment,\n\t\t\t\tboundariesElement:\n\t\t\t\t\tthis.props.position === 'absolute' ? 'scrollParent' : 'viewport',\n\t\t\t},\n\t\t\thide: { enabled: false },\n\t\t\t// By default, dialogs will flip their alignment if they extend beyond a boundary element such as a scrolling parent or a window/viewpoint\n\t\t\tflip: {\n\t\t\t\tenabled: !this.props.hasStaticAlignment,\n\t\t\t},\n\t\t\tremoveOnDestroy: true,\n\t\t\tupdateState: {\n\t\t\t\tenabled: true,\n\t\t\t\torder: 900,\n\t\t\t\tfn: (popperData) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\t(this.state.popperData &&\n\t\t\t\t\t\t\t!isEqual(popperData.offsets, this.state.popperData.offsets)) ||\n\t\t\t\t\t\t!this.state.popperData\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.setState({ popperData });\n\t\t\t\t\t}\n\t\t\t\t\treturn popperData;\n\t\t\t\t},\n\t\t\t},\n\t\t\t// arrow property can also point to an element\n\t\t};\n\t\tif (!reference) {\n\t\t\tconsole.error('Target node not found!', reference); // eslint-disable-line no-console\n\t\t}\n\t\tif (!popper) {\n\t\t\tconsole.error('Popper node not found!', popper); // eslint-disable-line no-console\n\t\t}\n\t\tthis.popper = new Popper(reference, popper, {\n\t\t\tplacement,\n\t\t\teventsEnabled,\n\t\t\tmodifiers,\n\t\t});\n\n\t\tthis.popper.scheduleUpdate();\n\t};\n\n\tdestroyPopper = () => {\n\t\tif (this.popper) {\n\t\t\tthis.popper.destroy();\n\t\t}\n\t};\n\n\trender() {\n\t\tlet style = {};\n\t\tconst role =\n\t\t\tthis.props.variant === 'popover' ? 'dialog' : this.props.variant;\n\t\tif (\n\t\t\tthis.props.position === 'absolute' ||\n\t\t\tthis.props.position === 'overflowBoundaryElement'\n\t\t) {\n\t\t\tstyle = {\n\t\t\t\t...style,\n\t\t\t\toutline: 0,\n\t\t\t\t...this.getPopperStyles(),\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.props.inheritWidthOf === 'target' &&\n\t\t\tthis.props.onRequestTargetElement()\n\t\t) {\n\t\t\tstyle.width = this.props\n\t\t\t\t.onRequestTargetElement()\n\t\t\t\t.getBoundingClientRect().width;\n\t\t} else if (\n\t\t\tthis.props.inheritWidthOf === 'menu' &&\n\t\t\tthis.dialogContent &&\n\t\t\tthis.dialogContent.querySelector('.slds-listbox')\n\t\t) {\n\t\t\t// inherit menu renderer width\n\t\t\tstyle.width = this.dialogContent\n\t\t\t\t.querySelector('.slds-listbox')\n\t\t\t\t.getBoundingClientRect().width;\n\t\t}\n\n\t\tstyle = {\n\t\t\t...style,\n\t\t\t...this.props.style,\n\t\t};\n\n\t\tconst contents = (\n\t\t\t
    \n\t\t\t\t{this.props.children}\n\t\t\t
    \n\t\t);\n\n\t\tconst subRenders = {\n\t\t\tabsolute: () => contents,\n\t\t\trelative: () => contents,\n\t\t\toverflowBoundaryElement: () => {\n\t\t\t\t// Cycle through current context, create object of\n\t\t\t\t// truthy values, and pass into Portal's context.\n\n\t\t\t\t// TODO: Add test when switched to `ReactDOM.createPortal`\n\t\t\t\tconst truthyIconSettingsContext = Object.keys(\n\t\t\t\t\tIconSettings.childContextTypes\n\t\t\t\t)\n\t\t\t\t\t.filter((key) => Boolean(this.context[key]))\n\t\t\t\t\t.reduce(\n\t\t\t\t\t\t(accumulatedContext, key) => ({\n\t\t\t\t\t\t\t...accumulatedContext,\n\t\t\t\t\t\t\t...{ [key]: this.context[key] },\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\treturn (\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t{contents}\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\n\t\treturn subRenders[this.props.position] && subRenders[this.props.position]();\n\t}\n}\n\nDialog.contextTypes = {\n\ticonPath: PropTypes.string,\n};\n\nexport default Dialog;\n\n\n\n// WEBPACK FOOTER //\n// ./components/utilities/dialog/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### React\nimport React from 'react';\n\nimport PropTypes from 'prop-types';\n\n// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames)\n// This project uses `classnames`, \"a simple javascript utility for conditionally\n// joining classNames together.\"\nimport classnames from 'classnames';\n\nimport { MEDIA_OBJECT } from '../../utilities/constants';\n\n// Allow for predicatable DOM queries with `querySelectorAll(cssClasses.base)`\nexport const cssClasses = {\n\tbase: 'slds-media',\n\tfigure: 'slds-media__figure',\n\tbody: 'slds-media__body',\n};\n\n/**\n * When you need text and a figure next to each other, use a media object.\n */\nclass MediaObject extends React.Component {\n\t// ### Display Name\n\t// Always use the canonical component name as the React display name.\n\tstatic displayName = MEDIA_OBJECT;\n\n\t// ### Prop Types\n\tstatic propTypes = {\n\t\t/**\n\t\t * Often the body may need to be truncated for correct layout. This is only applicable if using the component within a flexbox container.\n\t\t */\n\t\tcanTruncate: PropTypes.bool,\n\t\t/**\n\t\t * Class names to be added to the component's HTML tag with `slds-media` class.\n\t\t */\n\t\tclassName: PropTypes.oneOfType([\n\t\t\tPropTypes.array,\n\t\t\tPropTypes.object,\n\t\t\tPropTypes.string,\n\t\t]),\n\t\t/**\n\t\t * The body is often text such as a heading or paragraph.\n\t\t */\n\t\tbody: PropTypes.node,\n\t\t/**\n\t\t * The figure is the optional visualization of the text within the body.\n\t\t */\n\t\tfigure: PropTypes.node,\n\t\t/**\n\t\t * Vertically centers the body with the middle of the figure.\n\t\t */\n\t\tverticalCenter: PropTypes.bool,\n\t};\n\n\trender() {\n\t\treturn (\n\t\t\t\n\t\t\t\t{this.props.figure ? (\n\t\t\t\t\t
    {this.props.figure}
    \n\t\t\t\t) : null}\n\t\t\t\t
    {this.props.body}
    \n\t\t\t
    \n\t\t);\n\t}\n}\n\nexport default MediaObject;\n\n\n\n// WEBPACK FOOTER //\n// ./components/media-object/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\n// This component's `checkProps` which issues warnings to developers about properties\n// when in development mode (similar to React's built in development tools)\nimport checkProps from './check-props';\n\nimport Svg from './svg';\n\nimport SLDS_ICONS_UTILITY from '../../../icons/utility';\nimport SLDS_ICONS_ACTION from '../../../icons/action';\nimport SLDS_ICONS_CUSTOM from '../../../icons/custom';\nimport SLDS_ICONS_DOCTYPE from '../../../icons/doctype';\nimport SLDS_ICONS_STANDARD from '../../../icons/standard';\n\n/*\n * If inline icons are present and icon bundle imports are not just an empty object, then inline icons will be used instead of external icons that require HTTP access.\n */\nconst UtilityIcon = (\n\t{\n\t\tname = '',\n\t\tassistiveText, // eslint-disable-line no-unused-vars\n\t\tcategory,\n\t\ticon,\n\t\tpath,\n\t\t...rest\n\t},\n\tcontext\n) => {\n\tcheckProps('UtilityIcon', { name, category, path, context });\n\n\tconst inlineIcons = {\n\t\taction: SLDS_ICONS_ACTION,\n\t\tcustom: SLDS_ICONS_CUSTOM,\n\t\tdoctype: SLDS_ICONS_DOCTYPE,\n\t\tstandard: SLDS_ICONS_STANDARD,\n\t\tutility: SLDS_ICONS_UTILITY,\n\t};\n\tlet inlineData;\n\n\tif (icon) {\n\t\t// Use SVG data passed in with `icon` prop\n\t\tinlineData = icon;\n\t} else if (Object.keys(inlineIcons[category]).length) {\n\t\t// Use inline icon data if it exists. ENV variables will have to set to allow this.\n\t\tinlineData = inlineIcons[category][name.toLowerCase()];\n\t\tinlineData.viewBox = inlineIcons[category].viewBox;\n\t}\n\n\tlet modifiedPath;\n\n\tif (path) {\n\t\t// Use `path` prop of Icon if present\n\t\tmodifiedPath = path;\n\t} else if (context.onRequestIconPath) {\n\t\tmodifiedPath = context.onRequestIconPath({ category, name });\n\t} else if (context[`${category}Sprite`]) {\n\t\t// Use category sprite file from IconSettings if present\n\t\tmodifiedPath = `${context[`${category}Sprite`]}#${name}`;\n\t} else {\n\t\t// Otherwise, use external URLs for icons\n\t\tmodifiedPath =\n\t\t\tcontext.iconPath &&\n\t\t\t`${context.iconPath}/${category}-sprite/svg/symbols.svg#${name}`;\n\t}\n\n\treturn inlineData ? (\n\t\t\n\t) : (\n\t\t\n\t\t\t\n\t\t\n\t);\n};\n\nUtilityIcon.displayName = 'UtilityIcon';\n\nUtilityIcon.propTypes = {\n\tassistiveText: PropTypes.object,\n\tcategory: PropTypes.oneOf([\n\t\t'action',\n\t\t'custom',\n\t\t'doctype',\n\t\t'standard',\n\t\t'utility',\n\t]),\n\t/**\n\t * An SVG object to use instead of name / category, look in `design-system-react/icons` for examples\n\t */\n\ticon: PropTypes.object,\n\t/**\n\t * Name of the icon. Visit Lightning Design System Icons to reference icon names.\n\t */\n\tname: PropTypes.string,\n\t/**\n\t * Path to the icon. This will override any global icon settings.\n\t */\n\tpath: PropTypes.string,\n};\n\nUtilityIcon.defaultProps = {\n\tcategory: 'utility',\n};\n\nUtilityIcon.contextTypes = {\n\ticonPath: PropTypes.string,\n\tonRequestIconPath: PropTypes.func,\n\tactionSprite: PropTypes.string,\n\tcustomSprite: PropTypes.string,\n\tdoctypeSprite: PropTypes.string,\n\tstandardSprite: PropTypes.string,\n\tutilitySprite: PropTypes.string,\n};\n\nexport default UtilityIcon;\n\n\n\n// WEBPACK FOOTER //\n// ./components/utilities/utility-icon/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n/* eslint-disable import/no-mutable-exports */\n\n// This function will deliver a warning message to the browser console about the component being a deprecated component.\nimport lowPriorityWarning from './low-priority-warning';\n\nlet isPrototype = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\tconst hasWarned = {};\n\n\tisPrototype = function(control, comment) {\n\t\tconst additionalComment = comment ? ` ${comment}` : '';\n\t\tif (!hasWarned[control]) {\n\t\t\t/* eslint-disable max-len */\n\t\t\tlowPriorityWarning(\n\t\t\t\tfalse,\n\t\t\t\t`[Design System React] ${control} is a deprecated component. Bugfixes can be contributed, but new features and additional alignment with SLDS may be declined.${additionalComment}`\n\t\t\t);\n\t\t\t/* eslint-enable max-len */\n\t\t\thasWarned[control] = true;\n\t\t}\n\t};\n}\n\nexport default isPrototype;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/warning/component-is-deprecated.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### React\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\n// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames)\n// This project uses `classnames`, \"a simple javascript utility for conditionally\n// joining classNames together.\"\nimport classNames from 'classnames';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode (similar to React's built in development tools)\nimport checkProps from './check-props';\n\n// ### Children\nimport SLDSUtilityIcon from '../../utilities/utility-icon';\n\nimport { BUTTON_ICON } from '../../../utilities/constants';\n\n/**\n * This is a non-interactive wrapper component for `UtilityIcon` that specifies button icon classes for an icon inside a `button` tag. Use of this component by itself is not recommended, but should be used as part of other components to obtain the correct styling for icons within buttons. This component only partially implements [Button Icons](http://www.lightningdesignsystem.com/components/button-icons). It does not return a `button` HTML tag. It only returns an icon for use within a button. Assistive text must also be rendered by the parent.\n */\nconst ButtonIcon = (props) => {\n\tcheckProps(BUTTON_ICON, props);\n\n\treturn (\n\t\t\n\t);\n};\n\nconst propTypes = {\n\t/**\n\t * Icon category from [lightningdesignsystem.com/icons/](https://www.lightningdesignsystem.com/icons/)\n\t */\n\tcategory: PropTypes.oneOf([\n\t\t'action',\n\t\t'custom',\n\t\t'doctype',\n\t\t'standard',\n\t\t'utility',\n\t]).isRequired,\n\t/**\n\t * Associates an icon button with another element on the page by changes the color of the SVG. Please reference Lightning Design System Buttons > Hint.\n\t */\n\thint: PropTypes.bool,\n\t/**\n\t * An SVG object to use instead of name / category, look in `design-system-react/icons` for examples\n\t */\n\ticon: PropTypes.object,\n\t/**\n\t * Class names to be added to the SVG.\n\t */\n\tclassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * Setting `inverse` to true will switch the color of the icon: light to dark, dark to light.\n\t */\n\tinverse: PropTypes.bool,\n\t/**\n\t * Name of the icon. Visit Lightning Design System Icons to reference icon names.\n\t */\n\tname: PropTypes.string,\n\t/**\n\t * Path to the icon. This will override any global icon settings.\n\t */\n\tpath: PropTypes.string,\n\t/**\n\t * Adds additional spacing on the opposite side specified between button icon and the button label\n\t */\n\tposition: PropTypes.oneOf(['left', 'right']),\n\t/**\n\t * Size of the icon. Visit [lightningdesignsystem.com/components/icons/#flavor-sizes](https://www.lightningdesignsystem.com/components/icons/#flavor-sizes)\n\t */\n\tsize: PropTypes.oneOf(['x-small', 'small', 'medium', 'large']),\n};\n\nconst defaultProps = {\n\tcategory: 'utility',\n\tsize: 'medium',\n};\n\nButtonIcon.displayName = BUTTON_ICON;\nButtonIcon.propTypes = propTypes;\nButtonIcon.defaultProps = defaultProps;\n\nexport default ButtonIcon;\n\n\n\n// WEBPACK FOOTER //\n// ./components/icon/button-icon/index.jsx","module.exports = function(module) {\r\n\tif(!module.webpackPolyfill) {\r\n\t\tmodule.deprecate = function() {};\r\n\t\tmodule.paths = [];\r\n\t\t// module.parent = undefined by default\r\n\t\tif(!module.children) module.children = [];\r\n\t\tObject.defineProperty(module, \"loaded\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.l;\r\n\t\t\t}\r\n\t\t});\r\n\t\tObject.defineProperty(module, \"id\", {\r\n\t\t\tenumerable: true,\r\n\t\t\tget: function() {\r\n\t\t\t\treturn module.i;\r\n\t\t\t}\r\n\t\t});\r\n\t\tmodule.webpackPolyfill = 1;\r\n\t}\r\n\treturn module;\r\n};\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/buildin/module.js\n// module id = 28\n// module chunks = 0","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n/* eslint-disable jsx-a11y/no-redundant-roles */\n\n// # Breadcrumbs\n\n// Implements the [Breadcrumbs design pattern](https://www.lightningdesignsystem.com/components/breadcrumbs) in React.\n// Based on SLDS v2.1.0-rc.2\n\n// ## Dependencies\n\n// ### React\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode (similar to React's built in development tools)\nimport checkProps from './check-props';\nimport componentDoc from './docs.json';\n\n// ## Constants\nimport { BREADCRUMB } from '../../utilities/constants';\n\nconst defaultProps = {\n\tassistiveText: {\n\t\tlabel: 'Breadcrumbs',\n\t},\n};\n\n/**\n * Use breadcrumbs to note the path of a record and help the user to navigate back to the parent.Breadcrumb based on SLDS 2.1.0-dev\n */\nconst Breadcrumb = (props) => {\n\tcheckProps(BREADCRUMB, props, componentDoc);\n\n\tconst { trail } = props;\n\tconst assistiveText =\n\t\ttypeof props.assistiveText === 'string'\n\t\t\t? props.assistiveText\n\t\t\t: {\n\t\t\t\t\t...defaultProps.assistiveText,\n\t\t\t\t\t...props.assistiveText,\n\t\t\t\t}.label;\n\n\treturn (\n\t\t\n\t);\n};\n\nBreadcrumb.displayName = BREADCRUMB;\n\nBreadcrumb.propTypes = {\n\t/**\n\t * **Assistive text for accessibility.**\n\t * This object is merged with the default props object on every render.\n\t * * `label`: The assistive text for the breadcrumb trail.\n\t */\n\tassistiveText: PropTypes.shape({\n\t\tlabel: PropTypes.string,\n\t}),\n\t/**\n\t * An array of react elements presumably anchor elements.\n\t */\n\ttrail: PropTypes.array,\n};\n\nBreadcrumb.defaultProps = defaultProps;\n\nexport default Breadcrumb;\n\n\n\n// WEBPACK FOOTER //\n// ./components/breadcrumb/index.jsx","import { Component, createElement } from 'react';\nimport { findDOMNode } from 'react-dom';\n\nfunction _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}\n\nfunction _objectWithoutProperties(source, excluded) {\n if (source == null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key, i;\n\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n\n if (Object.getOwnPropertySymbols) {\n var sourceSymbolKeys = Object.getOwnPropertySymbols(source);\n\n for (i = 0; i < sourceSymbolKeys.length; i++) {\n key = sourceSymbolKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;\n target[key] = source[key];\n }\n }\n\n return target;\n}\n\n/**\n * Check whether some DOM node is our Component's node.\n */\nfunction isNodeFound(current, componentNode, ignoreClass) {\n if (current === componentNode) {\n return true;\n } // SVG elements do not technically reside in the rendered DOM, so\n // they do not have classList directly, but they offer a link to their\n // corresponding element, which can have classList. This extra check is for\n // that case.\n // See: http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGUseElement\n // Discussion: https://github.com/Pomax/react-onclickoutside/pull/17\n\n\n if (current.correspondingElement) {\n return current.correspondingElement.classList.contains(ignoreClass);\n }\n\n return current.classList.contains(ignoreClass);\n}\n/**\n * Try to find our node in a hierarchy of nodes, returning the document\n * node as highest node if our node is not found in the path up.\n */\n\nfunction findHighest(current, componentNode, ignoreClass) {\n if (current === componentNode) {\n return true;\n } // If source=local then this event came from 'somewhere'\n // inside and should be ignored. We could handle this with\n // a layered approach, too, but that requires going back to\n // thinking in terms of Dom node nesting, running counter\n // to React's 'you shouldn't care about the DOM' philosophy.\n\n\n while (current.parentNode) {\n if (isNodeFound(current, componentNode, ignoreClass)) {\n return true;\n }\n\n current = current.parentNode;\n }\n\n return current;\n}\n/**\n * Check if the browser scrollbar was clicked\n */\n\nfunction clickedScrollbar(evt) {\n return document.documentElement.clientWidth <= evt.clientX || document.documentElement.clientHeight <= evt.clientY;\n}\n\n// ideally will get replaced with external dep\n// when rafrex/detect-passive-events#4 and rafrex/detect-passive-events#5 get merged in\nvar testPassiveEventSupport = function testPassiveEventSupport() {\n if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') {\n return;\n }\n\n var passive = false;\n var options = Object.defineProperty({}, 'passive', {\n get: function get() {\n passive = true;\n }\n });\n\n var noop = function noop() {};\n\n window.addEventListener('testPassiveEventSupport', noop, options);\n window.removeEventListener('testPassiveEventSupport', noop, options);\n return passive;\n};\n\nfunction autoInc(seed) {\n if (seed === void 0) {\n seed = 0;\n }\n\n return function () {\n return ++seed;\n };\n}\n\nvar uid = autoInc();\n\nvar passiveEventSupport;\nvar handlersMap = {};\nvar enabledInstances = {};\nvar touchEvents = ['touchstart', 'touchmove'];\nvar IGNORE_CLASS_NAME = 'ignore-react-onclickoutside';\n/**\n * Options for addEventHandler and removeEventHandler\n */\n\nfunction getEventHandlerOptions(instance, eventName) {\n var handlerOptions = null;\n var isTouchEvent = touchEvents.indexOf(eventName) !== -1;\n\n if (isTouchEvent && passiveEventSupport) {\n handlerOptions = {\n passive: !instance.props.preventDefault\n };\n }\n\n return handlerOptions;\n}\n/**\n * This function generates the HOC function that you'll use\n * in order to impart onOutsideClick listening to an\n * arbitrary component. It gets called at the end of the\n * bootstrapping code to yield an instance of the\n * onClickOutsideHOC function defined inside setupHOC().\n */\n\n\nfunction onClickOutsideHOC(WrappedComponent, config) {\n var _class, _temp;\n\n var componentName = WrappedComponent.displayName || WrappedComponent.name || 'Component';\n return _temp = _class =\n /*#__PURE__*/\n function (_Component) {\n _inheritsLoose(onClickOutside, _Component);\n\n function onClickOutside(props) {\n var _this;\n\n _this = _Component.call(this, props) || this;\n\n _this.__outsideClickHandler = function (event) {\n if (typeof _this.__clickOutsideHandlerProp === 'function') {\n _this.__clickOutsideHandlerProp(event);\n\n return;\n }\n\n var instance = _this.getInstance();\n\n if (typeof instance.props.handleClickOutside === 'function') {\n instance.props.handleClickOutside(event);\n return;\n }\n\n if (typeof instance.handleClickOutside === 'function') {\n instance.handleClickOutside(event);\n return;\n }\n\n throw new Error(\"WrappedComponent: \" + componentName + \" lacks a handleClickOutside(event) function for processing outside click events.\");\n };\n\n _this.enableOnClickOutside = function () {\n if (typeof document === 'undefined' || enabledInstances[_this._uid]) {\n return;\n }\n\n if (typeof passiveEventSupport === 'undefined') {\n passiveEventSupport = testPassiveEventSupport();\n }\n\n enabledInstances[_this._uid] = true;\n var events = _this.props.eventTypes;\n\n if (!events.forEach) {\n events = [events];\n }\n\n handlersMap[_this._uid] = function (event) {\n if (_this.componentNode === null) return;\n\n if (_this.props.preventDefault) {\n event.preventDefault();\n }\n\n if (_this.props.stopPropagation) {\n event.stopPropagation();\n }\n\n if (_this.props.excludeScrollbar && clickedScrollbar(event)) return;\n var current = event.target;\n\n if (findHighest(current, _this.componentNode, _this.props.outsideClickIgnoreClass) !== document) {\n return;\n }\n\n _this.__outsideClickHandler(event);\n };\n\n events.forEach(function (eventName) {\n document.addEventListener(eventName, handlersMap[_this._uid], getEventHandlerOptions(_this, eventName));\n });\n };\n\n _this.disableOnClickOutside = function () {\n delete enabledInstances[_this._uid];\n var fn = handlersMap[_this._uid];\n\n if (fn && typeof document !== 'undefined') {\n var events = _this.props.eventTypes;\n\n if (!events.forEach) {\n events = [events];\n }\n\n events.forEach(function (eventName) {\n return document.removeEventListener(eventName, fn, getEventHandlerOptions(_this, eventName));\n });\n delete handlersMap[_this._uid];\n }\n };\n\n _this.getRef = function (ref) {\n return _this.instanceRef = ref;\n };\n\n _this._uid = uid();\n return _this;\n }\n /**\n * Access the WrappedComponent's instance.\n */\n\n\n var _proto = onClickOutside.prototype;\n\n _proto.getInstance = function getInstance() {\n if (!WrappedComponent.prototype.isReactComponent) {\n return this;\n }\n\n var ref = this.instanceRef;\n return ref.getInstance ? ref.getInstance() : ref;\n };\n\n /**\n * Add click listeners to the current document,\n * linked to this component's state.\n */\n _proto.componentDidMount = function componentDidMount() {\n // If we are in an environment without a DOM such\n // as shallow rendering or snapshots then we exit\n // early to prevent any unhandled errors being thrown.\n if (typeof document === 'undefined' || !document.createElement) {\n return;\n }\n\n var instance = this.getInstance();\n\n if (config && typeof config.handleClickOutside === 'function') {\n this.__clickOutsideHandlerProp = config.handleClickOutside(instance);\n\n if (typeof this.__clickOutsideHandlerProp !== 'function') {\n throw new Error(\"WrappedComponent: \" + componentName + \" lacks a function for processing outside click events specified by the handleClickOutside config option.\");\n }\n }\n\n this.componentNode = findDOMNode(this.getInstance()); // return early so we dont initiate onClickOutside\n\n if (this.props.disableOnClickOutside) return;\n this.enableOnClickOutside();\n };\n\n _proto.componentDidUpdate = function componentDidUpdate() {\n this.componentNode = findDOMNode(this.getInstance());\n };\n /**\n * Remove all document's event listeners for this component\n */\n\n\n _proto.componentWillUnmount = function componentWillUnmount() {\n this.disableOnClickOutside();\n };\n /**\n * Can be called to explicitly enable event listening\n * for clicks and touches outside of this element.\n */\n\n\n /**\n * Pass-through render\n */\n _proto.render = function render() {\n // eslint-disable-next-line no-unused-vars\n var _props = this.props,\n excludeScrollbar = _props.excludeScrollbar,\n props = _objectWithoutProperties(_props, [\"excludeScrollbar\"]);\n\n if (WrappedComponent.prototype.isReactComponent) {\n props.ref = this.getRef;\n } else {\n props.wrappedRef = this.getRef;\n }\n\n props.disableOnClickOutside = this.disableOnClickOutside;\n props.enableOnClickOutside = this.enableOnClickOutside;\n return createElement(WrappedComponent, props);\n };\n\n return onClickOutside;\n }(Component), _class.displayName = \"OnClickOutside(\" + componentName + \")\", _class.defaultProps = {\n eventTypes: ['mousedown', 'touchstart'],\n excludeScrollbar: config && config.excludeScrollbar || false,\n outsideClickIgnoreClass: IGNORE_CLASS_NAME,\n preventDefault: false,\n stopPropagation: false\n }, _class.getClass = function () {\n return WrappedComponent.getClass ? WrappedComponent.getClass() : WrappedComponent;\n }, _temp;\n}\n\nexport { IGNORE_CLASS_NAME };\nexport default onClickOutsideHOC;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/react-onclickoutside/dist/react-onclickoutside.es.js\n// module id = 30\n// module chunks = 0","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n/* eslint-disable import/no-mutable-exports */\n\n// This function will deliver an error message to the browser console when all of the props passed in are undefined (falsey).\nimport warning from 'warning';\n\nlet oneOfRequired;\n\nif (process.env.NODE_ENV !== 'production') {\n\tconst hasWarned = {};\n\n\toneOfRequired = function(control, selectedProps, comment) {\n\t\tconst additionalComment = comment ? ` ${comment}` : '';\n\t\tlet atLeastOnePropIsSet = false;\n\t\tconst keys = Object.keys(selectedProps);\n\t\tkeys.forEach((key) => {\n\t\t\tif (selectedProps[key]) {\n\t\t\t\tatLeastOnePropIsSet = true;\n\t\t\t}\n\t\t});\n\n\t\tif (!hasWarned[control]) {\n\t\t\t/* eslint-disable max-len */\n\t\t\twarning(\n\t\t\t\tatLeastOnePropIsSet,\n\t\t\t\t`[Design System React] One of the following props are required by ${control}: [${keys.join()}].${additionalComment}`\n\t\t\t);\n\t\t\t/* eslint-enable max-len */\n\t\t\thasWarned[control] = !!selectedProps;\n\t\t}\n\t};\n} else {\n\toneOfRequired = function() {};\n}\n\nexport default oneOfRequired;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/warning/one-of-required-property.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Dropdown Trigger Component (Simple Button Flavor) --- SLDS for React\n\n// ### React\n// React is an external dependency of the project.\nimport React from 'react';\n\nimport PropTypes from 'prop-types';\n\n// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames)\n// This project uses `classnames`, \"a simple javascript utility for conditionally\n// joining classNames together.\"\nimport classnames from 'classnames';\n\nimport Button from '../button';\n\n// ### Children\nimport { MENU_DROPDOWN_TRIGGER } from '../../utilities/constants';\n\n/**\n * The Dropdown Button Trigger renders the default trigger button for the dropdown menu. If this component has children, it does not render itself to the DOM. Instead, it renders its child element, `Button`, and all that child's properties. This component may be used as a template to create custom triggers that do not use `Button`.\n */\nclass Trigger extends React.Component {\n\t// ### Display Name\n\t// Always use the canonical component name (set in the core) as the React\n\t// display name.\n\tstatic displayName = MENU_DROPDOWN_TRIGGER;\n\n\t// ### Prop Types\n\tstatic propTypes = {\n\t\t/**\n\t\t * Import the module `design-system-react/dropdown/button-trigger` and render a grandchild of the element type `Button`. Any `props` specified on that `Button` will be assigned to the triggering button. Any `id` prop or event hanlders (`onBlur`, `onClick`, etc.) set on the button grandchild will be overwritten by `MenuDropdown` to allow functionality and accessibility.\n\t\t * ```\n\t\t * \n\t\t * \n\t\t *
    \n\t\t);\n\t}\n}\n\nexport default Trigger;\n\n\n\n// WEBPACK FOOTER //\n// ./components/menu-dropdown/button-trigger.jsx","'use strict';\n\nvar randomFromSeed = require('./random/random-from-seed');\n\nvar ORIGINAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';\nvar alphabet;\nvar previousSeed;\n\nvar shuffled;\n\nfunction reset() {\n shuffled = false;\n}\n\nfunction setCharacters(_alphabet_) {\n if (!_alphabet_) {\n if (alphabet !== ORIGINAL) {\n alphabet = ORIGINAL;\n reset();\n }\n return;\n }\n\n if (_alphabet_ === alphabet) {\n return;\n }\n\n if (_alphabet_.length !== ORIGINAL.length) {\n throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. You submitted ' + _alphabet_.length + ' characters: ' + _alphabet_);\n }\n\n var unique = _alphabet_.split('').filter(function(item, ind, arr){\n return ind !== arr.lastIndexOf(item);\n });\n\n if (unique.length) {\n throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. These characters were not unique: ' + unique.join(', '));\n }\n\n alphabet = _alphabet_;\n reset();\n}\n\nfunction characters(_alphabet_) {\n setCharacters(_alphabet_);\n return alphabet;\n}\n\nfunction setSeed(seed) {\n randomFromSeed.seed(seed);\n if (previousSeed !== seed) {\n reset();\n previousSeed = seed;\n }\n}\n\nfunction shuffle() {\n if (!alphabet) {\n setCharacters(ORIGINAL);\n }\n\n var sourceArray = alphabet.split('');\n var targetArray = [];\n var r = randomFromSeed.nextValue();\n var characterIndex;\n\n while (sourceArray.length > 0) {\n r = randomFromSeed.nextValue();\n characterIndex = Math.floor(r * sourceArray.length);\n targetArray.push(sourceArray.splice(characterIndex, 1)[0]);\n }\n return targetArray.join('');\n}\n\nfunction getShuffled() {\n if (shuffled) {\n return shuffled;\n }\n shuffled = shuffle();\n return shuffled;\n}\n\n/**\n * lookup shuffled letter\n * @param index\n * @returns {string}\n */\nfunction lookup(index) {\n var alphabetShuffled = getShuffled();\n return alphabetShuffled[index];\n}\n\nfunction get () {\n return alphabet || ORIGINAL;\n}\n\nmodule.exports = {\n get: get,\n characters: characters,\n seed: setSeed,\n lookup: lookup,\n shuffled: getShuffled\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/shortid/lib/alphabet.js\n// module id = 33\n// module chunks = 0","/**\n * Lodash (Custom Build) \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright JS Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n asyncTag = '[object AsyncFunction]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n nullTag = '[object Null]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n proxyTag = '[object Proxy]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]',\n undefinedTag = '[object Undefined]',\n weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\ntypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\ntypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\ntypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\ntypedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] =\ntypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\ntypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\ntypedArrayTags[errorTag] = typedArrayTags[funcTag] =\ntypedArrayTags[mapTag] = typedArrayTags[numberTag] =\ntypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\ntypedArrayTags[setTag] = typedArrayTags[stringTag] =\ntypedArrayTags[weakMapTag] = false;\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = (function() {\n try {\n return freeProcess && freeProcess.binding && freeProcess.binding('util');\n } catch (e) {}\n}());\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * A specialized version of `_.filter` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\nfunction arrayFilter(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\n/**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\nfunction arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n}\n\n/**\n * A specialized version of `_.some` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\nfunction arraySome(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\n/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\n/**\n * Checks if a `cache` value for `key` exists.\n *\n * @private\n * @param {Object} cache The cache to query.\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction cacheHas(cache, key) {\n return cache.has(key);\n}\n\n/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\n/**\n * Converts `map` to its key-value pairs.\n *\n * @private\n * @param {Object} map The map to convert.\n * @returns {Array} Returns the key-value pairs.\n */\nfunction mapToArray(map) {\n var index = -1,\n result = Array(map.size);\n\n map.forEach(function(value, key) {\n result[++index] = [key, value];\n });\n return result;\n}\n\n/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\n/**\n * Converts `set` to an array of its values.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the values.\n */\nfunction setToArray(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = value;\n });\n return result;\n}\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype,\n funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined,\n Symbol = root.Symbol,\n Uint8Array = root.Uint8Array,\n propertyIsEnumerable = objectProto.propertyIsEnumerable,\n splice = arrayProto.splice,\n symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeGetSymbols = Object.getOwnPropertySymbols,\n nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,\n nativeKeys = overArg(Object.keys, Object);\n\n/* Built-in method references that are verified to be native. */\nvar DataView = getNative(root, 'DataView'),\n Map = getNative(root, 'Map'),\n Promise = getNative(root, 'Promise'),\n Set = getNative(root, 'Set'),\n WeakMap = getNative(root, 'WeakMap'),\n nativeCreate = getNative(Object, 'create');\n\n/** Used to detect maps, sets, and weakmaps. */\nvar dataViewCtorString = toSource(DataView),\n mapCtorString = toSource(Map),\n promiseCtorString = toSource(Promise),\n setCtorString = toSource(Set),\n weakMapCtorString = toSource(WeakMap);\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n}\n\n/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n}\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n}\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n}\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n}\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n}\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\n/**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\nfunction SetCache(values) {\n var index = -1,\n length = values == null ? 0 : values.length;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n}\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\n/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\n// Add methods to `SetCache`.\nSetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\nSetCache.prototype.has = setCacheHas;\n\n/**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Stack(entries) {\n var data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n}\n\n/**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\nfunction stackClear() {\n this.__data__ = new ListCache;\n this.size = 0;\n}\n\n/**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction stackDelete(key) {\n var data = this.__data__,\n result = data['delete'](key);\n\n this.size = data.size;\n return result;\n}\n\n/**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction stackGet(key) {\n return this.__data__.get(key);\n}\n\n/**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction stackHas(key) {\n return this.__data__.has(key);\n}\n\n/**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\nfunction stackSet(key, value) {\n var data = this.__data__;\n if (data instanceof ListCache) {\n var pairs = data.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n}\n\n// Add methods to `Stack`.\nStack.prototype.clear = stackClear;\nStack.prototype['delete'] = stackDelete;\nStack.prototype.get = stackGet;\nStack.prototype.has = stackHas;\nStack.prototype.set = stackSet;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n var isArr = isArray(value),\n isArg = !isArr && isArguments(value),\n isBuff = !isArr && !isArg && isBuffer(value),\n isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n skipIndexes = isArr || isArg || isBuff || isType,\n result = skipIndexes ? baseTimes(value.length, String) : [],\n length = result.length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key == 'length' ||\n // Node.js 0.10 has enumerable non-index properties on buffers.\n (isBuff && (key == 'offset' || key == 'parent')) ||\n // PhantomJS 2 has enumerable non-index properties on typed arrays.\n (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n // Skip index properties.\n isIndex(key, length)\n ))) {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of `getAllKeys` and `getAllKeysIn` which uses\n * `keysFunc` and `symbolsFunc` to get the enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @param {Function} symbolsFunc The function to get the symbols of `object`.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction baseGetAllKeys(object, keysFunc, symbolsFunc) {\n var result = keysFunc(object);\n return isArray(object) ? result : arrayPush(result, symbolsFunc(object));\n}\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\n/**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\nfunction baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n}\n\n/**\n * The base implementation of `_.isEqual` which supports partial comparisons\n * and tracks traversed objects.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Unordered comparison\n * 2 - Partial comparison\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\nfunction baseIsEqual(value, other, bitmask, customizer, stack) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);\n}\n\n/**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = objIsArr ? arrayTag : getTag(object),\n othTag = othIsArr ? arrayTag : getTag(other);\n\n objTag = objTag == argsTag ? objectTag : objTag;\n othTag = othTag == argsTag ? objectTag : othTag;\n\n var objIsObj = objTag == objectTag,\n othIsObj = othTag == objectTag,\n isSameTag = objTag == othTag;\n\n if (isSameTag && isBuffer(object)) {\n if (!isBuffer(other)) {\n return false;\n }\n objIsArr = true;\n objIsObj = false;\n }\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)\n : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);\n }\n if (!(bitmask & COMPARE_PARTIAL_FLAG)) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n var objUnwrapped = objIsWrapped ? object.value() : object,\n othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);\n }\n }\n if (!isSameTag) {\n return false;\n }\n stack || (stack = new Stack);\n return equalObjects(object, other, bitmask, customizer, equalFunc, stack);\n}\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n}\n\n/**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `array` and `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\nfunction equalArrays(array, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(array);\n if (stacked && stack.get(other)) {\n return stacked == other;\n }\n var index = -1,\n result = true,\n seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, arrValue, index, other, array, stack)\n : customizer(arrValue, othValue, index, array, other, stack);\n }\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (seen) {\n if (!arraySome(other, function(othValue, othIndex) {\n if (!cacheHas(seen, othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {\n return seen.push(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, bitmask, customizer, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n}\n\n/**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n\n case arrayBufferTag:\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n return false;\n }\n return true;\n\n case boolTag:\n case dateTag:\n case numberTag:\n // Coerce booleans to `1` or `0` and dates to milliseconds.\n // Invalid dates are coerced to `NaN`.\n return eq(+object, +other);\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings, primitives and objects,\n // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n // for more details.\n return object == (other + '');\n\n case mapTag:\n var convert = mapToArray;\n\n case setTag:\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG;\n convert || (convert = setToArray);\n\n if (object.size != other.size && !isPartial) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n bitmask |= COMPARE_UNORDERED_FLAG;\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);\n stack['delete'](object);\n return result;\n\n case symbolTag:\n if (symbolValueOf) {\n return symbolValueOf.call(object) == symbolValueOf.call(other);\n }\n }\n return false;\n}\n\n/**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalObjects(object, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n objProps = getAllKeys(object),\n objLength = objProps.length,\n othProps = getAllKeys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isPartial) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked && stack.get(other)) {\n return stacked == other;\n }\n var result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n var skipCtor = isPartial;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, objValue, key, other, object, stack)\n : customizer(objValue, othValue, key, object, other, stack);\n }\n // Recursively compare objects (susceptible to call stack limits).\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (result && !skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n}\n\n/**\n * Creates an array of own enumerable property names and symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction getAllKeys(object) {\n return baseGetAllKeys(object, keys, getSymbols);\n}\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\n/**\n * Creates an array of the own enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\nvar getSymbols = !nativeGetSymbols ? stubArray : function(object) {\n if (object == null) {\n return [];\n }\n object = Object(object);\n return arrayFilter(nativeGetSymbols(object), function(symbol) {\n return propertyIsEnumerable.call(object, symbol);\n });\n};\n\n/**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nvar getTag = baseGetTag;\n\n// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.\nif ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n (Map && getTag(new Map) != mapTag) ||\n (Promise && getTag(Promise.resolve()) != promiseTag) ||\n (Set && getTag(new Set) != setTag) ||\n (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n getTag = function(value) {\n var result = baseGetTag(value),\n Ctor = result == objectTag ? value.constructor : undefined,\n ctorString = Ctor ? toSource(Ctor) : '';\n\n if (ctorString) {\n switch (ctorString) {\n case dataViewCtorString: return dataViewTag;\n case mapCtorString: return mapTag;\n case promiseCtorString: return promiseTag;\n case setCtorString: return setTag;\n case weakMapCtorString: return weakMapTag;\n }\n }\n return result;\n };\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nvar isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n !propertyIsEnumerable.call(value, 'callee');\n};\n\n/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\nvar isBuffer = nativeIsBuffer || stubFalse;\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.isEqual(object, other);\n * // => true\n *\n * object === other;\n * // => false\n */\nfunction isEqual(value, other) {\n return baseIsEqual(value, other);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\n/**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\nfunction keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n}\n\n/**\n * This method returns a new empty array.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Array} Returns the new empty array.\n * @example\n *\n * var arrays = _.times(2, _.stubArray);\n *\n * console.log(arrays);\n * // => [[], []]\n *\n * console.log(arrays[0] === arrays[1]);\n * // => false\n */\nfunction stubArray() {\n return [];\n}\n\n/**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\nfunction stubFalse() {\n return false;\n}\n\nmodule.exports = isEqual;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/lodash.isequal/index.js\n// module id = 34\n// module chunks = 0","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nconst canUseDOM = !!(\n\ttypeof window !== 'undefined' &&\n\twindow.document &&\n\twindow.document.createElement\n);\nconst canUseEventListeners =\n\tcanUseDOM && Boolean(window.addEventListener || window.attachEvent);\nconst canUseViewport = canUseDOM && Boolean(window.screen);\n\nexport { canUseDOM, canUseEventListeners, canUseViewport };\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/execution-environment.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n/* eslint-disable react/prefer-es6-class, jsx-a11y/no-noninteractive-element-interactions */\n\n// Implements the [Modal design pattern](https://lightningdesignsystem.com/components/modals/) in React.\n// Based on SLDS v2.2.1\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport ReactDOM from 'react-dom';\n\nimport classNames from 'classnames';\nimport ReactModal from 'react-modal';\n\n// ### shortid\n// [npmjs.com/package/shortid](https://www.npmjs.com/package/shortid)\n// shortid is a short, non-sequential, url-friendly, unique id generator\nimport shortid from 'shortid';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode (similar to React's built in development tools)\nimport checkProps from './check-props';\n\nimport checkAppElementIsSet from '../../utilities/warning/check-app-element-set';\n\nimport Button from '../button';\n\nimport { MODAL } from '../../utilities/constants';\nimport componentDoc from './docs.json';\n\nconst documentDefined = typeof document !== 'undefined';\nconst windowDefined = typeof window !== 'undefined';\n\nconst propTypes = {\n\t/**\n\t * Vertical alignment of Modal.\n\t */\n\talign: PropTypes.oneOf(['top', 'center']),\n\t/**\n\t * Boolean indicating if the appElement should be hidden.\n\t */\n\tariaHideApp: PropTypes.bool,\n\t/**\n\t * **Assistive text for accessibility.**\n\t * This object is merged with the default props object on every render.\n\t * * `dialogLabel`: This is a visually hidden label for the dialog. If not provided, `heading` is used.\n\t * * `closeButton`: This is a visually hidden label for the close button.\n\t */\n\tassistiveText: PropTypes.shape({\n\t\tdialogLabel: PropTypes.string,\n\t\tcloseButton: PropTypes.string,\n\t}),\n\t/**\n\t * Modal content.\n\t */\n\tchildren: PropTypes.node.isRequired,\n\t/**\n\t * Custom CSS classes for the modal's container. This is the element with `.slds-modal__container`. Use `classNames` [API](https://github.com/JedWatson/classnames).\n\t */\n\tcontainerClassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * Custom CSS classes for the modal's body. This is the element that has overflow rules and should be used to set a static height if desired. Use `classNames` [API](https://github.com/JedWatson/classnames).\n\t */\n\tcontentClassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * Custom styles for the modal's body. This is the element that has overflow rules and should be used to set a static height if desired.\n\t */\n\tcontentStyle: PropTypes.object,\n\t/**\n\t * If true, modal footer buttons render left and right. An example use case would be for \"back\" and \"next\" buttons.\n\t */\n\tdirectional: PropTypes.bool,\n\t/**\n\t * If true, Modals cannot be dismissed by clicking on the close icon or pressing esc key.\n\t */\n\tdisableClose: PropTypes.bool,\n\t/**\n\t * If true, Modals can be dismissed by clicking outside of modal. If unspecified, defaults to disableClose.\n\t */\n\tdismissOnClickOutside: PropTypes.bool,\n\t/**\n\t * Callback to fire with Modal is dismissed\n\t */\n\tonRequestClose: PropTypes.func,\n\t/**\n\t * Accepts a node or array of nodes that are typically a `Button` or `ProgressIndicator`. If an array, the nodes render on the right side first but are then floated left and right if directional prop is `true`.\n\t */\n\tfooter: PropTypes.oneOfType([PropTypes.array, PropTypes.node]),\n\t/**\n\t * Allows for a custom modal header that does not scroll with modal content. If this is defined, `heading` and `tagline` will be ignored. The close button will still be present.\n\t */\n\theader: PropTypes.node,\n\t/**\n\t * Adds CSS classes to the container surrounding the modal header and the close button. Use `classNames` [API](https://github.com/JedWatson/classnames).\n\t */\n\theaderClassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * Forces the modal to be open or closed.\n\t */\n\tisOpen: PropTypes.bool.isRequired,\n\t/**\n\t * Function whose return value is the mount node to insert the Modal element into. The default is `() => document.body`.\n\t */\n\tparentSelector: PropTypes.func,\n\t/**\n\t * Custom CSS classes for the portal DOM node. This node is a direct descendant of the `body` and is the parent of `ReactModal__Overlay`. Use `classNames` [API](https://github.com/JedWatson/classnames).\n\t */\n\tportalClassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * Styles the modal as a prompt.\n\t */\n\tprompt: PropTypes.oneOf([\n\t\t'success',\n\t\t'warning',\n\t\t'error',\n\t\t'wrench',\n\t\t'offline',\n\t\t'info',\n\t]),\n\t/**\n\t * Specifiies the modal's width. May be deprecated in favor of `width` in the future.\n\t */\n\tsize: PropTypes.oneOf(['medium', 'large']),\n\t/**\n\t * Content underneath the heading in the modal header.\n\t */\n\ttagline: PropTypes.node,\n\t/**\n\t * Content underneath the title in the modal header.\n\t */\n\ttitle: PropTypes.node,\n\t/**\n\t * Text heading at the top of a modal.\n\t */\n\theading: PropTypes.node,\n\t/**\n\t * Allows adding additional notifications within the modal.\n\t */\n\ttoast: PropTypes.node,\n};\n\nconst defaultProps = {\n\tassistiveText: {\n\t\tdialogLabel: '',\n\t\tcloseButton: 'Close',\n\t},\n\talign: 'center',\n\tariaHideApp: true,\n};\n\n/**\n * The Modal component is used for the Lightning Design System Modal and Notification > Prompt components. The Modal opens from a state change outside of the component itself (pass this state to the isOpen prop). For more details on the Prompt markup, please review the Notifications > Prompt.\n *\n * By default, `Modal` will add `aria-hidden=true` to the `body` tag, but this disables some assistive technologies. To prevent this you can add the following to your application with `#mount` being the root node of your application that you would like to hide from assistive technologies when the `Modal` is open.\n * ```\n * import settings from 'design-system-react/components/settings';\n * settings.setAppElement('#mount');\n * ```\n * This component uses a portalMount (a disconnected React subtree mount) to create a modal as a child of `body`.\n */\nclass Modal extends React.Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.state = {\n\t\t\tisClosing: false,\n\t\t};\n\n\t\t// Bind\n\t\tthis.handleModalClick = this.handleModalClick.bind(this);\n\t\tthis.closeModal = this.closeModal.bind(this);\n\t\tthis.dismissModalOnClickOutside = this.dismissModalOnClickOutside.bind(\n\t\t\tthis\n\t\t);\n\t}\n\n\tcomponentWillMount() {\n\t\tthis.generatedId = shortid.generate();\n\t\tcheckProps(MODAL, this.props, componentDoc);\n\t\tif (this.props.ariaHideApp) {\n\t\t\tcheckAppElementIsSet();\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tthis.setReturnFocus();\n\t\tthis.updateBodyScroll();\n\t}\n\n\tcomponentDidUpdate(prevProps, prevState) {\n\t\tif (this.props.isOpen !== prevProps.isOpen) {\n\t\t\tthis.updateBodyScroll();\n\t\t}\n\t\tif (this.state.isClosing !== prevState.isClosing) {\n\t\t\tif (this.state.isClosing) {\n\t\t\t\t// This section of code should be removed once trigger.jsx\n\t\t\t\t// and manager.jsx are removed. They appear to have\n\t\t\t\t// been created in order to do modals in portals.\n\t\t\t\tif (!this.isUnmounting) {\n\t\t\t\t\tconst el = ReactDOM.findDOMNode(this); // eslint-disable-line react/no-find-dom-node\n\t\t\t\t\tif (\n\t\t\t\t\t\tel &&\n\t\t\t\t\t\tel.parentNode &&\n\t\t\t\t\t\tel.parentNode.getAttribute('data-slds-modal')\n\t\t\t\t\t) {\n\t\t\t\t\t\tReactDOM.unmountComponentAtNode(el);\n\t\t\t\t\t\tdocument.body.removeChild(el);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.isUnmounting = true;\n\t\tthis.clearBodyScroll();\n\t}\n\n\tgetId() {\n\t\treturn this.props.id || this.generatedId;\n\t}\n\n\tgetModal() {\n\t\tconst modalStyle =\n\t\t\tthis.props.align === 'top' ? { justifyContent: 'flex-start' } : null;\n\t\tconst borderRadius =\n\t\t\tthis.props.title || this.props.heading || this.props.header\n\t\t\t\t? {}\n\t\t\t\t: { borderRadius: '.25rem' };\n\t\tconst contentStyleFromProps = this.props.contentStyle || {};\n\t\tconst contentStyle = {\n\t\t\t...borderRadius,\n\t\t\t...contentStyleFromProps,\n\t\t};\n\t\treturn (\n\t\t\t// temporarily disabling eslint for the onClicks on the div tags\n\t\t\t/* eslint-disable */\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t{this.headerComponent()}\n\t\t\t\t\t\n\t\t\t\t\t\t{this.props.children}\n\t\t\t\t\t
    \n\t\t\t\t\t{this.footerComponent()}\n\t\t\t\t
    \n\t\t\t
    \n\t\t\t/* eslint-enable */\n\t\t);\n\t}\n\n\tsetReturnFocus() {\n\t\tthis.setState({\n\t\t\treturnFocusTo: documentDefined ? document.activeElement : null,\n\t\t});\n\t}\n\n\t// eslint-disable-next-line class-methods-use-this\n\tclearBodyScroll() {\n\t\tif (windowDefined && documentDefined && document.body) {\n\t\t\tdocument.body.style.overflow = 'inherit';\n\t\t}\n\t}\n\n\tcloseModal() {\n\t\tif (!this.props.disableClose) {\n\t\t\tthis.dismissModal();\n\t\t}\n\t}\n\n\tdismissModal() {\n\t\tthis.setState({ isClosing: true });\n\t\tif (this.state.returnFocusTo && this.state.returnFocusTo.focus) {\n\t\t\tthis.state.returnFocusTo.focus();\n\t\t}\n\t\tif (this.props.onRequestClose) {\n\t\t\tthis.props.onRequestClose();\n\t\t}\n\t}\n\n\tdismissModalOnClickOutside() {\n\t\t// if dismissOnClickOutside is not set, default its value to disableClose\n\t\tconst dismissOnClickOutside =\n\t\t\tthis.props.dismissOnClickOutside !== undefined\n\t\t\t\t? this.props.dismissOnClickOutside\n\t\t\t\t: !this.props.disableClose;\n\n\t\tif (dismissOnClickOutside) {\n\t\t\tthis.dismissModal();\n\t\t}\n\t}\n\n\tfooterComponent() {\n\t\tlet footer = null;\n\t\tconst hasFooter = this.props.footer;\n\t\tconst footerClass = {\n\t\t\t'slds-modal__footer': true,\n\t\t\t'slds-modal__footer_directional': this.props.directional,\n\t\t\t'slds-theme_default': this.isPrompt(),\n\t\t};\n\n\t\tif (hasFooter) {\n\t\t\tfooter = ( // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/no-noninteractive-element-interactions\n\t\t\t\t\n\t\t\t\t\t{this.props.footer}\n\t\t\t\t\n\t\t\t);\n\t\t}\n\t\treturn footer;\n\t}\n\n\t// eslint-disable-next-line class-methods-use-this\n\thandleModalClick(event) {\n\t\tif (event && event.stopPropagation) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\t}\n\n\thandleSubmitModal() {\n\t\tthis.closeModal();\n\t}\n\n\theaderComponent() {\n\t\tlet headerContent = this.props.header;\n\t\tconst headerEmpty =\n\t\t\t!headerContent &&\n\t\t\t!(this.props.heading || this.props.title) &&\n\t\t\t!this.props.tagline;\n\t\tconst assistiveText = {\n\t\t\t...defaultProps.assistiveText,\n\t\t\t...this.props.assistiveText,\n\t\t};\n\t\tconst closeButtonAssistiveText =\n\t\t\tthis.props.closeButtonAssistiveText || assistiveText.closeButton;\n\t\tconst closeButton = (\n\t\t\t\n\t\t);\n\n\t\tif (\n\t\t\t(!headerContent && (this.props.heading || this.props.title)) ||\n\t\t\tthis.props.tagline\n\t\t) {\n\t\t\theaderContent = (\n\t\t\t\t
    \n\t\t\t\t\t{this.props.toast}\n\t\t\t\t\t\n\t\t\t\t\t\t{this.props.heading ? this.props.heading : this.props.title}\n\t\t\t\t\t\n\t\t\t\t\t{this.props.tagline ? (\n\t\t\t\t\t\t

    {this.props.tagline}

    \n\t\t\t\t\t) : null}\n\t\t\t\t
    \n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t\t\n\t\t\t\t{this.props.disableClose ? null : closeButton}\n\t\t\t\t{headerContent}\n\t\t\t\n\t\t);\n\t}\n\n\tisPrompt() {\n\t\treturn this.props.prompt !== undefined;\n\t}\n\n\tupdateBodyScroll() {\n\t\tif (windowDefined && documentDefined && document.body) {\n\t\t\tif (this.props.isOpen) {\n\t\t\t\tdocument.body.style.overflow = 'hidden';\n\t\t\t} else {\n\t\t\t\tdocument.body.style.overflow = 'inherit';\n\t\t\t}\n\t\t}\n\t}\n\n\trender() {\n\t\tconst customStyles = {\n\t\t\tcontent: {\n\t\t\t\tposition: 'default',\n\t\t\t\ttop: 'default',\n\t\t\t\tleft: 'default',\n\t\t\t\tright: 'default',\n\t\t\t\tbottom: 'default',\n\t\t\t\tborder: 'default',\n\t\t\t\tbackground: 'default',\n\t\t\t\toverflow: 'default',\n\t\t\t\tWebkitOverflowScrolling: 'default',\n\t\t\t\tborderRadius: 'default',\n\t\t\t\toutline: 'default',\n\t\t\t\tpadding: 'default',\n\t\t\t},\n\t\t\toverlay: {\n\t\t\t\tzIndex: 8000, // following SLDS guideline for z-index overlay\n\t\t\t\tbackgroundColor: 'default',\n\t\t\t},\n\t\t};\n\n\t\treturn (\n\t\t\t\n\t\t\t\t{this.getModal()}\n\t\t\t\t
    \n\t\t\t\n\t\t);\n\t}\n}\n\nModal.displayName = MODAL;\nModal.propTypes = propTypes;\nModal.defaultProps = defaultProps;\n\nexport default Modal;\n\n\n\n// WEBPACK FOOTER //\n// ./components/modal/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### React\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\n// ### ReactHighlighter\nimport ReactHighlighter from 'react-highlighter';\n\n// ## Constants\nimport { HIGHLIGHTER } from '../../../utilities/constants';\n\n/**\n * A utility component that highlights occurrences of a particular pattern in its contents.\n */\nconst Highlighter = (props) => {\n\tif (props.search) {\n\t\tlet children;\n\t\tif (typeof props.children === 'string') {\n\t\t\tchildren = (\n\t\t\t\t\n\t\t\t\t\t{props.children}\n\t\t\t\t\n\t\t\t);\n\t\t} else {\n\t\t\tconst findString = (nodeArr) =>\n\t\t\t\tnodeArr.map((element) => {\n\t\t\t\t\tlet newElement;\n\t\t\t\t\tif (typeof element === 'string') {\n\t\t\t\t\t\tnewElement = (\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t{element}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewElement = element;\n\t\t\t\t\t}\n\t\t\t\t\treturn newElement;\n\t\t\t\t});\n\n\t\t\tif (props.children.props) {\n\t\t\t\tconst node = props.children.props.children;\n\t\t\t\tchildren = node instanceof Array ? findString(node) : node;\n\t\t\t}\n\t\t}\n\n\t\treturn {children};\n\t}\n\n\tif (typeof props.children === 'string') {\n\t\treturn (\n\t\t\t\n\t\t\t\t{props.children}\n\t\t\t\n\t\t);\n\t}\n\n\treturn {props.children};\n};\n\n// ### Display Name\nHighlighter.displayName = HIGHLIGHTER;\n\n// ### Prop Types\nHighlighter.propTypes = {\n\t/**\n\t * The full string to display.\n\t */\n\tchildren: PropTypes.oneOfType([\n\t\tPropTypes.string,\n\t\tPropTypes.number,\n\t\tPropTypes.bool,\n\t\tPropTypes.node,\n\t]),\n\tclassName: PropTypes.string,\n\t/**\n\t * The string of text (or Regular Expression) to highlight.\n\t */\n\tsearch: PropTypes.any,\n};\n\nexport default Highlighter;\n\n\n\n// WEBPACK FOOTER //\n// ./components/utilities/highlighter/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n/* eslint-disable import/no-mutable-exports */\n\n// This function will deliver an warning message to the browser console if extraneous properties are defined (falsey).\nimport warning from 'warning';\n\nlet onlyOneOf = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\tconst hasWarned = {};\n\n\tonlyOneOf = function(control, selectedProps, comment) {\n\t\tconst additionalComment = comment ? ` ${comment}` : '';\n\t\tlet keys = Object.keys(selectedProps);\n\t\tkeys = keys.filter((key) => selectedProps[key]);\n\n\t\tif (!hasWarned[control]) {\n\t\t\t/* eslint-disable max-len */\n\t\t\twarning(\n\t\t\t\tkeys.length <= 1,\n\t\t\t\t`[Design System React] Only one of the following props is needed by ${control}: [${keys.join()}].${additionalComment}`\n\t\t\t);\n\t\t\t/* eslint-enable max-len */\n\t\t\thasWarned[control] = !!selectedProps;\n\t\t}\n\t};\n}\n\nexport default onlyOneOf;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/warning/only-one-of-properties.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n/* eslint-disable import/no-mutable-exports */\n\n// This function will deliver a warning message to the browser console about the component being a prototype component.\nimport lowPriorityWarning from './low-priority-warning';\n\nlet isPrototype = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\tconst hasWarned = {};\n\n\tisPrototype = function(control, comment) {\n\t\tconst additionalComment = comment ? ` ${comment}` : '';\n\t\tif (!hasWarned[control]) {\n\t\t\t/* eslint-disable max-len */\n\t\t\tlowPriorityWarning(\n\t\t\t\tfalse,\n\t\t\t\t`[Design System React] ${control} is a prototype. (a) Props may change within a minor release. (b) Web Content Accessibility Guidelines may not be met. (c) CSS imports may be required, since it is being added to SLDS.${additionalComment}`\n\t\t\t);\n\t\t\t/* eslint-enable max-len */\n\t\t\thasWarned[control] = true;\n\t\t}\n\t};\n}\n\nexport default isPrototype;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/warning/component-is-prototype.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n/* eslint-disable import/no-mutable-exports */\n\nlet lowPriorityWarning = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\tconst printWarning = function(originalMessage, ...args) {\n\t\tlet argIndex = 0;\n\t\tconst message = `Warning: ${originalMessage.replace(/%s/g, () => {\n\t\t\tconst argument = args[argIndex];\n\t\t\targIndex += 1;\n\t\t\treturn argument;\n\t\t})}`;\n\t\tif (typeof console !== 'undefined') {\n\t\t\tconsole.warn(message); // eslint-disable-line no-console\n\t\t}\n\t\ttry {\n\t\t\t// Throw error to enable tracing the callstack.\n\t\t\tthrow new Error(message);\n\t\t} catch (event) {} // eslint-disable-line no-empty\n\t};\n\n\tlowPriorityWarning = (condition, originalMessage, ...args) => {\n\t\tif (!condition && originalMessage) {\n\t\t\tprintWarning(originalMessage, ...args);\n\t\t}\n\t};\n}\n\nexport default lowPriorityWarning;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/warning/low-priority-warning.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport shortid from 'shortid';\nimport classNames from 'classnames';\n\nimport KEYS from '../../utilities/key-code';\nimport { RADIO } from '../../utilities/constants';\nimport getDataProps from '../../utilities/get-data-props';\nimport Swatch from '../../components/color-picker/private/swatch';\n\nconst propTypes = {\n\t/**\n\t * The ID of an element that describes this radio input. Often used for error messages.\n\t */\n\t'aria-describedby': PropTypes.string,\n\t/**\n\t * This is a controlled component. This radio is checked according to this value.\n\t */\n\tchecked: PropTypes.bool,\n\t/**\n\t * Class name to be passed to radio input wrapper ( `span` element)\n\t */\n\tclassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]) /**\n\t * This is the initial value of an uncontrolled form element and is present only to provide compatibility\n\t * with hybrid framework applications that are not entirely React. It should only be used in an application\n\t * without centralized state (Redux, Flux). \"Controlled components\" with centralized state is highly recommended.\n\t * See [Code Overview](https://github.com/salesforce/design-system-react/blob/master/docs/codebase-overview.md#controlled-and-uncontrolled-components) for more information.\n\t */,\n\tdefaultChecked: PropTypes.bool,\n\t/**\n\t * Disable this radio input.\n\t */\n\tdisabled: PropTypes.bool,\n\t/**\n\t * A unique ID that is used to associating a label to the `input` element. This ID is added to the `input` element.\n\t */\n\tid: PropTypes.string,\n\t/**\n\t * The string or element that is shown as both the title and the label for this radio input.\n\t */\n\tlabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,\n\t/**\n\t * The name of the radio input group.\n\t */\n\tname: PropTypes.string,\n\t/**\n\t * This event fires when the radio selection changes. Passes in `event, { checked }`.\n\t */\n\tonChange: PropTypes.func,\n\t/**\n\t * The value of this radio input.\n\t */\n\tvalue: PropTypes.string,\n\t/**\n\t * Variant of the Radio button. Base is the default and button-group makes the radio button look like a normal button (should be a child of ).\n\t */\n\tvariant: PropTypes.oneOf(['base', 'button-group', 'swatch']),\n\t/**\n\t * Ref callback that will pass in the radio's `input` tag\n\t */\n\trefs: PropTypes.shape({\n\t\tinput: PropTypes.func,\n\t}),\n};\n\nconst defaultProps = {\n\tvariant: 'base',\n};\n\n/**\n * A radio input that can have a single input checked at any one time. Radios should be wrapped with\n * a [RadioGroup](/components/radio-group) or [RadioButtonGroup](/components/radio-button-group)\n */\nclass Radio extends React.Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.generatedId = shortid.generate();\n\t\tthis.preventDuplicateChangeEvent = false;\n\t}\n\n\tgetId() {\n\t\treturn this.props.id || this.generatedId;\n\t}\n\n\thandleChange = (event, preventDuplicateChangeEvent) => {\n\t\tif (!this.preventDuplicateChangeEvent) {\n\t\t\tthis.preventDuplicateChangeEvent = Boolean(preventDuplicateChangeEvent);\n\t\t\tif (this.props.onChange) {\n\t\t\t\tthis.props.onChange(event, {\n\t\t\t\t\tchecked: !this.props.checked,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tthis.preventDuplicateChangeEvent = false;\n\t\t}\n\t};\n\n\trender() {\n\t\tconst dataProps = getDataProps(this.props);\n\n\t\tlet radio;\n\n\t\tif (this.props.variant === 'swatch') {\n\t\t\tradio = (\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t);\n\t\t} else if (this.props.variant === 'button-group')\n\t\t\tradio = (\n\t\t\t\t\n\t\t\t);\n\t\telse {\n\t\t\tradio = (\n\t\t\t\t\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t\n\t\t\t\t {\n\t\t\t\t\t\tthis.handleChange(event);\n\t\t\t\t\t}}\n\t\t\t\t\tonClick={(event) => {\n\t\t\t\t\t\tif (this.props.checked && this.props.deselectable) {\n\t\t\t\t\t\t\tthis.handleChange(event);\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t\tonKeyPress={(event) => {\n\t\t\t\t\t\tconst charCode = event.charCode;\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcharCode === KEYS.SPACE &&\n\t\t\t\t\t\t\tthis.props.checked &&\n\t\t\t\t\t\t\tthis.props.deselectable\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthis.handleChange(event, true);\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t(charCode === KEYS.ENTER &&\n\t\t\t\t\t\t\t\t(this.props.checked && this.props.deselectable)) ||\n\t\t\t\t\t\t\t!this.props.checked\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthis.handleChange(event);\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t\taria-describedby={this.props['aria-describedby']}\n\t\t\t\t\tdisabled={this.props.disabled}\n\t\t\t\t\t{...dataProps}\n\t\t\t\t\tref={(input) => {\n\t\t\t\t\t\tif (this.props.refs && this.props.refs.input) {\n\t\t\t\t\t\t\tthis.props.refs.input(input);\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t{radio}\n\t\t\t\n\t\t);\n\t}\n}\n\nRadio.displayName = RADIO;\nRadio.propTypes = propTypes;\nRadio.defaultProps = defaultProps;\n\nexport default Radio;\n\n\n\n// WEBPACK FOOTER //\n// ./components/radio/index.jsx","/**\n * lodash (Custom Build) \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/** Used as the `TypeError` message for \"Functions\" methods. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used to compose bitmasks for comparison styles. */\nvar UNORDERED_COMPARE_FLAG = 1,\n PARTIAL_COMPARE_FLAG = 2;\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991,\n MAX_INTEGER = 1.7976931348623157e+308,\n NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]',\n weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/** Used to match property names within property paths. */\nvar reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,\n reIsPlainProp = /^\\w*$/,\n reLeadingDot = /^\\./,\n rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g;\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to match backslashes in property paths. */\nvar reEscapeChar = /\\\\(\\\\)?/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\ntypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\ntypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\ntypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\ntypedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] =\ntypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\ntypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\ntypedArrayTags[errorTag] = typedArrayTags[funcTag] =\ntypedArrayTags[mapTag] = typedArrayTags[numberTag] =\ntypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\ntypedArrayTags[setTag] = typedArrayTags[stringTag] =\ntypedArrayTags[weakMapTag] = false;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = (function() {\n try {\n return freeProcess && freeProcess.binding('util');\n } catch (e) {}\n}());\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * A specialized version of `_.some` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\nfunction arraySome(array, predicate) {\n var index = -1,\n length = array ? array.length : 0;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * The base implementation of `_.findIndex` and `_.findLastIndex` without\n * support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} predicate The function invoked per iteration.\n * @param {number} fromIndex The index to search from.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction baseFindIndex(array, predicate, fromIndex, fromRight) {\n var length = array.length,\n index = fromIndex + (fromRight ? 1 : -1);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of `_.property` without support for deep paths.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\nfunction baseProperty(key) {\n return function(object) {\n return object == null ? undefined : object[key];\n };\n}\n\n/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\n/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\n/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\n/**\n * Checks if `value` is a host object in IE < 9.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a host object, else `false`.\n */\nfunction isHostObject(value) {\n // Many host objects are `Object` objects that can coerce to strings\n // despite having improperly defined `toString` methods.\n var result = false;\n if (value != null && typeof value.toString != 'function') {\n try {\n result = !!(value + '');\n } catch (e) {}\n }\n return result;\n}\n\n/**\n * Converts `map` to its key-value pairs.\n *\n * @private\n * @param {Object} map The map to convert.\n * @returns {Array} Returns the key-value pairs.\n */\nfunction mapToArray(map) {\n var index = -1,\n result = Array(map.size);\n\n map.forEach(function(value, key) {\n result[++index] = [key, value];\n });\n return result;\n}\n\n/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\n/**\n * Converts `set` to an array of its values.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the values.\n */\nfunction setToArray(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = value;\n });\n return result;\n}\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype,\n funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/** Built-in value references. */\nvar Symbol = root.Symbol,\n Uint8Array = root.Uint8Array,\n propertyIsEnumerable = objectProto.propertyIsEnumerable,\n splice = arrayProto.splice;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeKeys = overArg(Object.keys, Object),\n nativeMax = Math.max;\n\n/* Built-in method references that are verified to be native. */\nvar DataView = getNative(root, 'DataView'),\n Map = getNative(root, 'Map'),\n Promise = getNative(root, 'Promise'),\n Set = getNative(root, 'Set'),\n WeakMap = getNative(root, 'WeakMap'),\n nativeCreate = getNative(Object, 'create');\n\n/** Used to detect maps, sets, and weakmaps. */\nvar dataViewCtorString = toSource(DataView),\n mapCtorString = toSource(Map),\n promiseCtorString = toSource(Promise),\n setCtorString = toSource(Set),\n weakMapCtorString = toSource(WeakMap);\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n}\n\n/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n return this.has(key) && delete this.__data__[key];\n}\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);\n}\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n}\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n return true;\n}\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n return getMapData(this, key)['delete'](key);\n}\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n getMapData(this, key).set(key, value);\n return this;\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\n/**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\nfunction SetCache(values) {\n var index = -1,\n length = values ? values.length : 0;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n}\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\n/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\n// Add methods to `SetCache`.\nSetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\nSetCache.prototype.has = setCacheHas;\n\n/**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Stack(entries) {\n this.__data__ = new ListCache(entries);\n}\n\n/**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\nfunction stackClear() {\n this.__data__ = new ListCache;\n}\n\n/**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction stackDelete(key) {\n return this.__data__['delete'](key);\n}\n\n/**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction stackGet(key) {\n return this.__data__.get(key);\n}\n\n/**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction stackHas(key) {\n return this.__data__.has(key);\n}\n\n/**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\nfunction stackSet(key, value) {\n var cache = this.__data__;\n if (cache instanceof ListCache) {\n var pairs = cache.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n return this;\n }\n cache = this.__data__ = new MapCache(pairs);\n }\n cache.set(key, value);\n return this;\n}\n\n// Add methods to `Stack`.\nStack.prototype.clear = stackClear;\nStack.prototype['delete'] = stackDelete;\nStack.prototype.get = stackGet;\nStack.prototype.has = stackHas;\nStack.prototype.set = stackSet;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n // Safari 8.1 makes `arguments.callee` enumerable in strict mode.\n // Safari 9 makes `arguments.length` enumerable in strict mode.\n var result = (isArray(value) || isArguments(value))\n ? baseTimes(value.length, String)\n : [];\n\n var length = result.length,\n skipIndexes = !!length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (key == 'length' || isIndex(key, length)))) {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of `_.get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\nfunction baseGet(object, path) {\n path = isKey(path, object) ? [path] : castPath(path);\n\n var index = 0,\n length = path.length;\n\n while (object != null && index < length) {\n object = object[toKey(path[index++])];\n }\n return (index && index == length) ? object : undefined;\n}\n\n/**\n * The base implementation of `getTag`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n return objectToString.call(value);\n}\n\n/**\n * The base implementation of `_.hasIn` without support for deep paths.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {Array|string} key The key to check.\n * @returns {boolean} Returns `true` if `key` exists, else `false`.\n */\nfunction baseHasIn(object, key) {\n return object != null && key in Object(object);\n}\n\n/**\n * The base implementation of `_.isEqual` which supports partial comparisons\n * and tracks traversed objects.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {boolean} [bitmask] The bitmask of comparison flags.\n * The bitmask may be composed of the following flags:\n * 1 - Unordered comparison\n * 2 - Partial comparison\n * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\nfunction baseIsEqual(value, other, customizer, bitmask, stack) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);\n}\n\n/**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`\n * for more details.\n * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = arrayTag,\n othTag = arrayTag;\n\n if (!objIsArr) {\n objTag = getTag(object);\n objTag = objTag == argsTag ? objectTag : objTag;\n }\n if (!othIsArr) {\n othTag = getTag(other);\n othTag = othTag == argsTag ? objectTag : othTag;\n }\n var objIsObj = objTag == objectTag && !isHostObject(object),\n othIsObj = othTag == objectTag && !isHostObject(other),\n isSameTag = objTag == othTag;\n\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)\n : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);\n }\n if (!(bitmask & PARTIAL_COMPARE_FLAG)) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n var objUnwrapped = objIsWrapped ? object.value() : object,\n othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);\n }\n }\n if (!isSameTag) {\n return false;\n }\n stack || (stack = new Stack);\n return equalObjects(object, other, equalFunc, customizer, bitmask, stack);\n}\n\n/**\n * The base implementation of `_.isMatch` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property values to match.\n * @param {Array} matchData The property names, values, and compare flags to match.\n * @param {Function} [customizer] The function to customize comparisons.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n */\nfunction baseIsMatch(object, source, matchData, customizer) {\n var index = matchData.length,\n length = index,\n noCustomizer = !customizer;\n\n if (object == null) {\n return !length;\n }\n object = Object(object);\n while (index--) {\n var data = matchData[index];\n if ((noCustomizer && data[2])\n ? data[1] !== object[data[0]]\n : !(data[0] in object)\n ) {\n return false;\n }\n }\n while (++index < length) {\n data = matchData[index];\n var key = data[0],\n objValue = object[key],\n srcValue = data[1];\n\n if (noCustomizer && data[2]) {\n if (objValue === undefined && !(key in object)) {\n return false;\n }\n } else {\n var stack = new Stack;\n if (customizer) {\n var result = customizer(objValue, srcValue, key, object, source, stack);\n }\n if (!(result === undefined\n ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)\n : result\n )) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[objectToString.call(value)];\n}\n\n/**\n * The base implementation of `_.iteratee`.\n *\n * @private\n * @param {*} [value=_.identity] The value to convert to an iteratee.\n * @returns {Function} Returns the iteratee.\n */\nfunction baseIteratee(value) {\n // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.\n // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.\n if (typeof value == 'function') {\n return value;\n }\n if (value == null) {\n return identity;\n }\n if (typeof value == 'object') {\n return isArray(value)\n ? baseMatchesProperty(value[0], value[1])\n : baseMatches(value);\n }\n return property(value);\n}\n\n/**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * The base implementation of `_.matches` which doesn't clone `source`.\n *\n * @private\n * @param {Object} source The object of property values to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction baseMatches(source) {\n var matchData = getMatchData(source);\n if (matchData.length == 1 && matchData[0][2]) {\n return matchesStrictComparable(matchData[0][0], matchData[0][1]);\n }\n return function(object) {\n return object === source || baseIsMatch(object, source, matchData);\n };\n}\n\n/**\n * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.\n *\n * @private\n * @param {string} path The path of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction baseMatchesProperty(path, srcValue) {\n if (isKey(path) && isStrictComparable(srcValue)) {\n return matchesStrictComparable(toKey(path), srcValue);\n }\n return function(object) {\n var objValue = get(object, path);\n return (objValue === undefined && objValue === srcValue)\n ? hasIn(object, path)\n : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);\n };\n}\n\n/**\n * A specialized version of `baseProperty` which supports deep paths.\n *\n * @private\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\nfunction basePropertyDeep(path) {\n return function(object) {\n return baseGet(object, path);\n };\n}\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\n/**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {Array} Returns the cast property path array.\n */\nfunction castPath(value) {\n return isArray(value) ? value : stringToPath(value);\n}\n\n/**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Function} customizer The function to customize comparisons.\n * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`\n * for more details.\n * @param {Object} stack Tracks traversed `array` and `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\nfunction equalArrays(array, other, equalFunc, customizer, bitmask, stack) {\n var isPartial = bitmask & PARTIAL_COMPARE_FLAG,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(array);\n if (stacked && stack.get(other)) {\n return stacked == other;\n }\n var index = -1,\n result = true,\n seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, arrValue, index, other, array, stack)\n : customizer(arrValue, othValue, index, array, other, stack);\n }\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (seen) {\n if (!arraySome(other, function(othValue, othIndex) {\n if (!seen.has(othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {\n return seen.add(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, customizer, bitmask, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n}\n\n/**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Function} customizer The function to customize comparisons.\n * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`\n * for more details.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n\n case arrayBufferTag:\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n return false;\n }\n return true;\n\n case boolTag:\n case dateTag:\n case numberTag:\n // Coerce booleans to `1` or `0` and dates to milliseconds.\n // Invalid dates are coerced to `NaN`.\n return eq(+object, +other);\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings, primitives and objects,\n // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n // for more details.\n return object == (other + '');\n\n case mapTag:\n var convert = mapToArray;\n\n case setTag:\n var isPartial = bitmask & PARTIAL_COMPARE_FLAG;\n convert || (convert = setToArray);\n\n if (object.size != other.size && !isPartial) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n bitmask |= UNORDERED_COMPARE_FLAG;\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);\n stack['delete'](object);\n return result;\n\n case symbolTag:\n if (symbolValueOf) {\n return symbolValueOf.call(object) == symbolValueOf.call(other);\n }\n }\n return false;\n}\n\n/**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Function} customizer The function to customize comparisons.\n * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`\n * for more details.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalObjects(object, other, equalFunc, customizer, bitmask, stack) {\n var isPartial = bitmask & PARTIAL_COMPARE_FLAG,\n objProps = keys(object),\n objLength = objProps.length,\n othProps = keys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isPartial) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked && stack.get(other)) {\n return stacked == other;\n }\n var result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n var skipCtor = isPartial;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, objValue, key, other, object, stack)\n : customizer(objValue, othValue, key, object, other, stack);\n }\n // Recursively compare objects (susceptible to call stack limits).\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (result && !skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n}\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\n/**\n * Gets the property names, values, and compare flags of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the match data of `object`.\n */\nfunction getMatchData(object) {\n var result = keys(object),\n length = result.length;\n\n while (length--) {\n var key = result[length],\n value = object[key];\n\n result[length] = [key, value, isStrictComparable(value)];\n }\n return result;\n}\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\n/**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nvar getTag = baseGetTag;\n\n// Fallback for data views, maps, sets, and weak maps in IE 11,\n// for data views in Edge < 14, and promises in Node.js.\nif ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n (Map && getTag(new Map) != mapTag) ||\n (Promise && getTag(Promise.resolve()) != promiseTag) ||\n (Set && getTag(new Set) != setTag) ||\n (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n getTag = function(value) {\n var result = objectToString.call(value),\n Ctor = result == objectTag ? value.constructor : undefined,\n ctorString = Ctor ? toSource(Ctor) : undefined;\n\n if (ctorString) {\n switch (ctorString) {\n case dataViewCtorString: return dataViewTag;\n case mapCtorString: return mapTag;\n case promiseCtorString: return promiseTag;\n case setCtorString: return setTag;\n case weakMapCtorString: return weakMapTag;\n }\n }\n return result;\n };\n}\n\n/**\n * Checks if `path` exists on `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @param {Function} hasFunc The function to check properties.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n */\nfunction hasPath(object, path, hasFunc) {\n path = isKey(path, object) ? [path] : castPath(path);\n\n var result,\n index = -1,\n length = path.length;\n\n while (++index < length) {\n var key = toKey(path[index]);\n if (!(result = object != null && hasFunc(object, key))) {\n break;\n }\n object = object[key];\n }\n if (result) {\n return result;\n }\n var length = object ? object.length : 0;\n return !!length && isLength(length) && isIndex(key, length) &&\n (isArray(object) || isArguments(object));\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if `value` is a property name and not a property path.\n *\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n */\nfunction isKey(value, object) {\n if (isArray(value)) {\n return false;\n }\n var type = typeof value;\n if (type == 'number' || type == 'symbol' || type == 'boolean' ||\n value == null || isSymbol(value)) {\n return true;\n }\n return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||\n (object != null && value in Object(object));\n}\n\n/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\n/**\n * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` if suitable for strict\n * equality comparisons, else `false`.\n */\nfunction isStrictComparable(value) {\n return value === value && !isObject(value);\n}\n\n/**\n * A specialized version of `matchesProperty` for source values suitable\n * for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction matchesStrictComparable(key, srcValue) {\n return function(object) {\n if (object == null) {\n return false;\n }\n return object[key] === srcValue &&\n (srcValue !== undefined || (key in Object(object)));\n };\n}\n\n/**\n * Converts `string` to a property path array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\nvar stringToPath = memoize(function(string) {\n string = toString(string);\n\n var result = [];\n if (reLeadingDot.test(string)) {\n result.push('');\n }\n string.replace(rePropName, function(match, number, quote, string) {\n result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));\n });\n return result;\n});\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n */\nfunction toKey(value) {\n if (typeof value == 'string' || isSymbol(value)) {\n return value;\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to process.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\n/**\n * This method is like `_.find` except that it returns the index of the first\n * element `predicate` returns truthy for instead of the element itself.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [predicate=_.identity]\n * The function invoked per iteration.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {number} Returns the index of the found element, else `-1`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * _.findIndex(users, function(o) { return o.user == 'barney'; });\n * // => 0\n *\n * // The `_.matches` iteratee shorthand.\n * _.findIndex(users, { 'user': 'fred', 'active': false });\n * // => 1\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findIndex(users, ['active', false]);\n * // => 0\n *\n * // The `_.property` iteratee shorthand.\n * _.findIndex(users, 'active');\n * // => 2\n */\nfunction findIndex(array, predicate, fromIndex) {\n var length = array ? array.length : 0;\n if (!length) {\n return -1;\n }\n var index = fromIndex == null ? 0 : toInteger(fromIndex);\n if (index < 0) {\n index = nativeMax(length + index, 0);\n }\n return baseFindIndex(array, baseIteratee(predicate, 3), index);\n}\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * **Note:** The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `_.memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `delete`, `get`, `has`, and `set`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n * var other = { 'c': 3, 'd': 4 };\n *\n * var values = _.memoize(_.values);\n * values(object);\n * // => [1, 2]\n *\n * values(other);\n * // => [3, 4]\n *\n * object.a = 2;\n * values(object);\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b']);\n * values(object);\n * // => ['a', 'b']\n *\n * // Replace `_.memoize.Cache`.\n * _.memoize.Cache = WeakMap;\n */\nfunction memoize(func, resolver) {\n if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var memoized = function() {\n var args = arguments,\n key = resolver ? resolver.apply(this, args) : args[0],\n cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n var result = func.apply(this, args);\n memoized.cache = cache.set(key, result);\n return result;\n };\n memoized.cache = new (memoize.Cache || MapCache);\n return memoized;\n}\n\n// Assign cache to `_.memoize`.\nmemoize.Cache = MapCache;\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nfunction isArguments(value) {\n // Safari 8.1 makes `arguments.callee` enumerable in strict mode.\n return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&\n (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);\n}\n\n/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * This method is like `_.isArrayLike` except that it also checks if `value`\n * is an object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array-like object,\n * else `false`.\n * @example\n *\n * _.isArrayLikeObject([1, 2, 3]);\n * // => true\n *\n * _.isArrayLikeObject(document.body.children);\n * // => true\n *\n * _.isArrayLikeObject('abc');\n * // => false\n *\n * _.isArrayLikeObject(_.noop);\n * // => false\n */\nfunction isArrayLikeObject(value) {\n return isObjectLike(value) && isArrayLike(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\n/**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\nfunction toFinite(value) {\n if (!value) {\n return value === 0 ? value : 0;\n }\n value = toNumber(value);\n if (value === INFINITY || value === -INFINITY) {\n var sign = (value < 0 ? -1 : 1);\n return sign * MAX_INTEGER;\n }\n return value === value ? value : 0;\n}\n\n/**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\nfunction toInteger(value) {\n var result = toFinite(value),\n remainder = result % 1;\n\n return result === result ? (remainder ? result - remainder : result) : 0;\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\n/**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\nfunction toString(value) {\n return value == null ? '' : baseToString(value);\n}\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.get(object, 'a[0].b.c');\n * // => 3\n *\n * _.get(object, ['a', '0', 'b', 'c']);\n * // => 3\n *\n * _.get(object, 'a.b.c', 'default');\n * // => 'default'\n */\nfunction get(object, path, defaultValue) {\n var result = object == null ? undefined : baseGet(object, path);\n return result === undefined ? defaultValue : result;\n}\n\n/**\n * Checks if `path` is a direct or inherited property of `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n * @example\n *\n * var object = _.create({ 'a': _.create({ 'b': 2 }) });\n *\n * _.hasIn(object, 'a');\n * // => true\n *\n * _.hasIn(object, 'a.b');\n * // => true\n *\n * _.hasIn(object, ['a', 'b']);\n * // => true\n *\n * _.hasIn(object, 'b');\n * // => false\n */\nfunction hasIn(object, path) {\n return object != null && hasPath(object, path, baseHasIn);\n}\n\n/**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\nfunction keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n}\n\n/**\n * This method returns the first argument it receives.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {*} value Any value.\n * @returns {*} Returns `value`.\n * @example\n *\n * var object = { 'a': 1 };\n *\n * console.log(_.identity(object) === object);\n * // => true\n */\nfunction identity(value) {\n return value;\n}\n\n/**\n * Creates a function that returns the value at `path` of a given object.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n * @example\n *\n * var objects = [\n * { 'a': { 'b': 2 } },\n * { 'a': { 'b': 1 } }\n * ];\n *\n * _.map(objects, _.property('a.b'));\n * // => [2, 1]\n *\n * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');\n * // => [1, 2]\n */\nfunction property(path) {\n return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);\n}\n\nmodule.exports = findIndex;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/lodash.findindex/index.js\n// module id = 42\n// module chunks = 0","/**\n * lodash (Custom Build) \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/** Used as the `TypeError` message for \"Functions\" methods. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used to compose bitmasks for comparison styles. */\nvar UNORDERED_COMPARE_FLAG = 1,\n PARTIAL_COMPARE_FLAG = 2;\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991,\n MAX_INTEGER = 1.7976931348623157e+308,\n NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]',\n weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/** Used to match property names within property paths. */\nvar reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,\n reIsPlainProp = /^\\w*$/,\n reLeadingDot = /^\\./,\n rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g;\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to match backslashes in property paths. */\nvar reEscapeChar = /\\\\(\\\\)?/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\ntypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\ntypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\ntypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\ntypedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] =\ntypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\ntypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\ntypedArrayTags[errorTag] = typedArrayTags[funcTag] =\ntypedArrayTags[mapTag] = typedArrayTags[numberTag] =\ntypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\ntypedArrayTags[setTag] = typedArrayTags[stringTag] =\ntypedArrayTags[weakMapTag] = false;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = (function() {\n try {\n return freeProcess && freeProcess.binding('util');\n } catch (e) {}\n}());\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * A specialized version of `_.some` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\nfunction arraySome(array, predicate) {\n var index = -1,\n length = array ? array.length : 0;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * The base implementation of `_.findIndex` and `_.findLastIndex` without\n * support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} predicate The function invoked per iteration.\n * @param {number} fromIndex The index to search from.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction baseFindIndex(array, predicate, fromIndex, fromRight) {\n var length = array.length,\n index = fromIndex + (fromRight ? 1 : -1);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of `_.property` without support for deep paths.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\nfunction baseProperty(key) {\n return function(object) {\n return object == null ? undefined : object[key];\n };\n}\n\n/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\n/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\n/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\n/**\n * Checks if `value` is a host object in IE < 9.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a host object, else `false`.\n */\nfunction isHostObject(value) {\n // Many host objects are `Object` objects that can coerce to strings\n // despite having improperly defined `toString` methods.\n var result = false;\n if (value != null && typeof value.toString != 'function') {\n try {\n result = !!(value + '');\n } catch (e) {}\n }\n return result;\n}\n\n/**\n * Converts `map` to its key-value pairs.\n *\n * @private\n * @param {Object} map The map to convert.\n * @returns {Array} Returns the key-value pairs.\n */\nfunction mapToArray(map) {\n var index = -1,\n result = Array(map.size);\n\n map.forEach(function(value, key) {\n result[++index] = [key, value];\n });\n return result;\n}\n\n/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\n/**\n * Converts `set` to an array of its values.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the values.\n */\nfunction setToArray(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = value;\n });\n return result;\n}\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype,\n funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/** Built-in value references. */\nvar Symbol = root.Symbol,\n Uint8Array = root.Uint8Array,\n propertyIsEnumerable = objectProto.propertyIsEnumerable,\n splice = arrayProto.splice;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeKeys = overArg(Object.keys, Object),\n nativeMax = Math.max;\n\n/* Built-in method references that are verified to be native. */\nvar DataView = getNative(root, 'DataView'),\n Map = getNative(root, 'Map'),\n Promise = getNative(root, 'Promise'),\n Set = getNative(root, 'Set'),\n WeakMap = getNative(root, 'WeakMap'),\n nativeCreate = getNative(Object, 'create');\n\n/** Used to detect maps, sets, and weakmaps. */\nvar dataViewCtorString = toSource(DataView),\n mapCtorString = toSource(Map),\n promiseCtorString = toSource(Promise),\n setCtorString = toSource(Set),\n weakMapCtorString = toSource(WeakMap);\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n}\n\n/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n return this.has(key) && delete this.__data__[key];\n}\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);\n}\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n}\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n return true;\n}\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n return getMapData(this, key)['delete'](key);\n}\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n getMapData(this, key).set(key, value);\n return this;\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\n/**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\nfunction SetCache(values) {\n var index = -1,\n length = values ? values.length : 0;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n}\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\n/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\n// Add methods to `SetCache`.\nSetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\nSetCache.prototype.has = setCacheHas;\n\n/**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Stack(entries) {\n this.__data__ = new ListCache(entries);\n}\n\n/**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\nfunction stackClear() {\n this.__data__ = new ListCache;\n}\n\n/**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction stackDelete(key) {\n return this.__data__['delete'](key);\n}\n\n/**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction stackGet(key) {\n return this.__data__.get(key);\n}\n\n/**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction stackHas(key) {\n return this.__data__.has(key);\n}\n\n/**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\nfunction stackSet(key, value) {\n var cache = this.__data__;\n if (cache instanceof ListCache) {\n var pairs = cache.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n return this;\n }\n cache = this.__data__ = new MapCache(pairs);\n }\n cache.set(key, value);\n return this;\n}\n\n// Add methods to `Stack`.\nStack.prototype.clear = stackClear;\nStack.prototype['delete'] = stackDelete;\nStack.prototype.get = stackGet;\nStack.prototype.has = stackHas;\nStack.prototype.set = stackSet;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n // Safari 8.1 makes `arguments.callee` enumerable in strict mode.\n // Safari 9 makes `arguments.length` enumerable in strict mode.\n var result = (isArray(value) || isArguments(value))\n ? baseTimes(value.length, String)\n : [];\n\n var length = result.length,\n skipIndexes = !!length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (key == 'length' || isIndex(key, length)))) {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of `_.get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\nfunction baseGet(object, path) {\n path = isKey(path, object) ? [path] : castPath(path);\n\n var index = 0,\n length = path.length;\n\n while (object != null && index < length) {\n object = object[toKey(path[index++])];\n }\n return (index && index == length) ? object : undefined;\n}\n\n/**\n * The base implementation of `getTag`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n return objectToString.call(value);\n}\n\n/**\n * The base implementation of `_.hasIn` without support for deep paths.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {Array|string} key The key to check.\n * @returns {boolean} Returns `true` if `key` exists, else `false`.\n */\nfunction baseHasIn(object, key) {\n return object != null && key in Object(object);\n}\n\n/**\n * The base implementation of `_.isEqual` which supports partial comparisons\n * and tracks traversed objects.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {boolean} [bitmask] The bitmask of comparison flags.\n * The bitmask may be composed of the following flags:\n * 1 - Unordered comparison\n * 2 - Partial comparison\n * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\nfunction baseIsEqual(value, other, customizer, bitmask, stack) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);\n}\n\n/**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`\n * for more details.\n * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = arrayTag,\n othTag = arrayTag;\n\n if (!objIsArr) {\n objTag = getTag(object);\n objTag = objTag == argsTag ? objectTag : objTag;\n }\n if (!othIsArr) {\n othTag = getTag(other);\n othTag = othTag == argsTag ? objectTag : othTag;\n }\n var objIsObj = objTag == objectTag && !isHostObject(object),\n othIsObj = othTag == objectTag && !isHostObject(other),\n isSameTag = objTag == othTag;\n\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)\n : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);\n }\n if (!(bitmask & PARTIAL_COMPARE_FLAG)) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n var objUnwrapped = objIsWrapped ? object.value() : object,\n othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);\n }\n }\n if (!isSameTag) {\n return false;\n }\n stack || (stack = new Stack);\n return equalObjects(object, other, equalFunc, customizer, bitmask, stack);\n}\n\n/**\n * The base implementation of `_.isMatch` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property values to match.\n * @param {Array} matchData The property names, values, and compare flags to match.\n * @param {Function} [customizer] The function to customize comparisons.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n */\nfunction baseIsMatch(object, source, matchData, customizer) {\n var index = matchData.length,\n length = index,\n noCustomizer = !customizer;\n\n if (object == null) {\n return !length;\n }\n object = Object(object);\n while (index--) {\n var data = matchData[index];\n if ((noCustomizer && data[2])\n ? data[1] !== object[data[0]]\n : !(data[0] in object)\n ) {\n return false;\n }\n }\n while (++index < length) {\n data = matchData[index];\n var key = data[0],\n objValue = object[key],\n srcValue = data[1];\n\n if (noCustomizer && data[2]) {\n if (objValue === undefined && !(key in object)) {\n return false;\n }\n } else {\n var stack = new Stack;\n if (customizer) {\n var result = customizer(objValue, srcValue, key, object, source, stack);\n }\n if (!(result === undefined\n ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)\n : result\n )) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[objectToString.call(value)];\n}\n\n/**\n * The base implementation of `_.iteratee`.\n *\n * @private\n * @param {*} [value=_.identity] The value to convert to an iteratee.\n * @returns {Function} Returns the iteratee.\n */\nfunction baseIteratee(value) {\n // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.\n // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.\n if (typeof value == 'function') {\n return value;\n }\n if (value == null) {\n return identity;\n }\n if (typeof value == 'object') {\n return isArray(value)\n ? baseMatchesProperty(value[0], value[1])\n : baseMatches(value);\n }\n return property(value);\n}\n\n/**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n}\n\n/**\n * The base implementation of `_.matches` which doesn't clone `source`.\n *\n * @private\n * @param {Object} source The object of property values to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction baseMatches(source) {\n var matchData = getMatchData(source);\n if (matchData.length == 1 && matchData[0][2]) {\n return matchesStrictComparable(matchData[0][0], matchData[0][1]);\n }\n return function(object) {\n return object === source || baseIsMatch(object, source, matchData);\n };\n}\n\n/**\n * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.\n *\n * @private\n * @param {string} path The path of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction baseMatchesProperty(path, srcValue) {\n if (isKey(path) && isStrictComparable(srcValue)) {\n return matchesStrictComparable(toKey(path), srcValue);\n }\n return function(object) {\n var objValue = get(object, path);\n return (objValue === undefined && objValue === srcValue)\n ? hasIn(object, path)\n : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);\n };\n}\n\n/**\n * A specialized version of `baseProperty` which supports deep paths.\n *\n * @private\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\nfunction basePropertyDeep(path) {\n return function(object) {\n return baseGet(object, path);\n };\n}\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\n/**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {Array} Returns the cast property path array.\n */\nfunction castPath(value) {\n return isArray(value) ? value : stringToPath(value);\n}\n\n/**\n * Creates a `_.find` or `_.findLast` function.\n *\n * @private\n * @param {Function} findIndexFunc The function to find the collection index.\n * @returns {Function} Returns the new find function.\n */\nfunction createFind(findIndexFunc) {\n return function(collection, predicate, fromIndex) {\n var iterable = Object(collection);\n if (!isArrayLike(collection)) {\n var iteratee = baseIteratee(predicate, 3);\n collection = keys(collection);\n predicate = function(key) { return iteratee(iterable[key], key, iterable); };\n }\n var index = findIndexFunc(collection, predicate, fromIndex);\n return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;\n };\n}\n\n/**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Function} customizer The function to customize comparisons.\n * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`\n * for more details.\n * @param {Object} stack Tracks traversed `array` and `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\nfunction equalArrays(array, other, equalFunc, customizer, bitmask, stack) {\n var isPartial = bitmask & PARTIAL_COMPARE_FLAG,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(array);\n if (stacked && stack.get(other)) {\n return stacked == other;\n }\n var index = -1,\n result = true,\n seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, arrValue, index, other, array, stack)\n : customizer(arrValue, othValue, index, array, other, stack);\n }\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (seen) {\n if (!arraySome(other, function(othValue, othIndex) {\n if (!seen.has(othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {\n return seen.add(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, customizer, bitmask, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n}\n\n/**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Function} customizer The function to customize comparisons.\n * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`\n * for more details.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n\n case arrayBufferTag:\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n return false;\n }\n return true;\n\n case boolTag:\n case dateTag:\n case numberTag:\n // Coerce booleans to `1` or `0` and dates to milliseconds.\n // Invalid dates are coerced to `NaN`.\n return eq(+object, +other);\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings, primitives and objects,\n // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n // for more details.\n return object == (other + '');\n\n case mapTag:\n var convert = mapToArray;\n\n case setTag:\n var isPartial = bitmask & PARTIAL_COMPARE_FLAG;\n convert || (convert = setToArray);\n\n if (object.size != other.size && !isPartial) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n bitmask |= UNORDERED_COMPARE_FLAG;\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);\n stack['delete'](object);\n return result;\n\n case symbolTag:\n if (symbolValueOf) {\n return symbolValueOf.call(object) == symbolValueOf.call(other);\n }\n }\n return false;\n}\n\n/**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Function} customizer The function to customize comparisons.\n * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`\n * for more details.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalObjects(object, other, equalFunc, customizer, bitmask, stack) {\n var isPartial = bitmask & PARTIAL_COMPARE_FLAG,\n objProps = keys(object),\n objLength = objProps.length,\n othProps = keys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isPartial) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked && stack.get(other)) {\n return stacked == other;\n }\n var result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n var skipCtor = isPartial;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, objValue, key, other, object, stack)\n : customizer(objValue, othValue, key, object, other, stack);\n }\n // Recursively compare objects (susceptible to call stack limits).\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (result && !skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n}\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\n/**\n * Gets the property names, values, and compare flags of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the match data of `object`.\n */\nfunction getMatchData(object) {\n var result = keys(object),\n length = result.length;\n\n while (length--) {\n var key = result[length],\n value = object[key];\n\n result[length] = [key, value, isStrictComparable(value)];\n }\n return result;\n}\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\n/**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nvar getTag = baseGetTag;\n\n// Fallback for data views, maps, sets, and weak maps in IE 11,\n// for data views in Edge < 14, and promises in Node.js.\nif ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n (Map && getTag(new Map) != mapTag) ||\n (Promise && getTag(Promise.resolve()) != promiseTag) ||\n (Set && getTag(new Set) != setTag) ||\n (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n getTag = function(value) {\n var result = objectToString.call(value),\n Ctor = result == objectTag ? value.constructor : undefined,\n ctorString = Ctor ? toSource(Ctor) : undefined;\n\n if (ctorString) {\n switch (ctorString) {\n case dataViewCtorString: return dataViewTag;\n case mapCtorString: return mapTag;\n case promiseCtorString: return promiseTag;\n case setCtorString: return setTag;\n case weakMapCtorString: return weakMapTag;\n }\n }\n return result;\n };\n}\n\n/**\n * Checks if `path` exists on `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @param {Function} hasFunc The function to check properties.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n */\nfunction hasPath(object, path, hasFunc) {\n path = isKey(path, object) ? [path] : castPath(path);\n\n var result,\n index = -1,\n length = path.length;\n\n while (++index < length) {\n var key = toKey(path[index]);\n if (!(result = object != null && hasFunc(object, key))) {\n break;\n }\n object = object[key];\n }\n if (result) {\n return result;\n }\n var length = object ? object.length : 0;\n return !!length && isLength(length) && isIndex(key, length) &&\n (isArray(object) || isArguments(object));\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if `value` is a property name and not a property path.\n *\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n */\nfunction isKey(value, object) {\n if (isArray(value)) {\n return false;\n }\n var type = typeof value;\n if (type == 'number' || type == 'symbol' || type == 'boolean' ||\n value == null || isSymbol(value)) {\n return true;\n }\n return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||\n (object != null && value in Object(object));\n}\n\n/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\n/**\n * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` if suitable for strict\n * equality comparisons, else `false`.\n */\nfunction isStrictComparable(value) {\n return value === value && !isObject(value);\n}\n\n/**\n * A specialized version of `matchesProperty` for source values suitable\n * for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction matchesStrictComparable(key, srcValue) {\n return function(object) {\n if (object == null) {\n return false;\n }\n return object[key] === srcValue &&\n (srcValue !== undefined || (key in Object(object)));\n };\n}\n\n/**\n * Converts `string` to a property path array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\nvar stringToPath = memoize(function(string) {\n string = toString(string);\n\n var result = [];\n if (reLeadingDot.test(string)) {\n result.push('');\n }\n string.replace(rePropName, function(match, number, quote, string) {\n result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));\n });\n return result;\n});\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n */\nfunction toKey(value) {\n if (typeof value == 'string' || isSymbol(value)) {\n return value;\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to process.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\n/**\n * This method is like `_.find` except that it returns the index of the first\n * element `predicate` returns truthy for instead of the element itself.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [predicate=_.identity]\n * The function invoked per iteration.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {number} Returns the index of the found element, else `-1`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * _.findIndex(users, function(o) { return o.user == 'barney'; });\n * // => 0\n *\n * // The `_.matches` iteratee shorthand.\n * _.findIndex(users, { 'user': 'fred', 'active': false });\n * // => 1\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findIndex(users, ['active', false]);\n * // => 0\n *\n * // The `_.property` iteratee shorthand.\n * _.findIndex(users, 'active');\n * // => 2\n */\nfunction findIndex(array, predicate, fromIndex) {\n var length = array ? array.length : 0;\n if (!length) {\n return -1;\n }\n var index = fromIndex == null ? 0 : toInteger(fromIndex);\n if (index < 0) {\n index = nativeMax(length + index, 0);\n }\n return baseFindIndex(array, baseIteratee(predicate, 3), index);\n}\n\n/**\n * Iterates over elements of `collection`, returning the first element\n * `predicate` returns truthy for. The predicate is invoked with three\n * arguments: (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to inspect.\n * @param {Function} [predicate=_.identity]\n * The function invoked per iteration.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {*} Returns the matched element, else `undefined`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false },\n * { 'user': 'pebbles', 'age': 1, 'active': true }\n * ];\n *\n * _.find(users, function(o) { return o.age < 40; });\n * // => object for 'barney'\n *\n * // The `_.matches` iteratee shorthand.\n * _.find(users, { 'age': 1, 'active': true });\n * // => object for 'pebbles'\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.find(users, ['active', false]);\n * // => object for 'fred'\n *\n * // The `_.property` iteratee shorthand.\n * _.find(users, 'active');\n * // => object for 'barney'\n */\nvar find = createFind(findIndex);\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * **Note:** The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `_.memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `delete`, `get`, `has`, and `set`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n * var other = { 'c': 3, 'd': 4 };\n *\n * var values = _.memoize(_.values);\n * values(object);\n * // => [1, 2]\n *\n * values(other);\n * // => [3, 4]\n *\n * object.a = 2;\n * values(object);\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b']);\n * values(object);\n * // => ['a', 'b']\n *\n * // Replace `_.memoize.Cache`.\n * _.memoize.Cache = WeakMap;\n */\nfunction memoize(func, resolver) {\n if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var memoized = function() {\n var args = arguments,\n key = resolver ? resolver.apply(this, args) : args[0],\n cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n var result = func.apply(this, args);\n memoized.cache = cache.set(key, result);\n return result;\n };\n memoized.cache = new (memoize.Cache || MapCache);\n return memoized;\n}\n\n// Assign cache to `_.memoize`.\nmemoize.Cache = MapCache;\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nfunction isArguments(value) {\n // Safari 8.1 makes `arguments.callee` enumerable in strict mode.\n return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&\n (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);\n}\n\n/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * This method is like `_.isArrayLike` except that it also checks if `value`\n * is an object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array-like object,\n * else `false`.\n * @example\n *\n * _.isArrayLikeObject([1, 2, 3]);\n * // => true\n *\n * _.isArrayLikeObject(document.body.children);\n * // => true\n *\n * _.isArrayLikeObject('abc');\n * // => false\n *\n * _.isArrayLikeObject(_.noop);\n * // => false\n */\nfunction isArrayLikeObject(value) {\n return isObjectLike(value) && isArrayLike(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\n/**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\nfunction toFinite(value) {\n if (!value) {\n return value === 0 ? value : 0;\n }\n value = toNumber(value);\n if (value === INFINITY || value === -INFINITY) {\n var sign = (value < 0 ? -1 : 1);\n return sign * MAX_INTEGER;\n }\n return value === value ? value : 0;\n}\n\n/**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\nfunction toInteger(value) {\n var result = toFinite(value),\n remainder = result % 1;\n\n return result === result ? (remainder ? result - remainder : result) : 0;\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\n/**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\nfunction toString(value) {\n return value == null ? '' : baseToString(value);\n}\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.get(object, 'a[0].b.c');\n * // => 3\n *\n * _.get(object, ['a', '0', 'b', 'c']);\n * // => 3\n *\n * _.get(object, 'a.b.c', 'default');\n * // => 'default'\n */\nfunction get(object, path, defaultValue) {\n var result = object == null ? undefined : baseGet(object, path);\n return result === undefined ? defaultValue : result;\n}\n\n/**\n * Checks if `path` is a direct or inherited property of `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n * @example\n *\n * var object = _.create({ 'a': _.create({ 'b': 2 }) });\n *\n * _.hasIn(object, 'a');\n * // => true\n *\n * _.hasIn(object, 'a.b');\n * // => true\n *\n * _.hasIn(object, ['a', 'b']);\n * // => true\n *\n * _.hasIn(object, 'b');\n * // => false\n */\nfunction hasIn(object, path) {\n return object != null && hasPath(object, path, baseHasIn);\n}\n\n/**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\nfunction keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n}\n\n/**\n * This method returns the first argument it receives.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {*} value Any value.\n * @returns {*} Returns `value`.\n * @example\n *\n * var object = { 'a': 1 };\n *\n * console.log(_.identity(object) === object);\n * // => true\n */\nfunction identity(value) {\n return value;\n}\n\n/**\n * Creates a function that returns the value at `path` of a given object.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n * @example\n *\n * var objects = [\n * { 'a': { 'b': 2 } },\n * { 'a': { 'b': 1 } }\n * ];\n *\n * _.map(objects, _.property('a.b'));\n * // => [2, 1]\n *\n * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');\n * // => [1, 2]\n */\nfunction property(path) {\n return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);\n}\n\nmodule.exports = find;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/lodash.find/index.js\n// module id = 43\n// module chunks = 0","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\nimport EventUtil from './event';\n\n/*\n * Helper function that has callbacks passed into it with the key\n * being the keycode of the event. This allows an object literal to\n * control key event callback mapping and avoids a long conditional\n * if statement and uses an enumeration pattern instead.\n */\nconst mapKeyEventCallbacks = (\n\tevent,\n\t{ callbacks = {}, shiftCallbacks = {}, stopPropagation = true }\n) => {\n\tif (event.shiftKey && event.keyCode && shiftCallbacks[event.keyCode]) {\n\t\tif (stopPropagation) {\n\t\t\tEventUtil.trapEvent(event);\n\t\t}\n\t\tshiftCallbacks[event.keyCode].callback(\n\t\t\tevent,\n\t\t\tshiftCallbacks[event.keyCode].data\n\t\t);\n\t} else if (event.keyCode && callbacks[event.keyCode]) {\n\t\tif (stopPropagation) {\n\t\t\tEventUtil.trapEvent(event);\n\t\t}\n\t\tcallbacks[event.keyCode].callback(event, callbacks[event.keyCode].data);\n\t} else if (event.keyCode && callbacks.other) {\n\t\t// You will likely NOT want to stop propagation of all key presses!\n\t\tif (callbacks.other.stopPropagation) {\n\t\t\tEventUtil.trapEvent(event);\n\t\t}\n\t\tcallbacks.other.callback(event, callbacks.other.data);\n\t}\n};\n\nexport default mapKeyEventCallbacks;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/key-callbacks.js","/**\n * lodash (Custom Build) \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g,\n reHasRegExpChar = RegExp(reRegExpChar.source);\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\nfunction toString(value) {\n return value == null ? '' : baseToString(value);\n}\n\n/**\n * Escapes the `RegExp` special characters \"^\", \"$\", \"\\\", \".\", \"*\", \"+\",\n * \"?\", \"(\", \")\", \"[\", \"]\", \"{\", \"}\", and \"|\" in `string`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to escape.\n * @returns {string} Returns the escaped string.\n * @example\n *\n * _.escapeRegExp('[lodash](https://lodash.com/)');\n * // => '\\[lodash\\]\\(https://lodash\\.com/\\)'\n */\nfunction escapeRegExp(string) {\n string = toString(string);\n return (string && reHasRegExpChar.test(string))\n ? string.replace(reRegExpChar, '\\\\$&')\n : string;\n}\n\nmodule.exports = escapeRegExp;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/lodash.escaperegexp/index.js\n// module id = 45\n// module chunks = 0","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n/* eslint-disable import/no-mutable-exports */\n\nimport componentIsDeprecated from '../../utilities/warning/component-is-deprecated';\nimport deprecatedProperty from '../../utilities/warning/deprecated-property';\nimport getComponentDocFn from '../../utilities/get-component-doc';\nimport sunsetProperty from '../../utilities/warning/sunset-property';\n\n// ## Constants\nimport {\n\tGLOBAL_HEADER_BUTTON,\n\tGLOBAL_HEADER_DROPDOWN,\n\tGLOBAL_HEADER_PROFILE,\n} from '../../utilities/constants';\n\nlet checkProps = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n\tcheckProps = function(COMPONENT, props, jsonDoc) {\n\t\tif (\n\t\t\tCOMPONENT === GLOBAL_HEADER_BUTTON ||\n\t\t\tCOMPONENT === GLOBAL_HEADER_DROPDOWN\n\t\t) {\n\t\t\tcomponentIsDeprecated(\n\t\t\t\tCOMPONENT,\n\t\t\t\t`${COMPONENT} has been deprecated in favor of more-specific global header subcomponents. Please see docs for updated examples.`\n\t\t\t);\n\t\t}\n\n\t\tif (COMPONENT === GLOBAL_HEADER_PROFILE) {\n\t\t\tconst popoverExtraMessage =\n\t\t\t\t'Use the `popover` attribute to provide a `Popover` component with content inside the `body` prop instead.';\n\n\t\t\tsunsetProperty(COMPONENT, props.align, 'align');\n\n\t\t\tsunsetProperty(\n\t\t\t\tCOMPONENT,\n\t\t\t\tprops.children,\n\t\t\t\t'children',\n\t\t\t\tpopoverExtraMessage\n\t\t\t);\n\n\t\t\tsunsetProperty(COMPONENT, props.nubbinPosition, 'nubbinPosition');\n\n\t\t\tsunsetProperty(COMPONENT, props.offset, 'offset');\n\n\t\t\tsunsetProperty(COMPONENT, props.onSelect, 'onSelect');\n\n\t\t\tsunsetProperty(COMPONENT, props.options, 'options', popoverExtraMessage);\n\t\t}\n\n\t\tconst createDocUrl = getComponentDocFn(jsonDoc);\n\n\t\tdeprecatedProperty(\n\t\t\tCOMPONENT,\n\t\t\tprops.skipToContentAssistiveText,\n\t\t\t'skipToContentAssistiveText',\n\t\t\t\"assistiveText['skipToContent']\",\n\t\t\tcreateDocUrl('assistiveText')\n\t\t);\n\t\tdeprecatedProperty(\n\t\t\tCOMPONENT,\n\t\t\tprops.skipToNavAssistiveText,\n\t\t\t'skipToNavAssistiveText',\n\t\t\t\"assistiveText['skipToNav']\",\n\t\t\tcreateDocUrl('assistiveText')\n\t\t);\n\t};\n}\n\nexport default checkProps;\n\n\n\n// WEBPACK FOOTER //\n// ./components/global-header/check-props.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### React\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\n// ### classNames\nimport classNames from 'classnames';\n\n// ## Constants\nimport { DATA_TABLE_CELL } from '../../utilities/constants';\n\n/**\n * The default Cell renderer for the DataTable. Pass in any React component with the same `displayName` which takes the same props to provide custom rendering.\n */\nconst DataTableCell = (props) => {\n\tconst childText = React.isValidElement(props.children)\n\t\t? props.children.props.children\n\t\t: props.children;\n\tconst contents = (\n\t\t\n\t\t\t{props.children}\n\t\t
    \n\t);\n\n\tlet cell = (\n\t\t\n\t\t\t{contents}\n\t\t\n\t);\n\n\tif (props.primaryColumn) {\n\t\tcell = (\n\t\t\t\n\t\t\t\t{contents}\n\t\t\t\n\t\t);\n\t}\n\n\treturn cell;\n};\n\n// ### Display Name\n// Always use the canonical component name as the React display name.\nDataTableCell.displayName = DATA_TABLE_CELL;\n\n// ### Prop Types\nDataTableCell.propTypes = {\n\t/**\n\t * The contents of the cell. This can be simple text or DOM nodes. Equivalent to `props.item[props.property]`\n\t */\n\tchildren: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),\n\t/**\n\t * Class names to be added to the cell.\n\t */\n\tclassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * Use this if you are creating an advanced table (selectable, sortable, or resizable rows)\n\t */\n\tfixedLayout: PropTypes.bool,\n\t/**\n\t * The item from the items which represents this row.\n\t */\n\titem: PropTypes.object,\n\t/**\n\t * The primary column for a row. This is almost always the first column.\n\t */\n\tprimaryColumn: PropTypes.bool,\n\t/**\n\t * The property of this item to display.\n\t */\n\tproperty: PropTypes.string,\n\t/**\n\t * Shows on hover. Useful for truncated cells.\n\t */\n\ttitle: PropTypes.string,\n\t/**\n\t * Width of column. This is required for advanced/fixed layout tables. Please provide units. (`rems` are recommended)\n\t */\n\twidth: PropTypes.string,\n};\n\nexport default DataTableCell;\n\n\n\n// WEBPACK FOOTER //\n// ./components/data-table/cell.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nconst DateUtil = {\n\tfirstDayOfMonth(date) {\n\t\tconst newDate = new Date(date);\n\t\tnewDate.setDate(1);\n\t\treturn newDate;\n\t},\n\n\tisFirstDayOfMonth(date) {\n\t\treturn date.getDate() === 1;\n\t},\n\n\tisLastDayOfMonth(date) {\n\t\treturn !DateUtil.isSameMonth(date, DateUtil.addDays(date, 1));\n\t},\n\tisSameMonth(d1, d2) {\n\t\tif (!d1 || !d2) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\td1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth()\n\t\t);\n\t},\n\tisSameDay(d1, d2) {\n\t\tif (!d1 || !d2) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\td1.getFullYear() === d2.getFullYear() &&\n\t\t\td1.getMonth() === d2.getMonth() &&\n\t\t\td1.getDate() === d2.getDate()\n\t\t);\n\t},\n\tisCurrentMonth(date) {\n\t\tif (!date) {\n\t\t\treturn false;\n\t\t}\n\t\treturn DateUtil.isSameMonth(date, new Date());\n\t},\n\tisToday(date) {\n\t\tif (!date) {\n\t\t\treturn false;\n\t\t}\n\t\treturn DateUtil.isSameDay(date, new Date());\n\t},\n\tisEqual(d1, d2) {\n\t\treturn d1.getTime() === d2.getTime();\n\t},\n\taddDays(date, deltaDays) {\n\t\tconst newDate = new Date(date);\n\t\tnewDate.setDate(newDate.getDate() + parseInt(deltaDays, 10));\n\t\treturn newDate;\n\t},\n\taddWeeks(date, deltaWeeks) {\n\t\treturn DateUtil.addDays(date, parseInt(deltaWeeks, 10) * 7);\n\t},\n\tnearestWeekDay(date, weekDayIndex) {\n\t\tlet delta = weekDayIndex - date.getDay();\n\t\tif (delta < 0) {\n\t\t\tdelta += 7;\n\t\t}\n\t\treturn DateUtil.addDays(date, delta);\n\t},\n\tisLeapYear(year) {\n\t\treturn (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n\t},\n\n\tgetDaysInMonth(year, month) {\n\t\treturn [\n\t\t\t31,\n\t\t\tDateUtil.isLeapYear(year) ? 29 : 28,\n\t\t\t31,\n\t\t\t30,\n\t\t\t31,\n\t\t\t30,\n\t\t\t31,\n\t\t\t31,\n\t\t\t30,\n\t\t\t31,\n\t\t\t30,\n\t\t\t31,\n\t\t][month];\n\t},\n\n\taddMonths(date, value) {\n\t\tconst newDate = new Date(date);\n\t\tconst dateOfNewDate = newDate.getDate();\n\t\tnewDate.setDate(1);\n\t\tnewDate.setMonth(newDate.getMonth() + value);\n\t\tnewDate.setDate(\n\t\t\tMath.min(\n\t\t\t\tdateOfNewDate,\n\t\t\t\tDateUtil.getDaysInMonth(newDate.getFullYear(), newDate.getMonth())\n\t\t\t)\n\t\t);\n\t\treturn newDate;\n\t},\n};\n\nexport default DateUtil;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/date.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// Implements the [Vertical Navigation design pattern](https://lightningdesignsystem.com/components/vertical-navigation/) in React.\n// Based on SLDS v2.2.1\n\nimport React from 'react';\n\nimport PropTypes from 'prop-types';\n\n// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames)\n// This project uses `classnames`, 'a simple javascript utility for conditionally\n// joining classNames together.'\nimport classNames from 'classnames';\n\n// ### shortid\n// [npmjs.com/package/shortid](https://www.npmjs.com/package/shortid)\n// shortid is a short, non-sequential, url-friendly, unique id generator\nimport shortid from 'shortid';\nimport componentDoc from './docs.json';\nimport checkProps from './check-props';\n\nimport { VERTICAL_NAVIGATION } from '../../utilities/constants';\n\n// Child components\nimport Item from './private/item';\n\n/**\n * Vertical Navigation represents a list of links that either take the user to another page or parts of the page the user is in.\n */\nclass VerticalNavigation extends React.Component {\n\tstatic displayName = VERTICAL_NAVIGATION;\n\n\tstatic propTypes = {\n\t\t/**\n\t\t * HTML id for component. _Tested with snapshot testing._\n\t\t */\n\t\tid: PropTypes.string,\n\t\t/**\n\t\t * CSS class names to be added to the container element. _Tested with snapshot testing._\n\t\t */\n\t\tclassName: PropTypes.oneOfType([\n\t\t\tPropTypes.array,\n\t\t\tPropTypes.object,\n\t\t\tPropTypes.string,\n\t\t]),\n\t\t/**\n\t\t * Array of categories. The required shape is: `{id: string, label: string, items: array}`. The required shape of an item is `{id: string, label: string, url: string}`. All item ids are expected to be unique. _Tested with snapshot testing._\n\t\t */\n\t\tcategories: PropTypes.array,\n\t\t/**\n\t\t * The ID of the item that is currently selected. Defaults to the ID of the first item. _Tested with Mocha framework._\n\t\t */\n\t\tselectedId: PropTypes.string,\n\t\t/**\n\t\t * Triggered when the selection changes. It receives an event and an item object in the shape: `event, {item: [object] }`. _Tested with Mocha framework._\n\t\t */\n\t\tonSelect: PropTypes.func,\n\t};\n\n\tstatic defaultProps = {};\n\n\tcomponentWillMount() {\n\t\tthis.generatedId = shortid.generate();\n\t\tcheckProps(VERTICAL_NAVIGATION, this.props, componentDoc);\n\t}\n\n\tgetId = () => this.props.id || this.generatedId;\n\n\tgetSelectedId = () => {\n\t\tconst categories = this.props.categories;\n\t\tlet selectedId;\n\t\tif (this.props.selectedId) {\n\t\t\tselectedId = this.props.selectedId;\n\t\t} else if (\n\t\t\tcategories.length > 0 &&\n\t\t\tcategories[0].items &&\n\t\t\tcategories[0].items.length > 0\n\t\t) {\n\t\t\tselectedId = categories[0].items[0].id;\n\t\t}\n\t\treturn selectedId;\n\t};\n\n\trender() {\n\t\tconst rootId = this.getId();\n\t\treturn (\n\t\t\t\n\t\t\t\t{this.props.categories.map((category) => {\n\t\t\t\t\tconst categoryId = `${rootId}-${category.id}`;\n\t\t\t\t\tconst selectedId = this.getSelectedId();\n\t\t\t\t\treturn (\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t

    \n\t\t\t\t\t\t\t\t{category.label}\n\t\t\t\t\t\t\t

    \n\t\t\t\t\t\t\t
      \n\t\t\t\t\t\t\t\t{category.items.map((item) => (\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t\n\t\t);\n\t}\n}\n\nexport default VerticalNavigation;\n\n\n\n// WEBPACK FOOTER //\n// ./components/vertical-navigation/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport shortid from 'shortid';\nimport classNames from 'classnames';\n\nimport ToggleButton, { TOGGLE_BUTTON_WIDTH } from './private/toggle-button';\n\nimport { SPLIT_VIEW } from '../../utilities/constants';\n\nconst propTypes = {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `toggleButtonOpen`: The button used to open the split view.\n\t * * `toggleButtonClose`: The button used to close the split view.\n\t */\n\tassistiveText: PropTypes.shape({\n\t\ttoggleButtonOpen: PropTypes.string,\n\t\ttoggleButtonClose: PropTypes.string,\n\t}),\n\t/**\n\t * HTML Id for the component.\n\t */\n\tid: PropTypes.string,\n\t/**\n\t * CSS classes to be added to the root `div` tag. Uses `classNames` [API](https://github.com/JedWatson/classnames).\n\t */\n\tclassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * Sets the split view to be open or closed.\n\t */\n\tisOpen: PropTypes.bool,\n\t/**\n\t * Event Callbacks\n\t * * `onClose`: Triggered when the split view has closed.\n\t * * `onOpen`: Triggered when the split view has opened.\n\t */\n\tevents: PropTypes.shape({\n\t\tonClose: PropTypes.func,\n\t\tonOpen: PropTypes.func,\n\t}),\n\t/**\n\t * The React component that is rendered in the master section.\n\t * You need to pass in an array of elements in order for the scrolling to in the SplitViewList to work correctly.\n\t * React requires that you also supply a unique `key` for each element [React Lists and Keys](https://reactjs.org/docs/lists-and-keys.html#keys).\n\t */\n\tmaster: PropTypes.oneOfType([\n\t\tPropTypes.arrayOf(PropTypes.element),\n\t\tPropTypes.element,\n\t]).isRequired,\n\t/**\n\t * The width of the master section.\n\t */\n\tmasterWidth: PropTypes.string,\n\t/**\n\t * The React component that is rendered in the detail section.\n\t */\n\tdetail: PropTypes.oneOfType([\n\t\tPropTypes.arrayOf(PropTypes.element),\n\t\tPropTypes.element,\n\t]).isRequired,\n};\n\nconst defaultProps = {\n\tassistiveText: {\n\t\ttoggleButtonOpen: 'Close split view',\n\t\ttoggleButtonClose: 'Open split view',\n\t},\n\tevents: {},\n\tmasterWidth: '20rem',\n};\n\n/**\n * Split view is used to navigate between records in a list while staying on the same screen.\n */\nclass SplitView extends React.Component {\n\tstatic displayName = SPLIT_VIEW;\n\tstatic propTypes = propTypes;\n\tstatic defaultProps = defaultProps;\n\n\tconstructor(props) {\n\t\tsuper(props);\n\n\t\tthis.state = {\n\t\t\tisOpen: true,\n\t\t};\n\t}\n\n\tcomponentWillMount() {\n\t\tthis.generatedId = shortid.generate();\n\n\t\tthis.setIsOpen({ isOpen: this.props.isOpen });\n\t}\n\n\tcomponentWillReceiveProps(nextProps) {\n\t\tif (nextProps.isOpen !== this.props.isOpen) {\n\t\t\tthis.setIsOpen({ isOpen: nextProps.isOpen });\n\t\t}\n\t}\n\n\tgetId() {\n\t\treturn this.props.id || this.generatedId;\n\t}\n\n\tgetMasterViewId() {\n\t\treturn `master_view_${this.getId()}`;\n\t}\n\n\tsetIsOpen({ isOpen }) {\n\t\tif (typeof this.props.isOpen === 'boolean') {\n\t\t\tthis.setState({\n\t\t\t\tisOpen,\n\t\t\t});\n\t\t}\n\t}\n\n\ttoggle(event) {\n\t\tthis.setIsOpen({ isOpen: !this.state.isOpen });\n\n\t\tif (this.state.isOpen && this.props.events.onClose) {\n\t\t\tthis.props.events.onClose(event);\n\t\t} else if (!this.state.isOpen && this.props.events.onOpen) {\n\t\t\tthis.props.events.onOpen(event);\n\t\t}\n\t}\n\n\tmasterContent() {\n\t\treturn this.state.isOpen ? (\n\t\t\t\n\t\t\t\t{this.props.master}\n\t\t\t\n\t\t) : null;\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t this.toggle(event),\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t\t{this.masterContent()}\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t\t\t{this.props.detail}\n\t\t\t\t
    \n\t\t\t
    \n\t\t);\n\t}\n}\n\nexport default SplitView;\n\n\n\n// WEBPACK FOOTER //\n// ./components/split-view/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport Modal from 'react-modal';\n\n/*\n * The following are component utility methods that aid in global settings.\n*/\n\nlet assetsPath = 'assets/';\nlet appRoot;\n\nconst settings = {\n\tsetAssetsPath: (path) => {\n\t\tif (path) {\n\t\t\tassetsPath = path;\n\t\t}\n\t},\n\n\tgetAssetsPath: () => String(assetsPath),\n\n\t/*\n\t * The app element allows you to specify the portion of your app that should be hidden (via aria-hidden)\n\tto prevent assistive technologies such as screenreaders from reading content outside of the content of\n\tyour modal. It can be specified in the following ways:\n\t * element\n\tModal.setAppElement(appElement);\n\t * query selector - uses the first element found if you pass in a class.\n\tModal.setAppElement('#your-app-element');\n\t*/\n\tsetAppElement: (el) => {\n\t\tif (el) {\n\t\t\tappRoot = el;\n\t\t\tModal.setAppElement(el);\n\t\t}\n\t},\n\n\tgetAppElement: () => appRoot,\n};\n\nexport default settings;\n\n\n\n// WEBPACK FOOTER //\n// ./components/settings.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { ICON_SETTINGS } from '../../utilities/constants';\n\n/**\n * The Icon Settings component allows for the path to the icons to be specified in all child components and is recommended to be used at the root of the application. It's render function is `return this.props.children`, so it can only have one child node.\n *\n * **Individual sprites**\n * If you are using webpack it is advised to use the sprite properties\n * {actionSprite, standardSprite...} to specify the individual sprite paths so that webpack can\n * easily re-write the paths.\n * ```\n * import actionSprite from '......';\n *\n * \n * ```\n * **Root icon path**\n * Otherwise use the iconPath to specify the root path to where the icon files will be located in you application\n * such as `/assets/icons`.\n */\nclass IconSettings extends React.Component {\n\tgetChildContext() {\n\t\treturn {\n\t\t\ticonPath: this.props.iconPath,\n\t\t\tonRequestIconPath: this.props.onRequestIconPath,\n\t\t\tactionSprite: this.props.actionSprite,\n\t\t\tcustomSprite: this.props.customSprite,\n\t\t\tdoctypeSprite: this.props.doctypeSprite,\n\t\t\tstandardSprite: this.props.standardSprite,\n\t\t\tutilitySprite: this.props.utilitySprite,\n\t\t};\n\t}\n\n\trender() {\n\t\treturn this.props.children;\n\t}\n}\n\nIconSettings.displayName = ICON_SETTINGS;\n\nIconSettings.childContextTypes = {\n\ticonPath: PropTypes.string,\n\tonRequestIconPath: PropTypes.func,\n\tactionSprite: PropTypes.string,\n\tcustomSprite: PropTypes.string,\n\tdoctypeSprite: PropTypes.string,\n\tstandardSprite: PropTypes.string,\n\tutilitySprite: PropTypes.string,\n};\n\nIconSettings.propTypes = {\n\t/**\n\t * Path to the root icon folder\n\t * example: `/assets/icons`\n\t */\n\ticonPath: PropTypes.string,\n\t/**\n\t * Function to allow developers to return a custom icon path--for instance, on the same page with a local anchor (`#down`). This is helpful for when there are Cross-Origin Resource Sharing (CORS) issues with SVGs that are located on another domain such as a CDN. `({category, name}) => { return \\`#${name}\\` }`\n\t */\n\tonRequestIconPath: PropTypes.func,\n\t/**\n\t * Path to the action sprite\n\t * example: '@salesforce-ux/design-system/assets/icons/action-sprite/svg/symbols.svg';\n\t */\n\tactionSprite: PropTypes.string,\n\t/**\n\t * Path to the custom sprite\n\t * example: '@salesforce-ux/design-system/assets/icons/custom-sprite/svg/symbols.svg';\n\t */\n\tcustomSprite: PropTypes.string,\n\t/**\n\t * Path to the doctype sprite\n\t * example: '@salesforce-ux/design-system/assets/icons/doctype-sprite/svg/symbols.svg';\n\t */\n\tdoctypeSprite: PropTypes.string,\n\t/**\n\t * Path to the standard sprite\n\t * example: '@salesforce-ux/design-system/assets/icons/standard-sprite/svg/symbols.svg';\n\t */\n\tstandardSprite: PropTypes.string,\n\t/**\n\t * Path to the utility sprite\n\t * example: '@salesforce-ux/design-system/assets/icons/utility-sprite/svg/symbols.svg';\n\t */\n\tutilitySprite: PropTypes.string,\n};\n\nexport default IconSettings;\n\n\n\n// WEBPACK FOOTER //\n// ./components/icon-settings/index.jsx","import findTabbableElement from './tabbable';\nimport KEYS from './key-code';\nimport { canUseDOM } from './execution-environment';\n\nlet ancestor = null;\nlet focusLaterElement = null;\n\nconst handleScopedKeyDown = (event) => {\n\tif (!canUseDOM || !ancestor || event.keyCode !== KEYS.TAB) {\n\t\treturn;\n\t}\n\tconst tabbableElements = findTabbableElement(ancestor);\n\tconst finalTabbable =\n\t\ttabbableElements[event.shiftKey ? 0 : tabbableElements.length - 1];\n\tconst leavingFinalTabbable =\n\t\tfinalTabbable === document.activeElement ||\n\t\t// handle immediate shift+tab after opening with mouse\n\t\tancestor === document.activeElement;\n\tif (!leavingFinalTabbable) return;\n\tevent.preventDefault();\n\tconst target =\n\t\ttabbableElements[event.shiftKey ? tabbableElements.length - 1 : 0];\n\ttarget.focus();\n};\n\n// PUBLIC methods\n\nconst ElementFocus = {\n\tfocusAncestor: ({ isPortal }) => {\n\t\tif (canUseDOM) {\n\t\t\t// When a portal is used (that is attaching a separate React mount, such as with Popover) programatic focusing within that portal may cause the window to scroll down to the DOM insertion point at the end of `body`. The following prevents the scrolling from occuring.\n\t\t\tif (isPortal) {\n\t\t\t\tconst offset = window.pageYOffset;\n\t\t\t\tancestor.focus({ preventScroll: true });\n\t\t\t\twindow.scrollTo(window.pageXOffset, offset);\n\t\t\t} else {\n\t\t\t\tancestor.focus();\n\t\t\t}\n\t\t}\n\t},\n\thasOrAncestorHasFocus: () =>\n\t\tcanUseDOM &&\n\t\t(document.activeElement === ancestor ||\n\t\t\tancestor.contains(document.activeElement)),\n\treturnFocusToStoredElement: () => {\n\t\tif (canUseDOM) {\n\t\t\ttry {\n\t\t\t\tfocusLaterElement.focus();\n\t\t\t} catch (e) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`You tried to return focus to ${focusLaterElement} but it is not in the DOM anymore`\n\t\t\t\t);\n\t\t\t}\n\t\t\tfocusLaterElement = null;\n\t\t}\n\t},\n\tsetupScopedFocus: ({ ancestorElement }) => {\n\t\tancestor = ancestorElement;\n\t\twindow.addEventListener('keydown', handleScopedKeyDown, false);\n\t},\n\tstoreActiveElement: () => {\n\t\tfocusLaterElement = canUseDOM ? document.activeElement : null;\n\t},\n\tteardownScopedFocus: () => {\n\t\tancestor = null;\n\t\tif (canUseDOM) {\n\t\t\twindow.removeEventListener('keydown', handleScopedKeyDown);\n\t\t}\n\t},\n};\n\nexport default ElementFocus;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/dom-element-focus.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Avatar Component\n\n// Implements the [Avatar design pattern](https://lightningdesignsystem.com/components/avatar/) in React.\n\n// ### React\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode (similar to React's built in development tools)\nimport checkProps from './check-props';\n\n// ### classNames\n// [github.com/JedWatson/classnames](https://github.com/JedWatson/classnames) A\n// simple javascript utility for conditionally joining classNames together.\nimport classNames from '../../utilities/class-names';\nimport { AVATAR } from '../../utilities/constants';\nimport UtilityIcon from '../icon';\nimport componentDoc from './docs.json';\n\n// ### Display Name Always use the canonical component name as the React display\n// name.\nconst displayName = AVATAR;\n\n// ### Prop Types\nconst propTypes = {\n\t/**\n\t * **Assistive text for accessibility.**\n\t * This object is merged with the default props object on every render.\n\t * * `icon`: Assistive text for accessibility that labels the icon.\n\t */\n\tassistiveText: PropTypes.shape({\n\t\ticon: PropTypes.string,\n\t}),\n\t/**\n\t * Alt attribute to be applied to image (base case) element.\n\t */\n\timgAlt: PropTypes.string,\n\t/**\n\t * Source attribute to be applied to image (base case) element.\n\t */\n\timgSrc: PropTypes.string,\n\t/**\n\t * Initials attribute to optionally pass in initials directly in case of \"initials\" fallback case.\n\t */\n\tinitials: PropTypes.string,\n\t/**\n\t * Avatar with initials that are dark text on light background\n\t */\n\tinverse: PropTypes.bool,\n\t/**\n\t * Label attibute to display inside \"initials\" fallback case. Will be passed as title prop in `abbr` element to provide more specificity.\n\t */\n\tlabel: PropTypes.string,\n\t/**\n\t * Avatar variants to apply relevant styling (circle: user, square: entity) and icon rendering if applicable.\n\t */\n\tvariant: PropTypes.oneOf(['entity', 'user']).isRequired,\n\t/**\n\t * Size of the icon in \"icon\" fallback case.\n\t */\n\tsize: PropTypes.oneOf(['x-small', 'small', 'medium', 'large']).isRequired,\n\t/**\n\t * Title attribute for the avatar container.\n\t */\n\ttitle: PropTypes.string,\n};\n\nconst defaultProps = {\n\tassistiveText: {\n\t\ticon: 'User or Account Icon',\n\t},\n\timgAlt: '',\n\tsize: 'medium',\n\ttitle: 'user avatar',\n\tvariant: 'user',\n};\n\n/**\n * The avatar component represents an object or entity. An image is the preferred format for an avatar.\n If the `imgSrc` prop is undefined, and if a `label` or `initials` prop is available, the fallback avatar will render with initials. If initals are passed in directly in the `initials` prop, this will render in the fallback avatar. If `initals` prop is unavailable but a `label` prop is available, the fallback avatar will render with built initials of the user name or entity name.\n\n Intials built from the `label` prop will apply the following logic: If the label name contains two words, like first and last name, the first letter of each will be capitalized and returned. For labels that only have a single word name, the first two letters of that word, using one capital and one lower case letter, will be returned. For labels that contain three or more words, the first character of the first and last words will be capitalized and returned.\n\n If `initials` or `label` are not available, the fallback avatar will render a standard icon. If `variant='user'`, a user icon will\n render. If `variant='entity'`, an account icon will render.\n */\n\nclass Avatar extends React.Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.state = {\n\t\t\timgLoadError: false,\n\t\t};\n\t}\n\n\tcomponentWillMount() {\n\t\tcheckProps(AVATAR, this.props, componentDoc);\n\t}\n\n\tbuildInitials() {\n\t\tconst { label } = this.props;\n\t\tconst name = label.trim();\n\t\tconst nameParts = name.split(' ');\n\t\tif (nameParts.length > 1) {\n\t\t\treturn (\n\t\t\t\tnameParts[0].charAt(0).toUpperCase() +\n\t\t\t\tnameParts[nameParts.length - 1].charAt(0).toUpperCase()\n\t\t\t);\n\t\t}\n\t\treturn (name[0] || '').toUpperCase() + (name[1] || '').toLowerCase();\n\t}\n\n\thandleImageError() {\n\t\treturn this.setState(() => ({ imgLoadError: true }));\n\t}\n\n\trenderBaseAvatar() {\n\t\tconst { imgAlt, imgSrc, title } = this.props;\n\t\treturn (\n\t\t\t this.handleImageError()}\n\t\t\t\ttitle={title}\n\t\t\t/>\n\t\t);\n\t}\n\n\trenderIconAvatar() {\n\t\tconst { variant } = this.props;\n\t\tconst iconAssistiveText =\n\t\t\ttypeof this.props.assistiveText === 'string'\n\t\t\t\t? this.props.assistiveText\n\t\t\t\t: {\n\t\t\t\t\t\t...defaultProps.assistiveText,\n\t\t\t\t\t\t...this.props.assistiveText,\n\t\t\t\t\t}.icon;\n\t\treturn (\n\t\t\t\n\t\t);\n\t}\n\n\trenderInitialsAvatar() {\n\t\tconst { initials, inverse, label, variant } = this.props;\n\t\treturn (\n\t\t\t\n\t\t\t\t{initials ? initials : this.buildInitials()}\n\t\t\t\n\t\t);\n\t}\n\n\trender() {\n\t\tconst { imgSrc, initials, variant, label, size } = this.props;\n\n\t\tconst renderAvatar = () => {\n\t\t\t/* eslint no-unneeded-ternary: */\n\t\t\tif (!this.state.imgLoadError && imgSrc) {\n\t\t\t\treturn this.renderBaseAvatar();\n\t\t\t}\n\t\t\tif (initials || (label && label.trim())) {\n\t\t\t\treturn this.renderInitialsAvatar();\n\t\t\t}\n\t\t\treturn this.renderIconAvatar();\n\t\t};\n\n\t\treturn (\n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\t{renderAvatar()}\n\t\t\t\t\n\t\t\t
    \n\t\t);\n\t}\n}\n\nAvatar.defaultProps = defaultProps;\nAvatar.displayName = displayName;\nAvatar.propTypes = propTypes;\n\nexport default Avatar;\n\n\n\n// WEBPACK FOOTER //\n// ./components/avatar/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### React\n// React is an external dependency of the project.\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { CARD_EMPTY } from '../../utilities/constants';\n\n/**\n * A default empty state for Cards.\n */\nconst CardEmpty = (props) => (\n\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t\t{props.heading}\n\t\t\t

    \n\t\t\t{props.children}\n\t\t
    \n\t
    \n);\n\n// ### Display Name\n// Always use the canonical component name as the React display name.\nCardEmpty.displayName = CARD_EMPTY;\n\n// ### Prop Types\nCardEmpty.propTypes = {\n\t/**\n\t * Additional call to actions that will render under the heading. Often this is an \"Add Item\" button.\n\t */\n\tchildren: PropTypes.node,\n\t/**\n\t * Primary text for an Empty Card.\n\t */\n\theading: PropTypes.string,\n};\n\nCardEmpty.defaultProps = {\n\theading: 'No Related Items',\n};\n\nexport default CardEmpty;\n\n\n\n// WEBPACK FOOTER //\n// ./components/card/empty.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Spinner Component --- SLDS for React\n\n// Implements the [Spinner design pattern - 2.1.0-beta.3 (204)](https://latest-204.lightningdesignsystem.com/components/spinners) in React.\n\n// ### React\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nimport classNames from 'classnames';\n\nimport checkProps from './check-props';\n\n// ## Constants\nimport { SPINNER } from '../../utilities/constants';\n\nimport componentDoc from './docs.json';\n\n// ### Prop Types\nconst propTypes = {\n\t/**\n\t * **Assistive text for accessibility.**\n\t * This object is merged with the default props object on every render.\n\t * * `label`: Assistive text that is read out loud to screen readers.\n\t */\n\tassistiveText: PropTypes.shape({\n\t\tlabel: PropTypes.string,\n\t}),\n\t/**\n\t * Custom css classes applied to Spinner container\n\t */\n\tcontainerClassName: PropTypes.string,\n\t/**\n\t * Unique html id placed on div with role=\"status\".\n\t */\n\tid: PropTypes.string,\n\t/**\n\t * Adds delay of 300ms to the spinner\n\t */\n\tisDelayed: PropTypes.bool,\n\t/**\n\t * Add styling to support a spinner inside an input field.\n\t */\n\tisInput: PropTypes.bool,\n\t/**\n\t * Determines the size of the spinner\n\t */\n\tsize: PropTypes.oneOf(['x-small', 'small', 'medium', 'large']),\n\t/**\n\t * Determines the color of the spinner: `base` is gray, `brand` is blue, and `inverse` is white.\n\t */\n\tvariant: PropTypes.oneOf(['base', 'brand', 'inverse']),\n};\n\nconst defaultProps = {\n\tassistiveText: { label: 'Loading...' },\n\tisDelayed: false,\n\tsize: 'medium',\n\tvariant: 'base',\n};\n\n/**\n * Spinners are CSS loading indicators that should be shown when retrieving data or performing slow computations. In some cases, the first time a parent component loads, a stencil is preferred to indicate network activity.\n */\nconst Spinner = (props) => {\n\tcheckProps(SPINNER, props, componentDoc);\n\tconst { containerClassName, id, isDelayed, isInput, size, variant } = props;\n\tconst assistiveText =\n\t\ttypeof props.assistiveText === 'string'\n\t\t\t? props.assistiveText\n\t\t\t: {\n\t\t\t\t\t...defaultProps.assistiveText,\n\t\t\t\t\t...props.assistiveText,\n\t\t\t\t}.label;\n\n\tconst spinnerClassName = classNames('slds-spinner', {\n\t\t'slds-input__spinner': isInput,\n\t\t'slds-spinner_brand': variant === 'brand',\n\t\t'slds-spinner_inverse': variant === 'inverse',\n\t\t'slds-spinner_delayed': isDelayed,\n\t\t[`slds-spinner_${size}`]: size,\n\t});\n\n\treturn (\n\t\t
    \n\t\t\t\n\t\t\t\t{assistiveText && (\n\t\t\t\t\t{assistiveText}\n\t\t\t\t)}\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t);\n};\n\nSpinner.displayName = SPINNER;\nSpinner.propTypes = propTypes;\nSpinner.defaultProps = defaultProps;\n\nexport default Spinner;\n\n\n\n// WEBPACK FOOTER //\n// ./components/spinner/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Checkbox Component\n\n// Implements the [Checkbox design pattern](https://www.lightningdesignsystem.com/components/forms/#checkbox) in React.\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nimport classNames from 'classnames';\n\n// ### shortid\n// [npmjs.com/package/shortid](https://www.npmjs.com/package/shortid)\n// shortid is a short, non-sequential, url-friendly, unique id generator\nimport shortid from 'shortid';\n\n// ### Event Helpers\nimport KEYS from '../../utilities/key-code';\nimport EventUtil from '../../utilities/event';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode (similar to React's built in development tools)\nimport checkProps from './check-props';\nimport componentDoc from './docs.json';\n\nimport { CHECKBOX } from '../../utilities/constants';\n\nconst propTypes = {\n\t/**\n\t * An HTML ID that is shared with ARIA-supported devices with the\n\t * `aria-controls` attribute in order to relate the input with\n\t * another region of the page. An example would be a select box\n\t * that shows or hides a panel.\n\t */\n\t'aria-controls': PropTypes.string,\n\t/**\n\t * The `aria-describedby` attribute is used to indicate the IDs of the elements that describe the object. It is used to establish a relationship between widgets or groups and text that described them. This is very similar to aria-labelledby: a label describes the essence of an object, while a description provides more information that the user might need.\n\t */\n\t'aria-describedby': PropTypes.string,\n\t/**\n\t * `aria-owns` indicate that an element depends on the current one when the relation can't be determined by the hierarchy structure.\n\t */\n\t'aria-owns': PropTypes.string,\n\t/**\n\t * The `aria-required` attribute is used to indicate that user input is required on an element before a form can be submitted.\n\t */\n\t'aria-required': PropTypes.bool,\n\t/**\n\t * **Assistive text for accessibility**\n\t * This object is merged with the default props object on every render.\n\t * * `label`: This is used as a visually hidden label if, no `labels.label` is provided.\n\t */\n\tassistiveText: PropTypes.shape({\n\t\tlabel: PropTypes.string,\n\t}),\n\t/**\n\t * The Checkbox should be a controlled component, and will always be in the state specified. If checked is not defined, the state of the uncontrolled native `input` component will be used.\n\t */\n\tchecked: PropTypes.bool,\n\t/**\n\t * This is the initial value of an uncontrolled form element and is present only\n\t * to provide compatibility with hybrid framework applications that are not\n\t * entirely React. It should only be used in an application without centralized\n\t * state (Redux, Flux). \"Controlled components\" with centralized state is highly recommended. See [Code Overview](https://github.com/salesforce/design-system-react/blob/master/docs/codebase-overview.md#controlled-and-uncontrolled-components) for more information.\n\t */\n\tdefaultChecked: PropTypes.bool,\n\t/**\n\t * Class names to be added to the outer container of the Checkbox.\n\t */\n\tclassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * Disables the Checkbox and prevents clicking it.\n\t */\n\tdisabled: PropTypes.bool,\n\t/**\n\t * Message to display when the Checkbox is in an error state. When this is present, also visually highlights the component as in error.\n\t */\n\terrorText: PropTypes.string,\n\t/**\n\t * A unique ID is needed in order to support keyboard navigation and ARIA support. This ID is added to the `input` element\n\t */\n\tid: PropTypes.string,\n\t/**\n\t * The Checkbox will be indeterminate if its state can not be figured out or is partially checked. Once a checkbox is indeterminate, a click should cause it to be checked. Since a user cannot put a checkbox into an indeterminate state, it is assumed you are controlling the value of `checked` with the parent, also, and that this is a controlled component. **Note:** `indeterminate` proptype does nothing in the `toggle` variant, as [SLDS does not support it](https://lightningdesignsystem.com/components/forms/#flavor-checkbox-toggle-checkbox-toggle).\n\t */\n\tindeterminate: PropTypes.bool,\n\t/**\n\t * **Text labels for internationalization**\n\t * This object is merged with the default props object on every render.\n\t * * `label`: Label for the _enabled_ state of the Toggle variant. Defaults to \"Enabled\".\n\t * * `toggleDisabled`: Label for the _disabled_ state of the Toggle variant. Defaults to \"Disabled\". Note that this uses SLDS language, and meaning, of \"Enabled\" and \"Disabled\"; referring to the state of whatever the checkbox is _toggling_, not whether the checkbox itself is enabled or disabled.\n\t * * `toggleEnabled`: Label for the _enabled_ state of the Toggle variant. Defaults to \"Enabled\".\n\t */\n\tlabels: PropTypes.shape({\n\t\tlabel: PropTypes.string,\n\t\ttoggleDisabled: PropTypes.string,\n\t\ttoggleEnabled: PropTypes.string,\n\t}),\n\t/**\n\t * Name of the submitted form parameter.\n\t */\n\tname: PropTypes.string,\n\t/**\n\t * This event fires when the Checkbox looses focus. It passes in `{ event }`.\n\t */\n\tonBlur: PropTypes.func,\n\t/**\n\t * This event fires when the Checkbox changes. Passes in `event, { checked }`. This used to be `checked, event, { checked }`.\n\t */\n\tonChange: PropTypes.func,\n\t/**\n\t * This event fires when the Checkbox is focused. It passes in `{ event }`.\n\t */\n\tonFocus: PropTypes.func,\n\t/**\n\t * This event fires when a key is pressed down. It passes in `{ event }`.\n\t */\n\tonKeyDown: PropTypes.func,\n\t/**\n\t * This event fires when a character is typed. See [this article](http://www.bloggingdeveloper.com/post/KeyPress-KeyDown-KeyUp-The-Difference-Between-Javascript-Key-Events.aspx) for more information. It passes in `{ event }`.\n\t */\n\tonKeyPress: PropTypes.func,\n\t/**\n\t * This event fires when a pressed key is released. It passes in `{ event }`.\n\t */\n\tonKeyUp: PropTypes.func,\n\t/**\n\t * Displays the value of the input, but does not allow changes.\n\t */\n\treadOnly: PropTypes.bool,\n\t/**\n\t * Highlights the Checkbox as a required field (does not perform any validation).\n\t */\n\trequired: PropTypes.bool,\n\t/**\n\t * The aria-role of the checkbox.\n\t */\n\trole: PropTypes.string,\n\t/**\n\t * Which UX pattern of checkbox? The default is `base` while other option is `toggle`. (**Note:** `toggle` variant does not support the `indeterminate` feature, because [SLDS does not support it](https://lightningdesignsystem.com/components/forms/#flavor-checkbox-toggle-checkbox-toggle).)\n\t */\n\tvariant: PropTypes.oneOf(['base', 'toggle', 'button-group']),\n};\n\nconst defaultProps = {\n\tassistiveText: {},\n\tlabels: {\n\t\ttoggleDisabled: 'Disabled',\n\t\ttoggleEnabled: 'Enabled',\n\t},\n\tvariant: 'base',\n};\n\n/**\n * The ability to style checkboxes with CSS varies across browsers. Using this component ensures checkboxes look the same everywhere.\n */\nclass Checkbox extends React.Component {\n\tcomponentWillMount() {\n\t\tcheckProps(CHECKBOX, this.props, componentDoc);\n\t\tthis.generatedId = shortid.generate();\n\t}\n\n\tgetId = () => this.props.id || this.generatedId;\n\n\thandleChange = (event) => {\n\t\tconst { checked, indeterminate, onChange } = this.props;\n\n\t\tif (typeof onChange === 'function') {\n\t\t\t// `target.checked` is present twice to maintain backwards compatibility. Please remove first parameter `value` on the next breaking change or when `forms/checkbox` is removed.\n\t\t\tif (this.props.oldEventParameterOrder) {\n\t\t\t\tonChange(event.target.checked, event, {\n\t\t\t\t\tchecked: indeterminate ? true : !checked,\n\t\t\t\t\tindeterminate: false,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// NEW API\n\t\t\t\tonChange(event, {\n\t\t\t\t\tchecked: indeterminate ? true : !checked,\n\t\t\t\t\tindeterminate: false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n\n\thandleKeyDown = (event) => {\n\t\tif (event.keyCode) {\n\t\t\tif (event.keyCode === KEYS.ENTER || event.keyCode === KEYS.SPACE) {\n\t\t\t\tEventUtil.trapImmediate(event);\n\t\t\t\tthis.handleChange(event);\n\t\t\t}\n\t\t}\n\t};\n\n\trenderButtonGroupVariant = (props, assistiveText, labels) => (\n\t\t\n\t\t\t {\n\t\t\t\t\tthis.input = component;\n\t\t\t\t}}\n\t\t\t\trole={props.role}\n\t\t\t\trequired={props.required}\n\t\t\t\ttype=\"checkbox\"\n\t\t\t/>\n\t\t\t\n\t\t\n\t);\n\n\trenderBaseVariant = (props, assistiveText, labels) => (\n\t\t\n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\t{props.required ? (\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\t\n\t\t\t\t\t) : null}\n\t\t\t\t\t {\n\t\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\t\tcomponent.indeterminate = props.indeterminate;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.input = component;\n\t\t\t\t\t\t}}\n\t\t\t\t\t\trole={props.role}\n\t\t\t\t\t\trequired={props.required}\n\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t/>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t\t{props.errorText ? (\n\t\t\t\t
    {props.errorText}
    \n\t\t\t) : null}\n\t\t
    \n\t);\n\n\trenderToggleVariant = (props, assistiveText, labels) => (\n\t\t\n\t\t\t\n\t\t\t{props.errorText ? (\n\t\t\t\t
    {props.errorText}
    \n\t\t\t) : null}\n\t\t
    \n\t);\n\n\trender() {\n\t\tconst assistiveText = {\n\t\t\t...defaultProps.assistiveText,\n\t\t\t/* Remove backward compatibility at next breaking change */\n\t\t\t...(typeof this.props.assistiveText === 'string'\n\t\t\t\t? { label: this.props.assistiveText }\n\t\t\t\t: {}),\n\t\t\t...(typeof this.props.assistiveText === 'object'\n\t\t\t\t? this.props.assistiveText\n\t\t\t\t: {}),\n\t\t};\n\t\tconst labels = {\n\t\t\t...defaultProps.labels,\n\t\t\t/* Remove backward compatibility at next breaking change */\n\t\t\t...(this.props.label ? { label: this.props.label } : {}),\n\t\t\t...this.props.labels,\n\t\t};\n\n\t\tconst subRenders = {\n\t\t\tbase: this.renderBaseVariant,\n\t\t\t'button-group': this.renderButtonGroupVariant,\n\t\t\ttoggle: this.renderToggleVariant,\n\t\t};\n\t\tconst variantExists = subRenders[this.props.variant];\n\n\t\treturn variantExists\n\t\t\t? subRenders[this.props.variant](this.props, assistiveText, labels)\n\t\t\t: subRenders.base(this.props, assistiveText, labels);\n\t}\n}\n\nCheckbox.displayName = CHECKBOX;\nCheckbox.propTypes = propTypes;\nCheckbox.defaultProps = defaultProps;\n\nexport default Checkbox;\n\n\n\n// WEBPACK FOOTER //\n// ./components/checkbox/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// Implements the [Radio Button Group design pattern](https://lightningdesignsystem.com/components/radio-button-group/) in React.\n// Based on SLDS v2.5.0\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\nimport shortid from 'shortid';\nimport assign from 'lodash.assign';\n\nimport { RADIO_BUTTON_GROUP } from '../../utilities/constants';\n\nconst propTypes = {\n\t/**\n\t * **Assistive text for accessibility**\n\t * * `label`: This label appears in the legend.\n\t */\n\tassistiveText: PropTypes.shape({\n\t\tlabel: PropTypes.string,\n\t}),\n\t/**\n\t * Children are expected to be Radio components.\n\t */\n\tchildren: PropTypes.node.isRequired,\n\t/**\n\t * Custom CSS classes added to `slds-radio_button-group` node.\n\t */\n\tclassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * **Text labels for internationalization**\n\t * This object is merged with the default props object on every render.\n\t * * `error`: Message to display when any of Checkboxes are in an error state.\n\t * * `label`: This label appears above the button group.\n\t */\n\tlabels: PropTypes.shape({\n\t\terror: PropTypes.string,\n\t\tlabel: PropTypes.string,\n\t}),\n\t/**\n\t * This event fires when the radio selection changes.\n\t */\n\tonChange: PropTypes.func,\n\t/**\n\t * Disable all radio inputs.\n\t */\n\tdisabled: PropTypes.bool,\n\t/**\n\t * Adds an indicator that this field is required.\n\t */\n\trequired: PropTypes.bool,\n\t/**\n\t * The name of this radio group.\n\t */\n\tname: PropTypes.string,\n\t/**\n\t * The ID of the error message, for linking to radio inputs with aria-describedby.\n\t */\n\terrorId: PropTypes.string,\n};\n\nconst defaultProps = { labels: {}, assistiveText: {} };\n\n/**\n * A styled select list that can have a single entry checked at any one time.\n * The RadioButtonGroup component wraps [Radio](/components/radios) components, which should be used as children.\n */\nclass RadioButtonGroup extends React.Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\n\t\t// Merge objects of strings with their default object\n\t\tthis.labels = this.props.labels\n\t\t\t? assign({}, defaultProps.labels, this.props.labels)\n\t\t\t: defaultProps.labels;\n\n\t\tthis.generatedName = shortid.generate();\n\t\tthis.generatedErrorId = this.labels.error ? shortid.generate() : null;\n\t}\n\n\tgetErrorId() {\n\t\tif (this.hasError()) {\n\t\t\treturn this.props.errorId || this.generatedErrorId;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tgetName() {\n\t\treturn this.props.name || this.generatedName;\n\t}\n\n\thasError() {\n\t\treturn !!this.labels.error;\n\t}\n\n\trender() {\n\t\tconst children = React.Children.map(this.props.children, (child) =>\n\t\t\tReact.cloneElement(child, {\n\t\t\t\tname: this.getName(),\n\t\t\t\tonChange: this.props.onChange,\n\t\t\t\t'aria-describedby': this.getErrorId(),\n\t\t\t\tdisabled: this.props.disabled,\n\t\t\t})\n\t\t);\n\n\t\treturn (\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t{this.props.required ? (\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\t\n\t\t\t\t\t) : null}\n\t\t\t\t\t{this.props.assistiveText.label\n\t\t\t\t\t\t? this.props.assistiveText.label\n\t\t\t\t\t\t: this.labels.label}\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t
    \n\t\t\t\t\t\t{children}\n\t\t\t\t\t
    \n\t\t\t\t\t{this.labels.error ? (\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t{this.labels.error}\n\t\t\t\t\t\t
    \n\t\t\t\t\t) : null}\n\t\t\t\t
    \n\t\t\t\n\t\t);\n\t}\n}\n\nRadioButtonGroup.displayName = RADIO_BUTTON_GROUP;\nRadioButtonGroup.propTypes = propTypes;\nRadioButtonGroup.defaultProps = defaultProps;\n\nexport default RadioButtonGroup;\n\n\n\n// WEBPACK FOOTER //\n// ./components/radio-button-group/index.jsx","import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst Swatch = ({ color, style, label, labels }) => {\n\tconst innerStyle = {\n\t\tbackgroundColor: color,\n\t\tborder: '1px solid #cccccc',\n\t\t...style,\n\t};\n\tlet assistiveText;\n\t// falsey values output a transparent swatch\n\tif (!color) {\n\t\tinnerStyle.backgroundImage =\n\t\t\t'linear-gradient(-45deg, white 47%, #870500 0, #870500 53%, white 0)';\n\t\tassistiveText = labels && labels.swatchTabTransparentSwatch;\n\t} else {\n\t\tassistiveText = label || color;\n\t}\n\n\treturn (\n\t\t\n\t\t\t{assistiveText}\n\t\t\n\t);\n};\n\nSwatch.propTypes = {\n\tcolor: PropTypes.string.isRequired,\n};\n\nexport default Swatch;\n\n\n\n// WEBPACK FOOTER //\n// ./components/color-picker/private/swatch.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Tabs Component\n\n// Implements the [Tabs design pattern](https://www.lightningdesignsystem.com/components/tabs/) in React.\n\n// ## Dependencies\n\n// ### React\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\n// ### shortid\n// `shortid` is a short, non-sequential, url-friendly, unique id generator. It is used here to provide unique strings for the HTML attribute `id` on the Tabs components. It is only used if the `id` prop is not provided on the man component.\nimport shortid from 'shortid';\n\n// ### classNames\nimport classNames from 'classnames';\n\n// ### isFunction\nimport isFunction from 'lodash.isfunction';\n\n// Child components\nimport TabsList from './private/tabs-list';\nimport Tab from './private/tab';\nimport TabPanel from './private/tab-panel';\n\n// ## Constants\nimport { TABS } from '../../utilities/constants';\n\n// ### Event Helpers\nimport KEYS from '../../utilities/key-code';\nimport EventUtil from '../../utilities/event';\n\n// Determine if a node from event.target is a Tab element\nfunction isTabNode(node) {\n\treturn (\n\t\t(node.nodeName === 'A' && node.getAttribute('role') === 'tab') ||\n\t\t(node.nodeName === 'LI' && node.getAttribute('role') === 'tab')\n\t);\n}\n\n// Determine if a tab node is disabled\nfunction isTabDisabled(node) {\n\tif (node.getAttribute) {\n\t\treturn node.getAttribute('aria-disabled') === 'true';\n\t}\n\n\treturn !!node.props.disabled;\n}\n\n/**\n * Tabs keeps related content in a single container that is shown and hidden through navigation.\n */\nconst displayName = TABS;\nconst propTypes = {\n\t/**\n\t * HTML `id` attribute of primary element that has `.slds-tabs_default` on it. Optional: If one is not supplied, a `shortid` will be created.\n\t */\n\tid: PropTypes.string,\n\n\t/**\n\t * The `children` are the actual tabs and panels to be displayed.\n\t *\n\t * Note that the structure of the `` component **does not** correspond to the DOM structure that is rendered. The `` component requires one or more children of type ``, which themselves require a `label` property which will be what shows in the `` and has `children`, which end up being the _contents of the tab's corresponding panel_.\n\t *\n\t * The component iterates through each `` and rendering one `` and one `` for each of them. The tab(s) end up being children of the ``.\n\t *\n\t * ```\n\t * \n\t * \t\n\t * \t\t
    \n\t * \t\t\t

    This is my tab 1 contents!

    \n\t * \t\t\t

    They show when you click the first tab.

    \n\t * \t\t
    \n\t * \t
    \n\t * \t\n\t * \t\t
    \n\t * \t\t\t

    This is my tab 2 contents!

    \n\t * \t\t\t

    They show when you click the second tab.

    \n\t * \t\t
    \n\t * \t
    \n\t *
    \n\t * ```\n\t */\n\tchildren: PropTypes.oneOfType([\n\t\tPropTypes.arrayOf(PropTypes.node),\n\t\tPropTypes.node,\n\t\tPropTypes.element,\n\t]).isRequired,\n\n\t/**\n\t * Class names to be added to the container element and is passed along to its children.\n\t */\n\tclassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\n\t/**\n\t * The Tab (and corresponding TabPanel) that is selected when the component first renders. Defaults to `0`.\n\t */\n\tdefaultSelectedIndex: PropTypes.number,\n\n\t/**\n\t * This function triggers when a tab is selected.\n\t */\n\tonSelect: PropTypes.func,\n\n\t/**\n\t * If the Tabs should be scopped, defaults to false\n\t */\n\tvariant: PropTypes.oneOf(['default', 'scoped']),\n\n\t/**\n\t * The Tab (and corresponding TabPanel) that is currently selected.\n\t */\n\tselectedIndex: PropTypes.number,\n};\nconst defaultProps = {\n\tdefaultSelectedIndex: 0,\n\tvariant: 'default',\n};\n\n/**\n * A tab keeps related content in a single container that is shown and hidden through navigation.\n */\nclass Tabs extends React.Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.tabs = [];\n\t}\n\n\tcomponentWillMount() {\n\t\t// If no `id` is supplied in the props we generate one. An HTML ID is _required_ for several elements in a tabs component in order to leverage ARIA attributes for accessibility.\n\t\tthis.generatedId = shortid.generate();\n\t\tthis.flavor = this.getVariant();\n\t\tthis.setState({\n\t\t\tselectedIndex: this.props.defaultSelectedIndex,\n\t\t});\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.setState({\n\t\t\tfocus: false,\n\t\t});\n\t}\n\n\tgetNextTab(index) {\n\t\tconst count = this.getTabsCount();\n\n\t\t// Look for non-disabled tab from index to the last tab on the right\n\t\t// eslint-disable-next-line no-plusplus\n\t\tfor (let i = index + 1; i < count; i++) {\n\t\t\tconst tab = this.getTab(i);\n\t\t\tif (!isTabDisabled(tab)) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\n\t\t// If no tab found, continue searching from first on left to index\n\t\t// eslint-disable-next-line no-plusplus\n\t\tfor (let i = 0; i < index; i++) {\n\t\t\tconst tab = this.getTab(i);\n\t\t\tif (!isTabDisabled(tab)) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\n\t\t// No tabs are disabled, return index\n\t\treturn index;\n\t}\n\n\tgetPanelsCount() {\n\t\treturn this.props.children ? React.Children.count(this.props.children) : 0;\n\t}\n\n\tgetPrevTab(index) {\n\t\tlet i = index;\n\n\t\t// Look for non-disabled tab from index to first tab on the left\n\t\t// eslint-disable-next-line no-plusplus\n\t\twhile (i--) {\n\t\t\tconst tab = this.getTab(i);\n\t\t\tif (!isTabDisabled(tab)) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\n\t\t// If no tab found, continue searching from last tab on right to index\n\t\ti = this.getTabsCount();\n\t\t// eslint-disable-next-line no-plusplus\n\t\twhile (i-- > index) {\n\t\t\tconst tab = this.getTab(i);\n\t\t\tif (!isTabDisabled(tab)) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\n\t\t// No tabs are disabled, return index\n\t\treturn index;\n\t}\n\n\tgetSelectedIndex() {\n\t\treturn Number.isInteger(this.props.selectedIndex)\n\t\t\t? this.props.selectedIndex\n\t\t\t: this.state.selectedIndex;\n\t}\n\n\tgetTab(index) {\n\t\treturn this.tabs[index].tab;\n\t}\n\n\tgetTabNode(index) {\n\t\treturn this.tabs[index].node;\n\t}\n\n\tgetTabsCount() {\n\t\treturn this.props.children ? React.Children.count(this.props.children) : 0;\n\t}\n\n\tgetVariant() {\n\t\treturn this.props.variant === 'scoped' ? 'scoped' : 'default';\n\t}\n\n\tsetSelected(index, focus) {\n\t\t// Check index boundary\n\t\tif (index < 0 || index >= this.getTabsCount()) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Keep reference to last index for event handler\n\t\tconst last = this.getSelectedIndex();\n\n\t\t/**\n\t\t * This is a temporary solution that could be broken in the future without notification,\n\t\t * since this component is not a controlled component and only relies on internal state.\n\t\t * If this breaks in the future an alternative way to control the state from outside the\n\t\t * component should be present.\n\t\t * */\n\t\tlet shouldContinue;\n\t\t// Call change event handler\n\t\tif (isFunction(this.props.onSelect)) {\n\t\t\tshouldContinue = this.props.onSelect(index, last);\n\t\t}\n\n\t\t// Don't update the state if nothing has changed\n\t\tif (shouldContinue !== false && index !== this.state.selectedIndex) {\n\t\t\tthis.setState({ selectedIndex: index, focus: focus === true });\n\t\t}\n\t}\n\n\thandleClick = (e) => {\n\t\tlet node = e.target;\n\t\t/* eslint-disable no-cond-assign */\n\t\tdo {\n\t\t\tif (this.isTabFromContainer(node)) {\n\t\t\t\tif (isTabDisabled(node)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst index = [].slice.call(node.parentNode.children).indexOf(node);\n\t\t\t\tthis.setSelected(index);\n\t\t\t\treturn;\n\t\t\t}\n\t\t} while ((node = node.parentNode) !== null);\n\t\t/* eslint-enable no-cond-assign */\n\t};\n\n\thandleKeyDown = (event) => {\n\t\tif (this.isTabFromContainer(event.target)) {\n\t\t\tlet index = this.getSelectedIndex();\n\t\t\tlet preventDefault = false;\n\n\t\t\tif (event.keyCode === KEYS.LEFT || event.keyCode === KEYS.UP) {\n\t\t\t\t// Select next tab to the left\n\t\t\t\tindex = this.getPrevTab(index);\n\t\t\t\tpreventDefault = true;\n\t\t\t} else if (event.keyCode === KEYS.RIGHT || event.keyCode === KEYS.DOWN) {\n\t\t\t\t// Select next tab to the right\n\t\t\t\tindex = this.getNextTab(index);\n\t\t\t\tpreventDefault = true;\n\t\t\t}\n\n\t\t\t// Prevent any dumn scrollbars from moving around as we type.\n\t\t\tif (preventDefault) {\n\t\t\t\tEventUtil.trap(event);\n\t\t\t}\n\n\t\t\tthis.setSelected(index, true);\n\t\t}\n\t};\n\n\t/**\n\t * Determine if a node from event.target is a Tab element for the current Tabs container.\n\t * If the clicked element is not a Tab, it returns false.\n\t * If it finds another Tabs container between the Tab and `this`, it returns false.\n\t */\n\tisTabFromContainer(node) {\n\t\t// Return immediately if the clicked element is not a Tab. This prevents tab panel content from selecting a tab.\n\t\tif (!isTabNode(node)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check if the first occurrence of a Tabs container is `this` one.\n\t\tlet nodeAncestor = node.parentElement;\n\t\tdo {\n\t\t\tif (nodeAncestor === this.tabsNode) return true;\n\t\t\telse if (nodeAncestor.getAttribute('data-tabs')) break;\n\n\t\t\tnodeAncestor = nodeAncestor.parentElement;\n\t\t} while (nodeAncestor);\n\n\t\treturn false;\n\t}\n\n\trenderTabPanels(parentId) {\n\t\tconst children = React.Children.toArray(this.props.children);\n\t\tconst selectedIndex = this.getSelectedIndex();\n\t\tlet result = null;\n\n\t\tresult = children.map((child, index) => {\n\t\t\tconst tabId = `${parentId}-slds-tabs_tab-${index}`;\n\t\t\tconst id = `${parentId}-slds-tabs_panel-${index}`;\n\t\t\tconst selected = selectedIndex === index;\n\t\t\tconst variant = this.getVariant();\n\n\t\t\treturn (\n\t\t\t\t\n\t\t\t\t\t{children[index]}\n\t\t\t\t
    \n\t\t\t);\n\t\t});\n\t\treturn result;\n\t}\n\n\trenderTabsList(parentId) {\n\t\tconst children = React.Children.toArray(this.props.children);\n\n\t\treturn (\n\t\t\t// `parentId` gets consumed by TabsList, adding a suffix of `-tabs__nav`\n\t\t\t\n\t\t\t\t{children.map((child, index) => {\n\t\t\t\t\tconst id = `${parentId}-slds-tabs_tab-${index}`;\n\t\t\t\t\tconst panelId = `${parentId}-slds-tabs_panel-${index}`;\n\t\t\t\t\tconst selected = this.getSelectedIndex() === index;\n\t\t\t\t\tconst focus = selected && this.state.focus;\n\t\t\t\t\tconst variant = this.getVariant();\n\t\t\t\t\treturn (\n\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\tthis.tabs[index] = { tab: child, node };\n\t\t\t\t\t\t\t\tif (this.state.focus) {\n\t\t\t\t\t\t\t\t\tthis.setState({ focus: false });\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tfocus={focus}\n\t\t\t\t\t\t\tselected={selected}\n\t\t\t\t\t\t\tid={id}\n\t\t\t\t\t\t\tpanelId={panelId}\n\t\t\t\t\t\t\tdisabled={child.props.disabled}\n\t\t\t\t\t\t\tvariant={variant}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{child.props.label}\n\t\t\t\t\t\t
    \n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tclassName,\n\t\t\tid = this.generatedId,\n\t\t\tvariant = this.getVariant,\n\t\t} = this.props;\n\n\t\treturn (\n\t\t\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\t\t\t {\n\t\t\t\t\tthis.tabsNode = node;\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{/* eslint-enable jsx-a11y/no-static-element-interactions */}\n\t\t\t\t{this.renderTabsList(id)}\n\t\t\t\t{this.renderTabPanels(id)}\n\t\t\t
    \n\t\t);\n\t}\n}\nTabs.displayName = displayName;\nTabs.propTypes = propTypes;\nTabs.defaultProps = defaultProps;\n\nexport default Tabs;\n\n\n\n// WEBPACK FOOTER //\n// ./components/tabs/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { TABS_PANEL } from '../../utilities/constants';\n\n/**\n * The `` component allows us to simplify the structure of the `` component.\n\n * Rather than require different (deeply nested) children for tabslist, with its tab(s) as well as tabpanel(s), we provide this `TabsPanel` component which takes a `label` property that will become what is shown on the `` that will be associated with it.\n\n * The `children` of the Panel will be fed to the `` component, while its `label` is handled in ``, via ``.\n *\n * ```\n * \n * \t
    \n * \t\t

    This is my tab 1 contents!

    \n * \t\t

    They show when you click the first tab.

    \n * \t
    \n *
    \n * ```\n */\nconst Panel = ({ children }) =>
    {React.Children.toArray(children)}
    ;\n\nPanel.displayName = TABS_PANEL;\n\nPanel.propTypes = {\n\t/**\n\t * The string or element that is handed off to the `` component, ends up being the title and the label for the tab associated with its tab panel.\n\t */\n\tlabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,\n\n\t/**\n\t * The `children` are the actual tab panels to be rendered. They get created by [tabs/index.jsx](./index.jsx) in the `renderTabPanels` function.\n\t *\n\t * Note that the `` component inserts a `div` element around the children, because React requires exactly one \"parent\" element returned. The `` component simply dips down into `children` to get the children of this wrapping `div` so that it does not get rendered in the DOM.\n\t */\n\tchildren: PropTypes.oneOfType([\n\t\tPropTypes.arrayOf(PropTypes.node),\n\t\tPropTypes.node,\n\t\tPropTypes.element,\n\t]).isRequired,\n};\n\nexport default Panel;\n\n\n\n// WEBPACK FOOTER //\n// ./components/tabs/panel.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Pill Component\n// Implements the [Pill design pattern](https://lightningdesignsystem.com/components/pills/) in React.\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { PILL } from '../../utilities/constants';\nimport UtilityIcon from '../utilities/utility-icon';\nimport KEYS from '../../utilities/key-code';\nimport EventUtil from '../../utilities/event';\n\nconst propTypes = {\n\t/**\n\t * **Assistive text for accessibility**\n\t * This object is merged with the default props object on every render.\n\t * * `remove`: This is a visually hidden label for the close button.\n\t * _Tested with snapshot testing._\n\t */\n\tassistiveText: PropTypes.shape({\n\t\tremove: PropTypes.string,\n\t}),\n\t/**\n\t * SLDSAvatar component to show on the left of the pill.\n\t * _Tested with Mocha framework._\n\t */\n\tavatar: PropTypes.element,\n\t/**\n\t * Applies the bare style to the component.\n\t * _Tested with Mocha framework._\n\t */\n\tbare: PropTypes.bool,\n\t/**\n\t * This is a way to specify custom contents for the pill in the case a simple text label is not enough.\n\t * _Tested with Mocha framework._\n\t */\n\tchildren: PropTypes.node,\n\t/**\n\t * CSS classes to be added to tag with `.slds-pill`. Uses `classNames` [API](https://github.com/JedWatson/classnames).\n\t * _Tested with Mocha framework._\n\t */\n\tclassName: PropTypes.oneOfType([\n\t\tPropTypes.array,\n\t\tPropTypes.object,\n\t\tPropTypes.string,\n\t]),\n\t/**\n\t * Applies the error style to the component.\n\t * _Tested with Mocha framework._\n\t */\n\thasError: PropTypes.bool,\n\t/**\n\t * An href to use if the pill is shown as a link.\n\t * _Tested with Mocha framework._\n\t */\n\thref: PropTypes.string,\n\t/**\n\t * SLDSIcon component to show on the left of the pill.\n\t * _Tested with Mocha framework._\n\t */\n\ticon: PropTypes.element,\n\t/**\n\t * **Text labels for internationalization**\n\t * This object is merged with the default props object on every render.\n\t * * `label`: Pill's label.\n\t * * `title`: Pill's title.\n\t * * `removeTitle`: A title to use for the remove icon.\n\t *\n\t * _Tested with snapshot testing._\n\t */\n\tlabels: PropTypes.shape({\n\t\tlabel: PropTypes.string,\n\t\ttitle: PropTypes.string,\n\t\tremoveTitle: PropTypes.string,\n\t}),\n\t/**\n\t * `onBlur` callback executes when the component loses focus.\n\t * _Tested with Mocha framework._\n\t */\n\tonBlur: PropTypes.func,\n\t/**\n\t * `onClick` callback executes when a user clicks on the pill or presses the Enter key.\n\t * _Tested with Mocha framework._\n\t */\n\tonClick: PropTypes.func,\n\t/**\n\t * `onFocus` callback executes when the component receives focus.\n\t * _Tested with Mocha framework._\n\t */\n\tonFocus: PropTypes.func,\n\t/**\n\t * `onKeyDown` callback executes when a user presses a key.\n\t * _Tested with Mocha framework._\n\t */\n\tonKeyDown: PropTypes.func,\n\t/**\n\t * `onRemove` callback executes when a user clicks on the pill's remove icon or presses the delete or the backspace keys.\n\t * _Tested with Mocha framework._\n\t */\n\tonRemove: PropTypes.func,\n\t/**\n\t * A variant of a pill\n\t * _Tested with Mocha framework._\n\t */\n\tvariant: PropTypes.oneOf(['link', 'option']),\n};\n\n/**\n * A pill displays a label that can contain links and can be removed from view. Use `PillContainer` for a list of pills in a container that resembles an `input` form field. A pill is useful for displaying read-only text that can be added and removed on demand.\n */\nclass Pill extends React.Component {\n\tgetHref = () =>\n\t\ttypeof this.props.href === 'string'\n\t\t\t? this.props.href\n\t\t\t: 'javascript:void(0);'; // eslint-disable-line no-script-url\n\n\t/**\n\t * Removes focus from the component.\n\t */\n\tblur = () => {\n\t\tthis.root.blur();\n\t};\n\n\t/**\n\t * Give focus to the Pill component.\n\t */\n\tfocus = () => {\n\t\tthis.root.focus();\n\t};\n\n\thandleKeyDown = (event, ...rest) => {\n\t\tif (typeof this.props.onKeyDown === 'function') {\n\t\t\t// Make a callback to onKeyDown.\n\t\t\tthis.props.onKeyDown.call(null, event, ...rest);\n\t\t\t// Cancel further handling if the default handling for the event was prevented.\n\t\t\tif (event.defaultPrevented) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tswitch (event.keyCode) {\n\t\t\tcase KEYS.ENTER:\n\t\t\t\tif (typeof this.props.onClick === 'function') {\n\t\t\t\t\tEventUtil.trap(event);\n\t\t\t\t\tthis.props.onClick();\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase KEYS.BACKSPACE:\n\t\t\tcase KEYS.DELETE:\n\t\t\t\tif (typeof this.props.onRemove === 'function') {\n\t\t\t\t\tEventUtil.trap(event);\n\t\t\t\t\tthis.props.onRemove();\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t};\n\n\thandleRef = (root) => {\n\t\t// Keeping the top-most element to support focus() and blur()\n\t\tthis.root = root;\n\t};\n\n\t/**\n\t * Extracts a set of custom properties. A custom property is a property, which is not described in propTypes of a component.\n\t */\n\trestProps = () => {\n\t\tconst {\n\t\t\tbare,\n\t\t\thasError,\n\t\t\tvariant,\n\t\t\tclassName,\n\t\t\tonClick,\n\t\t\tonRemove,\n\t\t\tlabels,\n\t\t\tassistiveText,\n\t\t\tchildren,\n\t\t\thref,\n\t\t\ticon,\n\t\t\tavatar,\n\t\t\tonKeyDown,\n\t\t\t...other\n\t\t} = this.props;\n\t\treturn other;\n\t};\n\n\trenderIcon = () => {\n\t\tconst icon = this.props.icon || this.props.avatar;\n\t\tif (icon) {\n\t\t\treturn {icon};\n\t\t}\n\t\treturn null;\n\t};\n\n\trenderLabel = () => {\n\t\tif (this.props.labels.label) {\n\t\t\tif (this.props.variant === 'link') {\n\t\t\t\treturn (\n\t\t\t\t\t\n\t\t\t\t\t\t{this.props.labels.label}\n\t\t\t\t\t\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn (\n\t\t\t\t\n\t\t\t\t\t{this.props.labels.label}\n\t\t\t\t\n\t\t\t);\n\t\t}\n\t\treturn this.props.children;\n\t};\n\n\trenderRemoveIcon = () => {\n\t\tif (typeof this.props.onRemove === 'function') {\n\t\t\treturn (\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t{this.props.assistiveText.remove || this.props.labels.removeTitle}\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t};\n\n\trender() {\n\t\tlet role;\n\t\tswitch (this.props.variant) {\n\t\t\tcase 'link':\n\t\t\t\trole = 'button';\n\t\t\t\tbreak;\n\t\t\tcase 'option':\n\t\t\t\trole = 'option';\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t}\n\n\t\treturn (\n\t\t\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\t\t\t\n\t\t\t\t{this.renderIcon()}\n\t\t\t\t{this.renderLabel()}\n\t\t\t\t{this.renderRemoveIcon()}\n\t\t\t\n\t\t);\n\t}\n}\n\nPill.displayName = PILL;\n\nPill.defaultProps = {\n\tvariant: 'link',\n\tlabels: {},\n\tassistiveText: {},\n};\n\nPill.propTypes = propTypes;\n\nexport default Pill;\n\n\n\n// WEBPACK FOOTER //\n// ./components/pill/index.jsx","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\nfunction KeyBuffer() {\n\tthis.buffer = '';\n\n\treturn (key) => {\n\t\tif (this.timeout) {\n\t\t\tclearTimeout(this.timeout);\n\t\t\tthis.timeout = undefined;\n\t\t}\n\n\t\tthis.timeout = setTimeout(() => {\n\t\t\tthis.buffer = '';\n\t\t}, 400);\n\n\t\tthis.buffer = this.buffer + key;\n\t\treturn this.buffer;\n\t};\n}\n\nexport default KeyBuffer;\n\n\n\n// WEBPACK FOOTER //\n// ./utilities/key-buffer.js","/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// # Global Header Button Component\n// NOTE: THIS COMPONENT HAS BEEN DEPRECATED AND WILL BE REMOVED IN FUTURE MAJOR RELEASES\n\n// ## Dependencies\n\n// ### React\nimport React from 'react';\n\n// ### Button\nimport Button from '../button';\n\n// This component's `checkProps` which issues warnings to developers about properties\n// when in development mode (similar to React's built in development tools)\nimport checkProps from './check-props';\n\n// ## Constants\nimport {\n\tGLOBAL_HEADER_BUTTON,\n\tGLOBAL_HEADER_TOOL,\n} from '../../utilities/constants';\n\n/**\n * A helper component that renders a Button in the tools area of the Global Header. Currently defaults to a bare icon, but this can be overriden if text-based buttons are required.\n */\nconst GlobalHeaderButton = (props) => {\n\tcheckProps(GLOBAL_HEADER_BUTTON, props);\n\tconst { buttonVariant, ...rest } = props;\n\tconst btn =