@culturehq/add-to-calendar
Advanced tools
Comparing version 1.0.4 to 1.1.0
@@ -9,2 +9,12 @@ # Changelog | ||
## [1.1.0] - 2020-07-10 | ||
### Added | ||
- The ability to specify the file name used when downloading an iCal file through the `filename` prop. | ||
### Changed | ||
- Instead of explicitly defining the type of what `makeUrls` returns, use the `ReturnType` type. | ||
## [1.0.4] - 2019-08-22 | ||
@@ -63,9 +73,10 @@ | ||
[unreleased]: https://github.com/CultureHQ/add-to-calendar/compare/v1.0.4...HEAD | ||
[1.0.4]: https://github.com/CultureHQ/add-to-calendar/compare/v1.0.3...v1.0.4 | ||
[1.0.3]: https://github.com/CultureHQ/add-to-calendar/compare/v1.0.2...v1.0.3 | ||
[1.0.2]: https://github.com/CultureHQ/add-to-calendar/compare/v1.0.1...v1.0.2 | ||
[1.0.1]: https://github.com/CultureHQ/add-to-calendar/compare/v1.0.0...v1.0.1 | ||
[1.0.0]: https://github.com/CultureHQ/add-to-calendar/compare/v0.2.0...v1.0.0 | ||
[0.2.0]: https://github.com/CultureHQ/add-to-calendar/compare/v0.1.0...v0.2.0 | ||
[0.1.0]: https://github.com/CultureHQ/add-to-calendar/compare/d105a7...v0.1.0 | ||
[unreleased]: https://github.com/culturehq/add-to-calendar/compare/v1.1.0...HEAD | ||
[1.1.0]: https://github.com/culturehq/add-to-calendar/compare/v1.0.4...v1.1.0 | ||
[1.0.4]: https://github.com/culturehq/add-to-calendar/compare/v1.0.3...v1.0.4 | ||
[1.0.3]: https://github.com/culturehq/add-to-calendar/compare/v1.0.2...v1.0.3 | ||
[1.0.2]: https://github.com/culturehq/add-to-calendar/compare/v1.0.1...v1.0.2 | ||
[1.0.1]: https://github.com/culturehq/add-to-calendar/compare/v1.0.0...v1.0.1 | ||
[1.0.0]: https://github.com/culturehq/add-to-calendar/compare/v0.2.0...v1.0.0 | ||
[0.2.0]: https://github.com/culturehq/add-to-calendar/compare/v0.1.0...v0.2.0 | ||
[0.1.0]: https://github.com/culturehq/add-to-calendar/compare/d105a7...v0.1.0 |
@@ -1,9 +0,9 @@ | ||
import * as React from "react"; | ||
import React from "react"; | ||
import { CalendarEvent } from "./makeUrls"; | ||
interface AddToCalendarProps { | ||
children?: React.ReactNode; | ||
declare type AddToCalendarProps = { | ||
event: CalendarEvent; | ||
open?: boolean; | ||
} | ||
declare const AddToCalendar: ({ children, event, open: initialOpen }: AddToCalendarProps) => JSX.Element; | ||
filename?: string; | ||
}; | ||
declare const AddToCalendar: React.FC<AddToCalendarProps>; | ||
export default AddToCalendar; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var React = require("react"); | ||
var makeUrls_1 = require("./makeUrls"); | ||
var react_1 = __importStar(require("react")); | ||
var makeUrls_1 = __importDefault(require("./makeUrls")); | ||
var useAutoFocus = function () { | ||
var elementRef = React.useRef(null); | ||
React.useEffect(function () { | ||
var elementRef = react_1.useRef(null); | ||
react_1.useEffect(function () { | ||
var previous = document.activeElement; | ||
@@ -21,5 +43,5 @@ var element = elementRef.current; | ||
var useOpenState = function (initialOpen) { | ||
var _a = React.useState(initialOpen), open = _a[0], setOpen = _a[1]; | ||
var _a = react_1.useState(initialOpen), open = _a[0], setOpen = _a[1]; | ||
var onToggle = function () { return setOpen(function (current) { return !current; }); }; | ||
React.useEffect(function () { | ||
react_1.useEffect(function () { | ||
if (open) { | ||
@@ -34,8 +56,8 @@ var onClose_1 = function () { return setOpen(false); }; | ||
}; | ||
var Calendar = React.forwardRef(function (_a, ref) { | ||
var children = _a.children, _b = _a.download, download = _b === void 0 ? false : _b, href = _a.href; | ||
return (React.createElement("a", { ref: ref, download: download, href: href, target: "_blank", rel: "noopener noreferrer" }, children)); | ||
var Calendar = react_1.default.forwardRef(function (_a, ref) { | ||
var children = _a.children, _b = _a.filename, filename = _b === void 0 ? false : _b, href = _a.href; | ||
return (react_1.default.createElement("a", { ref: ref, download: filename, href: href, target: "_blank", rel: "noopener noreferrer" }, children)); | ||
}); | ||
var Dropdown = function (_a) { | ||
var onToggle = _a.onToggle, urls = _a.urls; | ||
var filename = _a.filename, onToggle = _a.onToggle, urls = _a.urls; | ||
var ref = useAutoFocus(); | ||
@@ -47,21 +69,21 @@ var onKeyDown = function (event) { | ||
}; | ||
return (React.createElement("div", { className: "chq-atc--dropdown", onKeyDown: onKeyDown, role: "presentation" }, | ||
React.createElement(Calendar, { href: urls.ics, download: true, ref: ref }, "Apple Calendar"), | ||
React.createElement(Calendar, { href: urls.google }, "Google"), | ||
React.createElement(Calendar, { href: urls.ics, download: true }, "Outlook"), | ||
React.createElement(Calendar, { href: urls.outlook }, "Outlook Web App"), | ||
React.createElement(Calendar, { href: urls.yahoo }, "Yahoo"))); | ||
return (react_1.default.createElement("div", { className: "chq-atc--dropdown", onKeyDown: onKeyDown, role: "presentation" }, | ||
react_1.default.createElement(Calendar, { href: urls.ics, filename: filename, ref: ref }, "Apple Calendar"), | ||
react_1.default.createElement(Calendar, { href: urls.google }, "Google"), | ||
react_1.default.createElement(Calendar, { href: urls.ics, filename: filename }, "Outlook"), | ||
react_1.default.createElement(Calendar, { href: urls.outlook }, "Outlook Web App"), | ||
react_1.default.createElement(Calendar, { href: urls.yahoo }, "Yahoo"))); | ||
}; | ||
var AddToCalendar = function (_a) { | ||
var _b = _a.children, children = _b === void 0 ? "Add to My Calendar" : _b, event = _a.event, _c = _a.open, initialOpen = _c === void 0 ? false : _c; | ||
var _d = useOpenState(initialOpen), open = _d[0], onToggle = _d[1]; | ||
var urls = React.useMemo(function () { return makeUrls_1.default(event); }, [event]); | ||
return (React.createElement("div", { className: "chq-atc" }, | ||
event && (React.createElement("button", { type: "button", className: "chq-atc--button", onClick: onToggle }, | ||
React.createElement("svg", { width: "20px", height: "20px", viewBox: "0 0 1024 1024" }, | ||
React.createElement("path", { d: "M704 192v-64h-32v64h-320v-64h-32v64h-192v704h768v-704h-192z M864 864h-704v-480h704v480z M864 352h-704v-128h160v64h32v-64h320v64h32v-64h160v128z" })), | ||
var _b = _a.children, children = _b === void 0 ? "Add to My Calendar" : _b, event = _a.event, _c = _a.filename, filename = _c === void 0 ? "download" : _c, _d = _a.open, initialOpen = _d === void 0 ? false : _d; | ||
var _e = useOpenState(initialOpen), open = _e[0], onToggle = _e[1]; | ||
var urls = react_1.useMemo(function () { return makeUrls_1.default(event); }, [event]); | ||
return (react_1.default.createElement("div", { className: "chq-atc" }, | ||
event && (react_1.default.createElement("button", { type: "button", className: "chq-atc--button", onClick: onToggle }, | ||
react_1.default.createElement("svg", { width: "20px", height: "20px", viewBox: "0 0 1024 1024" }, | ||
react_1.default.createElement("path", { d: "M704 192v-64h-32v64h-320v-64h-32v64h-192v704h768v-704h-192z M864 864h-704v-480h704v480z M864 352h-704v-128h160v64h32v-64h320v64h32v-64h160v128z" })), | ||
" ", | ||
children)), | ||
open && React.createElement(Dropdown, { onToggle: onToggle, urls: urls }))); | ||
open && react_1.default.createElement(Dropdown, { filename: filename, onToggle: onToggle, urls: urls }))); | ||
}; | ||
exports.default = AddToCalendar; |
@@ -8,9 +8,6 @@ export interface CalendarEvent { | ||
} | ||
export interface CalendarURLs { | ||
google: string; | ||
outlook: string; | ||
yahoo: string; | ||
ics: string; | ||
} | ||
declare const makeUrls: (event: CalendarEvent) => CalendarURLs; | ||
declare type URLSet = { | ||
[key: string]: string; | ||
}; | ||
declare const makeUrls: (event: CalendarEvent) => URLSet; | ||
export default makeUrls; |
{ | ||
"name": "@culturehq/add-to-calendar", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "A small package for adding an event to a calendar.", | ||
@@ -8,6 +8,6 @@ "main": "dist/AddToCalendar.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"compile": "tsc --noEmit", | ||
"docs": "webpack --mode production", | ||
"lint": "chq-scripts lint --ext .js,.ts,.tsx", | ||
"prepublishOnly": "rm -f dist/* && yarn build --declaration && cp src/styles.css dist", | ||
"lint": "chq-scripts lint", | ||
"prepublishOnly": "rm -f dist/* && yarn tsc --declaration && cp src/styles.css dist", | ||
"start": "webpack-dev-server --mode development --hot", | ||
@@ -31,18 +31,16 @@ "test": "chq-scripts test" | ||
"devDependencies": { | ||
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/preset-react": "^7.0.0", | ||
"@babel/preset-typescript": "^7.3.3", | ||
"@babel/register": "^7.5.5", | ||
"@culturehq/scripts": "^3.0.1", | ||
"@testing-library/react": "^9.1.0", | ||
"@types/jest": "^24.0.18", | ||
"@types/react": "^16.9.2", | ||
"@babel/cli": "^7.10.4", | ||
"@babel/core": "^7.10.4", | ||
"@babel/preset-env": "^7.10.4", | ||
"@babel/preset-react": "^7.10.4", | ||
"@babel/preset-typescript": "^7.10.4", | ||
"@babel/register": "^7.10.4", | ||
"@culturehq/scripts": "^6.0.1", | ||
"@testing-library/react": "^10.0.0", | ||
"@types/jest": "^26.0.0", | ||
"@types/react": "^16.9.42", | ||
"@types/react-dom": "^16.9.0", | ||
"@typescript-eslint/eslint-plugin": "^2.0.0", | ||
"@typescript-eslint/parser": "^2.0.0", | ||
"awesome-typescript-loader": "^5.2.1", | ||
"babel-loader": "^8.0.6", | ||
"css-loader": "^3.1.0", | ||
"css-loader": "^3.4.2", | ||
"react": "^16.9.0", | ||
@@ -52,23 +50,10 @@ "react-dom": "^16.9.0", | ||
"typescript": "^3.5.3", | ||
"webpack": "^4.37.0", | ||
"webpack": "^4.41.4", | ||
"webpack-cli": "^3.3.3", | ||
"webpack-dev-server": "^3.8.0" | ||
"webpack-dev-server": "^3.10.1" | ||
}, | ||
"resolutions": { | ||
"@types/react": "^16.9.2", | ||
"@types/react": "^16.9.42", | ||
"@types/react-dom": "^16.9.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"@culturehq", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": [ | ||
"@typescript-eslint" | ||
] | ||
}, | ||
"jest": { | ||
"testRegex": "\\.test\\.(j|t)sx?$" | ||
} | ||
} |
# @culturehq/add-to-calendar | ||
[![Build Status](https://github.com/CultureHQ/add-to-calendar/workflows/Push/badge.svg)](https://github.com/CultureHQ/add-to-calendar/actions) | ||
[![Build Status](https://github.com/CultureHQ/add-to-calendar/workflows/Main/badge.svg)](https://github.com/CultureHQ/add-to-calendar/actions) | ||
[![Package Version](https://img.shields.io/npm/v/@culturehq/add-to-calendar.svg)](https://www.npmjs.com/package/@culturehq/add-to-calendar) | ||
@@ -44,4 +44,8 @@ | ||
## Testing locally | ||
### `filename` | ||
Used to specify the name of the downloaded iCalendar file (where applicable - Apple Calendar, Outlook). Defaults to `"download"`. | ||
## Development | ||
You can run the tests by running `yarn test` and lint by running `yarn lint`. You can run the local server by running `yarn start` which will start the docs server on `http://localhost:8080`. | ||
@@ -48,0 +52,0 @@ |
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"jsx": "react", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noImplicitAny": true, | ||
"outDir": "dist", | ||
@@ -8,0 +8,0 @@ "sourceMap": false, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19617
21
238
59