loon-bulma-react 2023.0.20 → 2023.0.22

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/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  > - `<CB>`-component gemaakt. Een kale checkbox met een label. Geen wrapper, geen direction, geen form.
6
6
  > - `<RB>`-component gemaakt. Een Radio-button met een label. Geen wrapper, geen direction, geen form.
7
7
  > - `ColorProp` uitgebreid met `"is-${`_string_`}"`-template literal. Als _Bulma_ nog andere kleuren gebruikt dan de standaard-kleuren, kan je die op die manier gebruiken.
8
+ > - `<Tooltip>`-component gemaakt Deze is nog niet af. Tot nu toe alleen een `bottom`-positie. Wel alle bulma-kleuren. Voeg de te hoveren spullen als `children` toe aan de component om de tooltip te weergeven.
8
9
 
9
10
  ## [Bulma](https://bulma.io/) &amp; [React](https://reactjs.org/) componenten voor Loon Salarissoftware.
10
11
 
@@ -1,4 +1,4 @@
1
- import { MouseEvent } from 'react';
1
+ import React, { MouseEvent } from 'react';
2
2
  import { EventOptions, BaseEventProps } from '../Props';
3
3
  declare type CalendarColoredItemProps<T extends BaseEventProps> = {
4
4
  /** Het event */
@@ -8,7 +8,7 @@ declare type CalendarColoredItemProps<T extends BaseEventProps> = {
8
8
  options?: EventOptions<T>;
9
9
  /** Onclick handler voor het event */
10
10
  onClick?: (event: T, clickEvent: MouseEvent<HTMLElement>) => void;
11
- tooltip?: string;
11
+ tooltip?: React.ReactNode;
12
12
  };
13
13
  /**
14
14
  * Component voor een event dat de hele dag duurt
@@ -1,4 +1,4 @@
1
- import { MouseEvent } from 'react';
1
+ import React, { MouseEvent } from 'react';
2
2
  import { EventOptions, BaseEventProps } from '../Props';
3
3
  declare type CalendarItemProps<T extends BaseEventProps> = {
4
4
  desc: (event: T) => JSX.Element;
@@ -8,7 +8,7 @@ declare type CalendarItemProps<T extends BaseEventProps> = {
8
8
  options?: EventOptions<T>;
9
9
  /** Onclick handler */
10
10
  onClick?: (event: T, clickEvent: MouseEvent<HTMLElement>) => void;
11
- tooltip?: string;
11
+ tooltip?: React.ReactNode;
12
12
  };
13
13
  /**
14
14
  * Component voor een event met een tijdstip en NIET de hele dag duurt
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { ColorProp } from '~/loon-react-bulma-types';
3
+ declare type PositionProp = 'bottom';
4
+ export declare class Tooltip extends React.Component<{
5
+ content: React.ReactNode;
6
+ color?: ColorProp;
7
+ children: React.ReactNode;
8
+ }> {
9
+ static defaultProps: {
10
+ position: PositionProp;
11
+ color: ColorProp;
12
+ };
13
+ state: {
14
+ active: boolean;
15
+ };
16
+ show: () => void;
17
+ hide: () => void;
18
+ render(): JSX.Element;
19
+ }
20
+ export {};
@@ -55,3 +55,4 @@ export { Calendar } from './Calendar';
55
55
  export type { BaseEventProps, CalendarOptions } from './Calendar/Props';
56
56
  export type { MonthViewProps } from './Calendar';
57
57
  export type { WeekViewProps } from './Calendar';
58
+ export { Tooltip } from './Tooltip/Tooltip';
@@ -14,8 +14,6 @@ declare type CBInputProps = Omit<BaseInputProps, 'keyboardType' | 'icons' | 'dir
14
14
  * @param checked: is de checkbox checked ?
15
15
  */
16
16
  onValueChanged?(checked: boolean): void;
17
- /** classes voor de omringende `<div>` van de checkbox/label combi */
18
- className?: string;
19
17
  };
20
18
  /**
21
19
  * Maak een kale checkbox input met een label, dus ZONDER alle form-functies met controls, fields en directions.
@@ -43,6 +41,6 @@ declare type CBInputProps = Omit<BaseInputProps, 'keyboardType' | 'icons' | 'dir
43
41
  * | onValueChanged() | `function` | | (value: boolean, valid?: boolean) => void |
44
42
  * | onKeyDown() | `function` | | (event: React.KeyboardEvent) => void |
45
43
  */
