@neo4j-ndl/react 4.9.44 → 4.9.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/_common/use-semi-controlled-input.js +1 -4
- package/lib/cjs/_common/use-semi-controlled-input.js.map +1 -1
- package/lib/cjs/_common/use-semi-controlled-state.js +1 -4
- package/lib/cjs/_common/use-semi-controlled-state.js.map +1 -1
- package/lib/cjs/clean-icon-button/CleanIconButton.js +2 -2
- package/lib/cjs/clean-icon-button/CleanIconButton.js.map +1 -1
- package/lib/cjs/clean-icon-button/stories/clean-icon-button-keyboard-display.story.js +31 -0
- package/lib/cjs/clean-icon-button/stories/clean-icon-button-keyboard-display.story.js.map +1 -0
- package/lib/cjs/clean-icon-button/stories/index.js +5 -1
- package/lib/cjs/clean-icon-button/stories/index.js.map +1 -1
- package/lib/cjs/clipboard-button/ClipboardButton.js +6 -5
- package/lib/cjs/clipboard-button/ClipboardButton.js.map +1 -1
- package/lib/cjs/icon-button/IconButton.js +2 -2
- package/lib/cjs/icon-button/IconButton.js.map +1 -1
- package/lib/cjs/icon-button-base/IconButtonBase.js +43 -4
- package/lib/cjs/icon-button-base/IconButtonBase.js.map +1 -1
- package/lib/cjs/kbd/Kbd.js +7 -6
- package/lib/cjs/kbd/Kbd.js.map +1 -1
- package/lib/cjs/kbd/kbd-utils.js +29 -0
- package/lib/cjs/kbd/kbd-utils.js.map +1 -1
- package/lib/cjs/menu/stories/index.js +3 -3
- package/lib/cjs/menu/stories/index.js.map +1 -1
- package/lib/cjs/text-input/TextInput.js +5 -5
- package/lib/cjs/text-input/TextInput.js.map +1 -1
- package/lib/cjs/tooltip/stories/index.js +5 -5
- package/lib/cjs/tooltip/stories/index.js.map +1 -1
- package/lib/cjs/tooltip/stories/{tooltip-with-keyboard-shortcut.story.js → tooltip-with-keyboard-display.story.js} +1 -1
- package/lib/cjs/tooltip/stories/tooltip-with-keyboard-display.story.js.map +1 -0
- package/lib/esm/_common/use-semi-controlled-input.js +2 -5
- package/lib/esm/_common/use-semi-controlled-input.js.map +1 -1
- package/lib/esm/_common/use-semi-controlled-state.js +2 -5
- package/lib/esm/_common/use-semi-controlled-state.js.map +1 -1
- package/lib/esm/clean-icon-button/CleanIconButton.js +2 -2
- package/lib/esm/clean-icon-button/CleanIconButton.js.map +1 -1
- package/lib/esm/clean-icon-button/stories/clean-icon-button-keyboard-display.story.js +29 -0
- package/lib/esm/clean-icon-button/stories/clean-icon-button-keyboard-display.story.js.map +1 -0
- package/lib/esm/clean-icon-button/stories/index.js +3 -0
- package/lib/esm/clean-icon-button/stories/index.js.map +1 -1
- package/lib/esm/clipboard-button/ClipboardButton.js +6 -5
- package/lib/esm/clipboard-button/ClipboardButton.js.map +1 -1
- package/lib/esm/icon-button/IconButton.js +2 -2
- package/lib/esm/icon-button/IconButton.js.map +1 -1
- package/lib/esm/icon-button-base/IconButtonBase.js +11 -5
- package/lib/esm/icon-button-base/IconButtonBase.js.map +1 -1
- package/lib/esm/kbd/Kbd.js +8 -7
- package/lib/esm/kbd/Kbd.js.map +1 -1
- package/lib/esm/kbd/kbd-utils.js +28 -0
- package/lib/esm/kbd/kbd-utils.js.map +1 -1
- package/lib/esm/menu/stories/index.js +3 -3
- package/lib/esm/menu/stories/index.js.map +1 -1
- package/lib/esm/text-input/TextInput.js +5 -5
- package/lib/esm/text-input/TextInput.js.map +1 -1
- package/lib/esm/tooltip/stories/index.js +3 -3
- package/lib/esm/tooltip/stories/index.js.map +1 -1
- package/lib/esm/tooltip/stories/{tooltip-with-keyboard-shortcut.story.js → tooltip-with-keyboard-display.story.js} +1 -1
- package/lib/esm/tooltip/stories/tooltip-with-keyboard-display.story.js.map +1 -0
- package/lib/types/_common/use-semi-controlled-input.d.ts.map +1 -1
- package/lib/types/_common/use-semi-controlled-state.d.ts.map +1 -1
- package/lib/types/clean-icon-button/CleanIconButton.d.ts +1 -1
- package/lib/types/clean-icon-button/CleanIconButton.d.ts.map +1 -1
- package/lib/types/clean-icon-button/stories/clean-icon-button-keyboard-display.story.d.ts +24 -0
- package/lib/types/clean-icon-button/stories/clean-icon-button-keyboard-display.story.d.ts.map +1 -0
- package/lib/types/clean-icon-button/stories/index.d.ts +2 -0
- package/lib/types/clean-icon-button/stories/index.d.ts.map +1 -1
- package/lib/types/clipboard-button/ClipboardButton.d.ts +3 -1
- package/lib/types/clipboard-button/ClipboardButton.d.ts.map +1 -1
- package/lib/types/icon-button/IconButton.d.ts +1 -1
- package/lib/types/icon-button/IconButton.d.ts.map +1 -1
- package/lib/types/icon-button-base/IconButtonBase.d.ts +7 -4
- package/lib/types/icon-button-base/IconButtonBase.d.ts.map +1 -1
- package/lib/types/kbd/Kbd.d.ts.map +1 -1
- package/lib/types/kbd/kbd-utils.d.ts +2 -0
- package/lib/types/kbd/kbd-utils.d.ts.map +1 -1
- package/lib/types/menu/stories/index.d.ts +2 -2
- package/lib/types/menu/stories/index.d.ts.map +1 -1
- package/lib/types/tooltip/stories/index.d.ts +2 -2
- package/lib/types/tooltip/stories/index.d.ts.map +1 -1
- package/lib/types/tooltip/stories/{tooltip-with-keyboard-shortcut.story.d.ts → tooltip-with-keyboard-display.story.d.ts} +1 -1
- package/lib/types/tooltip/stories/tooltip-with-keyboard-display.story.d.ts.map +1 -0
- package/package.json +25 -25
- package/lib/cjs/tooltip/stories/tooltip-with-keyboard-shortcut.story.js.map +0 -1
- package/lib/esm/tooltip/stories/tooltip-with-keyboard-shortcut.story.js.map +0 -1
- package/lib/types/tooltip/stories/tooltip-with-keyboard-shortcut.story.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kbd-utils.js","sourceRoot":"","sources":["../../../src/kbd/kbd-utils.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"kbd-utils.js","sourceRoot":"","sources":["../../../src/kbd/kbd-utils.ts"],"names":[],"mappings":";;AAgDA,4BAcC;AAKD,sCA0BC;AAKD,gDAwBC;AAkBD,wEAkBC;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,CAAC;AAED,SAAgB,8BAA8B,CAC5C,IAAiD,EACjD,YAA2C,EAC3C,KAAsB,QAAQ,EAAE;IAEhC,MAAM,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,CAAC,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC;SAC3B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;SACtC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;SAAM,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC,CAAC,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport type { ReactNode } from 'react';\n\nexport type OperatingSystem = 'mac' | 'windows' | 'linux';\n\nexport type KbdKey =\n | 'meta'\n | 'shift'\n | 'ctrl'\n | 'enter'\n | 'delete'\n | 'escape'\n | 'tab'\n | 'capslock'\n | 'up'\n | 'right'\n | 'down'\n | 'left'\n | 'pageup'\n | 'pagedown'\n | 'home'\n | 'end'\n | 'space'\n | 'fn'\n | 'alt';\n\n/**\n * Detects the operating system based on the user agent\n */\nexport function detectOS(): OperatingSystem {\n if (typeof window === 'undefined') {\n return 'linux';\n }\n\n const userAgent = window.navigator.userAgent.toLowerCase();\n\n if (userAgent.includes('mac')) {\n return 'mac';\n } else if (userAgent.includes('win')) {\n return 'windows';\n } else {\n return 'linux';\n }\n}\n\n/**\n * Returns OS-aware keyboard key symbols\n */\nexport function getKbdKeysMap(\n os: OperatingSystem = detectOS(),\n): Record<KbdKey, string> {\n const baseMap: Record<KbdKey, string> = {\n alt: os === 'mac' ? '⌥' : 'alt',\n capslock: '⇪',\n ctrl: os === 'mac' ? '⌃' : 'ctrl',\n delete: os === 'mac' ? '⌫' : 'delete',\n down: '↓',\n end: 'end',\n enter: '↵',\n escape: '⎋',\n fn: 'Fn',\n home: 'home',\n left: '←',\n meta: os === 'mac' ? '⌘' : os === 'windows' ? '⊞' : 'meta',\n pagedown: '⇟',\n pageup: '⇞',\n right: '→',\n shift: '⇧',\n space: '␣',\n tab: '⇥',\n up: '↑',\n };\n\n return baseMap;\n}\n\n/**\n * Returns OS-aware keyboard key labels\n */\nexport function getKbdKeysLabelMap(\n os: OperatingSystem = detectOS(),\n): Record<KbdKey, string> {\n return {\n alt: 'Alt',\n capslock: 'Caps Lock',\n ctrl: 'Control',\n delete: 'Delete',\n down: 'Down',\n end: 'End',\n enter: 'Enter',\n escape: 'Escape',\n fn: 'Fn',\n home: 'Home',\n left: 'Left',\n meta: os === 'mac' ? 'Command' : os === 'windows' ? 'Windows' : 'Meta',\n pagedown: 'Page Down',\n pageup: 'Page Up',\n right: 'Right',\n shift: 'Shift',\n space: 'Space',\n tab: 'Tab',\n up: 'Up',\n };\n}\n\nfunction resolveKeyLabel(\n key: KbdKey | ReactNode,\n labels: Record<KbdKey, string>,\n): string {\n if (key === null || key === undefined || typeof key === 'boolean') {\n return '';\n }\n if (typeof key === 'string') {\n return key in labels ? labels[key as KbdKey] : key;\n }\n if (typeof key === 'number') {\n return String(key);\n }\n return '';\n}\n\nexport function getKbdScreenReaderFriendlyText(\n keys: readonly (KbdKey | ReactNode)[] | undefined,\n modifierKeys: readonly KbdKey[] | undefined,\n os: OperatingSystem = detectOS(),\n): string {\n const labels = getKbdKeysLabelMap(os);\n const modStr = (modifierKeys ?? []).map((k) => labels[k]).join(' + ');\n const keyLabels = (keys ?? [])\n .map((k) => resolveKeyLabel(k, labels))\n .filter(Boolean);\n let keyStr = '';\n if (keyLabels.length === 1) {\n keyStr = keyLabels[0];\n } else if (keyLabels.length > 1) {\n keyStr = keyLabels.join(' then ');\n }\n const body = [modStr, keyStr].filter(Boolean).join(' + ');\n return body ? `Shortcut: ${body}` : '';\n}\n"]}
|
|
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.MenuRadioAndNormalSrc = exports.MenuRadioItemsSrc = exports.
|
|
26
|
+
exports.MenuRadioAndNormalSrc = exports.MenuRadioItemsSrc = exports.MenuWithKeyboardDisplaySrc = exports.MenuPlacementsSrc = exports.MenuWithDisabledItemSrc = exports.MenuDividerSrc = exports.MenuInDialogSrc = exports.MenuInPopoverSrc = exports.MenuCustomItemsSrc = exports.MenuWithIconSrc = exports.MenuWithCategorySrc = exports.MenuNestedSrc = exports.MenuDefaultSrc = exports.MenuRadioAndNormal = exports.MenuRadioItems = exports.MenuWithKeyboardDisplay = exports.MenuPlacements = exports.MenuWithDisabledItem = exports.MenuDivider = exports.MenuInDialog = exports.MenuInPopover = exports.MenuCustomItems = exports.MenuWithIcon = exports.MenuWithCategory = exports.MenuNested = exports.MenuDefault = void 0;
|
|
27
27
|
var menu_default_story_1 = require("./menu-default.story");
|
|
28
28
|
Object.defineProperty(exports, "MenuDefault", { enumerable: true, get: function () { return __importDefault(menu_default_story_1).default; } });
|
|
29
29
|
var menu_nested_story_1 = require("./menu-nested.story");
|
|
@@ -45,7 +45,7 @@ Object.defineProperty(exports, "MenuWithDisabledItem", { enumerable: true, get:
|
|
|
45
45
|
var menu_placements_story_1 = require("./menu-placements.story");
|
|
46
46
|
Object.defineProperty(exports, "MenuPlacements", { enumerable: true, get: function () { return __importDefault(menu_placements_story_1).default; } });
|
|
47
47
|
var menu_with_keyboard_shortcuts_story_1 = require("./menu-with-keyboard-shortcuts.story");
|
|
48
|
-
Object.defineProperty(exports, "
|
|
48
|
+
Object.defineProperty(exports, "MenuWithKeyboardDisplay", { enumerable: true, get: function () { return __importDefault(menu_with_keyboard_shortcuts_story_1).default; } });
|
|
49
49
|
var menu_radio_items_story_1 = require("./menu-radio-items.story");
|
|
50
50
|
Object.defineProperty(exports, "MenuRadioItems", { enumerable: true, get: function () { return __importDefault(menu_radio_items_story_1).default; } });
|
|
51
51
|
var menu_radio_and_normal_story_1 = require("./menu-radio-and-normal.story");
|
|
@@ -74,7 +74,7 @@ exports.MenuInDialogSrc = (0, export_stories_utils_1.removeLicenseHeader)(menu_i
|
|
|
74
74
|
exports.MenuDividerSrc = (0, export_stories_utils_1.removeLicenseHeader)(menu_with_divider_story_raw_1.default);
|
|
75
75
|
exports.MenuWithDisabledItemSrc = (0, export_stories_utils_1.removeLicenseHeader)(menu_with_disabled_item_story_raw_1.default);
|
|
76
76
|
exports.MenuPlacementsSrc = (0, export_stories_utils_1.removeLicenseHeader)(menu_placements_story_raw_1.default);
|
|
77
|
-
exports.
|
|
77
|
+
exports.MenuWithKeyboardDisplaySrc = (0, export_stories_utils_1.removeLicenseHeader)(menu_with_keyboard_shortcuts_story_raw_1.default);
|
|
78
78
|
exports.MenuRadioItemsSrc = (0, export_stories_utils_1.removeLicenseHeader)(menu_radio_items_story_raw_1.default);
|
|
79
79
|
exports.MenuRadioAndNormalSrc = (0, export_stories_utils_1.removeLicenseHeader)(menu_radio_and_normal_story_raw_1.default);
|
|
80
80
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/menu/stories/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;AAEH,2DAA8D;AAArD,kIAAA,OAAO,OAAe;AAC/B,yDAA4D;AAAnD,gIAAA,OAAO,OAAc;AAC9B,uEAAyE;AAAhE,6IAAA,OAAO,OAAoB;AACpC,+DAAiE;AAAxD,qIAAA,OAAO,OAAgB;AAChC,qEAAuE;AAA9D,2IAAA,OAAO,OAAmB;AACnC,iEAAmE;AAA1D,uIAAA,OAAO,OAAiB;AACjC,+DAAiE;AAAxD,qIAAA,OAAO,OAAgB;AAChC,qEAAmE;AAA1D,uIAAA,OAAO,OAAe;AAC/B,iFAAkF;AAAzE,sJAAA,OAAO,OAAwB;AACxC,iEAAoE;AAA3D,wIAAA,OAAO,OAAkB;AAClC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/menu/stories/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;AAEH,2DAA8D;AAArD,kIAAA,OAAO,OAAe;AAC/B,yDAA4D;AAAnD,gIAAA,OAAO,OAAc;AAC9B,uEAAyE;AAAhE,6IAAA,OAAO,O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AAC;AACW,QAAA,iBAAiB,GAAG,IAAA,0CAAmB,EAAC,mCAAoB,CAAC,CAAC;AAC9D,QAAA,0BAA0B,GAAG,IAAA,0CAAmB,EAC3D,gDAA6B,CAC9B,CAAC;AACW,QAAA,iBAAiB,GAAG,IAAA,0CAAmB,EAAC,oCAAoB,CAAC,CAAC;AAC9D,QAAA,qBAAqB,GAAG,IAAA,0CAAmB,EACtD,yCAAwB,CACzB,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { default as MenuDefault } from './menu-default.story';\nexport { default as MenuNested } from './menu-nested.story';\nexport { default as MenuWithCategory } from './menu-with-category.story';\nexport { default as MenuWithIcon } from './menu-with-icon.story';\nexport { default as MenuCustomItems } from './menu-custom-items.story';\nexport { default as MenuInPopover } from './menu-in-popover.story';\nexport { default as MenuInDialog } from './menu-in-dialog.story';\nexport { default as MenuDivider } from './menu-with-divider.story';\nexport { default as MenuWithDisabledItem } from './menu-with-disabled-item.story';\nexport { default as MenuPlacements } from './menu-placements.story';\nexport { default as MenuWithKeyboardDisplay } from './menu-with-keyboard-shortcuts.story';\nexport { default as MenuRadioItems } from './menu-radio-items.story';\nexport { default as MenuRadioAndNormal } from './menu-radio-and-normal.story';\n\nimport { removeLicenseHeader } from '../../_common/export-stories-utils';\nimport MenuCustomItemsSrcRaw from './menu-custom-items.story?raw';\nimport MenuDefaultSrcRaw from './menu-default.story?raw';\nimport MenuInDialogSrcRaw from './menu-in-dialog.story?raw';\nimport MenuInPopoverSrcRaw from './menu-in-popover.story?raw';\nimport MenuNestedSrcRaw from './menu-nested.story?raw';\nimport MenuPlacementsSrcRaw from './menu-placements.story?raw';\nimport MenuRadioAndNormalSrcRaw from './menu-radio-and-normal.story?raw';\nimport MenuRadioItemsSrcRaw from './menu-radio-items.story?raw';\nimport MenuWithCategorySrcRaw from './menu-with-category.story?raw';\nimport MenuWithDisabledItemSrcRaw from './menu-with-disabled-item.story?raw';\nimport MenuDividerSrcRaw from './menu-with-divider.story?raw';\nimport MenuWithIconSrcRaw from './menu-with-icon.story?raw';\nimport MenuWithKeyboardDisplaySrcRaw from './menu-with-keyboard-shortcuts.story?raw';\n\nexport const MenuDefaultSrc = removeLicenseHeader(MenuDefaultSrcRaw);\nexport const MenuNestedSrc = removeLicenseHeader(MenuNestedSrcRaw);\nexport const MenuWithCategorySrc = removeLicenseHeader(MenuWithCategorySrcRaw);\nexport const MenuWithIconSrc = removeLicenseHeader(MenuWithIconSrcRaw);\nexport const MenuCustomItemsSrc = removeLicenseHeader(MenuCustomItemsSrcRaw);\nexport const MenuInPopoverSrc = removeLicenseHeader(MenuInPopoverSrcRaw);\nexport const MenuInDialogSrc = removeLicenseHeader(MenuInDialogSrcRaw);\nexport const MenuDividerSrc = removeLicenseHeader(MenuDividerSrcRaw);\nexport const MenuWithDisabledItemSrc = removeLicenseHeader(\n MenuWithDisabledItemSrcRaw,\n);\nexport const MenuPlacementsSrc = removeLicenseHeader(MenuPlacementsSrcRaw);\nexport const MenuWithKeyboardDisplaySrc = removeLicenseHeader(\n MenuWithKeyboardDisplaySrcRaw,\n);\nexport const MenuRadioItemsSrc = removeLicenseHeader(MenuRadioItemsSrcRaw);\nexport const MenuRadioAndNormalSrc = removeLicenseHeader(\n MenuRadioAndNormalSrcRaw,\n);\n"]}
|
|
@@ -55,7 +55,7 @@ const typography_1 = require("../typography");
|
|
|
55
55
|
*/
|
|
56
56
|
const TextInput = (_a) => {
|
|
57
57
|
var { label, isFluid, errorText, helpText, leadingElement, trailingElement, showRequiredOrOptionalLabel = false, moreInformationText, size = 'medium', placeholder, value, tooltipProps, htmlAttributes, isDisabled, isReadOnly, isRequired, onChange, isClearable = false, className, style, isSkeletonLoading = false, isLoading = false, skeletonProps, ref } = _a, restProps = __rest(_a, ["label", "isFluid", "errorText", "helpText", "leadingElement", "trailingElement", "showRequiredOrOptionalLabel", "moreInformationText", "size", "placeholder", "value", "tooltipProps", "htmlAttributes", "isDisabled", "isReadOnly", "isRequired", "onChange", "isClearable", "className", "style", "isSkeletonLoading", "isLoading", "skeletonProps", "ref"]);
|
|
58
|
-
const [
|
|
58
|
+
const [currentValue, handleChange] = (0, use_semi_controlled_input_1.useSemiControlledInput)({
|
|
59
59
|
inputType: 'text',
|
|
60
60
|
isControlled: value !== undefined,
|
|
61
61
|
onChange,
|
|
@@ -87,10 +87,10 @@ const TextInput = (_a) => {
|
|
|
87
87
|
const shouldRenderHint = isClearable || isLoading;
|
|
88
88
|
const handleInputKeyDown = (event) => {
|
|
89
89
|
var _a;
|
|
90
|
-
if (isClearable && event.key === 'Escape' && Boolean(
|
|
90
|
+
if (isClearable && event.key === 'Escape' && Boolean(currentValue)) {
|
|
91
91
|
event.preventDefault();
|
|
92
92
|
event.stopPropagation();
|
|
93
|
-
|
|
93
|
+
handleChange === null || handleChange === void 0 ? void 0 : handleChange({
|
|
94
94
|
target: { value: '' },
|
|
95
95
|
});
|
|
96
96
|
}
|
|
@@ -125,8 +125,8 @@ const TextInput = (_a) => {
|
|
|
125
125
|
? 'ndl-medium-spinner'
|
|
126
126
|
: 'ndl-small-spinner' })) : (leadingElement) })), (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('ndl-input-container', {
|
|
127
127
|
'ndl-clearable': isClearable,
|
|
128
|
-
}), children: [(0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref, readOnly: isReadOnly, disabled: isDisabled, required: isRequired, value:
|
|
129
|
-
|
|
128
|
+
}), children: [(0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref, readOnly: isReadOnly, disabled: isDisabled, required: isRequired, value: currentValue, placeholder: placeholder, type: "text", onChange: handleChange, "aria-describedby": combinedAriaDescribedby, "aria-invalid": Boolean(errorText) }, combinedHtmlInputAttributes, { onKeyDown: handleInputKeyDown }, restProps)), shouldRenderHint && ((0, jsx_runtime_1.jsxs)("span", { id: hintId, className: "ndl-text-input-hint", "aria-hidden": true, children: [isLoading && 'Loading ', isClearable && 'Press Escape to clear input.'] })), isClearable && Boolean(currentValue) && ((0, jsx_runtime_1.jsx)("div", { className: "ndl-element-clear ndl-element", children: (0, jsx_runtime_1.jsx)("button", { tabIndex: -1, "aria-hidden": true, type: "button", title: "Clear input (Esc)", onClick: () => {
|
|
129
|
+
handleChange === null || handleChange === void 0 ? void 0 : handleChange({
|
|
130
130
|
target: { value: '' },
|
|
131
131
|
});
|
|
132
132
|
}, children: (0, jsx_runtime_1.jsx)(icons_1.XMarkIconOutline, { className: "n-size-4" }) }) }))] }), trailingElement && ((0, jsx_runtime_1.jsx)("div", { className: "ndl-element-trailing ndl-element", children: isLoading && !leadingElement ? ((0, jsx_runtime_1.jsx)(loading_spinner_1.LoadingSpinner, { size: size === 'large' ? 'medium' : 'small', className: size === 'large'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../../src/text-input/TextInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,4DAAoC;AACpC,iCAMe;AAEf,kDAA8E;AAE9E,oFAA8E;AAC9E,4CAAwD;AACxD,oCAIkB;AAClB,wDAAoD;AACpD,0CAAuC;AACvC,wCAAqC;AACrC,8CAA2C;AAoE3C;;;;;;GAMG;AAEI,MAAM,SAAS,GAAG,CAAC,EA0Ba,EAAE,EAAE;QA1BjB,EACxB,KAAK,EACL,OAAO,EACP,SAAS,EACT,QAAQ,E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j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport classNames from 'classnames';\nimport {\n type InputHTMLAttributes,\n type ReactElement,\n type ReactNode,\n useId,\n useMemo,\n} from 'react';\n\nimport { customLabelAndNoAriaLabelWarningMessage } from '../_common/messages';\nimport { type CommonProps, type TooltipObjectProps } from '../_common/types';\nimport { useSemiControlledInput } from '../_common/use-semi-controlled-input';\nimport { needleWarningMessage } from '../_common/utils';\nimport {\n ExclamationCircleIconSolid,\n InformationCircleIconOutline,\n XMarkIconOutline,\n} from '../icons';\nimport { LoadingSpinner } from '../loading-spinner';\nimport { Skeleton } from '../skeleton';\nimport { Tooltip } from '../tooltip';\nimport { Typography } from '../typography';\n\ntype TextInputProps = {\n /** Assistive text displayed below the input */\n helpText?: string | ReactNode;\n\n /** Error message displayed below the input. When provided, it overrides `helpText` and shows an error icon */\n errorText?: string | ReactNode;\n\n /** Leading element rendered inside the input */\n leadingElement?: ReactElement;\n\n /** Trailing element rendered inside the input */\n trailingElement?: ReactElement;\n\n /** Size of the input */\n size?: 'small' | 'medium' | 'large';\n\n /** Whether the input is read-only */\n isReadOnly?: boolean;\n\n /**\n * Whether to display the Required/Optional label next to the field label.\n * Shows Required if isRequired is true, otherwise shows Optional.\n * @default false\n */\n showRequiredOrOptionalLabel?: boolean;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Whether the input is required */\n isRequired?: boolean;\n\n /** The current value of the input */\n value?: React.ComponentPropsWithoutRef<'input'>['value'];\n\n /** Placeholder text displayed when the input is empty */\n placeholder?: React.ComponentPropsWithoutRef<'input'>['placeholder'];\n\n /** Callback function triggered when the input value changes */\n onChange?: React.ComponentPropsWithoutRef<'input'>['onChange'];\n\n /** Whether the input should take the full available width */\n isFluid?: boolean;\n\n /** Text displayed in the information tooltip shown next to the label */\n moreInformationText?: React.ReactNode;\n\n /** The label displayed above the input */\n label?: string | React.ReactNode;\n\n /** Props for the Tooltip component used by the information icon */\n tooltipProps?: TooltipObjectProps;\n\n /** Whether to render skeletons instead of content */\n isSkeletonLoading?: boolean;\n\n /** Additional props forwarded to the underlying Skeleton components */\n skeletonProps?: React.ComponentProps<typeof Skeleton>;\n\n /** Whether to show the clear button */\n isClearable?: boolean;\n\n /** Whether to show the loading spinner */\n isLoading?: boolean;\n};\n\n/**\n *\n *\n * TextInput Component\n *\n *\n */\n\nexport const TextInput = ({\n label,\n isFluid,\n errorText,\n helpText,\n leadingElement,\n trailingElement,\n showRequiredOrOptionalLabel = false,\n moreInformationText,\n size = 'medium',\n placeholder,\n value,\n tooltipProps,\n htmlAttributes,\n isDisabled,\n isReadOnly,\n isRequired,\n onChange,\n isClearable = false,\n className,\n style,\n isSkeletonLoading = false,\n isLoading = false,\n skeletonProps,\n ref,\n ...restProps\n}: CommonProps<'input', TextInputProps>) => {\n const [internalState, internalOnChange] = useSemiControlledInput({\n inputType: 'text',\n isControlled: value !== undefined,\n onChange,\n state: value ?? '',\n });\n const hintId = useId();\n const helpTextId = useId();\n const errorTextId = useId();\n\n const containerWrappingClasses = classNames(`ndl-text-input`, className, {\n 'ndl-disabled': isDisabled,\n 'ndl-has-error': errorText,\n 'ndl-has-icon': leadingElement || trailingElement || errorText,\n 'ndl-has-leading-icon': leadingElement,\n 'ndl-has-trailing-icon': trailingElement || errorText,\n 'ndl-large': size === 'large',\n 'ndl-medium': size === 'medium',\n 'ndl-read-only': isReadOnly,\n 'ndl-small': size === 'small',\n });\n\n const hasEmptyLabelValue =\n label === undefined || label === null || label === '';\n\n const labelWrappingClasses = classNames('ndl-form-item-label', {\n 'ndl-fluid': isFluid,\n 'ndl-form-item-no-label': hasEmptyLabelValue,\n });\n\n const combinedHtmlInputAttributes: InputHTMLAttributes<HTMLInputElement> = {\n ...htmlAttributes,\n className: classNames('ndl-input', htmlAttributes?.className),\n };\n const ariaLabel = combinedHtmlInputAttributes['aria-label'];\n const isCustomLabel = Boolean(label) && typeof label !== 'string';\n const hasCustomLabelAndNoAriaLabel =\n isCustomLabel && (ariaLabel === undefined || ariaLabel === '');\n const shouldRenderHint = isClearable || isLoading;\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (isClearable && event.key === 'Escape' && Boolean(internalState)) {\n event.preventDefault();\n event.stopPropagation();\n internalOnChange?.({\n target: { value: '' },\n } as React.ChangeEvent<HTMLInputElement>);\n }\n htmlAttributes?.onKeyDown?.(event);\n };\n\n useMemo(() => {\n if (!label && !ariaLabel) {\n needleWarningMessage(\n 'A TextInput without a label does not have an aria label, be sure to include an aria label for screen readers. Link: https://dequeuniversity.com/rules/axe/4.2/label?application=axeAPI',\n );\n }\n\n if (hasCustomLabelAndNoAriaLabel) {\n needleWarningMessage(customLabelAndNoAriaLabelWarningMessage);\n }\n }, [label, ariaLabel, hasCustomLabelAndNoAriaLabel]);\n\n const informationIconClasses = classNames({\n 'ndl-information-icon-large': size === 'large',\n 'ndl-information-icon-small': size === 'small' || size === 'medium',\n });\n\n const combinedAriaDescribedby = useMemo(() => {\n const ariaDescribedby = [];\n\n if (hintId && shouldRenderHint) {\n ariaDescribedby.push(hintId);\n }\n if (helpText && !errorText) {\n ariaDescribedby.push(helpTextId);\n } else if (errorText) {\n ariaDescribedby.push(errorTextId);\n }\n return ariaDescribedby.join(' ');\n }, [hintId, shouldRenderHint, helpText, errorText, helpTextId, errorTextId]);\n\n return (\n <div className={containerWrappingClasses} style={style}>\n {/* We enable implicit label wrapping */}\n {/* Source: https://dequeuniversity.com/rules/axe/4.2/label?application=axeAPI */}\n <label className={labelWrappingClasses}>\n {!hasEmptyLabelValue && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n <div className=\"ndl-label-text-wrapper\">\n <Typography\n variant={size === 'large' ? 'body-large' : 'body-medium'}\n className=\"ndl-label-text\"\n >\n {label}\n </Typography>\n {Boolean(moreInformationText) && (\n <Tooltip {...tooltipProps?.root} type=\"simple\">\n <Tooltip.Trigger\n {...tooltipProps?.trigger}\n className={informationIconClasses}\n hasButtonWrapper\n >\n <div\n tabIndex={0}\n role=\"button\"\n aria-label=\"Information icon\"\n >\n <InformationCircleIconOutline />\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n {moreInformationText}\n </Tooltip.Content>\n </Tooltip>\n )}\n {showRequiredOrOptionalLabel && (\n <Typography\n variant={size === 'large' ? 'body-large' : 'body-medium'}\n className=\"ndl-form-item-optional\"\n >\n {isRequired === true ? 'Required' : 'Optional'}\n </Typography>\n )}\n </div>\n </Skeleton>\n )}\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n <div className=\"ndl-input-wrapper\">\n {(leadingElement || (isLoading && !trailingElement)) && (\n <div className=\"ndl-element-leading ndl-element\">\n {isLoading ? (\n <LoadingSpinner\n size={size === 'large' ? 'medium' : 'small'}\n className={\n size === 'large'\n ? 'ndl-medium-spinner'\n : 'ndl-small-spinner'\n }\n />\n ) : (\n leadingElement\n )}\n </div>\n )}\n <div\n className={classNames('ndl-input-container', {\n 'ndl-clearable': isClearable,\n })}\n >\n <input\n ref={ref}\n readOnly={isReadOnly}\n disabled={isDisabled}\n required={isRequired}\n value={internalState}\n placeholder={placeholder}\n type=\"text\"\n onChange={internalOnChange}\n aria-describedby={combinedAriaDescribedby}\n aria-invalid={Boolean(errorText)}\n {...combinedHtmlInputAttributes}\n onKeyDown={handleInputKeyDown}\n {...restProps}\n />\n {shouldRenderHint && (\n <span\n id={hintId}\n className=\"ndl-text-input-hint\"\n aria-hidden={true}\n >\n {isLoading && 'Loading '}\n {isClearable && 'Press Escape to clear input.'}\n </span>\n )}\n {isClearable && Boolean(internalState) && (\n <div className=\"ndl-element-clear ndl-element\">\n <button\n tabIndex={-1}\n aria-hidden={true}\n type=\"button\"\n title=\"Clear input (Esc)\"\n onClick={() => {\n internalOnChange?.({\n target: { value: '' },\n } as React.ChangeEvent<HTMLInputElement>);\n }}\n >\n <XMarkIconOutline className=\"n-size-4\" />\n </button>\n </div>\n )}\n </div>\n {trailingElement && (\n <div className=\"ndl-element-trailing ndl-element\">\n {isLoading && !leadingElement ? (\n <LoadingSpinner\n size={size === 'large' ? 'medium' : 'small'}\n className={\n size === 'large'\n ? 'ndl-medium-spinner'\n : 'ndl-small-spinner'\n }\n />\n ) : (\n trailingElement\n )}\n </div>\n )}\n </div>\n </Skeleton>\n </label>\n {Boolean(helpText) && !errorText && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n isLoading={isSkeletonLoading}\n >\n <Typography\n variant={size === 'large' ? 'body-medium' : 'body-small'}\n className=\"ndl-form-message\"\n htmlAttributes={{\n 'aria-live': 'polite',\n id: helpTextId,\n }}\n >\n {helpText}\n </Typography>\n </Skeleton>\n )}\n {Boolean(errorText) && (\n // TODO v4: We might want to have a min width for the container for the messages to help skeleton loading.\n // Currently the message fills 100% of the width while the rest of the text input has a set width.\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n width=\"fit-content\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n <div className=\"ndl-form-message\">\n <div className=\"ndl-error-icon\">\n <ExclamationCircleIconSolid />\n </div>\n <Typography\n className=\"ndl-error-text\"\n variant={size === 'large' ? 'body-medium' : 'body-small'}\n htmlAttributes={{\n 'aria-live': 'polite',\n id: errorTextId,\n }}\n >\n {errorText}\n </Typography>\n </div>\n </Skeleton>\n )}\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../../src/text-input/TextInput.tsx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AAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,EACxD,cAAc,EAAE;gCACd,WAAW,EAAE,QAAQ;gCACrB,EAAE,EAAE,WAAW;6BAChB,YAEA,SAAS,GACC,IACT,IACG,CACZ,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAxSW,QAAA,SAAS,aAwSpB","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport classNames from 'classnames';\nimport {\n type InputHTMLAttributes,\n type ReactElement,\n type ReactNode,\n useId,\n useMemo,\n} from 'react';\n\nimport { customLabelAndNoAriaLabelWarningMessage } from '../_common/messages';\nimport { type CommonProps, type TooltipObjectProps } from '../_common/types';\nimport { useSemiControlledInput } from '../_common/use-semi-controlled-input';\nimport { needleWarningMessage } from '../_common/utils';\nimport {\n ExclamationCircleIconSolid,\n InformationCircleIconOutline,\n XMarkIconOutline,\n} from '../icons';\nimport { LoadingSpinner } from '../loading-spinner';\nimport { Skeleton } from '../skeleton';\nimport { Tooltip } from '../tooltip';\nimport { Typography } from '../typography';\n\ntype TextInputProps = {\n /** Assistive text displayed below the input */\n helpText?: string | ReactNode;\n\n /** Error message displayed below the input. When provided, it overrides `helpText` and shows an error icon */\n errorText?: string | ReactNode;\n\n /** Leading element rendered inside the input */\n leadingElement?: ReactElement;\n\n /** Trailing element rendered inside the input */\n trailingElement?: ReactElement;\n\n /** Size of the input */\n size?: 'small' | 'medium' | 'large';\n\n /** Whether the input is read-only */\n isReadOnly?: boolean;\n\n /**\n * Whether to display the Required/Optional label next to the field label.\n * Shows Required if isRequired is true, otherwise shows Optional.\n * @default false\n */\n showRequiredOrOptionalLabel?: boolean;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Whether the input is required */\n isRequired?: boolean;\n\n /** The current value of the input */\n value?: React.ComponentPropsWithoutRef<'input'>['value'];\n\n /** Placeholder text displayed when the input is empty */\n placeholder?: React.ComponentPropsWithoutRef<'input'>['placeholder'];\n\n /** Callback function triggered when the input value changes */\n onChange?: React.ComponentPropsWithoutRef<'input'>['onChange'];\n\n /** Whether the input should take the full available width */\n isFluid?: boolean;\n\n /** Text displayed in the information tooltip shown next to the label */\n moreInformationText?: React.ReactNode;\n\n /** The label displayed above the input */\n label?: string | React.ReactNode;\n\n /** Props for the Tooltip component used by the information icon */\n tooltipProps?: TooltipObjectProps;\n\n /** Whether to render skeletons instead of content */\n isSkeletonLoading?: boolean;\n\n /** Additional props forwarded to the underlying Skeleton components */\n skeletonProps?: React.ComponentProps<typeof Skeleton>;\n\n /** Whether to show the clear button */\n isClearable?: boolean;\n\n /** Whether to show the loading spinner */\n isLoading?: boolean;\n};\n\n/**\n *\n *\n * TextInput Component\n *\n *\n */\n\nexport const TextInput = ({\n label,\n isFluid,\n errorText,\n helpText,\n leadingElement,\n trailingElement,\n showRequiredOrOptionalLabel = false,\n moreInformationText,\n size = 'medium',\n placeholder,\n value,\n tooltipProps,\n htmlAttributes,\n isDisabled,\n isReadOnly,\n isRequired,\n onChange,\n isClearable = false,\n className,\n style,\n isSkeletonLoading = false,\n isLoading = false,\n skeletonProps,\n ref,\n ...restProps\n}: CommonProps<'input', TextInputProps>) => {\n const [currentValue, handleChange] = useSemiControlledInput({\n inputType: 'text',\n isControlled: value !== undefined,\n onChange,\n state: value ?? '',\n });\n const hintId = useId();\n const helpTextId = useId();\n const errorTextId = useId();\n\n const containerWrappingClasses = classNames(`ndl-text-input`, className, {\n 'ndl-disabled': isDisabled,\n 'ndl-has-error': errorText,\n 'ndl-has-icon': leadingElement || trailingElement || errorText,\n 'ndl-has-leading-icon': leadingElement,\n 'ndl-has-trailing-icon': trailingElement || errorText,\n 'ndl-large': size === 'large',\n 'ndl-medium': size === 'medium',\n 'ndl-read-only': isReadOnly,\n 'ndl-small': size === 'small',\n });\n\n const hasEmptyLabelValue =\n label === undefined || label === null || label === '';\n\n const labelWrappingClasses = classNames('ndl-form-item-label', {\n 'ndl-fluid': isFluid,\n 'ndl-form-item-no-label': hasEmptyLabelValue,\n });\n\n const combinedHtmlInputAttributes: InputHTMLAttributes<HTMLInputElement> = {\n ...htmlAttributes,\n className: classNames('ndl-input', htmlAttributes?.className),\n };\n const ariaLabel = combinedHtmlInputAttributes['aria-label'];\n const isCustomLabel = Boolean(label) && typeof label !== 'string';\n const hasCustomLabelAndNoAriaLabel =\n isCustomLabel && (ariaLabel === undefined || ariaLabel === '');\n const shouldRenderHint = isClearable || isLoading;\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (isClearable && event.key === 'Escape' && Boolean(currentValue)) {\n event.preventDefault();\n event.stopPropagation();\n handleChange?.({\n target: { value: '' },\n } as React.ChangeEvent<HTMLInputElement>);\n }\n htmlAttributes?.onKeyDown?.(event);\n };\n\n useMemo(() => {\n if (!label && !ariaLabel) {\n needleWarningMessage(\n 'A TextInput without a label does not have an aria label, be sure to include an aria label for screen readers. Link: https://dequeuniversity.com/rules/axe/4.2/label?application=axeAPI',\n );\n }\n\n if (hasCustomLabelAndNoAriaLabel) {\n needleWarningMessage(customLabelAndNoAriaLabelWarningMessage);\n }\n }, [label, ariaLabel, hasCustomLabelAndNoAriaLabel]);\n\n const informationIconClasses = classNames({\n 'ndl-information-icon-large': size === 'large',\n 'ndl-information-icon-small': size === 'small' || size === 'medium',\n });\n\n const combinedAriaDescribedby = useMemo(() => {\n const ariaDescribedby = [];\n\n if (hintId && shouldRenderHint) {\n ariaDescribedby.push(hintId);\n }\n if (helpText && !errorText) {\n ariaDescribedby.push(helpTextId);\n } else if (errorText) {\n ariaDescribedby.push(errorTextId);\n }\n return ariaDescribedby.join(' ');\n }, [hintId, shouldRenderHint, helpText, errorText, helpTextId, errorTextId]);\n\n return (\n <div className={containerWrappingClasses} style={style}>\n {/* We enable implicit label wrapping */}\n {/* Source: https://dequeuniversity.com/rules/axe/4.2/label?application=axeAPI */}\n <label className={labelWrappingClasses}>\n {!hasEmptyLabelValue && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n <div className=\"ndl-label-text-wrapper\">\n <Typography\n variant={size === 'large' ? 'body-large' : 'body-medium'}\n className=\"ndl-label-text\"\n >\n {label}\n </Typography>\n {Boolean(moreInformationText) && (\n <Tooltip {...tooltipProps?.root} type=\"simple\">\n <Tooltip.Trigger\n {...tooltipProps?.trigger}\n className={informationIconClasses}\n hasButtonWrapper\n >\n <div\n tabIndex={0}\n role=\"button\"\n aria-label=\"Information icon\"\n >\n <InformationCircleIconOutline />\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n {moreInformationText}\n </Tooltip.Content>\n </Tooltip>\n )}\n {showRequiredOrOptionalLabel && (\n <Typography\n variant={size === 'large' ? 'body-large' : 'body-medium'}\n className=\"ndl-form-item-optional\"\n >\n {isRequired === true ? 'Required' : 'Optional'}\n </Typography>\n )}\n </div>\n </Skeleton>\n )}\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n <div className=\"ndl-input-wrapper\">\n {(leadingElement || (isLoading && !trailingElement)) && (\n <div className=\"ndl-element-leading ndl-element\">\n {isLoading ? (\n <LoadingSpinner\n size={size === 'large' ? 'medium' : 'small'}\n className={\n size === 'large'\n ? 'ndl-medium-spinner'\n : 'ndl-small-spinner'\n }\n />\n ) : (\n leadingElement\n )}\n </div>\n )}\n <div\n className={classNames('ndl-input-container', {\n 'ndl-clearable': isClearable,\n })}\n >\n <input\n ref={ref}\n readOnly={isReadOnly}\n disabled={isDisabled}\n required={isRequired}\n value={currentValue}\n placeholder={placeholder}\n type=\"text\"\n onChange={handleChange}\n aria-describedby={combinedAriaDescribedby}\n aria-invalid={Boolean(errorText)}\n {...combinedHtmlInputAttributes}\n onKeyDown={handleInputKeyDown}\n {...restProps}\n />\n {shouldRenderHint && (\n <span\n id={hintId}\n className=\"ndl-text-input-hint\"\n aria-hidden={true}\n >\n {isLoading && 'Loading '}\n {isClearable && 'Press Escape to clear input.'}\n </span>\n )}\n {isClearable && Boolean(currentValue) && (\n <div className=\"ndl-element-clear ndl-element\">\n <button\n tabIndex={-1}\n aria-hidden={true}\n type=\"button\"\n title=\"Clear input (Esc)\"\n onClick={() => {\n handleChange?.({\n target: { value: '' },\n } as React.ChangeEvent<HTMLInputElement>);\n }}\n >\n <XMarkIconOutline className=\"n-size-4\" />\n </button>\n </div>\n )}\n </div>\n {trailingElement && (\n <div className=\"ndl-element-trailing ndl-element\">\n {isLoading && !leadingElement ? (\n <LoadingSpinner\n size={size === 'large' ? 'medium' : 'small'}\n className={\n size === 'large'\n ? 'ndl-medium-spinner'\n : 'ndl-small-spinner'\n }\n />\n ) : (\n trailingElement\n )}\n </div>\n )}\n </div>\n </Skeleton>\n </label>\n {Boolean(helpText) && !errorText && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n isLoading={isSkeletonLoading}\n >\n <Typography\n variant={size === 'large' ? 'body-medium' : 'body-small'}\n className=\"ndl-form-message\"\n htmlAttributes={{\n 'aria-live': 'polite',\n id: helpTextId,\n }}\n >\n {helpText}\n </Typography>\n </Skeleton>\n )}\n {Boolean(errorText) && (\n // TODO v4: We might want to have a min width for the container for the messages to help skeleton loading.\n // Currently the message fills 100% of the width while the rest of the text input has a set width.\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n width=\"fit-content\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n <div className=\"ndl-form-message\">\n <div className=\"ndl-error-icon\">\n <ExclamationCircleIconSolid />\n </div>\n <Typography\n className=\"ndl-error-text\"\n variant={size === 'large' ? 'body-medium' : 'body-small'}\n htmlAttributes={{\n 'aria-live': 'polite',\n id: errorTextId,\n }}\n >\n {errorText}\n </Typography>\n </div>\n </Skeleton>\n )}\n </div>\n );\n};\n"]}
|
|
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.TooltipTriggerButtonWrapperSource = exports.TooltipWithKeyboardDisplaySource = exports.TooltipRichLinkSource = exports.TooltipRichActionsSource = exports.TooltipRichSource = exports.TooltipHoverDelaySource = exports.TooltipInDialogSource = exports.TooltipPlacementsSource = exports.TooltipInitialOpenSource = exports.TooltipControlledSource = exports.TooltipDisabledSource = exports.TooltipDefaultSource = exports.TooltipWithKeyboardDisplay = exports.TooltipRichLink = exports.TooltipRichActions = exports.TooltipRich = exports.TooltipTriggerButtonWrapper = exports.TooltipHoverDelay = exports.TooltipInDialog = exports.TooltipPlacements = exports.TooltipInitialOpen = exports.TooltipControlled = exports.TooltipDisabled = exports.TooltipDefault = void 0;
|
|
27
27
|
var tooltip_default_story_1 = require("./tooltip-default.story");
|
|
28
28
|
Object.defineProperty(exports, "TooltipDefault", { enumerable: true, get: function () { return __importDefault(tooltip_default_story_1).default; } });
|
|
29
29
|
var tooltip_disabled_story_1 = require("./tooltip-disabled.story");
|
|
@@ -46,8 +46,8 @@ var tooltip_rich_actions_story_1 = require("./tooltip-rich-actions.story");
|
|
|
46
46
|
Object.defineProperty(exports, "TooltipRichActions", { enumerable: true, get: function () { return __importDefault(tooltip_rich_actions_story_1).default; } });
|
|
47
47
|
var tooltip_rich_link_story_1 = require("./tooltip-rich-link.story");
|
|
48
48
|
Object.defineProperty(exports, "TooltipRichLink", { enumerable: true, get: function () { return __importDefault(tooltip_rich_link_story_1).default; } });
|
|
49
|
-
var
|
|
50
|
-
Object.defineProperty(exports, "
|
|
49
|
+
var tooltip_with_keyboard_display_story_1 = require("./tooltip-with-keyboard-display.story");
|
|
50
|
+
Object.defineProperty(exports, "TooltipWithKeyboardDisplay", { enumerable: true, get: function () { return __importDefault(tooltip_with_keyboard_display_story_1).default; } });
|
|
51
51
|
const export_stories_utils_1 = require("../../_common/export-stories-utils");
|
|
52
52
|
const tooltip_controlled_story_raw_1 = __importDefault(require("./tooltip-controlled.story?raw"));
|
|
53
53
|
const tooltip_default_story_raw_1 = __importDefault(require("./tooltip-default.story?raw"));
|
|
@@ -60,7 +60,7 @@ const tooltip_rich_story_raw_1 = __importDefault(require("./tooltip-rich.story?r
|
|
|
60
60
|
const tooltip_rich_actions_story_raw_1 = __importDefault(require("./tooltip-rich-actions.story?raw"));
|
|
61
61
|
const tooltip_rich_link_story_raw_1 = __importDefault(require("./tooltip-rich-link.story?raw"));
|
|
62
62
|
const tooltip_trigger_button_wrapper_story_raw_1 = __importDefault(require("./tooltip-trigger-button-wrapper.story?raw"));
|
|
63
|
-
const
|
|
63
|
+
const tooltip_with_keyboard_display_story_raw_1 = __importDefault(require("./tooltip-with-keyboard-display.story?raw"));
|
|
64
64
|
exports.TooltipDefaultSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_default_story_raw_1.default);
|
|
65
65
|
exports.TooltipDisabledSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_disabled_story_raw_1.default);
|
|
66
66
|
exports.TooltipControlledSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_controlled_story_raw_1.default);
|
|
@@ -71,6 +71,6 @@ exports.TooltipHoverDelaySource = (0, export_stories_utils_1.removeLicenseHeader
|
|
|
71
71
|
exports.TooltipRichSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_rich_story_raw_1.default);
|
|
72
72
|
exports.TooltipRichActionsSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_rich_actions_story_raw_1.default);
|
|
73
73
|
exports.TooltipRichLinkSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_rich_link_story_raw_1.default);
|
|
74
|
+
exports.TooltipWithKeyboardDisplaySource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_with_keyboard_display_story_raw_1.default);
|
|
74
75
|
exports.TooltipTriggerButtonWrapperSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_trigger_button_wrapper_story_raw_1.default);
|
|
75
|
-
exports.TooltipWithKeyboardShortcutSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_with_keyboard_shortcut_story_raw_1.default);
|
|
76
76
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;AAEH,iEAAoE;AAA3D,wIAAA,OAAO,OAAkB;AAClC,mEAAsE;AAA7D,0IAAA,OAAO,OAAmB;AACnC,uEAA0E;AAAjE,8IAAA,OAAO,OAAqB;AACrC,2EAA6E;AAApE,iJAAA,OAAO,OAAsB;AACtC,uEAA0E;AAAjE,8IAAA,OAAO,OAAqB;AACrC,qEAAuE;AAA9D,2IAAA,OAAO,OAAmB;AACnC,yEAA2E;AAAlE,+IAAA,OAAO,OAAqB;AACrC,+FAAgG;AAAvF,oKAAA,OAAO,OAA+B;AAC/C,2DAA8D;AAArD,kIAAA,OAAO,OAAe;AAC/B,2EAA6E;AAApE,iJAAA,OAAO,OAAsB;AACtC,qEAAuE;AAA9D,2IAAA,OAAO,OAAmB;AACnC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;AAEH,iEAAoE;AAA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wB,GAAG,IAAA,0CAAmB,EACzD,wCAA2B,CAC5B,CAAC;AACW,QAAA,qBAAqB,GAAG,IAAA,0CAAmB,EACtD,qCAAwB,CACzB,CAAC;AACW,QAAA,gCAAgC,GAAG,IAAA,0CAAmB,EACjE,iDAAmC,CACpC,CAAC;AACW,QAAA,iCAAiC,GAAG,IAAA,0CAAmB,EAClE,kDAAoC,CACrC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { default as TooltipDefault } from './tooltip-default.story';\nexport { default as TooltipDisabled } from './tooltip-disabled.story';\nexport { default as TooltipControlled } from './tooltip-controlled.story';\nexport { default as TooltipInitialOpen } from './tooltip-initial-open.story';\nexport { default as TooltipPlacements } from './tooltip-placements.story';\nexport { default as TooltipInDialog } from './tooltip-in-dialog.story';\nexport { default as TooltipHoverDelay } from './tooltip-hover-delay.story';\nexport { default as TooltipTriggerButtonWrapper } from './tooltip-trigger-button-wrapper.story';\nexport { default as TooltipRich } from './tooltip-rich.story';\nexport { default as TooltipRichActions } from './tooltip-rich-actions.story';\nexport { default as TooltipRichLink } from './tooltip-rich-link.story';\nexport { default as TooltipWithKeyboardDisplay } from './tooltip-with-keyboard-display.story';\n\nimport { removeLicenseHeader } from '../../_common/export-stories-utils';\nimport TooltipControlledSourceRaw from './tooltip-controlled.story?raw';\nimport TooltipDefaultSourceRaw from './tooltip-default.story?raw';\nimport TooltipDisabledSourceRaw from './tooltip-disabled.story?raw';\nimport TooltipHoverDelaySourceRaw from './tooltip-hover-delay.story?raw';\nimport TooltipInDialogSourceRaw from './tooltip-in-dialog.story?raw';\nimport TooltipInitialOpenSourceRaw from './tooltip-initial-open.story?raw';\nimport TooltipPlacementsSourceRaw from './tooltip-placements.story?raw';\nimport TooltipRichSourceRaw from './tooltip-rich.story?raw';\nimport TooltipRichActionsSourceRaw from './tooltip-rich-actions.story?raw';\nimport TooltipRichLinkSourceRaw from './tooltip-rich-link.story?raw';\nimport TooltipTriggerButtonWrapperSourceRaw from './tooltip-trigger-button-wrapper.story?raw';\nimport TooltipWithKeyboardDisplaySourceRaw from './tooltip-with-keyboard-display.story?raw';\n\nexport const TooltipDefaultSource = removeLicenseHeader(\n TooltipDefaultSourceRaw,\n);\nexport const TooltipDisabledSource = removeLicenseHeader(\n TooltipDisabledSourceRaw,\n);\nexport const TooltipControlledSource = removeLicenseHeader(\n TooltipControlledSourceRaw,\n);\nexport const TooltipInitialOpenSource = removeLicenseHeader(\n TooltipInitialOpenSourceRaw,\n);\nexport const TooltipPlacementsSource = removeLicenseHeader(\n TooltipPlacementsSourceRaw,\n);\nexport const TooltipInDialogSource = removeLicenseHeader(\n TooltipInDialogSourceRaw,\n);\nexport const TooltipHoverDelaySource = removeLicenseHeader(\n TooltipHoverDelaySourceRaw,\n);\nexport const TooltipRichSource = removeLicenseHeader(TooltipRichSourceRaw);\nexport const TooltipRichActionsSource = removeLicenseHeader(\n TooltipRichActionsSourceRaw,\n);\nexport const TooltipRichLinkSource = removeLicenseHeader(\n TooltipRichLinkSourceRaw,\n);\nexport const TooltipWithKeyboardDisplaySource = removeLicenseHeader(\n TooltipWithKeyboardDisplaySourceRaw,\n);\nexport const TooltipTriggerButtonWrapperSource = removeLicenseHeader(\n TooltipTriggerButtonWrapperSourceRaw,\n);\n"]}
|
|
@@ -27,4 +27,4 @@ const Component = () => {
|
|
|
27
27
|
return ((0, jsx_runtime_1.jsxs)(react_1.Tooltip, { type: "simple", children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Trigger, { children: "Hover me!" }), (0, jsx_runtime_1.jsxs)(react_1.Tooltip.Content, { children: ["This is a keyboard shortcut:", ' ', (0, jsx_runtime_1.jsx)(react_1.Kbd, { modifierKeys: ['meta'], keys: ['B'] })] })] }));
|
|
28
28
|
};
|
|
29
29
|
exports.default = Component;
|
|
30
|
-
//# sourceMappingURL=tooltip-with-keyboard-
|
|
30
|
+
//# sourceMappingURL=tooltip-with-keyboard-display.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip-with-keyboard-display.story.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-with-keyboard-display.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAgD;AAEhD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,wBAAC,eAAO,IAAC,IAAI,EAAC,QAAQ,aACpB,uBAAC,eAAO,CAAC,OAAO,4BAA4B,EAC5C,wBAAC,eAAO,CAAC,OAAO,+CACe,GAAG,EAChC,uBAAC,WAAG,IAAC,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,GAAI,IAC5B,IACV,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Kbd, Tooltip } from '@neo4j-ndl/react';\n\nconst Component = () => {\n return (\n <Tooltip type=\"simple\">\n <Tooltip.Trigger>Hover me!</Tooltip.Trigger>\n <Tooltip.Content>\n This is a keyboard shortcut:{' '}\n <Kbd modifierKeys={['meta']} keys={['B']} />\n </Tooltip.Content>\n </Tooltip>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -18,13 +18,10 @@
|
|
|
18
18
|
* You should have received a copy of the GNU General Public License
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
import { useCallback,
|
|
21
|
+
import { useCallback, useState } from 'react';
|
|
22
22
|
export function useSemiControlledInput({ state, onChange, isControlled, inputType = 'text', }) {
|
|
23
23
|
const [internalState, setInternalState] = useState(state);
|
|
24
|
-
|
|
25
|
-
const current = useMemo(() => {
|
|
26
|
-
return isControlled === true ? state : internalState;
|
|
27
|
-
}, [isControlled, state, internalState]);
|
|
24
|
+
const current = isControlled === true ? state : internalState;
|
|
28
25
|
const setStateFromEvent = useCallback((event) => {
|
|
29
26
|
let resolved;
|
|
30
27
|
if (['checkbox', 'radio', 'switch'].includes(inputType)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-semi-controlled-input.js","sourceRoot":"","sources":["../../../src/_common/use-semi-controlled-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"use-semi-controlled-input.js","sourceRoot":"","sources":["../../../src/_common/use-semi-controlled-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAW9C,MAAM,UAAU,sBAAsB,CAAI,EACxC,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,SAAS,GAAG,MAAM,GACa;IAI/B,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAI,KAAK,CAAC,CAAC;IAE7D,MAAM,OAAO,GAAG,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC;IAE9D,MAAM,iBAAiB,GAAG,WAAW,CACnC,CAAC,KAA0C,EAAE,EAAE;QAC7C,IAAI,QAAW,CAAC;QAEhB,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACxD,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,OAAY,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAU,CAAC;QACrC,CAAC;QAED,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;YAC1B,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC;QAED,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,KAAK,CAAC,CAAC;IACpB,CAAC,EACD,CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,CAAC,CACpC,CAAC;IAEF,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { useCallback, useState } from 'react';\n\nimport { type HtmlAttributes } from './types';\n\ntype UseSemiControlledInputProps<T> = {\n state: T;\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n isControlled?: boolean;\n inputType: HtmlAttributes<'input'>['type'];\n};\n\nexport function useSemiControlledInput<T>({\n state,\n onChange,\n isControlled,\n inputType = 'text',\n}: UseSemiControlledInputProps<T>): [\n T,\n (event: React.ChangeEvent<HTMLInputElement>) => void,\n] {\n const [internalState, setInternalState] = useState<T>(state);\n\n const current = isControlled === true ? state : internalState;\n\n const setStateFromEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n let resolved: T;\n\n if (['checkbox', 'radio', 'switch'].includes(inputType)) {\n resolved = event.target.checked as T;\n } else {\n resolved = event.target.value as T;\n }\n\n if (isControlled !== true) {\n setInternalState(resolved);\n }\n\n onChange?.(event);\n },\n [isControlled, onChange, inputType],\n );\n\n return [current, setStateFromEvent];\n}\n"]}
|
|
@@ -18,13 +18,10 @@
|
|
|
18
18
|
* You should have received a copy of the GNU General Public License
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
import { useCallback,
|
|
21
|
+
import { useCallback, useState } from 'react';
|
|
22
22
|
export function useSemicontrolledState({ state, onChange, isControlled, }) {
|
|
23
23
|
const [internal, setInternal] = useState(state);
|
|
24
|
-
|
|
25
|
-
const current = useMemo(() => {
|
|
26
|
-
return isControlled === true ? state : internal;
|
|
27
|
-
}, [isControlled, state, internal]);
|
|
24
|
+
const current = isControlled === true ? state : internal;
|
|
28
25
|
const setState = useCallback((next) => {
|
|
29
26
|
const resolved = typeof next === 'function' ? next(current) : next;
|
|
30
27
|
if (isControlled !== true) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-semi-controlled-state.js","sourceRoot":"","sources":["../../../src/_common/use-semi-controlled-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"use-semi-controlled-state.js","sourceRoot":"","sources":["../../../src/_common/use-semi-controlled-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAU9C,MAAM,UAAU,sBAAsB,CAAI,EACxC,KAAK,EACL,QAAQ,EACR,YAAY,GACmB;IAC/B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAI,KAAK,CAAC,CAAC;IAEnD,MAAM,OAAO,GAAG,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;IAEzD,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,IAAuB,EAAE,EAAE;QAC1B,MAAM,QAAQ,GACZ,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAE,IAAuB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAExE,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;YAC1B,WAAW,CAAC,QAAQ,CAAC,CAAC;QACxB,CAAC;QACD,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,QAAQ,CAAC,CAAC;IACvB,CAAC,EACD,CAAC,YAAY,EAAE,OAAO,EAAE,QAAQ,CAAC,CAClC,CAAC;IAEF,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { useCallback, useState } from 'react';\n\ntype SetStateAction<T> = T | ((prev: T) => T);\n\ntype UseSemiControlledStateProps<T> = {\n state: T;\n onChange?: (next: T) => void;\n isControlled?: boolean;\n};\n\nexport function useSemicontrolledState<T>({\n state,\n onChange,\n isControlled,\n}: UseSemiControlledStateProps<T>): [T, (setState: SetStateAction<T>) => void] {\n const [internal, setInternal] = useState<T>(state);\n\n const current = isControlled === true ? state : internal;\n\n const setState = useCallback(\n (next: SetStateAction<T>) => {\n const resolved =\n typeof next === 'function' ? (next as (prev: T) => T)(current) : next;\n\n if (isControlled !== true) {\n setInternal(resolved);\n }\n onChange?.(resolved);\n },\n [isControlled, current, onChange],\n );\n\n return [current, setState];\n}\n"]}
|
|
@@ -35,7 +35,7 @@ import { IconButtonBase } from '../icon-button-base';
|
|
|
35
35
|
export const CleanIconButton = (_a) => {
|
|
36
36
|
var { children, as, isLoading = false, isDisabled = false, size = 'medium',
|
|
37
37
|
// Does not have a default value to avoid setting aria-pressed to true if not explicitly set
|
|
38
|
-
isActive, variant = 'neutral', description, tooltipProps, className, style, htmlAttributes, onClick, ref } = _a, restProps = __rest(_a, ["children", "as", "isLoading", "isDisabled", "size", "isActive", "variant", "description", "tooltipProps", "className", "style", "htmlAttributes", "onClick", "ref"]);
|
|
39
|
-
return (_jsx(IconButtonBase, Object.assign({ as: as, iconButtonVariant: "clean", isDisabled: isDisabled, size: size, isLoading: isLoading, isActive: isActive, variant: variant, description: description, tooltipProps: tooltipProps, className: className, style: style, htmlAttributes: htmlAttributes, onClick: onClick, ref: ref }, restProps, { children: children })));
|
|
38
|
+
isActive, variant = 'neutral', description, descriptionKdbProps, tooltipProps, className, style, htmlAttributes, onClick, ref } = _a, restProps = __rest(_a, ["children", "as", "isLoading", "isDisabled", "size", "isActive", "variant", "description", "descriptionKdbProps", "tooltipProps", "className", "style", "htmlAttributes", "onClick", "ref"]);
|
|
39
|
+
return (_jsx(IconButtonBase, Object.assign({ as: as, iconButtonVariant: "clean", isDisabled: isDisabled, size: size, isLoading: isLoading, isActive: isActive, variant: variant, descriptionKdbProps: descriptionKdbProps, description: description, tooltipProps: tooltipProps, className: className, style: style, htmlAttributes: htmlAttributes, onClick: onClick, ref: ref }, restProps, { children: children })));
|
|
40
40
|
};
|
|
41
41
|
//# sourceMappingURL=CleanIconButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CleanIconButton.js","sourceRoot":"","sources":["../../../src/clean-icon-button/CleanIconButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAuBA,OAAO,EAAE,cAAc,EAA4B,MAAM,qBAAqB,CAAC;AAO/E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAyC,
|
|
1
|
+
{"version":3,"file":"CleanIconButton.js","sourceRoot":"","sources":["../../../src/clean-icon-button/CleanIconButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAuBA,OAAO,EAAE,cAAc,EAA4B,MAAM,qBAAqB,CAAC;AAO/E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAyC,EAkBhB,EAAE,EAAE;QAlBY,EACtE,QAAQ,EACR,EAAE,EACF,SAAS,GAAG,KAAK,EACjB,UAAU,GAAG,KAAK,EAClB,IAAI,GAAG,QAAQ;IACf,4FAA4F;IAC5F,QAAQ,EACR,OAAO,GAAG,SAAS,EACnB,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,KAAK,EACL,cAAc,EACd,OAAO,EACP,GAAG,OAEmD,EADnD,SAAS,cAjB0D,4LAkBvE,CADa;IAEZ,OAAO,CACL,KAAC,cAAc,kBACb,EAAE,EAAE,EAAE,EACN,iBAAiB,EAAC,OAAO,EACzB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,mBAAmB,EAAE,mBAAmB,EACxC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,IACJ,SAAS,cAEZ,QAAQ,IACM,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport type React from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { IconButtonBase, type IconButtonBaseProps } from '../icon-button-base';\n\ntype CleanIconButtonButtonProps = Omit<\n IconButtonBaseProps,\n 'iconButtonVariant' | 'isFloating'\n>;\n\nexport const CleanIconButton = <T extends React.ElementType = 'button'>({\n children,\n as,\n isLoading = false,\n isDisabled = false,\n size = 'medium',\n // Does not have a default value to avoid setting aria-pressed to true if not explicitly set\n isActive,\n variant = 'neutral',\n description,\n descriptionKdbProps,\n tooltipProps,\n className,\n style,\n htmlAttributes,\n onClick,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, CleanIconButtonButtonProps>) => {\n return (\n <IconButtonBase\n as={as}\n iconButtonVariant=\"clean\"\n isDisabled={isDisabled}\n size={size}\n isLoading={isLoading}\n isActive={isActive}\n variant={variant}\n descriptionKdbProps={descriptionKdbProps}\n description={description}\n tooltipProps={tooltipProps}\n className={className}\n style={style}\n htmlAttributes={htmlAttributes}\n onClick={onClick}\n ref={ref}\n {...restProps}\n >\n {children}\n </IconButtonBase>\n );\n};\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
23
|
+
import { CleanIconButton } from '@neo4j-ndl/react';
|
|
24
|
+
import { MagnifyingGlassIconOutline } from '@neo4j-ndl/react/icons';
|
|
25
|
+
const Component = () => {
|
|
26
|
+
return (_jsx("div", { className: "n-flex n-flex-col n-gap-token-16", children: _jsx("div", { className: "n-flex n-flex-row n-gap-token-16 n-items-center", children: _jsx(CleanIconButton, { description: "Search", descriptionKdbProps: { keys: ['B'], modifierKeys: ['meta'] }, variant: "neutral", children: _jsx(MagnifyingGlassIconOutline, {}) }) }) }));
|
|
27
|
+
};
|
|
28
|
+
export default Component;
|
|
29
|
+
//# sourceMappingURL=clean-icon-button-keyboard-display.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-icon-button-keyboard-display.story.js","sourceRoot":"","sources":["../../../../src/clean-icon-button/stories/clean-icon-button-keyboard-display.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,cAAK,SAAS,EAAC,kCAAkC,YAC/C,cAAK,SAAS,EAAC,iDAAiD,YAC9D,KAAC,eAAe,IACd,WAAW,EAAC,QAAQ,EACpB,mBAAmB,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,EAC5D,OAAO,EAAC,SAAS,YAEjB,KAAC,0BAA0B,KAAG,GACd,GACd,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { CleanIconButton } from '@neo4j-ndl/react';\nimport { MagnifyingGlassIconOutline } from '@neo4j-ndl/react/icons';\n\nconst Component = () => {\n return (\n <div className=\"n-flex n-flex-col n-gap-token-16\">\n <div className=\"n-flex n-flex-row n-gap-token-16 n-items-center\">\n <CleanIconButton\n description=\"Search\"\n descriptionKdbProps={{ keys: ['B'], modifierKeys: ['meta'] }}\n variant=\"neutral\"\n >\n <MagnifyingGlassIconOutline />\n </CleanIconButton>\n </div>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -24,10 +24,12 @@ export { default as CleanIconButtonDisabled } from './clean-icon-button-disabled
|
|
|
24
24
|
export { default as CleanIconButtonLoading } from './clean-icon-button-loading.story';
|
|
25
25
|
export { default as CleanIconButtonSizes } from './clean-icon-button-sizes.story';
|
|
26
26
|
export { default as CleanIconButtonTone } from './clean-icon-button-tone.story';
|
|
27
|
+
export { default as CleanIconButtonKeyboardDisplay } from './clean-icon-button-keyboard-display.story';
|
|
27
28
|
import { removeLicenseHeader } from '../../_common/export-stories-utils';
|
|
28
29
|
import CleanIconButtonActiveSrcRaw from './clean-icon-button-active.story?raw';
|
|
29
30
|
import CleanIconButtonDefaultSrcRaw from './clean-icon-button-default.story?raw';
|
|
30
31
|
import CleanIconButtonDisabledSrcRaw from './clean-icon-button-disabled.story?raw';
|
|
32
|
+
import CleanIconButtonKeyboardDisplaySrcRaw from './clean-icon-button-keyboard-display.story?raw';
|
|
31
33
|
import CleanIconButtonLoadingSrcRaw from './clean-icon-button-loading.story?raw';
|
|
32
34
|
import CleanIconButtonSizesSrcRaw from './clean-icon-button-sizes.story?raw';
|
|
33
35
|
import CleanIconButtonToneSrcRaw from './clean-icon-button-tone.story?raw';
|
|
@@ -37,4 +39,5 @@ export const CleanIconButtonDisabledSrc = removeLicenseHeader(CleanIconButtonDis
|
|
|
37
39
|
export const CleanIconButtonLoadingSrc = removeLicenseHeader(CleanIconButtonLoadingSrcRaw);
|
|
38
40
|
export const CleanIconButtonSizesSrc = removeLicenseHeader(CleanIconButtonSizesSrcRaw);
|
|
39
41
|
export const CleanIconButtonToneSrc = removeLicenseHeader(CleanIconButtonToneSrcRaw);
|
|
42
|
+
export const CleanIconButtonKeyboardDisplaySrc = removeLicenseHeader(CleanIconButtonKeyboardDisplaySrcRaw);
|
|
40
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/clean-icon-button/stories/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/clean-icon-button/stories/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAEvG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,2BAA2B,MAAM,sCAAsC,CAAC;AAC/E,OAAO,4BAA4B,MAAM,uCAAuC,CAAC;AACjF,OAAO,6BAA6B,MAAM,wCAAwC,CAAC;AACnF,OAAO,oCAAoC,MAAM,gDAAgD,CAAC;AAClG,OAAO,4BAA4B,MAAM,uCAAuC,CAAC;AACjF,OAAO,0BAA0B,MAAM,qCAAqC,CAAC;AAC7E,OAAO,yBAAyB,MAAM,oCAAoC,CAAC;AAE3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CACzD,2BAA2B,CAC5B,CAAC;AACF,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAAmB,CAC1D,4BAA4B,CAC7B,CAAC;AACF,MAAM,CAAC,MAAM,0BAA0B,GAAG,mBAAmB,CAC3D,6BAA6B,CAC9B,CAAC;AACF,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAAmB,CAC1D,4BAA4B,CAC7B,CAAC;AACF,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CACxD,0BAA0B,CAC3B,CAAC;AACF,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CACvD,yBAAyB,CAC1B,CAAC;AACF,MAAM,CAAC,MAAM,iCAAiC,GAAG,mBAAmB,CAClE,oCAAoC,CACrC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nexport { default as CleanIconButtonActive } from './clean-icon-button-active.story';\nexport { default as CleanIconButtonDefault } from './clean-icon-button-default.story';\nexport { default as CleanIconButtonDisabled } from './clean-icon-button-disabled.story';\nexport { default as CleanIconButtonLoading } from './clean-icon-button-loading.story';\nexport { default as CleanIconButtonSizes } from './clean-icon-button-sizes.story';\nexport { default as CleanIconButtonTone } from './clean-icon-button-tone.story';\nexport { default as CleanIconButtonKeyboardDisplay } from './clean-icon-button-keyboard-display.story';\n\nimport { removeLicenseHeader } from '../../_common/export-stories-utils';\nimport CleanIconButtonActiveSrcRaw from './clean-icon-button-active.story?raw';\nimport CleanIconButtonDefaultSrcRaw from './clean-icon-button-default.story?raw';\nimport CleanIconButtonDisabledSrcRaw from './clean-icon-button-disabled.story?raw';\nimport CleanIconButtonKeyboardDisplaySrcRaw from './clean-icon-button-keyboard-display.story?raw';\nimport CleanIconButtonLoadingSrcRaw from './clean-icon-button-loading.story?raw';\nimport CleanIconButtonSizesSrcRaw from './clean-icon-button-sizes.story?raw';\nimport CleanIconButtonToneSrcRaw from './clean-icon-button-tone.story?raw';\n\nexport const CleanIconButtonActiveSrc = removeLicenseHeader(\n CleanIconButtonActiveSrcRaw,\n);\nexport const CleanIconButtonDefaultSrc = removeLicenseHeader(\n CleanIconButtonDefaultSrcRaw,\n);\nexport const CleanIconButtonDisabledSrc = removeLicenseHeader(\n CleanIconButtonDisabledSrcRaw,\n);\nexport const CleanIconButtonLoadingSrc = removeLicenseHeader(\n CleanIconButtonLoadingSrcRaw,\n);\nexport const CleanIconButtonSizesSrc = removeLicenseHeader(\n CleanIconButtonSizesSrcRaw,\n);\nexport const CleanIconButtonToneSrc = removeLicenseHeader(\n CleanIconButtonToneSrcRaw,\n);\nexport const CleanIconButtonKeyboardDisplaySrc = removeLicenseHeader(\n CleanIconButtonKeyboardDisplaySrcRaw,\n);\n"]}
|
|
@@ -35,10 +35,11 @@ import { CleanIconButton } from '../clean-icon-button';
|
|
|
35
35
|
import { useCopyToClipboard } from '../hooks';
|
|
36
36
|
import { IconButton } from '../icon-button';
|
|
37
37
|
import { Square2StackIconOutline } from '../icons';
|
|
38
|
+
import { Kbd } from '../kbd';
|
|
38
39
|
import { OutlinedButton } from '../outlined-button';
|
|
39
40
|
import { Tooltip } from '../tooltip';
|
|
40
41
|
const ConfirmationButton = (_a) => {
|
|
41
|
-
var { description, actionFeedbackText, icon, children, onClick, htmlAttributes, tooltipProps, type = 'clean-icon-button' } = _a, restProps = __rest(_a, ["description", "actionFeedbackText", "icon", "children", "onClick", "htmlAttributes", "tooltipProps", "type"]);
|
|
42
|
+
var { descriptionKdbProps, description, actionFeedbackText, icon, children, onClick, htmlAttributes, tooltipProps, type = 'clean-icon-button' } = _a, restProps = __rest(_a, ["descriptionKdbProps", "description", "actionFeedbackText", "icon", "children", "onClick", "htmlAttributes", "tooltipProps", "type"]);
|
|
42
43
|
const [timeoutId, setTimeoutId] = React.useState(null);
|
|
43
44
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
44
45
|
const handleClick = () => {
|
|
@@ -59,7 +60,7 @@ const ConfirmationButton = (_a) => {
|
|
|
59
60
|
const content = timeoutId === null ? description : actionFeedbackText;
|
|
60
61
|
/* Controlling the tip to make it disappear in a timely manner*/
|
|
61
62
|
if (type === 'clean-icon-button') {
|
|
62
|
-
return (_jsx(CleanIconButton, Object.assign({}, restProps.cleanIconButtonProps, { description: content, tooltipProps: {
|
|
63
|
+
return (_jsx(CleanIconButton, Object.assign({}, restProps.cleanIconButtonProps, { description: content, descriptionKdbProps: descriptionKdbProps, tooltipProps: {
|
|
63
64
|
root: Object.assign(Object.assign({}, tooltipProps), { isOpen: isOpen || timeoutId !== null }),
|
|
64
65
|
trigger: {
|
|
65
66
|
htmlAttributes: {
|
|
@@ -115,10 +116,10 @@ const ConfirmationButton = (_a) => {
|
|
|
115
116
|
onClick(event);
|
|
116
117
|
}
|
|
117
118
|
handleClick();
|
|
118
|
-
}, leadingVisual: icon, className: restProps.className, htmlAttributes: htmlAttributes, children: children })) }),
|
|
119
|
+
}, leadingVisual: icon, className: restProps.className, htmlAttributes: htmlAttributes, children: children })) }), _jsxs(Tooltip.Content, { children: [content, descriptionKdbProps && _jsx(Kbd, Object.assign({}, descriptionKdbProps))] })] })));
|
|
119
120
|
}
|
|
120
121
|
};
|
|
121
|
-
export const ClipboardButton = ({ textToCopy, isDisabled, size, tooltipProps, htmlAttributes, type, }) => {
|
|
122
|
+
export const ClipboardButton = ({ textToCopy, descriptionKdbProps, isDisabled, size, tooltipProps, htmlAttributes, type, }) => {
|
|
122
123
|
const [, copyFunction] = useCopyToClipboard();
|
|
123
124
|
const isOutlinedButton = type === 'outlined-button';
|
|
124
125
|
const isIconButton = type === 'icon-button';
|
|
@@ -147,6 +148,6 @@ export const ClipboardButton = ({ textToCopy, isDisabled, size, tooltipProps, ht
|
|
|
147
148
|
},
|
|
148
149
|
type: 'clean-icon-button',
|
|
149
150
|
};
|
|
150
|
-
return (_jsx(ConfirmationButton, Object.assign({ onClick: () => copyFunction(textToCopy), description: "Copy to clipboard", actionFeedbackText: "Copied" }, props, { tooltipProps: tooltipProps, className: "n-gap-token-8", icon: _jsx(Square2StackIconOutline, { className: "ndl-icon-svg" }), htmlAttributes: Object.assign({ 'aria-live': 'polite' }, htmlAttributes), children: type === 'outlined-button' && 'Copy' })));
|
|
151
|
+
return (_jsx(ConfirmationButton, Object.assign({ onClick: () => copyFunction(textToCopy), description: "Copy to clipboard", actionFeedbackText: "Copied", descriptionKdbProps: descriptionKdbProps }, props, { tooltipProps: tooltipProps, className: "n-gap-token-8", icon: _jsx(Square2StackIconOutline, { className: "ndl-icon-svg" }), htmlAttributes: Object.assign({ 'aria-live': 'polite' }, htmlAttributes), children: type === 'outlined-button' && 'Copy' })));
|
|
151
152
|
};
|
|
152
153
|
//# sourceMappingURL=ClipboardButton.js.map
|