carbon-custom-elements
Version:
A Carbon Design System variant that's as easy to use as native HTML elements, with no framework tax, no framework silo.
1 lines • 1.64 kB
Source Map (JSON)
{"version":3,"sources":["components/date-picker/icon-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;;AAItD;;;GAGG;AACH,wBA+BE","file":"icon-plugin.d.ts","sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2019\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { render } from 'lit-html';\nimport { Instance as FlatpickrInstance } from 'flatpickr/dist/types/instance';\nimport { Plugin } from 'flatpickr/dist/types/options';\nimport ChevronLeft16 from '@carbon/icons/lib/chevron--left/16';\nimport ChevronRight16 from '@carbon/icons/lib/chevron--right/16';\n\n/**\n * @param config Plugin configuration.\n * @returns A Flatpickr plugin to set the right icons in the design system.\n */\nexport default (): Plugin => (fp: FlatpickrInstance) => {\n /**\n * Sets the icon in the design system.\n */\n const setIcon = () => {\n const { prevMonthNav, nextMonthNav } = fp;\n render(ChevronLeft16(), prevMonthNav);\n render(ChevronRight16(), nextMonthNav);\n };\n\n /**\n * Sets empty arrow icon contents as we render those icons after initialization.\n */\n const parseConfig = () => {\n const { config } = fp;\n config.prevArrow = '';\n config.nextArrow = '';\n };\n\n /**\n * Registers this Flatpickr plugin.\n * @param calendar The Flatpickr instance.\n */\n const register = () => {\n fp.loadedPlugins.push('carbonFlatpickrIconPlugin');\n };\n\n return {\n onParseConfig: parseConfig,\n onReady: [register, setIcon],\n };\n};\n"]}