46
- declare function JustACheckbox({ checked, label, name, id, size, color, styling, textAlign, disabled, errorMessage, className: containerClassName, onValueChanged, onKeyDown, }: CBInputProps): JSX.Element;
44
+ declare function JustACheckbox({ checked, label, name, id, size, color, styling, textAlign, disabled, errorMessage, onValueChanged, onKeyDown, }: CBInputProps): JSX.Element;
47
45
  export { JustACheckbox as CB };
48
46
  export type { CBInputProps };
@@ -18,8 +18,6 @@ declare type RBInputProps<T = string> = Omit<BaseInputProps, 'keyboardType' | 'i
18
18
  * @param checked: is de checkbox checked ?
19
19
  */
20
20
  onValueChanged?(value: T): void;
21
- /** classes voor de omringende `<div>` van de checkbox/label combi */
22
- className?: string;
23
21
  /** ID voor het item. Bij radio-buttons is deze VERPLICHT! */
24
22
  id: string;
25
23
  };
@@ -48,6 +46,6 @@ declare type RBInputProps<T = string> = Omit<BaseInputProps, 'keyboardType' | 'i
48
46
  * | errorMessage | `string ` | | een error message (van buiten setbaar) |
49
47
  * | setValueFn() | `function` | | (newVal: T) => void. Gebruik om een React-useState-setfunction aan te roepen |
50
48
  */
51
- declare function JustARadioButon<T = string>({ value, checked, label, groupName: name, id, size, color, styling, textAlign, disabled, errorMessage, className: containerClassName, onValueChanged, }: RBInputProps<T>): JSX.Element;
49
+ declare function JustARadioButon<T = string>({ value, checked, label, groupName: name, id, size, color, styling, textAlign, disabled, errorMessage, onValueChanged, }: RBInputProps<T>): JSX.Element;
52
50
  export { JustARadioButon as RB };
53
51
  export type { RBInputProps };
package/dist/index.js CHANGED
@@ -383,8 +383,8 @@ function Section(_ref) {
383
383
  var children = _ref.children,
384
384
  classes = _ref.className,
385
385
  styles = _ref.styles;
386
- var className = 'section ';
387
- if (className) className += " " + classes;
386
+ var className = 'section';
387
+ if (classes) className += " " + classes;
388
388
  return React__default.createElement("section", {
389
389
  className: className,
390
390
  style: styles
@@ -499,6 +499,18 @@ function _extends() {
499
499
  };
500
500
  return _extends.apply(this, arguments);
501
501
  }
502
+ function _inheritsLoose(subClass, superClass) {
503
+ subClass.prototype = Object.create(superClass.prototype);
504
+ subClass.prototype.constructor = subClass;
505
+ _setPrototypeOf(subClass, superClass);
506
+ }
507
+ function _setPrototypeOf(o, p) {
508
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
509
+ o.__proto__ = p;
510
+ return o;
511
+ };
512
+ return _setPrototypeOf(o, p);
513
+ }
502
514
  function _objectWithoutPropertiesLoose(source, excluded) {
503
515
  if (source == null) return {};
504
516
  var target = {};
@@ -3497,6 +3509,74 @@ var eventKleurBlockStyleBase = {
3497
3509
  transition: 'background-color .2s ease-in-out'
3498
3510
  };
3499
3511
 
3512
+ var Tooltip = /*#__PURE__*/function (_React$Component) {
3513
+ _inheritsLoose(Tooltip, _React$Component);
3514
+ function Tooltip() {
3515
+ var _this;
3516
+ _this = _React$Component.apply(this, arguments) || this;
3517
+ _this.state = {
3518
+ active: false
3519
+ };
3520
+ _this.show = function () {
3521
+ return _this.setState({
3522
+ active: true
3523
+ });
3524
+ };
3525
+ _this.hide = function () {
3526
+ return _this.setState({
3527
+ active: false
3528
+ });
3529
+ };
3530
+ return _this;
3531
+ }
3532
+ var _proto = Tooltip.prototype;
3533
+ _proto.render = function render() {
3534
+ var _this$props = this.props,
3535
+ content = _this$props.content,
3536
+ children = _this$props.children,
3537
+ color = _this$props.color;
3538
+ var active = this.state.active;
3539
+ var className = "tooltip is-bottom";
3540
+ var arrowClassName = 'tooltip-arrow';
3541
+ if (color === 'p') {
3542
+ className += ' is-primary';
3543
+ arrowClassName += ' is-primary';
3544
+ } else if (color === 'i') {
3545
+ className += ' is-info';
3546
+ arrowClassName += ' is-info';
3547
+ } else if (color === 'l') {
3548
+ className += ' is-link';
3549
+ arrowClassName += ' is-link';
3550
+ } else if (color === 'd') {
3551
+ className += ' is-danger';
3552
+ arrowClassName += ' is-danger';
3553
+ } else if (color === 's') {
3554
+ className += ' is-success';
3555
+ arrowClassName += ' is-success';
3556
+ } else if (color === 'w') {
3557
+ className += ' is-warning';
3558
+ arrowClassName += ' is-warning';
3559
+ } else {
3560
+ className += " " + color;
3561
+ arrowClassName += " " + color;
3562
+ }
3563
+ return React__default.createElement("span", {
3564
+ className: "tooltip-wrapper",
3565
+ onMouseEnter: this.show,
3566
+ onMouseLeave: this.hide
3567
+ }, children, active && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
3568
+ className: className
3569
+ }, content), React__default.createElement("div", {
3570
+ className: arrowClassName
3571
+ })));
3572
+ };
3573
+ return Tooltip;
3574
+ }(React__default.Component);
3575
+ Tooltip.defaultProps = {
3576
+ position: 'bottom',
3577
+ color: 'l'
3578
+ };
3579
+
3500
3580
  function CalendarColoredItem(_ref) {
3501
3581
  var event = _ref.event,
3502
3582
  options = _ref.options,
@@ -3521,12 +3601,26 @@ function CalendarColoredItem(_ref) {
3521
3601
  });
3522
3602
  }, [event, isHovered]);
3523
3603
  var ref = React__default.useRef(null);
3524
- return React__default.createElement("div", {
3604
+ if (tooltip) return React__default.createElement(Tooltip, {
3605
+ content: tooltip,
3606
+ color: "is-light"
3607
+ }, React__default.createElement("div", {
3608
+ ref: ref,
3609
+ onClick: function onClick(e) {
3610
+ return _onClick && _onClick(event, e);
3611
+ },
3612
+ style: eventStyle,
3613
+ onMouseEnter: function onMouseEnter() {
3614
+ return setHovered(true);
3615
+ },
3616
+ onMouseLeave: function onMouseLeave() {
3617
+ return setHovered(false);
3618
+ }
3619
+ }, React__default.createElement("span", null, desc(event))));else return React__default.createElement("div", {
3525
3620
  ref: ref,
3526
3621
  onClick: function onClick(e) {
3527
3622
  return _onClick && _onClick(event, e);
3528
3623
  },
3529
- title: tooltip,
3530
3624
  style: eventStyle,
3531
3625
  onMouseEnter: function onMouseEnter() {
3532
3626
  return setHovered(true);
@@ -3565,13 +3659,29 @@ function CalendarItem(_ref) {
3565
3659
  });
3566
3660
  }, [event, isHovered]);
3567
3661
  var ref = React__default.useRef(null);
3568
- return React__default.createElement("div", {
3662
+ if (tooltip) return React__default.createElement(Tooltip, {
3663
+ color: "is-light",
3664
+ content: tooltip
3665
+ }, React__default.createElement("div", {
3666
+ ref: ref,
3667
+ onClick: function onClick(e) {
3668
+ return _onClick && _onClick(event, e);
3669
+ },
3670
+ style: eventStyle,
3671
+ onMouseEnter: function onMouseEnter() {
3672
+ return setHovered(true);
3673
+ },
3674
+ onMouseLeave: function onMouseLeave() {
3675
+ return setHovered(false);
3676
+ }
3677
+ }, React__default.createElement("span", {
3678
+ style: eventSpan
3679
+ }), desc(event)));else return React__default.createElement("div", {
3569
3680
  ref: ref,
3570
3681
  onClick: function onClick(e) {
3571
3682
  return _onClick && _onClick(event, e);
3572
3683
  },
3573
3684
  style: eventStyle,
3574
- title: tooltip,
3575
3685
  onMouseEnter: function onMouseEnter() {
3576
3686
  return setHovered(true);
3577
3687
  },
@@ -4534,7 +4644,7 @@ function CheckBox(props) {
4534
4644
  var className = React__default.useMemo(function () {
4535
4645
  var cn = 'is-checkradio';
4536
4646
  if (size === 's') cn += ' is-small';else if (size === 'l') cn += ' is-medium';else if (size === 'xl') cn += ' is-large';
4537
- if (color === 'w') cn += ' is-warning';else if (color === 'l') cn += ' is-link';else if (color === 'd') cn += ' is-danger';else if (color === 'i') cn += ' is-info';else if (color === 's') cn += ' is-success';else if (color === 'p') cn += ' is-primary';else cn += color;
4647
+ if (color === 'w') cn += ' is-warning';else if (color === 'l') cn += ' is-link';else if (color === 'd') cn += ' is-danger';else if (color === 'i') cn += ' is-info';else if (color === 's') cn += ' is-success';else if (color === 'p') cn += ' is-primary';else cn += " " + color;
4538
4648
  if (styling === 'rounded') cn += ' is-circle';else if (styling === 'noborder') cn += ' has-no-border';else if (styling === 'colored') cn += ' has-background-color';else if (styling === 'blocky') cn += ' is-blocky';
4539
4649
  if (textAlign === 'c') cn += ' has-text-centered';else if (textAlign === 'r') cn += ' has-text-right';
4540
4650
  return cn;
@@ -6949,7 +7059,6 @@ function JustACheckbox(_ref) {
6949
7059
  textAlign = _ref.textAlign,
6950
7060
  disabled = _ref.disabled,
6951
7061
  errorMessage = _ref.errorMessage,
6952
- containerClassName = _ref.className,
6953
7062
  onValueChanged = _ref.onValueChanged,
6954
7063
  onKeyDown = _ref.onKeyDown;
6955
7064
  var handleClick = function handleClick() {
@@ -6958,16 +7067,14 @@ function JustACheckbox(_ref) {
6958
7067
  var className = React__default.useMemo(function () {
6959
7068
  var cn = 'is-checkradio';
6960
7069
  if (size === 's') cn += ' is-small';else if (size === 'l') cn += ' is-medium';else if (size === 'xl') cn += ' is-large';
6961
- if (color === 'w') cn += ' is-warning';else if (color === 'l') cn += ' is-link';else if (color === 'd') cn += ' is-danger';else if (color === 'i') cn += ' is-info';else if (color === 's') cn += ' is-success';else if (color === 'p') cn += ' is-primary';else cn += typeof color === 'function' ? color(checked) : color;
7070
+ if (color === 'w') cn += ' is-warning';else if (color === 'l') cn += ' is-link';else if (color === 'd') cn += ' is-danger';else if (color === 'i') cn += ' is-info';else if (color === 's') cn += ' is-success';else if (color === 'p') cn += ' is-primary';else cn += " " + (typeof color === 'function' ? color(checked) : color);
6962
7071
  if (styling === 'rounded') cn += ' is-circle';else if (styling === 'noborder') cn += ' has-no-border';else if (styling === 'colored') cn += ' has-background-color';else if (styling === 'blocky') cn += ' is-blocky';
6963
7072
  if (textAlign === 'c') cn += ' has-text-centered';else if (textAlign === 'r') cn += ' has-text-right';
6964
7073
  return cn;
6965
7074
  }, [textAlign, size, color, styling, checked]);
6966
7075
  var errorMsg = '';
6967
7076
  if (errorMessage) errorMsg = typeof errorMessage === 'string' ? errorMessage : errorMessage(checked);
6968
- return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
6969
- className: containerClassName
6970
- }, React__default.createElement("input", {
7077
+ return React__default.createElement(React__default.Fragment, null, React__default.createElement("input", {
6971
7078
  className: className,
6972
7079
  type: "checkbox",
6973
7080
  name: name,
@@ -6980,7 +7087,7 @@ function JustACheckbox(_ref) {
6980
7087
  onKeyDown: onKeyDown
6981
7088
  }), typeof label === 'string' && React__default.createElement("label", {
6982
7089
  htmlFor: id != null ? id : name
6983
- }, label != null ? label : name), typeof label !== 'string' && label), errorMessage && React__default.createElement("p", {
7090
+ }, label != null ? label : name), typeof label !== 'string' && label, errorMessage && React__default.createElement("p", {
6984
7091
  className: "help is-danger"
6985
7092
  }, errorMsg));
6986
7093
  }
@@ -6998,7 +7105,6 @@ function JustARadioButon(_ref) {
6998
7105
  textAlign = _ref.textAlign,
6999
7106
  disabled = _ref.disabled,
7000
7107
  errorMessage = _ref.errorMessage,
7001
- containerClassName = _ref.className,
7002
7108
  onValueChanged = _ref.onValueChanged;
7003
7109
  var handleClick = function handleClick() {
7004
7110
  if (!disabled) onValueChanged && onValueChanged(value);
@@ -7006,16 +7112,14 @@ function JustARadioButon(_ref) {
7006
7112
  var className = React__default.useMemo(function () {
7007
7113
  var cn = 'is-checkradio';
7008
7114
  if (size === 's') cn += ' is-small';else if (size === 'l') cn += ' is-medium';else if (size === 'xl') cn += ' is-large';
7009
- if (color === 'w') cn += ' is-warning';else if (color === 'l') cn += ' is-link';else if (color === 'd') cn += ' is-danger';else if (color === 'i') cn += ' is-info';else if (color === 's') cn += ' is-success';else if (color === 'p') cn += ' is-primary';else cn += typeof color === 'function' ? color(value) : color;
7115
+ if (color === 'w') cn += ' is-warning';else if (color === 'l') cn += ' is-link';else if (color === 'd') cn += ' is-danger';else if (color === 'i') cn += ' is-info';else if (color === 's') cn += ' is-success';else if (color === 'p') cn += ' is-primary';else cn += " " + (typeof color === 'function' ? color(value) : color);
7010
7116
  if (styling === 'rounded') cn += ' is-circle';else if (styling === 'noborder') cn += ' has-no-border';else if (styling === 'colored') cn += ' has-background-color';else if (styling === 'blocky') cn += ' is-blocky';
7011
7117
  if (textAlign === 'c') cn += ' has-text-centered';else if (textAlign === 'r') cn += ' has-text-right';
7012
7118
  return cn;
7013
7119
  }, [textAlign, size, color, styling]);
7014
7120
  var errorMsg = '';
7015
7121
  if (errorMessage) errorMsg = typeof errorMessage === 'string' ? errorMessage : errorMessage(value);
7016
- return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
7017
- className: containerClassName
7018
- }, React__default.createElement("input", {
7122
+ return React__default.createElement(React__default.Fragment, null, React__default.createElement("input", {
7019
7123
  className: className,
7020
7124
  type: "radio",
7021
7125
  name: name,
@@ -7025,7 +7129,7 @@ function JustARadioButon(_ref) {
7025
7129
  onChange: handleClick
7026
7130
  }), typeof label === 'string' && React__default.createElement("label", {
7027
7131
  htmlFor: id != null ? id : name
7028
- }, label != null ? label : name), typeof label !== 'string' && label), errorMessage && React__default.createElement("p", {
7132
+ }, label != null ? label : name), typeof label !== 'string' && label, errorMessage && React__default.createElement("p", {
7029
7133
  className: "help is-danger"
7030
7134
  }, errorMsg));
7031
7135
  }
@@ -7514,6 +7618,7 @@ exports.TimeLine = TimeLine;
7514
7618
  exports.Title = Title;
7515
7619
  exports.TitleWithSubtitle = TitleWithSubtitle;
7516
7620
  exports.ToggleBar = ToggleBar;
7621
+ exports.Tooltip = Tooltip;
7517
7622
  exports.calculateTxtColor = calculateTxtColor;
7518
7623
  exports.deserializeJSON = deserializeJSON;
7519
7624
  exports.getHotkeyHandler = getHotkeyHandler;