@lumx/core 3.20.1-alpha.10 → 3.20.1-alpha.12

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/CONTRIBUTING.md CHANGED
@@ -4,7 +4,7 @@ We'd love for you to contribute to our source code and to make it even better th
4
4
 
5
5
  ## Getting the source code
6
6
 
7
- To be able to contribute, you will have to use the global LumX package from our [GitHub repository](https://github.com/lumapps/design-system). You won't be able to contribute from the distributed packages `@lumx/<angularjs|react>`, so be sure to clone the repository before starting contributing:
7
+ To be able to contribute, you will have to use the global LumX package from our [GitHub repository](https://github.com/lumapps/design-system). You won't be able to contribute from the distributed packages, so be sure to clone the repository before starting contributing:
8
8
 
9
9
  ```bash
10
10
  git clone git@github.com:lumapps/design-system.git
@@ -25,10 +25,6 @@ Here are the guidelines we'd like you to follow.
25
25
  - [Coding rules](#coding-rules)
26
26
  - [Git commit guidelines](#git-commit-guidelines)
27
27
 
28
- ## <a name="code-of-conduct"></a> Code of Conduct
29
-
30
- As heavy users of [AngularJS](https://github.com/angular/angular.js) and [React](https://github.com/facebook/react/), we encourage you to read and follow the [AngularJS Code of Conduct](https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md) and the [React Code of Conduct](https://github.com/facebook/react/blob/master/CODE_OF_CONDUCT.md).
31
-
32
28
  ## <a name="got-a-question-or-a-problem-"></a> Got a question or a problem?
33
29
 
34
30
  If you have questions about how to use LumX, please direct these to [StackOverflow](http://stackoverflow.com/questions/tagged/LumX).
package/package.json CHANGED
@@ -6,7 +6,6 @@
6
6
  "url": "https://github.com/lumapps/design-system/issues"
7
7
  },
8
8
  "dependencies": {
9
- "@lumx/icons": "3.19.0",
10
9
  "classnames": "^2.3.2",
11
10
  "focus-visible": "^5.0.2",
12
11
  "lodash": "4.17.21",
@@ -34,7 +33,7 @@
34
33
  "update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
35
34
  },
36
35
  "sideEffects": false,
37
- "version": "3.20.1-alpha.10",
36
+ "version": "3.20.1-alpha.12",
38
37
  "devDependencies": {
39
38
  "@rollup/plugin-commonjs": "^19.0.2",
40
39
  "@rollup/plugin-terser": "^0.4.4",
@@ -50,9 +49,5 @@
50
49
  "style-dictionary": "^3.9.0",
51
50
  "tinycolor2": "^1.4.1",
52
51
  "version-changelog": "^3.1.1"
53
- },
54
- "peerDependencies": {
55
- "moment": ">= 2",
56
- "moment-range": "^4.0.2"
57
52
  }
58
53
  }
@@ -1,136 +0,0 @@
1
- import classNames from 'classnames';
2
-
3
- import { mdiAlertCircle } from '@lumx/icons';
4
-
5
- import { GenericProps, HasTheme } from '../../types';
6
- import { getRootClassName, handleBasicClasses, resolveColorWithVariants } from '../../utils/className';
7
- import { ColorPalette, ColorVariant, ColorWithVariants, Size, Theme } from '../../constants';
8
- import { InputHelper } from '../InputHelper';
9
-
10
- export type IconSizes = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;
11
-
12
- /**
13
- * Defines the props of the component.
14
- */
15
- export interface IconProps extends GenericProps, HasTheme {
16
- /** Color variant. */
17
- color?: ColorWithVariants;
18
- /** Lightened or darkened variant of the selected icon color. */
19
- colorVariant?: ColorVariant;
20
- /** Whether the icon has a shape. */
21
- hasShape?: boolean;
22
- /**
23
- * Icon (SVG path) draw code (`d` property of the `<path>` SVG element).
24
- * See https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
25
- */
26
- icon: string;
27
- /** Size variant. */
28
- size?: IconSizes;
29
- /** Sets an alternative text on the svg. Will set an `img` role to the svg. */
30
- alt?: string;
31
- }
32
-
33
- /**
34
- * Component display name.
35
- */
36
- const COMPONENT_NAME = 'Icon';
37
-
38
- /**
39
- * Component default class name and class prefix.
40
- */
41
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
42
-
43
- /**
44
- * Component default props.
45
- */
46
- const DEFAULT_PROPS: Partial<IconProps> = {};
47
-
48
- /**
49
- * Icon component.
50
- *
51
- * @param props Component props.
52
- * @param ref Component ref.
53
- * @return React element.
54
- */
55
- export const Icon = (props: IconProps) => {
56
- console.log(props);
57
- const {
58
- className,
59
- color: propColor,
60
- colorVariant: propColorVariant,
61
- hasShape,
62
- icon,
63
- size,
64
- theme,
65
- alt,
66
- ref,
67
- ...forwardedProps
68
- } = props;
69
- const [color, colorVariant] = resolveColorWithVariants(propColor, propColorVariant);
70
-
71
- // Color
72
- let iconColor = color;
73
- if (!iconColor && (hasShape || theme)) {
74
- iconColor = theme === Theme.dark ? ColorPalette.light : ColorPalette.dark;
75
- }
76
-
77
- // Color variant
78
- let iconColorVariant = colorVariant;
79
- if (!iconColorVariant && hasShape && iconColor === ColorPalette.dark) {
80
- iconColorVariant = 'L2';
81
- }
82
-
83
- // Size
84
- let iconSize = size;
85
- if (size && hasShape) {
86
- if (size === Size.xxs || size === Size.xs) {
87
- iconSize = Size.s;
88
- } else if (size === Size.xxl) {
89
- iconSize = Size.xl;
90
- }
91
- } else if (hasShape) {
92
- iconSize = Size.m;
93
- }
94
-
95
- return (
96
- <i
97
- ref={ref}
98
- {...forwardedProps}
99
- className={classNames(
100
- className,
101
- handleBasicClasses({
102
- color: iconColor,
103
- colorVariant: iconColorVariant,
104
- hasShape,
105
- prefix: CLASSNAME,
106
- theme,
107
- size: iconSize,
108
- }),
109
- !hasShape && `${CLASSNAME}--no-shape`,
110
- !hasShape &&
111
- iconColor === ColorPalette.yellow &&
112
- icon === mdiAlertCircle &&
113
- `${CLASSNAME}--has-dark-layer`,
114
- `${CLASSNAME}--path`,
115
- )}
116
- >
117
- <InputHelper>test</InputHelper>
118
- <svg
119
- aria-hidden={alt ? undefined : 'true'}
120
- role={alt ? 'img' : undefined}
121
- aria-label={alt}
122
- height="1em"
123
- preserveAspectRatio="xMidYMid meet"
124
- style={{ verticalAlign: '-0.125em' }}
125
- viewBox="0 0 24 24"
126
- width="1em"
127
- >
128
- <path d={icon} fill="currentColor" />
129
- </svg>
130
- </i>
131
- );
132
- };
133
-
134
- Icon.displayName = COMPONENT_NAME;
135
- Icon.className = CLASSNAME;
136
- Icon.defaultProps = DEFAULT_PROPS;
@@ -1,69 +0,0 @@
1
- import classNames from 'classnames';
2
-
3
- import { Theme, Kind } from '../../constants';
4
- import { GenericProps, HasTheme } from '../../types';
5
- import { getRootClassName, handleBasicClasses } from '../../utils/className';
6
-
7
- export const INPUT_HELPER_CONFIGURATION: Record<string, { color: string }> = {
8
- error: {
9
- color: 'red',
10
- },
11
- success: {
12
- color: 'green',
13
- },
14
- warning: {
15
- color: 'yellow',
16
- },
17
- };
18
-
19
- /**
20
- * Defines the props of the component.
21
- */
22
- export interface InputHelperProps extends GenericProps, HasTheme {
23
- /** Helper variant. */
24
- kind?: Kind;
25
- }
26
-
27
- /**
28
- * Component display name.
29
- */
30
- const COMPONENT_NAME = 'InputHelper';
31
-
32
- /**
33
- * Component default class name and class prefix.
34
- */
35
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
36
-
37
- /**
38
- * Component default props.
39
- */
40
- const DEFAULT_PROPS: Partial<InputHelperProps> = {
41
- kind: Kind.info,
42
- };
43
-
44
- /**
45
- * InputHelper component.
46
- *
47
- * @param props Component props.
48
- * @param ref Component ref.
49
- * @return React element.
50
- */
51
- export const InputHelper = (props: InputHelperProps, options) => {
52
- const defaultTheme = Theme.light;
53
- const { className, kind = DEFAULT_PROPS.kind, theme = defaultTheme, ...forwardedProps } = props;
54
- const childrenToRender = options && options.slots && options.slots.default ? options.slots.default() : props.children;
55
- const { color } = INPUT_HELPER_CONFIGURATION[kind as any] || {};
56
-
57
- return (
58
- <p
59
- {...forwardedProps}
60
- className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, color, theme }))}
61
- >
62
- {childrenToRender}
63
- </p>
64
- );
65
- };
66
-
67
- InputHelper.displayName = COMPONENT_NAME;
68
- InputHelper.className = CLASSNAME;
69
- InputHelper.defaultProps = DEFAULT_PROPS;
package/js/date-picker.js DELETED
@@ -1,71 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var range = require('lodash/range');
6
- var mMoment = require('moment');
7
- var momentRange = require('moment-range');
8
-
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- var range__default = /*#__PURE__*/_interopDefaultLegacy(range);
12
- var mMoment__default = /*#__PURE__*/_interopDefaultLegacy(mMoment);
13
-
14
- const moment = momentRange.extendMoment(mMoment__default["default"]);
15
- const DAYS_PER_WEEK = 7;
16
- /**
17
- * Get the list of days in a week based on locale.
18
- *
19
- * @deprecated will be removed in next major version along with the removal of moment (no replacement planned)
20
- *
21
- * @param locale The locale using to generate the order of days in a week.
22
- * @return The list of days in a week based on locale.
23
- */
24
- function getWeekDays(locale) {
25
- return range__default["default"](DAYS_PER_WEEK).map((_, i) => moment().locale(locale).weekday(i));
26
- }
27
- /**
28
- * Get month calendar based on locale and start date.
29
- *
30
- * @deprecated will be removed in next major version along with the removal of moment (no replacement planned)
31
- *
32
- * @param locale The locale using to generate the order of days in a week.
33
- * @param selectedMonth The selected month.
34
- * @return The list of days in a week based on locale.
35
- */
36
- function getMonthCalendar(locale, selectedMonth) {
37
- const firstDayOfMonth = moment(selectedMonth).startOf('month');
38
- const endDayOfMonth = moment(selectedMonth).endOf('month');
39
- // The first day of the week depends on the locale used. In FR the first day is a monday but in EN the first day is sunday
40
- const firstDay = firstDayOfMonth.locale(locale).startOf('week');
41
- const monthRange = moment.range(firstDay.toDate(), endDayOfMonth.toDate());
42
- return Array.from(monthRange.by('day'));
43
- }
44
- /**
45
- * Get month calendar based on locale and start date.
46
- * Each day is annotated to know if they are displayed and/or clickable.
47
- *
48
- * @deprecated will be removed in next major version along with the removal of moment (no replacement planned)
49
- *
50
- * @param locale The locale using to generate the order of days in a week.
51
- * @param minDate The first selectable date.
52
- * @param maxDate The last selectable date.
53
- * @param selectedMonth The selected month.
54
- * @return The list of days in a week based on locale.
55
- */
56
- function getAnnotatedMonthCalendar(locale, minDate, maxDate, selectedMonth) {
57
- const month = moment(selectedMonth).locale(locale).month();
58
- const clickableRange = moment.range(minDate, maxDate);
59
- return getMonthCalendar(locale, selectedMonth).map((date) => {
60
- return {
61
- date,
62
- isClickable: clickableRange.contains(date),
63
- isDisplayed: date.month() === month,
64
- isToday: date.isSame(moment(), 'day'),
65
- };
66
- });
67
- }
68
-
69
- exports.getAnnotatedMonthCalendar = getAnnotatedMonthCalendar;
70
- exports.getMonthCalendar = getMonthCalendar;
71
- exports.getWeekDays = getWeekDays;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/range"),t=require("moment"),n=require("moment-range");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(e),r=a(t);const s=n.extendMoment(r.default);function d(e,t){const n=s(t).startOf("month"),a=s(t).endOf("month"),o=n.locale(e).startOf("week"),r=s.range(o.toDate(),a.toDate());return Array.from(r.by("day"))}exports.getAnnotatedMonthCalendar=function(e,t,n,a){const o=s(a).locale(e).month(),r=s.range(t,n);return d(e,a).map(e=>({date:e,isClickable:r.contains(e),isDisplayed:e.month()===o,isToday:e.isSame(s(),"day")}))},exports.getMonthCalendar=d,exports.getWeekDays=function(e){return o.default(7).map((t,n)=>s().locale(e).weekday(n))};
package/js/date-picker.ts DELETED
@@ -1,77 +0,0 @@
1
- import range from 'lodash/range';
2
- import mMoment, { Moment } from 'moment';
3
- import { extendMoment } from 'moment-range';
4
-
5
- const moment = extendMoment(mMoment as any);
6
-
7
- const DAYS_PER_WEEK = 7;
8
-
9
- interface AnnotatedDate {
10
- date: Moment;
11
- isDisplayed: boolean;
12
- isClickable: boolean;
13
- isToday: boolean;
14
- }
15
-
16
- /**
17
- * Get the list of days in a week based on locale.
18
- *
19
- * @deprecated will be removed in next major version along with the removal of moment (no replacement planned)
20
- *
21
- * @param locale The locale using to generate the order of days in a week.
22
- * @return The list of days in a week based on locale.
23
- */
24
- export function getWeekDays(locale: string): Moment[] {
25
- return range(DAYS_PER_WEEK).map((_, i) => moment().locale(locale).weekday(i));
26
- }
27
-
28
- /**
29
- * Get month calendar based on locale and start date.
30
- *
31
- * @deprecated will be removed in next major version along with the removal of moment (no replacement planned)
32
- *
33
- * @param locale The locale using to generate the order of days in a week.
34
- * @param selectedMonth The selected month.
35
- * @return The list of days in a week based on locale.
36
- */
37
- export function getMonthCalendar(locale: string, selectedMonth?: Moment): Moment[] {
38
- const firstDayOfMonth = moment(selectedMonth).startOf('month');
39
- const endDayOfMonth = moment(selectedMonth).endOf('month');
40
- // The first day of the week depends on the locale used. In FR the first day is a monday but in EN the first day is sunday
41
- const firstDay = firstDayOfMonth.locale(locale).startOf('week');
42
- const monthRange = moment.range(firstDay.toDate(), endDayOfMonth.toDate());
43
-
44
- return Array.from(monthRange.by('day'));
45
- }
46
-
47
- /**
48
- * Get month calendar based on locale and start date.
49
- * Each day is annotated to know if they are displayed and/or clickable.
50
- *
51
- * @deprecated will be removed in next major version along with the removal of moment (no replacement planned)
52
- *
53
- * @param locale The locale using to generate the order of days in a week.
54
- * @param minDate The first selectable date.
55
- * @param maxDate The last selectable date.
56
- * @param selectedMonth The selected month.
57
- * @return The list of days in a week based on locale.
58
- */
59
- export function getAnnotatedMonthCalendar(
60
- locale: string,
61
- minDate?: Date,
62
- maxDate?: Date,
63
- selectedMonth?: Moment,
64
- ): AnnotatedDate[] {
65
- const month = moment(selectedMonth).locale(locale).month();
66
-
67
- const clickableRange = moment.range(minDate as Date, maxDate as Date);
68
-
69
- return getMonthCalendar(locale, selectedMonth).map((date) => {
70
- return {
71
- date,
72
- isClickable: clickableRange.contains(date),
73
- isDisplayed: date.month() === month,
74
- isToday: date.isSame(moment(), 'day'),
75
- };
76
- });
77
- }