react-period-of-stay-input
Version:
React.js component for entering a period of stay in a hotel: check-in + check-out date
1 lines • 6.04 kB
JSON
{"id":"demo.tsx","dependencies":[{"name":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/tsconfig.json","includedInParent":true,"mtime":1533819530549},{"name":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/package.json","includedInParent":true,"mtime":1534141269544},{"name":"react","loc":{"line":26,"column":33},"parent":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/src/demo.tsx","resolved":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/node_modules/react/index.js"},{"name":"react-dom","loc":{"line":27,"column":36},"parent":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/src/demo.tsx","resolved":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/node_modules/react-dom/index.js"},{"name":"insert-css","loc":{"line":28,"column":43},"parent":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/src/demo.tsx","resolved":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/node_modules/insert-css/index.js"},{"name":"react-intl","loc":{"line":29,"column":27},"parent":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/src/demo.tsx","resolved":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/node_modules/react-intl/lib/index.es.js"},{"name":"react-intl/locale-data/de","loc":{"line":30,"column":35},"parent":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/src/demo.tsx","resolved":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/node_modules/react-intl/locale-data/de.js"},{"name":"moment/locale/de-ch","loc":{"line":31,"column":8},"parent":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/src/demo.tsx","resolved":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/node_modules/moment/locale/de-ch.js"},{"name":"./index","loc":{"line":32,"column":22},"parent":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/src/demo.tsx","resolved":"/home/ikr/prj/stc-b2b/react-period-of-stay-input/src/index.ts"}],"generated":{"js":"\"use strict\";\n\nvar __extends = this && this.__extends || function () {\n var _extendStatics = function extendStatics(d, b) {\n _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {\n d.__proto__ = b;\n } || function (d, b) {\n for (var p in b) {\n if (b.hasOwnProperty(p)) d[p] = b[p];\n }\n };\n return _extendStatics(d, b);\n };\n return function (d, b) {\n _extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __importStar = this && this.__importStar || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) {\n if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n }result[\"default\"] = mod;\n return result;\n};\nvar __importDefault = this && this.__importDefault || function (mod) {\n return mod && mod.__esModule ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar React = __importStar(require(\"react\"));\nvar ReactDOM = __importStar(require(\"react-dom\"));\nvar insert_css_1 = __importDefault(require(\"insert-css\"));\nvar react_intl_1 = require(\"react-intl\");\nvar de_1 = __importDefault(require(\"react-intl/locale-data/de\"));\nrequire(\"moment/locale/de-ch\");\nvar index_1 = require(\"./index\");\n// In order to display localized messages, react-intl needs the locale definitions data, describing\n// the number and date formats, and the pluralization/gender rules.\n//\nreact_intl_1.addLocaleData(de_1.default);\n// The Environment describes the context where the period of stay input is used. The Environment\n// determines two things: 1) is the same-day check-out allowed? 2) what's the minimal check-in date?\n// Normally, the minimal check-in is the “today” or “tomorrow” date. However, the author had an\n// exotic requirement of having the minimal check-in being “yesterday”, in order to allow the\n// booking of a 1-night stay for late night (after 00:00:00) passengers whose flight was delayed or\n// cancelled.\n//\nvar environment = new index_1.Environment(index_1.ZeroNightsPolicy.ALLOW, new index_1.Day('1979-11-16'));\n// That function manipulates the DOM, in order to detect the feature, and is therefore slow. You'd\n// probably not want to have it called in a render() method.\n//\nvar useInputTypeDate = index_1.isInputTypeDateSupported();\nvar Container = /** @class */function (_super) {\n __extends(Container, _super);\n function Container(props) {\n var _this = _super.call(this, props) || this;\n // onChange, we'll do a state transition from one model value to the other.\n //\n _this.state = {\n model: new index_1.Model(new index_1.Day('1979-11-16'), new index_1.Day('1979-11-17'))\n };\n return _this;\n }\n Container.prototype.render = function () {\n var _this = this;\n return (\n // In a real application all the intlMessages for a given locale, for all the\n // sub-components would probably be pre-compiled on the server side into a single\n // bundle, and placed into a single global var, like `window['my-app-i18n']`.\n //\n React.createElement(react_intl_1.IntlProvider, { locale: 'de', messages: index_1.intlMessages().de }, React.createElement(index_1.PeriodOfStayInput, { useInputTypeDate: useInputTypeDate, locale: index_1.Locale.DE, environment: environment, model: this.state.model, onChange: function onChange(model) {\n _this.setState({ model: model });\n } }))\n );\n };\n return Container;\n}(React.Component);\n// It's a simple utility that inserts the react-datepicker CSS into the HTML document's <head>\n//\ninsert_css_1.default(index_1.css);\nReactDOM.render(React.createElement(Container, null), document.getElementById('root'));"},"hash":"9b04c765596e61735d4b1cd204ddaf71","cacheData":{"env":{}}}