Skip to content

Commit

Permalink
Merge branch 'master' into feature/vue3
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed Dec 27, 2022
2 parents f9f7f4e + 5f95328 commit 3169983
Show file tree
Hide file tree
Showing 169 changed files with 5,487 additions and 2,448 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"lib": [
"DOM",
"ES5",
"ES2015.Promise",
"es6"
],
"baseUrl": ".",
"paths": {
"survey-core": [
"../../build/survey-core"
]
},
"sourceMap": false,
"noImplicitAny": false,
"importHelpers": false,
"experimentalDecorators": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"declaration": true,
"emitDeclarationOnly": true,
"skipLibCheck": true,
"outFile": "../../build/survey-core/plugins/bootstrap-integration.d.ts"
},
"include": [
"../../src/plugins/themes/bootstrap/index.ts"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"lib": [
"DOM",
"ES5",
"ES2015.Promise",
"es6"
],
"baseUrl": ".",
"paths": {
"survey-core": [
"../../build/survey-core"
]
},
"sourceMap": false,
"noImplicitAny": false,
"importHelpers": false,
"experimentalDecorators": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"declaration": true,
"emitDeclarationOnly": true,
"skipLibCheck": true,
"outFile": "../../build/survey-core/plugins/bootstrap-material-integration.d.ts"
},
"include": [
"../../src/plugins/themes/bootstrapmaterial/index.ts"
]
}
38 changes: 38 additions & 0 deletions build-scripts/survey-core/webpack.plugins.bootstrap.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use strict";

const webpackCommonConfigCreator = require("../webpack.common");
const { merge } = require("webpack-merge");
var FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries");
const DtsGeneratorPlugin = require("../webpack-dts-generator");
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
var path = require("path");

const config = {
entry: {
["bootstrap-integration"]: path.resolve(__dirname, "../../src/plugins/themes/bootstrap/index.ts"),
},
plugins: [new FixStyleOnlyEntriesPlugin()],
externals: {
"survey-core": {
root: "Survey",
commonjs2: "survey-core",
commonjs: "survey-core",
amd: "survey-core"
}
}
};

