@bbl-digital/snorre 3.1.2 → 3.1.3

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/dist/bundle.js CHANGED
@@ -33125,10 +33125,12 @@ to {top: 100vh;}
33125
33125
  id,
33126
33126
  index,
33127
33127
  children,
33128
- subContent
33128
+ subContent,
33129
+ disableDrag
33129
33130
  }) => /*#__PURE__*/jsxRuntime.jsx(reactBeautifulDnd.Draggable, {
33130
33131
  draggableId: id,
33131
33132
  index: index,
33133
+ isDragDisabled: disableDrag,
33132
33134
  children: provided => /*#__PURE__*/jsxRuntime.jsxs(DraggableWrapper, {
33133
33135
  className: "table-dragable",
33134
33136
  ref: provided.innerRef,
@@ -0,0 +1 @@
1
+ export {};
@@ -9,10 +9,12 @@ const DraggableRow = ({
9
9
  id,
10
10
  index,
11
11
  children,
12
- subContent
12
+ subContent,
13
+ disableDrag
13
14
  }) => /*#__PURE__*/_jsx(Draggable, {
14
15
  draggableId: id,
15
16
  index: index,
17
+ isDragDisabled: disableDrag,
16
18
  children: provided => /*#__PURE__*/_jsxs(DraggableWrapper, {
17
19
  className: "table-dragable",
18
20
  ref: provided.innerRef,
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import { MONTHS } from '../../utils/dates';
3
+ import { StyledSelect, Div } from './styles';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+
7
+ const YearMonthForm = ({
8
+ onChange,
9
+ date,
10
+ fromDate,
11
+ toDate
12
+ }) => {
13
+ const months = MONTHS;
14
+ const years = [];
15
+
16
+ for (let i = fromDate.getFullYear(); i <= toDate.getFullYear(); i += 1) {
17
+ years.push(i);
18
+ }
19
+
20
+ const changeMonth = e => {
21
+ let newDate = date;
22
+ newDate.setMonth(e.target.value);
23
+ if (newDate > toDate) newDate = toDate;
24
+ onChange(newDate);
25
+ };
26
+
27
+ const changeYear = e => {
28
+ let newDate = date;
29
+ newDate.setFullYear(e.target.value);
30
+ if (newDate > toDate) newDate = toDate;
31
+ onChange(newDate);
32
+ };
33
+
34
+ return /*#__PURE__*/_jsxs(Div, {
35
+ className: "DayPicker-Caption",
36
+ children: [/*#__PURE__*/_jsx(StyledSelect, {
37
+ name: "month",
38
+ onChange: changeMonth,
39
+ value: date.getMonth(),
40
+ children: months.map((month, i) => /*#__PURE__*/_jsx("option", {
41
+ value: i,
42
+ children: month
43
+ }, month))
44
+ }), /*#__PURE__*/_jsx(StyledSelect, {
45
+ name: "year",
46
+ onChange: changeYear,
47
+ value: date.getFullYear(),
48
+ children: years.map(year => /*#__PURE__*/_jsx("option", {
49
+ value: year,
50
+ children: year
51
+ }, year))
52
+ })]
53
+ });
54
+ };
55
+
56
+ export default YearMonthForm;
@@ -0,0 +1 @@
1
+ export {};
@@ -9,6 +9,8 @@ interface IProps {
9
9
  children: React.ReactNode | React.ReactNode[];
10
10
  /**Extra react components beneath row */
11
11
  subContent?: React.ReactNode | React.ReactNode[];
12
+ /** Boolean to conditionally disable drag */
13
+ disableDrag?: boolean;
12
14
  }
13
15
  declare const DraggableRow: FC<IProps>;
14
16
  export default DraggableRow;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packages/core/BoxedTable/DraggableRow/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAW1B,UAAU,MAAM;IACd,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,eAAe;IACf,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;IAC7C,wCAAwC;IACxC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;CACjD;AAED,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,MAAM,CAmB5B,CAAA;AAED,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packages/core/BoxedTable/DraggableRow/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAW1B,UAAU,MAAM;IACd,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,eAAe;IACf,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;IAC7C,wCAAwC;IACxC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;IAChD,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,MAAM,CA8B5B,CAAA;AAED,eAAe,YAAY,CAAA"}
@@ -9,10 +9,12 @@ const DraggableRow = ({
9
9
  id,
10
10
  index,
11
11
  children,
12
- subContent
12
+ subContent,
13
+ disableDrag
13
14
  }) => /*#__PURE__*/_jsx(Draggable, {
14
15
  draggableId: id,
15
16
  index: index,
17
+ isDragDisabled: disableDrag,
16
18
  children: provided => /*#__PURE__*/_jsxs(DraggableWrapper, {
17
19
  className: "table-dragable",
18
20
  ref: provided.innerRef,
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface IProps {
3
+ date: Date;
4
+ onChange: (e: Date) => void;
5
+ fromDate: Date;
6
+ toDate: Date;
7
+ }
8
+ declare const YearMonthForm: React.FC<IProps>;
9
+ export default YearMonthForm;
10
+ //# sourceMappingURL=YearMonthForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YearMonthForm.d.ts","sourceRoot":"","sources":["../../../src/packages/core/DatepickerRange/YearMonthForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,UAAU,MAAM;IACd,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,CAAA;IAC3B,QAAQ,EAAE,IAAI,CAAA;IACd,MAAM,EAAE,IAAI,CAAA;CACb;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAmDnC,CAAA;AAED,eAAe,aAAa,CAAA"}
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import { MONTHS } from '../../utils/dates';
3
+ import { StyledSelect, Div } from './styles';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+
7
+ const YearMonthForm = ({
8
+ onChange,
9
+ date,
10
+ fromDate,
11
+ toDate
12
+ }) => {
13
+ const months = MONTHS;
14
+ const years = [];
15
+
16
+ for (let i = fromDate.getFullYear(); i <= toDate.getFullYear(); i += 1) {
17
+ years.push(i);
18
+ }
19
+
20
+ const changeMonth = e => {
21
+ let newDate = date;
22
+ newDate.setMonth(e.target.value);
23
+ if (newDate > toDate) newDate = toDate;
24
+ onChange(newDate);
25
+ };
26
+
27
+ const changeYear = e => {
28
+ let newDate = date;
29
+ newDate.setFullYear(e.target.value);
30
+ if (newDate > toDate) newDate = toDate;
31
+ onChange(newDate);
32
+ };
33
+
34
+ return /*#__PURE__*/_jsxs(Div, {
35
+ className: "DayPicker-Caption",
36
+ children: [/*#__PURE__*/_jsx(StyledSelect, {
37
+ name: "month",
38
+ onChange: changeMonth,
39
+ value: date.getMonth(),
40
+ children: months.map((month, i) => /*#__PURE__*/_jsx("option", {
41
+ value: i,
42
+ children: month
43
+ }, month))
44
+ }), /*#__PURE__*/_jsx(StyledSelect, {
45
+ name: "year",
46
+ onChange: changeYear,
47
+ value: date.getFullYear(),
48
+ children: years.map(year => /*#__PURE__*/_jsx("option", {
49
+ value: year,
50
+ children: year
51
+ }, year))
52
+ })]
53
+ });
54
+ };
55
+
56
+ export default YearMonthForm;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbl-digital/snorre",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "description": "Design library for BBL Digital",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",
@@ -1,13 +0,0 @@
1
- export let ModifierKey;
2
-
3
- (function (ModifierKey) {
4
- ModifierKey["enter"] = "Enter";
5
- ModifierKey["tab"] = "Tab";
6
- ModifierKey["space"] = " ";
7
- ModifierKey["escape"] = "Escape";
8
- ModifierKey["shift"] = "Shift";
9
- ModifierKey["right"] = "ArrowRight";
10
- ModifierKey["left"] = "ArrowLeft";
11
- ModifierKey["up"] = "ArrowUp";
12
- ModifierKey["down"] = "ArrowDown";
13
- })(ModifierKey || (ModifierKey = {}));
@@ -1,12 +0,0 @@
1
- export declare enum ModifierKey {
2
- enter = "Enter",
3
- tab = "Tab",
4
- space = " ",
5
- escape = "Escape",
6
- shift = "Shift",
7
- right = "ArrowRight",
8
- left = "ArrowLeft",
9
- up = "ArrowUp",
10
- down = "ArrowDown"
11
- }
12
- //# sourceMappingURL=ModifierKey.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModifierKey.d.ts","sourceRoot":"","sources":["../../src/packages/enums/ModifierKey.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,KAAK,MAAM;IACX,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,eAAe;IACpB,IAAI,cAAc;IAClB,EAAE,YAAY;IACd,IAAI,cAAc;CACnB"}
@@ -1,13 +0,0 @@
1
- export let ModifierKey;
2
-
3
- (function (ModifierKey) {
4
- ModifierKey["enter"] = "Enter";
5
- ModifierKey["tab"] = "Tab";
6
- ModifierKey["space"] = " ";
7
- ModifierKey["escape"] = "Escape";
8
- ModifierKey["shift"] = "Shift";
9
- ModifierKey["right"] = "ArrowRight";
10
- ModifierKey["left"] = "ArrowLeft";
11
- ModifierKey["up"] = "ArrowUp";
12
- ModifierKey["down"] = "ArrowDown";
13
- })(ModifierKey || (ModifierKey = {}));