Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lesca-click

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lesca-click - npm Package Compare versions

Comparing version 4.1.1 to 4.2.0

lib/constants.d.ts

15

dist/bundle.js.LICENSE.txt

@@ -53,1 +53,16 @@ /*!@license Copyright 2013, Heinrich Goebl, License: MIT, see https://github.com/hgoebl/mobile-detect.js*/

*/
/** @license MUI v5.8.0
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

135

lib/constants.js

@@ -1,76 +0,61 @@

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
define(["require", "exports", "mobile-detect"], function (require, exports, mobile_detect_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FIND_ROOT = exports.CHECK_PARENT_HAS_CLASS = exports.GET_DEVICE = void 0;
mobile_detect_1 = __importDefault(mobile_detect_1);
var GET_DEVICE = function () {
var m = new mobile_detect_1.default(window.navigator.userAgent);
if (m.tablet())
return 'mobile';
else if (m.mobile())
return 'mobile';
else
return 'desktop';
};
exports.GET_DEVICE = GET_DEVICE;
var CHECK_PARENT_HAS_CLASS = function (e, classDataset) {
var target = e.target;
var node = target;
var result = [];
var _loop_1 = function () {
var id = node.id, className = node.className;
var is = classDataset.filter(function (e) {
var attr = e.slice(0, 1);
var name = e.slice(1);
switch (attr) {
case '.':
if (className === name)
return true;
break;
case '#':
if (id === name)
return true;
break;
}
return false;
}).length > 0;
if (is)
result.push(node);
node = node.parentNode;
};
while (node && node.tagName !== 'HTML') {
_loop_1();
}
return result.length > 0;
};
exports.CHECK_PARENT_HAS_CLASS = CHECK_PARENT_HAS_CLASS;
var FIND_ROOT = function (e) {
var target = e.target;
var node = target;
var result;
while (node && node.tagName !== 'BODY') {
result = node;
node = node.parentNode;
}
return result;
};
exports.FIND_ROOT = FIND_ROOT;
});
exports.GET_DEVICE = exports.FIND_ROOT = exports.CHECK_PARENT_HAS_CLASS = void 0;
var _mobileDetect = _interopRequireDefault(require("mobile-detect"));
var GET_DEVICE = function GET_DEVICE() {
var m = new _mobileDetect["default"](window.navigator.userAgent);
if (m.tablet()) return 'mobile';else if (m.mobile()) return 'mobile';else return 'desktop';
};
/**
*
* @param {event} e
* @param {array} classDataset
*/
exports.GET_DEVICE = GET_DEVICE;
var CHECK_PARENT_HAS_CLASS = function CHECK_PARENT_HAS_CLASS(e, classDataset) {
var target = e.target;
var node = target;
var result = [];
var _loop = function _loop() {
var _node = node,
id = _node.id,
className = _node.className;
var is = classDataset.filter(function (e) {
var attr = e.slice(0, 1);
var name = e.slice(1);
switch (attr) {
case '.':
if (className === name) return true;
break;
case '#':
if (id === name) return true;
break;
}
return false;
}).length > 0;
if (is) result.push(node);
node = node.parentNode;
};
while (node.tagName !== 'HTML') {
_loop();
}
return result.length > 0;
};
exports.CHECK_PARENT_HAS_CLASS = CHECK_PARENT_HAS_CLASS;
var FIND_ROOT = function FIND_ROOT(e) {
var target = e.target;
var node = target;
var result;
while (node.tagName !== 'BODY') {
result = node;
node = node.parentNode;
}
return result;
};
exports.FIND_ROOT = FIND_ROOT;

