Skip to content

Commit eedf236

Browse files
committed
hello world
1 parent a970da5 commit eedf236

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+13655
-3105
lines changed

.eslintrc.js

+2-89
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,12 @@ module.exports = {
4848
},
4949
requireConfigFile: false,
5050
},
51-
plugins: [
52-
'ember',
53-
'qunit',
54-
'simple-import-sort',
55-
'import',
56-
'unused-imports',
57-
'unicorn',
58-
'no-useless-assign',
59-
],
51+
plugins: ['ember', 'qunit', 'import', 'unused-imports', 'no-useless-assign'],
6052
extends: [
6153
'eslint:recommended',
6254
'plugin:ember/recommended',
6355
'plugin:prettier/recommended',
6456
'plugin:qunit/recommended',
65-
'plugin:unicorn/recommended',
6657
],
6758
globals: {},
6859
env: {
@@ -86,15 +77,8 @@ module.exports = {
8677
'max-params': ['error', { max: 4 }],
8778
'max-depth': ['error', { max: 4 }],
8879
'max-statements': ['error', { max: 40 }],
89-
'max-lines-per-function': [
90-
'error',
91-
{ max: 80, skipBlankLines: true, skipComments: true },
92-
],
80+
9381
complexity: ['error', { max: 20 }],
94-
'no-magic-numbers': [
95-
'error',
96-
{ ignore: [0, 1, -1], ignoreArrayIndexes: true },
97-
],
9882

9983
'no-unused-vars': 'off', // or "@typescript-eslint/no-unused-vars": "off",
10084
'unused-imports/no-unused-imports': 'error',
@@ -216,15 +200,6 @@ module.exports = {
216200
// See https://github.com/eslint/eslint/issues/11899 and similar
217201
'require-atomic-updates': 'off',
218202

219-
'simple-import-sort/imports': ['error', { groups: ImportSortGroups }],
220-
'sort-imports': 'off',
221-
'import/order': 'off',
222-
'import/first': 'error',
223-
'import/newline-after-import': 'error',
224-
// this rule doesn't work properly with --fix
225-
// https://github.com/benmosher/eslint-plugin-import/issues/1504
226-
'import/no-duplicates': 'warn',
227-
228203
'ember/routes-segments-snake-case': 'off', // We should leave this off permanently
229204
'ember/use-brace-expansion': 'off', // has bugs and is annoying + only applies to computeds
230205

@@ -243,68 +218,6 @@ module.exports = {
243218
'ember/require-tagless-components': 'error',
244219
'ember/no-classic-components': 'error',
245220
'ember/no-side-effects': 'error',
246-
247-
// unicorn
248-
'unicorn/prefer-module': 'off',
249-
'unicorn/no-array-for-each': 'off', // this might be nice someday? better if it would do regular for loops for arrays
250-
'unicorn/number-literal-case': 'off', // conflicts with prettier
251-
'unicorn/no-nested-ternary': 'off', // conflicts with prettier
252-
'unicorn/no-null': 'off', // too WAT
253-
'unicorn/consistent-destructuring': 'off', // nice in some ways but heavy handed
254-
'unicorn/prefer-spread': 'off', // possibly nice if we had native arrays
255-
'unicorn/no-for-loop': 'off', // if for...of was good maybe we'd use this
256-
'unicorn/prefer-add-event-listener': 'error',
257-
'unicorn/better-regex': 'off', // would be awesome but has bugs https://github.com/sindresorhus/eslint-plugin-unicorn/issues?q=is%3Aissue+is%3Aopen+better-regex
258-
259-
'unicorn/prefer-includes': 'error',
260-
'unicorn/prefer-default-parameters': 'error',
261-
'unicorn/prefer-number-properties': 'error', // note Number.isNaN and Number.isFinite usage differs from global
262-
'unicorn/numeric-separators-style': 'error',
263-
'unicorn/prefer-optional-catch-binding': 'error',
264-
'unicorn/catch-error-name': 'error',
265-
'unicorn/prefer-ternary': 'error',
266-
'unicorn/no-lonely-if': 'error',
267-
'unicorn/prefer-regexp-test': 'error',
268-
'unicorn/prefer-array-find': 'error',
269-
'unicorn/prefer-array-some': 'error',
270-
'unicorn/prefer-string-replace-all': 'error',
271-
'unicorn/explicit-length-check': 'error',
272-
'unicorn/no-unsafe-regex': 'error',
273-
274-
// to consider activating
275-
'unicorn/prefer-negative-index': 'off',
276-
'unicorn/prefer-dom-node-append': 'off',
277-
'unicorn/prefer-dom-node-remove': 'off',
278-
'unicorn/prefer-query-selector': 'off',
279-
'unicorn/prefer-switch': 'off',
280-
'unicorn/prefer-string-slice': 'off',
281-
'unicorn/no-array-push-push': 'off',
282-
'unicorn/no-zero-fractions': 'off',
283-
'unicorn/consistent-function-scoping': 'off',
284-
'unicorn/no-array-reduce': 'off',
285-
'unicorn/new-for-builtins': 'off',
286-
'unicorn/escape-case': 'off',
287-
'unicorn/no-this-assignment': 'off',
288-
'unicorn/prefer-set-has': 'off',
289-
'unicorn/prefer-export-from': 'off',
290-
'unicorn/prefer-code-point': 'off',
291-
'unicorn/require-array-join-separator': 'off',
292-
'unicorn/error-message': 'off',
293-
'unicorn/no-array-callback-reference': 'off', // we may never want this
294-
'unicorn/prevent-abbreviations': [
295-
'off',
296-
{
297-
checkFilenames: false,
298-
checkDefaultAndNamespaceImports: false,
299-
extendDefaultReplacements: false,
300-
replacements: {
301-
e: {
302-
error: true,
303-
event: true,
304-
},
305-
},
306-
},
307-
],
308221
},
309222
overrides: [
310223
// TypeScript files in strict-mode
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const { addonV1Shim } = require("@embroider/addon-shim");
1+
const { addonV1Shim } = require('@embroider/addon-shim');
22

33
module.exports = addonV1Shim(__dirname);

addons/ember-rrule-generator/package.json

+36-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-rrule-generator",
3-
"description": "Add your description here",
3+
"description": "headless rrule generator",
44
"version": "0.0.0",
55
"private": false,
66
"license": "MIT",
@@ -17,16 +17,19 @@
1717
"npm": "Use pnpm",
1818
"yarn": "Use pnpm"
1919
},
20-
"keywords": ["ember-addon"],
20+
"keywords": [
21+
"ember-addon"
22+
],
2123
"volta": {
2224
"extends": "../../package.json"
2325
},
2426
"dependencies": {
27+
"@babel/runtime": "^7.18.9",
2528
"@embroider/addon-shim": "^1.5.0"
2629
},
2730
"exports": {
28-
".": "./dist/src/index.js",
29-
"./*": "./dist/src/*",
31+
".": "./dist/index.js",
32+
"./*": "./dist/*",
3033
"./addon-main.js": "./addon-main.js"
3134
},
3235
"files": [
@@ -35,33 +38,47 @@
3538
],
3639
"scripts": {
3740
"build": "rollup --config",
38-
"start": "rollup --config --watch",
41+
"start": "npm-run-all --parallel start:*",
42+
"start:test-app": "cd ../../apps/test-app && ember serve",
43+
"start:build": "rollup --config --watch",
3944
"prepublishOnly": "rollup --config"
4045
},
4146
"ember-addon": {
4247
"main": "addon-main.js",
4348
"type": "addon",
4449
"version": 2,
45-
"app-js": {},
50+
"app-js": {
51+
"./components/containers/start/index.js": "./dist/_app_/components/containers/start/index.js",
52+
"./components/r-rule-generator/index.js": "./dist/_app_/components/r-rule-generator/index.js"
53+
},
4654
"public-assets": {}
4755
},
48-
"peerDependencies": {},
56+
"peerDependencies": {
57+
"dayjs": "^1.11.5",
58+
"lodash-es": "^4",
59+
"rrule": "^2.7.1"
60+
},
4961
"devDependencies": {
50-
"@embroider/addon-dev": "^1.8.1",
51-
"rollup": "^2.75.7",
52-
"@babel/core": "^7.18.6",
53-
"@babel/plugin-proposal-class-properties": "^7.18.6",
54-
"@babel/plugin-proposal-decorators": "^7.16.6",
55-
"@babel/plugin-transform-typescript": "^7.18.6",
56-
"@babel/plugin-transform-runtime": "^7.18.6",
62+
"@babel/core": "^7.18.0",
63+
"@babel/plugin-proposal-class-properties": "^7.17.12",
64+
"@babel/plugin-proposal-decorators": "^7.18.9",
65+
"@babel/plugin-transform-runtime": "^7.18.9",
66+
"@babel/plugin-transform-typescript": "^7.18.8",
67+
"@babel/preset-env": "^7.18.9",
5768
"@babel/preset-typescript": "^7.18.6",
58-
"@babel/preset-env": "^7.18.6",
59-
"@babel/runtime": "^7.18.6",
69+
"@embroider/addon-dev": "^1.6.0",
6070
"@rollup/plugin-babel": "^5.3.1",
61-
"@rollup/plugin-typescript": "^8.3.3",
71+
"@rollup/plugin-typescript": "^8.3.2",
72+
"@types/chess.js": "^0.13.2",
73+
"@types/lodash-es": "^4.17.6",
74+
"dayjs": "^1.11.5",
75+
"lodash-es": "^4.17.21",
76+
"npm-run-all": "^4.1.5",
77+
"rollup": "^2.74.1",
78+
"rrule": "^2.7.1",
6279
"tslib": "^2.4.0",
63-
"walk-sync": "^3.0.0",
64-
"typescript": "^4.7.5"
80+
"typescript": "^4.7.4",
81+
"walk-sync": "^3.0.0"
6582
},
6683
"ember": {
6784
"edition": "octane"

addons/ember-rrule-generator/rollup.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ function templateOnlyPlugin(args) {
9090
export default {
9191
// This provides defaults that work well alongside `publicEntrypoints` below.
9292
// You can augment this if you need to.
93-
output: addon.output(),
93+
output: {
94+
...addon.output(),
95+
hoistTransitiveImports: false,
96+
},
9497

9598
external: [],
9699

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{#if @onDate.options.calendarComponent}}
2+
{{#let (component @onDate.options.calendarComponent) as |CalendarComponent|}}
3+
<CalendarComponent
4+
@onChange={{this.handleChange}}
5+
@value={{@onDate.date}}
6+
/>
7+
{{/let}}
8+
{{else}}
9+
<input type="date" {{on "input" this.handleChange}} value={{@onDate.date}} />
10+
{{/if}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Component from '@glimmer/component';
2+
3+
import RRuleGenerator from '../../r-rule-generator/index';
4+
5+
interface Signature {
6+
Args: {
7+
handleChange: RRuleGenerator['handleChange'];
8+
};
9+
}
10+
11+
export default class ContainersStartComponent extends Component<Signature> {
12+
handleChange = (e: { target: { value: unknown } }) => {
13+
const editedEvent = {
14+
target: {
15+
value: e.target.value,
16+
name: 'start.onDate.date',
17+
},
18+
};
19+
20+
this.args.handleChange(editedEvent);
21+
};
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{yield (hash Start=(component this.Start handleChange=this.handleChange))}}
2+
3+
{{this.data}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { cloneDeep, set } from 'lodash-es';
2+
3+
import Component from '@glimmer/component';
4+
import { tracked } from '@glimmer/tracking';
5+
6+
import computeRRuleToString from '../../utils/computeRRule/toString/computeRRule';
7+
import computeRRuleFromString from '../../utils/computeRRule/fromString/computeRRule';
8+
import configureInitialState from '../../utils/configureInitialState';
9+
10+
import Start from '../containers/start/index';
11+
12+
export interface ChangeEvent {
13+
target: {
14+
value: unknown;
15+
name: string;
16+
};
17+
}
18+
19+
export interface Config {
20+
frequency?: 'Yearly' | 'Monthy' | 'Weekly' | 'Daily' | 'Hourly'[];
21+
yearly?: 'on' | 'on the';
22+
monthly?: 'on' | 'on the';
23+
end?: 'Never' | 'After' | 'On date'[];
24+
hideStart?: boolean;
25+
hideEnd?: boolean;
26+
hideError?: boolean;
27+
weekStartOnSunday?: boolean;
28+
}
29+
30+
type Signature = {
31+
Element: HTMLUListElement;
32+
Args: {
33+
onChange: (rrule: string) => void;
34+
value?: string;
35+
config?: Config;
36+
id?: string;
37+
calendarComponent?: Component;
38+
};
39+
};
40+
41+
interface State {
42+
id: string;
43+
data: {
44+
start: unknown;
45+
repeat: unknown;
46+
end: unknown;
47+
options: unknown;
48+
};
49+
rrule: string;
50+
}
51+
52+
export default class RRuleGenerator extends Component<Signature> {
53+
Start = Start;
54+
55+
@tracked state: State = configureInitialState(
56+
this.args.config,
57+
this.args.calendarComponent,
58+
this.args.id
59+
);
60+
61+
handleChange = ({ target }: ChangeEvent) => {
62+
//eslint-disable-next-line
63+
const newData = cloneDeep(this.state.data);
64+
//eslint-disable-next-line
65+
set(newData, target.name, target.value);
66+
67+
this.state = {
68+
...this.state,
69+
data: newData,
70+
};
71+
72+
//eslint-disable-next-line
73+
const rrule = computeRRuleToString(newData);
74+
console.log(rrule);
75+
76+
this.args.onChange?.(rrule);
77+
};
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const computeDailyInterval = (data, rruleObj) => {
2+
if (rruleObj.freq !== 3) {
3+
return data.repeat.daily.interval;
4+
}
5+
6+
return rruleObj.interval;
7+
};
8+
9+
export default computeDailyInterval;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const computeEndAfter = (data, rruleObj) => {
2+
if (!rruleObj.count && rruleObj.count !== 0) {
3+
return data.end.after;
4+
}
5+
6+
return rruleObj.count;
7+
};
8+
9+
export default computeEndAfter;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const computeEndMode = (data, rruleObj) => {
2+
if (rruleObj.count || rruleObj.count === 0) {
3+
return 'After';
4+
}
5+
6+
if (rruleObj.until) {
7+
return 'On date';
8+
}
9+
10+
return 'Never';
11+
};
12+
13+
export default computeEndMode;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const computeEndOnDate = (data, rruleObj) => {
2+
if (!rruleObj.until) {
3+
return data.end.onDate.date;
4+
}
5+
6+
return rruleObj.until;
7+
};
8+
9+
export default computeEndOnDate;

0 commit comments

Comments
 (0)