diff --git a/README.md b/README.md index 9a0ff7cb..80786ada 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ ## REQUIREMENTS -* **Current SGNUIKit Version**: 1.1.5 + +**Current SGNUIKit Version**: 1.2.1 ### Core Requirements diff --git a/SECURITY.md b/SECURITY.md index a9db43ea..083540e5 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,9 +4,9 @@ | Version | Supported | |---------|--------------------| +| 1.2.1 | :white_check_mark: | | 1.1.5 | :white_check_mark: | -| 1.1.4 | :white_check_mark: | -| < 1.1.4 | :x: | +| < 1.1.5 | :x: | ## Reporting a Vulnerability diff --git a/build/config.js b/build/config.js index cc5eaab5..ae3b7d73 100644 --- a/build/config.js +++ b/build/config.js @@ -27,7 +27,7 @@ const version = { }; -const SGNUIKitLoader = "LyoNCiAqIENvcHlyaWdodCAoYykgMjAyMiBTR05ldHdvcmtzLiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KICoNCiAqIFRoZSBzb2Z0d2FyZSBpcyBhbiBleGNsdXNpdmUgY29weXJpZ2h0IG9mICJTR05ldHdvcmtzIiBhbmQgaXMgcHJvdmlkZWQgYXMgaXMgZXhjbHVzaXZlbHkgd2l0aCBvbmx5ICJVU0FHRSIgYWNjZXNzLiAiTW9kaWZpY2F0aW9uIiwgICJBbHRlcmF0aW9uIiwgIlJlLWRpc3RyaWJ1dGlvbiIgaXMgY29tcGxldGVseSBwcm9oaWJpdGVkLg0KICogVklPTEFUSU5HIFRIRSBBQk9WRSBURVJNUyBJUyBBIFBVTklTSEFCTEUgT0ZGRU5TRSBXSElDSCBNQVkgTEVBRCBUTyBMRUdBTCBDT05TRVFVRU5DRVMuDQogKi8NCg0KY29uc3QgU0dOVUlLaXQgPSB7DQoJaXNSZWFkeTogZmFsc2UsDQoJaXNQcmVsb2FkZXJIZWxkOiBmYWxzZSwNCgljb21wb25lbnRzOiB7fSwNCglvbkNoYW5nZUxpc3RlbmVyOiBbXSwNCglvblJlYWR5TGlzdGVu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XJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHsNCgkJY29uc3QgdGltZW91dEhhbmRsZXIgPSBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkgew0KCQkJaWYoY2hlY2tJbnRlcnZhbEhhbmRsZXIpDQoJCQkJY2xlYXJJbnRlcnZhbChjaGVja0ludGVydmFsSGFuZGxlcik7DQoJCX0sIDEwMDAwKTsNCg0KCQljb25zdCBjaGVja0ludGVydmFsSGFuZGxlciA9IHNldEludGVydmFsKGZ1bmN0aW9uKCkgew0KCQkJaWYod2luZG93LlNHTlVJS2l0UmVhZHkpIHsNCgkJCQlpZih0aW1lb3V0SGFuZGxlcikNCgkJCQkJY2xlYXJUaW1lb3V0KHRpbWVvdXRIYW5kbGVyKTsNCgkJCQljbGVhckludGVydmFsKGNoZWNrSW50ZXJ2YWxIYW5kbGVyKTsNCgkJCQljb25zdCBjID0gbmV3IFNHTmkxOG4oKTsNCg0KCQkJCS8qaWYodHlwZW9mIGNhbGxiYWNrID09PSAnZnVuY3Rpb24nKQ0KCQkJCSBjYWxsYmFjayhjKTsqLw0KCQkJCXJlc29sdmUoYyk7DQoJCQl9DQoJCX0sIDEwMCk7DQoJfSk7DQp9DQoNCg=="; module.exports = { args, SGNUIKitLoader, version, cdn_dir, diff --git a/demos/grids.html b/demos/grids.html new file mode 100644 index 00000000..50120031 --- /dev/null +++ b/demos/grids.html @@ -0,0 +1,160 @@ + + + + +
+ +${code}
`;
+ snippetCodeTab += ` ${code}
`;
+ snippetCodeTab += ` ${code}
`;
+ html += `