@@ -1,252 +0,191 @@

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setPreventDefault = exports.remove = exports.install = exports["default"] = exports.dataset = exports.clear = exports.addPreventExcept = exports.add = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _constants = require("./constants");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
/**
* event dataset
*/
var dataset = {};
exports.dataset = dataset;
var mousePropertyDown = {
x: 0,
y: 0
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var mousePropertyMove = {
x: mousePropertyDown.x,
y: mousePropertyDown.y
};
var extraEvent = {
down: function down() {},
move: function move() {},
up: function up() {}
};
var state = {
device: false,
isPress: false,
deviation: 30,
preventDefault: true
};
var eventProperty = {
passive: false,
capture: false
};
var moveOffsetProperty = {
x: 0,
y: 0
};
var exceptParentClassIDDataset = [];
var rootElement = false;
var checkDataset = function checkDataset(e) {
var target = e.target;
["".concat(target.id, "_id"), "".concat(target.className, "_class")].forEach(function (name) {
var _dataset$name, _dataset;
(_dataset$name = (_dataset = dataset)[name]) === null || _dataset$name === void 0 ? void 0 : _dataset$name.call(_dataset, e);
});
};
var areWePreventDefault = function areWePreventDefault(e) {
var preventDefault = state.preventDefault;
var root = (0, _constants.FIND_ROOT)(e);
var isRoot = false;
if (rootElement) {
if (rootElement.indexOf('.') >= 0) {
isRoot = rootElement === ".".concat(root.className);
} else if (rootElement.indexOf('#') >= 0) {
isRoot = rootElement === "#".concat(root.id);
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
}
if (isRoot) {
var hasClassID = (0, _constants.CHECK_PARENT_HAS_CLASS)(e, exceptParentClassIDDataset);
if (preventDefault && !hasClassID && e.cancelable && !e.defaultPrevented) {
var n = e.target.localName;
if (n != 'input' && n != 'button' && n != 'select') e.preventDefault();
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var down = function down(e) {
state.isPress = true;
var x = e.clientX || e.targetTouches[0].clientX || false;
var y = e.clientY || e.targetTouches[0].clientY || false;
if (!x || !y) return;
areWePreventDefault(e);
mousePropertyDown.x = x;
mousePropertyDown.y = y;
mousePropertyMove.x = x;
mousePropertyMove.y = y;
extraEvent.down(e);
};
var move = function move(e) {
if (!state.isPress) return;
var x = e.clientX || e.targetTouches[0].clientX || false;
var y = e.clientY || e.targetTouches[0].clientY || false;
if (!x || !y) return;
areWePreventDefault(e);
var dx = mousePropertyDown.x,
dy = mousePropertyDown.y;
moveOffsetProperty.x = x - dx;
moveOffsetProperty.y = y - dy;
mousePropertyMove.x = x;
mousePropertyMove.y = y;
extraEvent.move(_objectSpread(_objectSpread({}, e), {}, {
moveOffsetProperty: moveOffsetProperty
}));
};
var up = function up(e) {
state.isPress = false;
var dx = mousePropertyDown.x,
dy = mousePropertyDown.y;
var mx = mousePropertyMove.x,
my = mousePropertyMove.y;
var deviation = state.deviation;
var m = Math.sqrt(Math.pow(mx - dx, 2) + Math.pow(my - dy, 2));
if (m < deviation) checkDataset(e);
extraEvent.up(e);
};
var addListener = function addListener(device) {
if (device === 'mobile') {
document.addEventListener('touchstart', down, eventProperty);
document.addEventListener('touchmove', move, eventProperty);
document.addEventListener('touchend', up);
} else {
document.addEventListener('mousedown', down);
document.addEventListener('mousemove', move);
document.addEventListener('mouseup', up);
}
};
var removeListener = function removeListener(device) {
if (device === 'mobile') {
document.removeEventListener('mousedown', down);
document.removeEventListener('mousemove', move);
document.removeEventListener('mouseup', up);
} else {
document.removeEventListener('touchstart', down);
document.removeEventListener('touchmove', move);
document.removeEventListener('touchend', up);
}
};
var eventTransform = function eventTransform() {
var device = state.device;
var d = (0, _constants.GET_DEVICE)();
if (!device) {
state.device = d;
addListener(d);
} else if (device !== d) {
state.device = d;
removeListener(d);
addListener(d);
}
};
/**
*
* @param {queryString} query make sure it's uni-name.(ex: .target || #target)
*/
var addPreventExcept = function addPreventExcept(query) {
var type = (0, _typeof2["default"])(query);
if (type === 'string') exceptParentClassIDDataset.push(query);else if (Array.isArray(query)) {
exceptParentClassIDDataset = (0, _toConsumableArray2["default"])(query);
}
};
/**
* set preventDefault will call or not.
* @param {boolean} value
*/
exports.addPreventExcept = addPreventExcept;
var setPreventDefault = function setPreventDefault(value) {
state.preventDefault = value;
};
/**
*
* @param {queryString} query make sure it's uni-name.(ex: .target || #target)
* @param {function} callback call when click
* @returns
*/
exports.setPreventDefault = setPreventDefault;
var add = function add(query, callback) {
if (!callback) return;
var type = query.slice(0, 1) === '.' ? '_class' : '_id';
var name = query.slice(1);
var key = name + type;
dataset[key] = callback;
};
exports.add = add;
var remove = function remove(query) {
var type = query.slice(0, 1) == '.' ? '_class' : '_id';
var name = query.slice(1);
var key = name + type;
delete dataset[key];
};
/**
* add events
*/
exports.remove = remove;
var install = function install() {
var app = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#app';
rootElement = app;
eventTransform();
window.addEventListener('resize', eventTransform);
};
/**
* clear all dataset
*/
exports.install = install;
var clear = function clear() {
exports.dataset = dataset = {};
};
exports.clear = clear;
var Click = {
install: install,
dataset: dataset,
addPreventExcept: addPreventExcept,
setPreventDefault: setPreventDefault,
add: add,
clear: clear,
remove: remove
};
var _default = Click;
exports["default"] = _default;
define(["require", "exports", "./constants"], function (require, exports, constants_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setPreventDefault = exports.addPreventExcept = exports.clear = exports.install = exports.remove = exports.add = exports.dataset = void 0;
exports.dataset = {};
var mousePropertyDown = { x: 0, y: 0 };
var mousePropertyMove = { x: mousePropertyDown.x, y: mousePropertyDown.y };
var moveOffsetProperty = { x: 0, y: 0 };
var extraEvent = {
down: function (e) { },
move: function (e) { },
up: function (e) { },
};
var state = { device: '', isPress: false, deviation: 30, preventDefault: true };
var eventProperty = { passive: false, capture: false };
var exceptParentClassIDDataset = [];
var rootElement = '';
var checkDataset = function (e) {
var target = e.target;
if (target) {
if (target instanceof Element) {
["".concat(target.id, "_id"), "".concat(target.className, "_class")].forEach(function (name) {
var _a;
(_a = exports.dataset[name]) === null || _a === void 0 ? void 0 : _a.call(exports.dataset, e);
});
}
}
};
var eventTransform = function () {
var device = state.device;
var d = (0, constants_1.GET_DEVICE)();
if (!device) {
state.device = d;
addListener(d);
}
else if (device !== d) {
state.device = d;
removeListener(d);
addListener(d);
}
};
var areWePreventDefault = function (e) {
var preventDefault = state.preventDefault;
var root = (0, constants_1.FIND_ROOT)(e);
var isRoot = false;
if (root) {
if (rootElement) {
if (rootElement.indexOf('.') >= 0) {
isRoot = rootElement === ".".concat(root.className);
}
else if (rootElement.indexOf('#') >= 0) {
isRoot = rootElement === "#".concat(root.id);
}
}
}
if (isRoot) {
var hasClassID = (0, constants_1.CHECK_PARENT_HAS_CLASS)(e, exceptParentClassIDDataset);
if (preventDefault && !hasClassID && e.cancelable && !e.defaultPrevented) {
if (e.target instanceof Element) {
var localName = e.target.localName;
if (localName != 'input' && localName != 'button' && localName != 'select') {
e.preventDefault();
}
}
}
}
};
var down = function (e) {
state.isPress = true;
var x = e instanceof TouchEvent ? e.targetTouches[0].clientX : e.clientX || false;
var y = e instanceof TouchEvent ? e.targetTouches[0].clientY : e.clientY || false;
if (!x || !y)
return;
areWePreventDefault(e);
mousePropertyDown.x = x;
mousePropertyDown.y = y;
mousePropertyMove.x = x;
mousePropertyMove.y = y;
extraEvent.down(e);
};
var move = function (e) {
if (!state.isPress)
return;
var x = e instanceof TouchEvent ? e.targetTouches[0].clientX : e.clientX || false;
var y = e instanceof TouchEvent ? e.targetTouches[0].clientY : e.clientY || false;
if (!x || !y)
return;
areWePreventDefault(e);
var dx = mousePropertyDown.x, dy = mousePropertyDown.y;
moveOffsetProperty.x = x - dx;
moveOffsetProperty.y = y - dy;
mousePropertyMove.x = x;
mousePropertyMove.y = y;
extraEvent.move(__assign(__assign({}, e), { moveOffsetProperty: moveOffsetProperty }));
};
var up = function (e) {
state.isPress = false;
var dx = mousePropertyDown.x, dy = mousePropertyDown.y;
var mx = mousePropertyMove.x, my = mousePropertyMove.y;
var deviation = state.deviation;
var m = Math.sqrt(Math.pow((mx - dx), 2) + Math.pow((my - dy), 2));
if (m < deviation)
checkDataset(e);
extraEvent.up(e);
};
var addListener = function (device) {
if (device === 'mobile') {
document.addEventListener('touchstart', down, eventProperty);
document.addEventListener('touchmove', move, eventProperty);
document.addEventListener('touchend', up);
}
else {
document.addEventListener('mousedown', down);
document.addEventListener('mousemove', move);
document.addEventListener('mouseup', up);
}
};
var removeListener = function (device) {
if (device === 'mobile') {
document.removeEventListener('mousedown', down);
document.removeEventListener('mousemove', move);
document.removeEventListener('mouseup', up);
}
else {
document.removeEventListener('touchstart', down);
document.removeEventListener('touchmove', move);
document.removeEventListener('touchend', up);
}
};
var add = function (query, callback) {
if (!callback)
return;
var type = query.slice(0, 1) === '.' ? '_class' : '_id';
var name = query.slice(1);
var key = name + type;
exports.dataset[String(key)] = callback;
};
exports.add = add;
var remove = function (query) {
var type = query.slice(0, 1) == '.' ? '_class' : '_id';
var name = query.slice(1);
var key = name + type;
delete exports.dataset[key];
};
exports.remove = remove;
var install = function (app) {
if (app === void 0) { app = '#app'; }
rootElement = app;
eventTransform();
window.addEventListener('resize', eventTransform);
};
exports.install = install;
var clear = function () {
exports.dataset = {};
};
exports.clear = clear;
var addPreventExcept = function (query) {
if (Array.isArray(query)) {
exceptParentClassIDDataset = __spreadArray([], query, true);
}
else
exceptParentClassIDDataset.push(query);
};
exports.addPreventExcept = addPreventExcept;
var setPreventDefault = function (value) {
state.preventDefault = value;
};
exports.setPreventDefault = setPreventDefault;
var Click = { install: exports.install, dataset: exports.dataset, addPreventExcept: exports.addPreventExcept, setPreventDefault: exports.setPreventDefault, add: exports.add, clear: exports.clear, remove: exports.remove };
exports.default = Click;
});
{
"name": "lesca-click",
"version": "4.1.1",
"description": "replace click / touch start on SPY page",
"main": "lib/index.js",
"scripts": {
"start": "webpack-dev-server --mode development",
"watch": "babel src/lib -w -d lib --copy-files",
"op": "babel src/lib -d lib --copy-files",
"dev": "concurrently \"npm run watch\" \"npm run start\"",
"rm": "rm -rf node_modules/ package-lock.json",
"deploy": "gh-pages -d dist",
"build": "NODE_ENV=production webpack"
},
"keywords": [
"lesca",
"衝康吉",
"jameshsu1125",
"click"
],
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.17.10",
"@babel/core": "^7.18.2",
"@babel/plugin-proposal-class-properties": "^7.17.12",
"@babel/plugin-proposal-object-rest-spread": "^7.18.0",
"@babel/plugin-transform-runtime": "^7.18.2",
"@babel/preset-env": "^7.18.2",
"@babel/preset-react": "^7.17.12",
"autoprefixer": "^10.4.7",
"babel-loader": "^8.2.5",
"concurrently": "^7.2.1",
"css-loader": "^6.7.1",
"file-loader": "^6.2.0",
"gh-pages": "^4.0.0",
"html-react-parser": "^1.4.14",
"html-webpack-plugin": "^5.5.0",
"lesca-react-qrcode": "^1.0.3",
"less": "^4.1.2",
"less-loader": "^11.0.0",
"postcss": "^8.4.14",
"postcss-loader": "^7.0.0",
"prismjs": "^1.28.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"style-loader": "^3.3.1",
"webpack": "^5.73.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.9.1"
},
"author": "jamehsu1125 <jameshsu1125@gmail.com>",
"homepage": "https://github.com/jameshsu1125/lesca-touch-event",
"repository": {
"type": "git",
"url": "git@github.com:jameshsu1125/lesca-touch-event.git"
},
"dependencies": {
"mobile-detect": "^1.4.5"
}
"name": "lesca-click",
"version": "4.2.0",
"description": "replace click / touch start on SPY page",
"main": "lib/index.js",
"scripts": {
"start": "webpack-dev-server --mode development",
"watch": "babel --watch src/lib --out-dir lib --extensions '.ts,.tsx'",
"build": "NODE_ENV=production webpack",
"deploy": "gh-pages -d dist",
"tsc": "npx tsc --watch",
"dev": "concurrently \"npm run watch\" \"npm run tsc\" \"npm run start\"",
"rm": "rm -rf node_modules/ package-lock.json",
"op": "babel src/lib -d lib --copy-files"
},
"keywords": [
"lesca",
"衝康吉",
"jameshsu1125",
"click"
],
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.17.10",
"@babel/core": "^7.18.5",
"@babel/plugin-proposal-class-properties": "^7.17.12",
"@babel/plugin-proposal-object-rest-spread": "^7.18.0",
"@babel/plugin-transform-modules-amd": "^7.18.0",
"@babel/plugin-transform-runtime": "^7.18.5",
"@babel/preset-env": "^7.18.2",
"@babel/preset-react": "^7.17.12",
"@babel/preset-typescript": "^7.17.12",
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
"@mui/icons-material": "^5.8.4",
"@mui/material": "^5.8.5",
"autoprefixer": "^10.4.7",
"babel-loader": "^8.2.5",
"concurrently": "^7.2.2",
"css-loader": "^6.7.1",
"file-loader": "^6.2.0",
"gh-pages": "^4.0.0",
"html-react-parser": "^2.0.0",
"html-webpack-plugin": "^5.5.0",
"lesca-react-qrcode": "^1.0.3",
"less": "^4.1.3",
"less-loader": "^11.0.0",
"less-vars-to-js": "^1.3.0",
"postcss": "^8.4.14",
"postcss-loader": "^7.0.0",
"prismjs": "^1.28.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"style-loader": "^3.3.1",
"ts-loader": "^9.3.1",
"typescript": "^4.7.4",
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.9.2"
},
"author": "jamehsu1125 <jameshsu1125@gmail.com>",
"dependencies": {
"mobile-detect": "^1.4.5"
}
}

@@ -1,3 +0,15 @@

[![dev by JamesHsu](https://img.shields.io/badge/Dev%20by-Jameshsu1125-green)](https://github.com/jameshsu1125/) [![made in Taiwan](https://img.shields.io/badge/Made%20in-Taiwan-orange)](https://github.com/jameshsu1125/) [![npm](https://img.shields.io/badge/npm-Jameshsu1125-red)](https://www.npmjs.com/~jameshsu1125)
[![React](https://img.shields.io/badge/-ReactJs-61DAFB?style=for-the-badge&logo=react&logoColor=white)](https://zh-hant.reactjs.org/)
[![React](https://img.shields.io/badge/Less-1d365d?style=for-the-badge&logo=less&logoColor=white)](https://lesscss.org/)
[![React](https://img.shields.io/badge/Typescript-4277c0?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
[![React](https://img.shields.io/badge/HTML5-E34F26?style=for-the-badge&logo=html5&logoColor=white)](https://www.w3schools.com/html/)
[![React](https://img.shields.io/badge/-CSS3-1572B6?style=for-the-badge&logo=css3&logoColor=white)](https://www.w3schools.com/css/)
[![NPM](https://img.shields.io/badge/NPM-ba443f?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/)
[![React](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white)](https://nodejs.org/en/)
[![NPM](https://img.shields.io/badge/DEV-Jameshsu1125-9cf?style=for-the-badge)](https://www.npmjs.com/~jameshsu1125)
# Why use it?
use for prevent browser default behavior.
usually used in web without scroll app.
# Installation

@@ -15,3 +27,3 @@

```javascript
```JSX
import Click from 'lesca-click';

@@ -22,4 +34,9 @@

Click.add('.target', (e) => {
console.log('target clicked');
console.log('target clicked');
});
// find single className only
<div class='target'> // good
<div class='target on'> // bed
```

@@ -38,1 +55,5 @@

| addPreventExcept(target) | target | string | ".target" or "#target" | |
### Features
- maintain if necessary

@@ -0,53 +1,35 @@

import { Container } from '@mui/material';
import { ThemeProvider } from '@mui/material/styles';
import { useState } from 'react';
import { createRoot } from 'react-dom/client';
import Click from '../lib';
import { Code, Navation } from './components';
import Demo from './demo';
import Qrcode from 'lesca-react-qrcode';
import Navigation from './components/navigation';
import Demo from './pages/demo';
import Usage from './pages/usage';
import './styles.less';
import { theme } from './theme';
const homepage = 'https://github.com/jameshsu1125/lesca-click';
const name = 'lesca-click';
const description = 'simple exsample';
const code = `import Click from 'lesca-click';
const App = () => {
const [state, setState] = useState('demo');
Click.install();
`;
const appendPage = () => {
switch (state) {
default:
case 'demo':
return <Demo />;
Click.install('#app');
case 'usage':
return <Usage />;
}
};
const Page = () => {
return (
<>
<Navation />
<div className='content'>
<div>
<h1>{name}</h1>
<figcaption>{description}</figcaption>
</div>
<div>
<h2>install</h2>
<Code code={`npm install ${name} --save`} theme='markup' />
</div>
<div>
<h2>test on mobile</h2>
<Qrcode content={window.location.href} size='300' />
</div>
<div>
<h2>install on entry file. (ex: index.js)</h2>
<Code code={code} />
</div>
<div>
<h2>set onClick use id or class name.</h2>
</div>
<Demo />
<div>
<h2>Usage</h2>
<a href={homepage}>Documentation</a>
</div>
</div>
</>
);
return (
<ThemeProvider theme={theme}>
<Navigation setState={setState} state={state} />
<Container style={{ paddingTop: '70px' }} maxWidth='lg'>
{appendPage()}
</Container>
</ThemeProvider>
);
};
createRoot(document.getElementById('app')).render(<Page />);
createRoot(document.getElementById('app')).render(<App />);
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const template = './template/template.meta';
const Meta = require(template);
module.exports = {
entry: path.join(__dirname, 'src/docs'),
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.less$/,
use: ['style-loader', 'css-loader', 'postcss-loader', 'less-loader'],
},
{
test: /\.(png|jpg|gif|svg)$/,
use: [
{
loader: 'file-loader',
options: { name: 'img/[path][name].[ext]', context: 'src/docs' },
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src/docs/index.html'),
}),
],
resolve: {
extensions: ['.js', '.jsx'],
},
devServer: {
port: 8000,
},
entry: path.join(__dirname, 'src/docs'),
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
use: ['babel-loader', 'ts-loader'],
exclude: /node_modules/,
},
{
test: /\.(less|css)$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
esModule: false,
},
},
'postcss-loader',
'less-loader',
],
},
{
test: /\.(png|jpg|gif|svg)$/,
use: [
{
loader: 'file-loader',
options: { name: 'img/[path][name].[ext]', context: 'src/docs' },
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
...Meta,
template: 'template/template.html',
}),
],
resolve: {
extensions: ['.tsx', '.ts', '.js', '.jsx'],
},
devServer: {
port: 8000,
},
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc