@vanilla-bean/components 1.0.0
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/Component/Component.js +598 -0
- package/Component/Component.scenarios.js +88 -0
- package/Component/Component.test.js +717 -0
- package/Component/README.md +455 -0
- package/Component/index.js +3 -0
- package/Component/observeElementConnection.js +52 -0
- package/Component/observeElementConnection.test.js +121 -0
- package/Elem/Elem.js +304 -0
- package/Elem/Elem.test.js +679 -0
- package/Elem/README.md +373 -0
- package/Elem/index.js +1 -0
- package/FontWithASyntaxHighlighter-Regular.woff2 +0 -0
- package/LICENSE +21 -0
- package/README.md +413 -0
- package/components/BottomSheet/BottomSheet.js +192 -0
- package/components/BottomSheet/BottomSheet.lld.md +25 -0
- package/components/BottomSheet/README.md +66 -0
- package/components/BottomSheet/index.js +1 -0
- package/components/Button/Button.js +53 -0
- package/components/Button/Button.lld.md +21 -0
- package/components/Button/index.js +1 -0
- package/components/Calendar/Calendar.js +720 -0
- package/components/Calendar/Calendar.lld.md +22 -0
- package/components/Calendar/CalendarEvent.js +102 -0
- package/components/Calendar/Toolbar.js +78 -0
- package/components/Calendar/index.js +2 -0
- package/components/Calendar/utils.js +56 -0
- package/components/Code/Code.js +84 -0
- package/components/Code/Code.lld.md +21 -0
- package/components/Code/index.js +1 -0
- package/components/ColorPicker/ColorPicker.js +445 -0
- package/components/ColorPicker/ColorPicker.lld.md +21 -0
- package/components/ColorPicker/index.js +1 -0
- package/components/ColorPicker/svg.js +5 -0
- package/components/Dialog/Dialog.js +278 -0
- package/components/Dialog/Dialog.lld.md +20 -0
- package/components/Dialog/README.md +96 -0
- package/components/Dialog/index.js +1 -0
- package/components/Form/Form.js +257 -0
- package/components/Form/Form.lld.md +21 -0
- package/components/Form/README.md +87 -0
- package/components/Form/index.js +1 -0
- package/components/Icon/Icon.js +54 -0
- package/components/Icon/Icon.lld.md +21 -0
- package/components/Icon/index.js +1 -0
- package/components/Input/Input.js +173 -0
- package/components/Input/Input.lld.md +28 -0
- package/components/Input/README.md +97 -0
- package/components/Input/index.js +2 -0
- package/components/Input/utils.js +122 -0
- package/components/Keyboard/Key.js +38 -0
- package/components/Keyboard/Keyboard.js +173 -0
- package/components/Keyboard/Keyboard.lld.md +21 -0
- package/components/Keyboard/index.js +1 -0
- package/components/Label/Label.js +214 -0
- package/components/Label/Label.lld.md +20 -0
- package/components/Label/index.js +1 -0
- package/components/Link/Link.js +43 -0
- package/components/Link/Link.lld.md +15 -0
- package/components/Link/index.js +1 -0
- package/components/List/List.js +82 -0
- package/components/List/List.lld.md +19 -0
- package/components/List/index.js +1 -0
- package/components/Menu/Menu.js +93 -0
- package/components/Menu/Menu.lld.md +15 -0
- package/components/Menu/index.js +1 -0
- package/components/Notify/Notify.js +96 -0
- package/components/Notify/Notify.lld.md +20 -0
- package/components/Notify/index.js +1 -0
- package/components/Page/Page.js +67 -0
- package/components/Page/Page.lld.md +20 -0
- package/components/Page/index.js +1 -0
- package/components/Popover/Popover.js +175 -0
- package/components/Popover/Popover.lld.md +19 -0
- package/components/Popover/index.js +1 -0
- package/components/RadioButton/RadioButton.js +108 -0
- package/components/RadioButton/RadioButton.lld.md +15 -0
- package/components/RadioButton/index.js +1 -0
- package/components/Router/README.md +160 -0
- package/components/Router/Router.js +150 -0
- package/components/Router/Router.lld.md +31 -0
- package/components/Router/View.js +15 -0
- package/components/Router/index.js +2 -0
- package/components/Router/utils.js +17 -0
- package/components/Select/README.md +88 -0
- package/components/Select/Select.js +74 -0
- package/components/Select/Select.lld.md +20 -0
- package/components/Select/index.js +1 -0
- package/components/Table/README.md +94 -0
- package/components/Table/Table.js +171 -0
- package/components/Table/Table.lld.md +21 -0
- package/components/Table/index.js +1 -0
- package/components/TagList/Tag.js +84 -0
- package/components/TagList/TagList.js +118 -0
- package/components/TagList/TagList.lld.md +30 -0
- package/components/TagList/design.excalidraw.png +0 -0
- package/components/TagList/index.js +2 -0
- package/components/Tooltip/Tooltip.js +139 -0
- package/components/Tooltip/Tooltip.lld.md +22 -0
- package/components/Tooltip/index.js +1 -0
- package/components/TooltipWrapper/TooltipWrapper.js +89 -0
- package/components/TooltipWrapper/TooltipWrapper.lld.md +21 -0
- package/components/TooltipWrapper/index.js +1 -0
- package/components/Whiteboard/Whiteboard.js +198 -0
- package/components/Whiteboard/Whiteboard.lld.md +35 -0
- package/components/Whiteboard/index.js +1 -0
- package/components/index.js +27 -0
- package/eslint.config.cjs +118 -0
- package/index.d.ts +635 -0
- package/index.js +19 -0
- package/package.json +123 -0
- package/plugins/asText.js +38 -0
- package/plugins/loadPlugins.js +5 -0
- package/plugins/markdownLoader.js +121 -0
- package/prettier.config.cjs +7 -0
- package/spellcheck.config.cjs +227 -0
- package/styled/README.md +329 -0
- package/styled/appendStyles.js +26 -0
- package/styled/appendStyles.test.js +45 -0
- package/styled/index.js +4 -0
- package/styled/shimCSS.js +31 -0
- package/styled/shimCSS.test.js +103 -0
- package/styled/styled.js +91 -0
- package/styled/styled.test.js +586 -0
- package/styled/themeStyles.js +36 -0
- package/styled/themeStyles.test.js +135 -0
- package/test-setup.js +123 -0
- package/theme/.test.js +69 -0
- package/theme/README.md +607 -0
- package/theme/button.js +100 -0
- package/theme/code.js +123 -0
- package/theme/colors.js +42 -0
- package/theme/fonts.js +42 -0
- package/theme/index.js +33 -0
- package/theme/input.js +64 -0
- package/theme/page.js +208 -0
- package/theme/scrollbar.js +24 -0
- package/theme/table.js +53 -0
- package/utils/README.md +176 -0
- package/utils/browser.js +92 -0
- package/utils/class.js +30 -0
- package/utils/color.js +81 -0
- package/utils/data.js +164 -0
- package/utils/element.js +55 -0
- package/utils/index.js +7 -0
- package/utils/rand.js +12 -0
- package/utils/string.js +72 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { TooltipWrapper } from '../TooltipWrapper';
|
|
2
|
+
|
|
3
|
+
const defaultOptions = { tag: 'button' };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Interactive button component with keyboard accessibility and tooltip support.
|
|
7
|
+
*
|
|
8
|
+
* Extends TooltipWrapper to provide button-specific behavior including keyboard
|
|
9
|
+
* activation (Space/Enter keys) and proper semantic button element.
|
|
10
|
+
* @param {object} [options={}] - Button configuration options
|
|
11
|
+
* @param {string} [options.tag='button'] - HTML tag name, defaults to button for proper semantics
|
|
12
|
+
* @param {Function} [options.onPointerPress] - Handler called when button is activated via click, touch, or keyboard
|
|
13
|
+
* @param {string} [options.textContent] - Button label text
|
|
14
|
+
* @param {string} [options.icon] - FontAwesome icon name (without 'fa-' prefix)
|
|
15
|
+
* @param {string} [options.tooltip] - Tooltip text shown on hover
|
|
16
|
+
* @param {boolean} [options.disabled] - Whether button is disabled
|
|
17
|
+
* @param {...(Component|HTMLElement|string)} children - Child elements to append
|
|
18
|
+
* @returns {Button} Button component instance
|
|
19
|
+
* @example
|
|
20
|
+
* // Basic button
|
|
21
|
+
* new Button({
|
|
22
|
+
* textContent: 'Click me',
|
|
23
|
+
* onPointerPress: () => console.log('clicked')
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Button with tooltip
|
|
27
|
+
* new Button({
|
|
28
|
+
* textContent: 'Save',
|
|
29
|
+
* tooltip: 'Save current changes',
|
|
30
|
+
* onPointerPress: handleSave
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
33
|
+
export default class Button extends TooltipWrapper {
|
|
34
|
+
defaultOptions = { ...super.defaultOptions, ...defaultOptions };
|
|
35
|
+
|
|
36
|
+
constructor(options = {}, ...children) {
|
|
37
|
+
const userOnKeyUp = options.onKeyUp;
|
|
38
|
+
|
|
39
|
+
super(
|
|
40
|
+
{
|
|
41
|
+
...defaultOptions,
|
|
42
|
+
...options,
|
|
43
|
+
onKeyUp: event => {
|
|
44
|
+
userOnKeyUp?.call(this, event);
|
|
45
|
+
if (event.code === 'Space' || event.code === 'Enter') {
|
|
46
|
+
this.options.onPointerPress?.(event);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
...children,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
> ./Button.js
|
|
4
|
+
|
|
5
|
+
Activatable element that unifies pointer and keyboard interaction under one handler. The design decision is that activation, regardless of whether it came from a click, touch, Space, or Enter, always routes through `onPointerPress`. Callers write one handler, not three.
|
|
6
|
+
|
|
7
|
+
## Keyboard and pointer share one activation handler
|
|
8
|
+
|
|
9
|
+
- Space and Enter activate the button the same way a click does; the caller registers one `onPointerPress` and it fires for all input types
|
|
10
|
+
- does pressing Enter on a focused Button invoke onPointerPress?
|
|
11
|
+
- does clicking a Button invoke onPointerPress?
|
|
12
|
+
|
|
13
|
+
## Caller-provided onKeyUp is preserved alongside activation logic
|
|
14
|
+
|
|
15
|
+
- a caller-provided `onKeyUp` runs alongside the built-in keyboard activation; registering both handlers does not suppress either
|
|
16
|
+
- does providing a custom onKeyUp still trigger onPointerPress on Space/Enter?
|
|
17
|
+
|
|
18
|
+
## Tooltip is automatic — no setup beyond the tooltip option
|
|
19
|
+
|
|
20
|
+
- Button extends TooltipWrapper; a `tooltip` option produces tooltip behavior with no additional wiring
|
|
21
|
+
- does a Button with a tooltip option show a tooltip on hover?
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Button } from './Button';
|