Skip to content

Commit

Permalink
[New #94] Migrating to microbundle
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Mar 1, 2022
1 parent 3df1743 commit 63612f6
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 15,103 deletions.
10 changes: 0 additions & 10 deletions .prettierrc.js

This file was deleted.

15,026 changes: 0 additions & 15,026 deletions package-lock.json

This file was deleted.

34 changes: 22 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s-forms",
"version": "0.3.3",
"version": "0.3.4",
"description": "Semantic forms generator and processor",
"keywords": [
"react",
Expand Down Expand Up @@ -34,6 +34,12 @@
"type": "git",
"url": "https://kbss.felk.cvut.cz/git/s-forms.git"
},
"type": "module",
"source": "src/s-forms.js",
"exports": "./dist/s-forms.modern.js",
"module": "./dist/s-forms.js",
"unpkg": "./dist/s-forms.umd.js",
"private": true,
"dependencies": {
"@triply/yasgui": "^4.2.14",
"babel-runtime": "^6.26.0",
Expand All @@ -45,6 +51,7 @@
"javascript-time-ago": "^2.3.8",
"jsonld": "^0.4.12",
"jsonld-utils": "https://kbss.felk.cvut.cz/dist/jsonld-utils-0.0.11.tgz",
"microbundle": "^0.14.2",
"prop-types": "^15.7.2",
"react-bootstrap": "1.0.1",
"react-datepicker": "^4.2.1",
Expand All @@ -55,11 +62,12 @@
"yasgui-yasqe": "^2.11.22"
},
"peerDependencies": {
"framer-motion": "^6.2.3",
"javascript-time-ago": "^2.3.8",
"react": ">= 17.0.2",
"react-bootstrap": "1.0.1",
"react-dom": ">= 17.0.2"
},
"main": "dist/s-forms.js",
"private": true,
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.6",
Expand All @@ -68,8 +76,15 @@
"@babel/plugin-transform-runtime": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@babel/preset-react": "^7.9.4",
"@babel/preset-typescript": "^7.16.7",
"@babel/register": "^7.10.3",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^21.0.2",
"@types/jest": "^27.4.0",
"@types/jsonld": "^1.5.1",
"@types/node": "^17.0.12",
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
"babel-jest": "^26.0.1",
"babel-loader": "^8.1.0",
Expand All @@ -83,22 +98,17 @@
"react": "~17.0.2",
"react-dom": "~17.0.2",
"style-loader": "^1.2.1",
"typescript": "^4.5.5",
"watchify": "^3.11.1",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3",
"webpack-node-externals": "^1.7.2",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.12",
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
"typescript": "^4.5.5",
"@babel/preset-typescript": "^7.16.7"
"webpack-node-externals": "^1.7.2"
},
"scripts": {
"test": "jest",
"dev": "webpack-dev-server --config webpack.config.dev.js",
"build": "webpack --config webpack.config.prod.js",
"dev": "webpack-dev-server --config webpack.config.dev.cjs",
"build": "microbundle --jsx React.createElement",
"lib": "babel ./src -d ./lib",
"build:lib": "npm run build && npm run build:css && npm pack",
"build:css": "cleancss --skip-rebase -d -o ./css/s-forms.min.css ./src/styles/s-forms.css"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Answer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import TypeaheadAnswer from './answer/TypeaheadAnswer';
import Constants from '../constants/Constants';
import { FormGenContext } from '../contexts/FormGenContext';
import { ConfigurationContext } from '../contexts/ConfigurationContext';
import QuestionStatic from "./QuestionStatic.js";
import QuestionStatic from "./QuestionStatic.jsx";

const Answer = (props) => {
const formGenContext = React.useContext(FormGenContext);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Question.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import MediaContent from './MediaContent';
import { CaretSquareDown, CaretSquareUp, InfoCircle } from '../styles/icons';
import { ConfigurationContext } from '../contexts/ConfigurationContext';
import classNames from 'classnames';
import QuestionStatic from "./QuestionStatic";
import QuestionStatic from "./QuestionStatic.jsx";

// TODO Remove once the pretty layout is tested
const PRETTY_ANSWERABLE_LAYOUT = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import React from "react";
import Constants from "../constants/Constants.js";
import HelpIcon from "./HelpIcon.jsx";
import JsonLdUtils from "jsonld-utils";
import LinkIcon from "./LinkIcon.jsx";
import QuestionCommentIcon from "./comment/QuestionCommentIcon.jsx";
import JsonLdUtils from "jsonld-utils";

export default class QuestionStatic {
static renderIcons(question, options, onCommentChange, showIcon) {
let icons;
if (options.icons) icons = options.icons;
else icons = Constants.DEFAULT_OPTIONS.icons;
let iconsArray = [];
const renderQuestionHelp = QuestionStatic.renderQuestionHelp(
const renderQuestionHelp = this.renderQuestionHelp(
question,
options,
onCommentChange,
showIcon
);
const renderQuestionComments = QuestionStatic.renderQuestionComments(
const renderQuestionComments = this.renderQuestionComments(
question,
options,
onCommentChange,
showIcon
);

const renderQuestionLink = QuestionStatic.renderQuestionLink(
const renderQuestionLink = this.renderQuestionLink(
question,
options,
onCommentChange,
Expand Down
2 changes: 1 addition & 1 deletion src/components/wizard/WizardStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Constants from '../../constants/Constants';
import { FormQuestionsContext } from '../../contexts/FormQuestionsContext';
import Question from '../Question';
import JsonLdObjectMap from '../../util/JsonLdObjectMap';
import QuestionStatic from "../QuestionStatic";
import QuestionStatic from "../QuestionStatic.jsx";

export default class WizardStep extends React.Component {
constructor(props) {
Expand Down
3 changes: 2 additions & 1 deletion src/contexts/ConfigurationContext.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import DefaultInput from "../components/DefaultInput";

const ConfigurationContext = React.createContext({});

const defaultProps = {
components: {
inputComponent: require('../components/DefaultInput').default
inputComponent: DefaultInput
},
componentsOptions: {
dateTimeAnswer: {
Expand Down
4 changes: 3 additions & 1 deletion src/model/DefaultFormGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export default class DefaultFormGenerator {
* The form consists of a single step, which contains one text area for the description.
*/
static generateForm() {
let formTemplate = require('./defaultForm');
let formTemplate = fetch("./defaultForm.json").then(response => {
return response.json();
})
// Deep copy of the form template to prevent modifications
formTemplate = JSON.parse(JSON.stringify(formTemplate));

Expand Down
43 changes: 0 additions & 43 deletions src/model/defaultForm.js

This file was deleted.

43 changes: 43 additions & 0 deletions src/model/defaultForm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"@graph": [
{
"@type": "http://onto.fel.cvut.cz/ontologies/documentation/question",
"http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class": "form",
"http://onto.fel.cvut.cz/ontologies/documentation/has_related_question": [
{
"http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class": ["wizard-step", "section"],
"http://www.w3.org/2000/01/rdf-schema#label": [
{
"@language": "en",
"@value": "Description"
},
{
"@language": "cs",
"@value": "Popis"
}
],
"http://onto.fel.cvut.cz/ontologies/documentation/has_related_question": [
{
"@type": "http://onto.fel.cvut.cz/ontologies/documentation/question",
"http://onto.fel.cvut.cz/ontologies/form-layout/has-layout-class": ["textarea"],
"http://www.w3.org/2000/01/rdf-schema#label": [
{
"@language": "en",
"@value": "Description"
},
{
"@language": "cs",
"@value": "Popis"
}
],
"http://onto.fel.cvut.cz/ontologies/documentation/has_answer": {
"@type": "http://onto.fel.cvut.cz/ontologies/documentation/answer",
"http://onto.fel.cvut.cz/ontologies/documentation/has_data_value": ""
}
}
]
}
]
}
]
}
4 changes: 3 additions & 1 deletion src/s-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FormQuestionsContext } from './contexts/FormQuestionsContext';
import Answer from './components/Answer';
import HelpIcon from './components/HelpIcon';
import WizardStep from './components/wizard/WizardStep';
import QuestionStatic from './components/QuestionStatic';

export default SForms;
export {
Expand All @@ -23,5 +24,6 @@ export {
HelpIcon,
ConfigurationContext,
FormQuestionsContext,
WizardStep
WizardStep,
QuestionStatic
};
4 changes: 2 additions & 2 deletions src/util/MaskMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const REPLACEMENTS = {
s: '1'
};

module.exports = {
export default class MaskMapper {
/**
* Attempts to map regular mask (e.g. date) to the format supported by inputmask-core.
*
Expand All @@ -17,7 +17,7 @@ module.exports = {
* ISO 8601 acronyms (e.g. M for month and m for minute).
* @param mask The mask to map
*/
mapMask(mask) {
static mapMask(mask) {
if (!mask) {
return mask;
}
Expand Down

0 comments on commit 63612f6

Please sign in to comment.