module.exports = function (options) {
options.platform = "";
options.libraryName = "SurveyBootstrap";
if (options.buildType !== "prod") {
config.plugins.push(new DtsGeneratorPlugin({
tsConfigPath: "./build-scripts/survey-core/tsconfig.plugins.bootstrap.theme.typing.json",
filePath: "build/survey-core/plugins/bootstrap-integration.d.ts",
moduleName: "survey-core/plugins/bootstrap-integration",
importName: "bootstrap/index"
}));
}

return merge(webpackCommonConfigCreator(options, { "name": "survey-plugins" }, "survey.plugins", "survey-core/plugins"), config);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use strict";

const webpackCommonConfigCreator = require("../webpack.common");
const { merge } = require("webpack-merge");
var FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries");
const DtsGeneratorPlugin = require("../webpack-dts-generator");
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
var path = require("path");

const config = {
entry: {
["bootstrap-material-integration"]: path.resolve(__dirname, "../../src/plugins/themes/bootstrapmaterial/index.ts"),
},
plugins: [new FixStyleOnlyEntriesPlugin()],
externals: {
"survey-core": {
root: "Survey",
commonjs2: "survey-core",
commonjs: "survey-core",
amd: "survey-core"
}
}
};

module.exports = function (options) {
options.platform = "";
options.libraryName = "SurveyBootstrapMaterial";
if (options.buildType !== "prod") {
config.plugins.push(new DtsGeneratorPlugin({
tsConfigPath: "./build-scripts/survey-core/tsconfig.plugins.bootstrapmaterial.theme.typing.json",
filePath: "build/survey-core/plugins/bootstrap-material-integration.d.ts",
moduleName: "survey-core/plugins/bootstrap-material-integration",
importName: "bootstrapmaterial/index"
}));
}

return merge(webpackCommonConfigCreator(options, { "name": "survey-plugins" }, "survey.plugins", "survey-core/plugins"), config);
};
32 changes: 32 additions & 0 deletions build-scripts/webpack-camel-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function CamelCaseNamePlugin(options) {}

function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

CamelCaseNamePlugin.prototype.apply = function (compiler) {
const REGEXP_NAME = /\[camelname\]/gi;

compiler.hooks.compilation.tap("RemoveCoreFromNamePlugin", (compilation) => {
const mainTemplate = compilation.mainTemplate;

mainTemplate.hooks.assetPath.tap(
"CamelCaseNamePlugin",
(path, data) => {
const chunk = data.chunk;
const chunkName = chunk && (chunk.name || chunk.id);

if (typeof path === "function") {
path = path(data);
}

return path.replace(REGEXP_NAME, (match, ...args) => {
const parts = chunkName.split("-");
return parts.map(function(part) { return capitalizeFirstLetter(part) }).join("");
});
}
);
});
};

module.exports = CamelCaseNamePlugin;
43 changes: 25 additions & 18 deletions build-scripts/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const VueLoaderPlugin = require("vue-loader/lib/plugin");
var GenerateJsonPlugin = require("generate-json-webpack-plugin");
var DashedNamePlugin = require("./webpack-dashed-name");
var CamelCaseNamePlugin = require("./webpack-camel-name");

var packageJsonWithVersion = require("../package.json");
var fs = require("fs");
Expand All @@ -18,7 +19,7 @@ var svgStoreUtils = require(path.resolve(
"../node_modules/webpack-svgstore-plugin/src/helpers/utils.js"
));

module.exports = function (options, packageJson, chunkName) {
module.exports = function (options, packageJson, chunkName, buildFolderName) {
packageJson.version = packageJsonWithVersion.version;
const today = new Date();
const year = today.getFullYear();
Expand All @@ -28,7 +29,7 @@ module.exports = function (options, packageJson, chunkName) {
"License: MIT (http://www.opensource.org/licenses/mit-license.php)",
].join("\n");

var buildPath = __dirname + "/../build/" + packageJson.name + "/";
var buildPath = __dirname + "/../build/" + (buildFolderName || packageJson.name) + "/";
var isProductionBuild = options.buildType === "prod";

function createSVGBundle() {
Expand Down Expand Up @@ -115,12 +116,6 @@ module.exports = function (options, packageJson, chunkName) {

var config = {
mode: isProductionBuild ? "production" : "development",
entry: {
[packageName]: path.resolve(
__dirname,
"../src/entries/" + options.platform + ".ts"
),
},
resolve: {
extensions: [".ts", ".js", ".tsx", ".scss"],
plugins: [new TsconfigPathsPlugin({ configFile: "./tsconfig.json" })],
Expand Down Expand Up @@ -203,7 +198,6 @@ module.exports = function (options, packageJson, chunkName) {
umdNamedDefine: true,
},
plugins: [
new webpack.ProgressPlugin(percentage_handler),
new webpack.DefinePlugin({
"process.env.ENVIRONMENT": JSON.stringify(options.buildType),
"process.env.VERSION": JSON.stringify(packageJson.version),
Expand All @@ -218,19 +212,32 @@ module.exports = function (options, packageJson, chunkName) {
}),
new RemoveCoreFromName(),
new FixStyleOnlyEntriesPlugin(),
new DashedNamePlugin()
new DashedNamePlugin(),
new CamelCaseNamePlugin()
],
};

if(!!options.platform) {
config.plugins.unshift(new webpack.ProgressPlugin(percentage_handler));
config.entry = {
[packageName]: path.resolve(
__dirname,
"../src/entries/" + options.platform + ".ts"
),
};
}

if (isProductionBuild) {
config.plugins.push(
new GenerateJsonPlugin(
/*buildPath +*/ "package.json",
packageJson,
undefined,
2
)
);
if(!!options.platform) {
config.plugins.push(
new GenerateJsonPlugin(
/*buildPath +*/ "package.json",
packageJson,
undefined,
2
)
);
}
} else {
config.devtool = "inline-source-map";
config.plugins = config.plugins.concat([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChangeDetectorRef, Component, ViewEncapsulation } from "@angular/core";
import { StylesManager } from "survey-core";
import { TestComponent } from "./test.component";
import "survey-core/plugins/bootstrap-integration";

@Component({
selector: "test-bootstap",
Expand All @@ -11,6 +12,6 @@ import { TestComponent } from "./test.component";
export class TestBootstrapComponent extends TestComponent {
constructor(changeDetectorRef: ChangeDetectorRef) {
super(changeDetectorRef);
StylesManager.applyTheme("default");
StylesManager.applyTheme("bootstrap");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export class TestCustomWidgetComponent extends TestComponent {
super(changeDetectorRef);
StylesManager.applyTheme("default");
widgets.sortablejs(SurveyCore);
widgets.icheck(SurveyCore, window.jQuery);
widgets.icheck(SurveyCore, (<any>window).jQuery);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="surveyElement">
<popup-survey *ngIf="!!model && isPopup" [model]="model"></popup-survey>
<survey *ngIf="!!model && !isPopup" [model]="model"></survey></div>
<popup-survey *ngIf="!!model && isPopup" [model]="$any(model)"></popup-survey>
<survey *ngIf="!!model && !isPopup" [model]="$any(model)"></survey></div>
<div id="surveyResultElement"></div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChangeDetectorRef, Component } from "@angular/core";
import { SurveyModel } from "survey-core";
import * as Survey from "survey-core";
import { defaultCss } from "survey-core/plugins/bootstrap-integration";
import "survey-core/survey.i18n";

@Component({
Expand All @@ -9,13 +10,14 @@ import "survey-core/survey.i18n";
})
export class TestComponent {
public model?: SurveyModel | Survey.PopupSurveyModel;
public isPopup: boolean;
public isPopup: boolean = true;
constructor(private changeDetectorRef: ChangeDetectorRef) {
(window as any).Survey = Survey;
(<any>window).setSurvey = (survey: SurveyModel | Survey.PopupSurveyModel, isPopup: boolean) => {
this.model = survey;
this.isPopup = isPopup;
this.changeDetectorRef.detectChanges();
}
(window as any).Survey.defaultBootstrapCss = defaultCss;
}
}
25 changes: 0 additions & 25 deletions examples/angular-ui/tsconfig.app.json

This file was deleted.

13 changes: 9 additions & 4 deletions examples/knockout/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.5.0/knockout-debug.js"></script>

<!-- <link rel="stylesheet" href="https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css"> -->
<!-- <link rel="stylesheet" href="../../build/survey-knockout/survey.css" /> -->
<!-- <script src="../../build/survey-core/plugins/bootstrap-integration.js"></script> -->
<link rel="stylesheet" href="../../build/survey-knockout/survey.css" />
<!-- <link rel="stylesheet" href="../../build/survey-knockout/modern.css" /> -->
<link rel="stylesheet" href="../../build/survey-knockout/defaultV2.css" />
<!-- <link rel="stylesheet" href="../../build/survey-knockout/defaultV2.css" /> -->
<script src="../../build/survey-core/survey.core.js"></script>
<script src="../../build/survey-knockout/survey.ko.js"></script>
</head>
<!-- <script src="../../build/survey-knockout-ui/survey-knockout-ui.js"></script> -->
</head>

<body>
<div id="surveyElement"></div>
<div id="surveyElement">
<survey params="survey: model"/>
</div>
<div id="surveyResultElement"></div>
<script src="./index.js"></script>
</body>
Expand Down
5 changes: 3 additions & 2 deletions examples/knockout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ function init() {

//Survey.StylesManager.applyTheme("default");
//Survey.StylesManager.applyTheme("modern");
Survey.StylesManager.applyTheme("defaultV2");
// Survey.StylesManager.applyTheme("defaultV2");

var model = new Survey.Model(json);
//model.setDesignMode(true);
Expand All @@ -1047,7 +1047,8 @@ function init() {
}));
});

model.render("surveyElement");
//model.render("surveyElement");
ko.applyBindings({model});
}

if (!window["%hammerhead%"]) {
Expand Down
4 changes: 4 additions & 0 deletions examples_test/customWidget/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function init() {
Survey.StylesManager.applyTheme("default");
}
document.addEventListener("DOMContentLoaded", init);
Loading

0 comments on commit 3169983

Please sign in to comment.